-
Notifications
You must be signed in to change notification settings - Fork 16
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
How to avoid track changes at start of a route? #6
Comments
Note from @C4ptainCrunch: This comment was moved to its own issue, #7. So I have been playing around with this a bit more and decided to have a look at the OSRM tile service to plot the various ways, speeds and angles. But when I do that all the speeds and angles displayed at turnings seem to be set to zero: image removed I'm not really sure if that is a problem with the OSM data or the way OSRM has processed the data though? |
Hello Tom, There is no such option in OSRM as stations are points on a map, not a surface. How would OSRM know how much it may move away from your point to find a better path ? Nevertheless, i have in mind 2 solutions with a bit of code on your side: A. Sample randomly a few positions in a radius of a few hundreds meters around your station and keep the route that gives you the shortest path. Note: if you are searching the shortest path between a pair of stations, querying for each pair of samples might get a bit big. Is it your usecase ? B. Use the map-matching API with only 2 points (your arrival and destination) with big enough precision For the angles and speed of the turns, could you open another issue ? |
Hi @C4ptainCrunch, Thanks for your reply. Yes, I'm looking for the shortest path between a pair of stations. I've also opened a new issue #7 for the angles issue. |
Then, you could change the algorithm a bit:
Variation: if you really need to be precise, you could choose multiple values of C, by cutting the polyline not only at 50% but also at 45%, 55% and so on.
Thanks ! |
Side note: Almost all train stations have all their track in parallel, what you could also do to have better/faster results would be to sample all your points on a line (drawn in purple here) perpendicular to the start of your polyline. First, you can take a point (call it A in blue) ~200m (most stations have at least a few hundreds meters of straight track) from the center (call it C, red). Then draw a line perpendicular to A-C going through C (the purple line, call it L) Last, you can sample your points at regular interval of a 1.5 m on that line (tracks should be >3m apart so doubling that should be enough) |
Those are some excellent suggestions @C4ptainCrunch! |
I've just tried your suggestion for using the map-matching API (since that was the easiest to try) and tried it with a few different routes and it seems to work really well actually. Thank you very much for your help! |
I've started playing around with OSRM and your train profile (the basic one) to use for calculating routes and distances between stations. And while that works pretty well, I have got a small issue around stations with many tracks and platforms.
If I'm trying to get a route between stations A & B I want to use the stations' central coordinates as the start and end point of the route.
But currently it seems that it starts from the track nearest to those exact coordinates and then routes it back and forth across the available tracks and points to get it onto the right track that takes it into the direction of station B.
Here is an example of such a route:
Is there any way to change the routing or profile parameters to avoid those initial track changes and instead start the route from the most direct track nearest to the station A coordinates?
The text was updated successfully, but these errors were encountered: