[OSRM-talk] Need help: Customizing weights in Profile shows inconsistent results with Dijsktra
Niharika Shrivastava
chunnushrivastava at gmail.com
Tue Apr 14 09:34:16 UTC 2020
Hello, I'm new to OSRM and I went through previous issues and couldn't find
much related to this, hence posting it here.
I had used a python library OSMnx to extract Singapore's data and changed
certain edge attributes for it. I calculated an edge attribute `"BPR"`
(float) and stored it in the graph (This is travel time in case of real
traffic data). I then converted this modified graph into a shapefile and
then converted the shapefile into OSM XML using JOSM. I fed this to OSRM in
order to use CH. I want to find the shortest route between two points
wherein my weights (or cost) are the BPR value I had calculated. I
understand I have to specify that in the car profile. This is how I
specified it:
```
function setup()
return {
properties = {
...
weight_name = 'congestion',
...
},
...
}
function process_way(profile, way, result, relations)
local data = {
-- prefetch tags
...
BPR = way:get_value_by_key('BPR')
}
result.weight = data.BPR
...
}
```
This is the JSON response I get for a certain query:
```
{'code': 'Ok',
'routes': [{'geometry': 's}gG{ijyReEnNdm@|Wpl@~}@b\\lfAw\\twAbFjt at wM
`ZwSpAGnNgN|Dvm at fWwHhb@bErz at qFxeAzVfkAfr@b{Ak_ at rr@ocA~dAgCda at ji@dz@`j at di
@`Sfi at PfQcRpc@ySyCgw@~XjEx]dHDkEl\\ju at lf@ii at n}@oVqEiKlR_Elw at bJd[lc at wFdKf[',
'legs': [{'steps': [],
'distance': 32298.2,
'duration': 2308.4,
'summary': '',
'weight': 2179.6}],
'distance': 32298.2,
'duration': 2308.4,
'weight_name': 'congestion',
'weight': 2179.6}],
'waypoints': [{'hint':
'YwYBgG8GAYALAAAAAQAAAAAAAAAAAAAAHN-XQWpx4j0AAAAAAAAAAA0AAAABAAAAAAAAAAAAAAAJAAAAyOIxBiSzFADI4jEGJLMUAAAAzwFqJcKJ',
'distance': 0,
'name': 'Tampines Avenue 8',
'location': [103.932616, 1.35658]},
{'hint':
'EAYBgBcGAYAUAAAAAAAAAAAAAAAAAAAAPzfZQQAAAAAAAAAAAAAAABkAAAAAAAAAAAAAAAAAAAAJAAAA6oIuBlR3FADqgi4GVHcUAAAALwpqJcKJ',
'distance': 0,
'name': 'Boon Lay Drive',
'location': [103.711466, 1.341268]}]}
```
Looking at this part from the JSON:
```
'duration': 2308.4,
'weight': 2179.6}],
```
As I understand, weight is the summation of BPR values for each edge.
Duration is estimated free flow time:` length/max_speed for each edge`. The
`value of weight should be >= duration` which is true when I use Dijkstra
for routing using edge weights as BPR value (`3155.27`). But over here,
thats not the case.
BPR = duration*(some delay based on traffic) >= duration in case of no
traffic
Can someone please point out if my Profile is wrongly written or if I've
missed any steps?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/osrm-talk/attachments/20200414/ac4590c3/attachment.htm>
More information about the OSRM-talk
mailing list