4

I am working on an Android app for navigation with PostGIS and pgrouting. I have implemented pgr_dijkstra and it's working fine. I am not considering direction in routing at this point and just want routes from my source to destination.

I am facing a problem when I am implementing k-shortest path (pgr_ksp) for finding alternative paths from source to destination. I guess pgr_ksp always consider direction when calculating the route. So when I give it a particular source and target value in the query, its gives me nothing and the reason behind this is at some point on the route between that source and target, some road segments share starting or ending point, that is why it can't generate route.

Kindly tell me if there is any possibility that direction not considered here just like Dijkstra

enter image description here

In this picture A is my source, B is my destination. Ignoring the direction of travel, ksp should give me shortest path i.e. node 1, 2, 5, 6

But it is giving me 1, 2, 3, 4, 5, 6 which is not shortest path. startpoint and endpoint is also mentioned here with their road segment color

Kindly suggest me a solution.

  • Does it return the correct result when you flip the direction for edge "2->5"? – dkastl Apr 15 '14 at 15:46
  • how to flip that? – osqureshi Apr 16 '14 at 5:08
  • Well, change the source and target ID so start point becomes end point and end point becomes the start point. Then if the direction would matter, it would choose the right way. – dkastl Apr 16 '14 at 11:15
  • no it doesn't help, route from point B to point A is not possible either because look at the purple road segment its direction is also reversed – osqureshi Apr 16 '14 at 12:10
  • @osqureshi Did you find a solution for this problem? – Del Pedro Jul 14 '17 at 14:10

Your Answer

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

Browse other questions tagged or ask your own question.