osrm-backend icon indicating copy to clipboard operation
osrm-backend copied to clipboard

Before routing, how do I find the correct "PhantomNodes" through the start point?

Open GitBenjamin opened this issue 3 years ago • 9 comments

When the start point(lat, lon) is in the center of a two-way road, should I choose the left or right side of the road? Maybe the start point is actually on the left side of the road, but the result is to return to the “Phantom node” on the right.

Is there any way to correct these results?

such as: 1 2 3

note: 1、the blue point is the start point of the input's latitude and longitude; 2、the red line is the result of osrm; 3、the green line is the correct result; 4、in the third picture, the red line is the trajectory of the car before the routing;

Is this problem the same as https://github.com/Project-OSRM/osrm-backend/issues/5073 ? If i need to modify the code, can i start with "GetPhantomNodes"? @Michael Krasnyk @JackDanger

I hope I can get your help!Thanks!

GitBenjamin avatar Apr 19 '22 09:04 GitBenjamin

i fixed this problem in my display route function by checking if any point on the route is closer than x meters to the destination and if so stop my display routine there...

For your start you can do the same but instead of stopping just removing everything before...

(might not be pretty but functions)

philipphueber avatar Apr 28 '22 10:04 philipphueber

i fixed this problem in my display route function by checking if any point on the route is closer than x meters to the destination and if so stop my display routine there...

For your start you can do the same but instead of stopping just removing everything before...

(might not be pretty but functions)

Thank you for your answer. But, my problem seems to have nothing to do with your method. My problem is how to more accurately relate the starting point to the correct segment through the input information.

GitBenjamin avatar Apr 29 '22 09:04 GitBenjamin

I don't think that tere is any (efficient/ sensical) way to accomplish this as you basically need to know the route to know on wich side of the highway you need to start

(using the heading to the destination might come to mind first but that won't work bc the best route might not head in this direction initially)

So you would need to get an initial wrong route, find the "wrong" u turn (should work with a similar idea to what i described previously) then get the resulting right starting point and calculate that again from there....

And that would be just a stupid idea because u would senselessly do 2 routing calculations for nothing

There might be a way doing this with the osm mapdata and placing the point on the nearest street but that street might also have the wrong heading as u don't know what the router wants to do before you get the route

philipphueber avatar Apr 29 '22 11:04 philipphueber

http://project-osrm.org/docs/v5.24.0/api/?language=cURL#match-service

might potentially work but even then it could snap to the wrong side (i am pretty sure thats what is used inside the router anyway)

philipphueber avatar Apr 29 '22 11:04 philipphueber

If your origin point is from a vehicle, and you know the approximate direction of travel (and you trust it), then you can use the bearings= parameter to the request to filter out snapping to roads that aren't going the right direction for your vehicle, even if they're closer.

danpat avatar Apr 29 '22 15:04 danpat

I don't think that tere is any (efficient/ sensical) way to accomplish this as you basically need to know the route to know on wich side of the highway you need to start

(using the heading to the destination might come to mind first but that won't work bc the best route might not head in this direction initially)

So you would need to get an initial wrong route, find the "wrong" u turn (should work with a similar idea to what i described previously) then get the resulting right starting point and calculate that again from there....

And that would be just a stupid idea because u would senselessly do 2 routing calculations for nothing

There might be a way doing this with the osm mapdata and placing the point on the nearest street but that street might also have the wrong heading as u don't know what the router wants to do before you get the route

yeah, i tried using the "bearings=" parameter to correct the starting point binding. i had an idea that i could use the direction of the car to calculate bearing, but i am not sure what is the best way to determine "the range of the bearing". bearing {value},{range} integer 0 .. 360,integer 0 .. 180 Does range mean smaller is more accurate?

Thank you for your answer, which inspired me a lot.

In addition to, I don't really understand what snap does.

GitBenjamin avatar May 01 '22 04:05 GitBenjamin

If your origin point is from a vehicle, and you know the approximate direction of travel (and you trust it), then you can use the bearings= parameter to the request to filter out snapping to roads that aren't going the right direction for your vehicle, even if they're closer.

Thank you for your answer. This method really helped me a lot with my problem.

GitBenjamin avatar May 01 '22 04:05 GitBenjamin

i am not sure what is the best way to determine "the range of the bearing".

The "range" is the plus/minus the routing engine will allow - so if you set the range to "1", then it will filter out roads that are more than +/- 1 degree different to the value you supply.

I would suggest a broad range is usually what you want - like 60 or 90, which gives you lots of wiggle room for inaccuracy in your measurement, but will still filter out roads that generally head in the opposite direction, which is mostly what folks want.

danpat avatar May 01 '22 21:05 danpat

I would suggest a broad range is usually what you want - like 60 or 90, which gives you lots of wiggle room for inaccuracy in your measurement, but will still filter out roads that generally head in the opposite direction, which is mostly what folks want.

Thank you. I can experiment with that logic. It helped me a lot.

GitBenjamin avatar May 03 '22 10:05 GitBenjamin