Take the 2-minute tour ×

I am trying to use pgrouting's shortestpath function. It returns a set of edges for the shortest path. However, the start node of the next edge is not the end node of the previous edge. I mean they are not connected. So while displaying I am joining the end node of the first edge to the start node of the next edge.

However, I am seeing that the coordinates are repeating. I am not sure why, For eg plotting just the coordinates of the start and end node of each edge, I have something like this:

start end
A     B 
C     D
A     E

As you can see the coordinates are repeating like A,A in the previous case. As a result there are lots of lines crossing over.

Any suggestions or clarifications?

share|improve this question
add comment

1 Answer

Better you post your query as well to see what you're trying to do.

The reason might be that the query returns the list of edges in the way they are stored in the database. And they are stored in the database as they have been digitized/imported. So what is the start of an edge and what is the end depends on how they were created.

If not only the geometry but also the start end end order of the route is important for you, you need to check this as an additional step.

Possibility 2 (reading your post once more):

If your result is even more weird, then probably your network topology is wrong. How did you get source and target ID columns?

share|improve this answer
add comment

Your Answer


