[postgis-users] Pgrouting directions

Stephen Woodbridge woodbri at swoodbridge.com
Mon Dec 29 17:17:13 PST 2008


bdair2002 wrote:
> Hello,
> I am developing an application using Pgrouting with Postgis data, everything
> is fine, but now I am looking  to do something like Google directions guide,
> where it tells you turn left or right, I am wondering if this feature is a
> built-in feature in Pgrouting or Postgis.
> 
> Regards

No this is not a feature that is part of either.

I have implemented a directions explicator, but it is somewhat specific 
to the data that you have, as you need to know what column(s) contain 
the road names, if you have signage information then you need to know 
how to link to that. If you want to be able to explicate in multiple 
languages, then you probably need to consider supporting multiple 
languages each in a separate table the you can select from when you 
generate the languages.

The algorithm is pretty straight forward as the you currently get a list 
of segments that make up the route. Then you need to:

analyze each segment and
1) check to see if you want to join it with the previous segment because 
the road name matches
2) check the angle that it makes with the last segment to determine 
right, left, straightness of turn
3) compute the compass heading for the segment
4) determine if you have signage
5) based on these, determine if you are read to explicate and which 
predefined instruction you need to explicate an instruction
6) loop through all segments

For a demo of this you can try:
http://imaptools.com/leaddog/routing/dd.html

Zoom into a city in one of the yellow areas, set a start and end point 
and click [calculate route] button. The driving directions should show 
below the button if it was successful, be patience the routing is 
running on a 333MHz box.

-Steve



More information about the postgis-users mailing list