My pgRouting shortest path algorithm is able to take restrictions and oneway streets into account. Threrefore, OSM data was imported into a PostGIS database using the tool pypgroutingloader. Sadly, the left turn at major intersections is still not accurate. Using a different import-tool (like osm2pgrouting) does not help either.

This is, what a correct route (south to west) looks like (using OSRM). OSRM

My setup currently generates the shortest path like this: pgRouting

As you can see, it is not violating the oneway-rule. It illegaly turns left at the node after the driveway. How could I get rid of that behaviour? I already thought about calculating the angle between segments and ristricting sharp turns... But I have no idea about how to do that.

  • I'm a beginner in Python. I'm trying to install pypgrouting which is supposed to be a Python package but there's no setup.py. How am I supposed to do then, please ? – Olive17 Mar 27 '19 at 19:07

You need to add the turn restrictions into the dataset. MapBox have been working on this with the Openstreetmap data using the Turn restrictions plugin in JSOM - see this blog post for more details or using the iD editor (see here).

  • 1
    As OSRM already uses the correct way it is highly likely the turn restrictions are already there. But no idea how to enable 'considering turn restrictions' for pgrouting ... – Karussell Feb 22 '17 at 9:28
  • Thank you for your answer! It led me to the right direction :) As I mentioned above, thanks to pypgroutingloader the restrictions ARE already in the database. I just had to use the pgr_trsp() function pgRouting is offering. I used the aStar function in the SQL query before where restrictions were not being considered. Now I am able to route correctly through the whole dataset. – Sebastian Wieland Feb 22 '17 at 9:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.