-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
map matching returns name for the wrong direction #3625
Comments
@mortada The most likely cause is that OSRM (still) doesn't support different names in different directions on a way, only one name gets baked into the data structures at pre-processing time, and which one you get is basically random. This PR: #2298 implementes this for OSRMv5 The main reason this isn't implemented in the mainline is that it adds significant memory overhead (4 bytes per edge-based-node, so about 4-8GB for the planet), and it only affects a tiny number of ways in OpenStreetMap (about 40 roads in total, globally).
Something like this is definitely asking for a sparse data optimization (i.e. a separate lookup table for bidirectionally named roads, resolved at unpacking time). |
I'll also note, there are about 2180 instances of |
@danpat is there a reliable way to get the map matcher to return whether a trace is traversing in the forward or backward direction of the matched edge? |
@mortada you can pass the the See the documentation at http://project-osrm.org/docs/v5.5.4/api/#match-service and the structure of the |
Thanks @danpat -- we're planning to use |
@sjones94549 as a very quick-and-dirty hack, you could try encoding the first node ID value as part of the way name. If that value doesn't match the first value in the annotation node ID sequence, you know you've traversed it in reverse. It's a fugly hack, but I think it'll work. |
@danpat aren't the annotation node IDs a segment that may be somewhere in the middle of a long edge? How would one tie those segment IDs to an original OSM way without knowing the original node chain? |
@sjones94549 hmm, good point. It'll work for traces that cross the beginning of ways, but yeah, it won't work for traces that are only on a sub-section of a longer un-broken way. To do this inside OSRM, I really see two options:
Both of these will require some C++ work to implement. |
Can this be also done by mapping the road as two separate in space one-ways? |
possibly if we offset the endpoint nodes of these ways they'd make it through |
@danpat I'm curious if you've seen These long names are related to this ticket. I'm packing As an aside, I ran into two string length thresholds when trying this. First, osmium raises an exception at 1024 characters, and will simply reject any OSM or PBF with longer values when parsing. Second, OSRM silently truncates to ~254 characters ( |
Strings in OSM can only have a maximum length of 256 unicode characters. See #2844. |
@sjones94549 The sorting step that it's holding up on does perform a lexicographical comparison of the names (to determine the sort order). If the strings are long and similar looking, this could be a big source of the slowdown. There are lots of these comparisons done. The comparison done to sort edges is done here, it looks like you're triggering the final
|
@oxidase in my use case the graph is actually structured such that each way has a unique name. would it be possible to make it skip this inefficient sort? |
The problem is not in non-unique names in ways, but in non-unique ways that share the same nodes. Say there are four nodes "a b c d" and two ways "abcd" and "bcd". With the check all three segments ab, bc, cd always will have the name "abcd". Without the check the first segment will be always "abcd", but the second and the third will be either "abcd" or "bcd" depending on edges processing order and the result with collapsed names will be one of {"abcd", "abcd,bcd", "abcd,bcd,abcd"}. It is possible to compare only name ids that is cheap as comparing node ids, but there is also no fixed ordering in name ids, so one of {"abcd", "abcd,bcd"} result will be possible. Also it will not fix the original problem: the rtree contains only "westbound" edge and "eastbound" edge is not included into edge-based graph because of filtering. With removed filtering
```
{
"code": "Ok",
"matchings": [
{
"confidence": 0.973725,
"distance": 8.2,
"duration": 0.7,
"legs": [
{
"annotation": {
"datasources": [
0
],
"distance": [
8.188221
],
"duration": [
0.7
],
"nodes": [
2,
1
],
"weight": [
0.7
]
},
"distance": 8.2,
"duration": 0.7,
"steps": [],
"summary": "",
"weight": 0.7
}
],
"weight": 0.7,
"weight_name": "duration"
}
],
"tracepoints": [
{
"hint": "AQAAgAAAAAAIAAAAAAAAAFIAAAAAAAAAAAAAAAAAAABSAAAAAAAAAAAAAAABAAAAAQAAgL6w1vgdywwCvrDW-B3LDAIAAAEBWhICqw==",
"location": [
-120.147778,
34.392861
],
"matchings_index": 0,
"name": "eastbound",
"waypoint_index": 0
},
{
"hint": "AQAAgAAAAAAIAAAABwAAAEsAAAAAAAAAAAAAAAcAAABLAAAAAAAAAAAAAAABAAAAAQAAgBCx1vg6ywwCEbHW-DnLDAIAAAEBWhICqw==",
"location": [
-120.147696,
34.39289
],
"matchings_index": 0,
"name": "eastbound",
"waypoint_index": 1
}
]
}
```
/cc @TheMarex |
@oxidase in my use case the road network is such that two ways in the form of "abcd" and "bcd" would never happen. These two ways would be "ab" and "bcd". The only node sharing in my case would be having an identical but reversed list of nodes (i.e. "abcd" and "dcba") would it be possible to make this sort optional? |
@mortada sure, you can try it locally, but i guess making the lexicographical sort optional will not help, because it should not hit. The "eastbound" edge can not snapped in matching because the "eastbound" edge does not exists as an edge-based node in the graph due to filtering out here osrm-backend/src/extractor/edge_based_graph_factory.cpp Lines 282 to 287 in 2b00d92
|
@sjones94549 yes that looks like a bug. Broke this out into #3775 |
Using the v5.5.4 release, I notice that map matching can map a trace to the wrong direction. Here is a small example that reproduces the problem.
Given the following trace/query, which goes from west to east:
/match/v1/car/-120.147778,34.392861;-120.147695,34.392889?annotations=true&overview=false
and the following OSM:
the resulting matched name is the wrong direction (westbound)
Note that my OSM is such that both ways share the same nodes. I remember seeing this same problem in v4.x and it was fixed in v4.x. But this does not seem to work in v5.x.
I'd like to be upgrade from v4 to v5 and any help would be appreciate. Thanks
The text was updated successfully, but these errors were encountered: