osrm-backend
osrm-backend copied to clipboard
Use weight instead of duration for trip api
Issue
In the above case, Trip API returns a clockwise route for a roundabout trip instead of a counter-clockwise route.
As rate(weight) should take priority over speed(duration), this looks like a bug.
Fixed this by changing ManyToManySearch to return a weight matrix along with duration/distance matrices and using the matrix in TablePlugin::HandleRequest.
Below is data I used to test my code.
$ cat rectangle.osm
<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="none">
<bounds minlon="127.11664666" minlat="37.38013706" maxlon="127.12157070" maxlat="37.38390685" />
<node id="1" lon="127.11967395" lat="37.38390685" />
<node id="2" lon="127.12157070" lat="37.38217534" />
<node id="3" lon="127.11851713" lat="37.38013706" />
<node id="4" lon="127.11664666" lat="37.38172113" />
<way id="101">
<nd ref="1" />
<nd ref="2" />
</way>
<way id="102">
<nd ref="2" />
<nd ref="3" />
</way>
<way id="103">
<nd ref="3" />
<nd ref="4" />
</way>
<way id="104">
<nd ref="4" />
<nd ref="1" />
</way>
</osm>
$ cat trip.lua
api_version = 4
function setup()
return {
properties = {
weight_name = 'test',
}
}
end
function process_way(profile, way, result, data)
result.forward_mode = mode.driving
result.forward_speed = 10
result.forward_rate = 5
result.backward_mode = mode.driving
result.backward_speed = 5
result.backward_rate = 10
end
return {
setup = setup,
process_way = process_way,
}
$ curl 'http://localhost:5000/trip/v1/driving/127.11967395,37.38390685;127.12157070,37.38217534;127.11851713,37.38013706;127.11664666,37.38172113?roundtrip=true&source=first'
Tasklist
- [x] CHANGELOG.md entry (How to write a changelog entry)
- [ ] update relevant Wiki pages
- [ ] add tests (see testing documentation
- [ ] review
- [ ] adjust for comments
- [ ] cherry pick to release branch
Requirements / Relations
Link any requirements here. Other pull requests this PR is based on?