[postgis-users] Pgrouting directions
Stephen Woodbridge
woodbri at swoodbridge.com
Tue Dec 30 21:45:20 PST 2008
Ahmad Bdair wrote:
> Yes, that is something very similar to what I need to do, I already
> wrote a php code to check angels and slopes, but it was not accurate, it
> was more life "if else" code, I check the longlat for current segment
When you check the angles do not use the end points because they are
mis-leading.
B+---\
|
A+---/
If you have a segment from A to B like the above and you calculate the
heading or angles based on the vector AB then it will point north and is
should be pointing west at the end of the vector or east at the start of
the vector.
You also need to look at weather or not you need to flip segments
because you route might traverse them from start to end OR from end to
start.
When I compute angles I grid the angles into 8 pie pieces of 45 degrees
each.
continue straight
turn slight right/left
turn right/left
turn sharp right/left
make a u-turn
> with longlat for the previous one, I guess you didn't use the database
> for direction calculation(except for routing) am I right? Isn't steps 3
> and 4 depends on your angel calculations?
I have done this in C in a prototype router I wrote years ago. I have
implemented it in PHP and in perl in various incarnations in the past.
The demo page has it written in pgpsql, but it is based on my own
heavily modified versions of the pgRouting stored procedures.
Hope the above helps with your problems. I find it easiest to work out
the math problems of computing the angles and headings first and make
sure they are correct. Then move on to the other issues. If your math is
wrong computing the headings and angles it will cloud all the other results.
Best regards,
-Steve
> I have the roads with two different languages, a road map like anyother
> road map I guess.
>
> On Tue, Dec 30, 2008 at 3:17 AM, Stephen Woodbridge
> <woodbri at swoodbridge.com <mailto:woodbri at swoodbridge.com>> wrote:
>
> 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
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> <mailto:postgis-users at postgis.refractions.net>
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
More information about the postgis-users
mailing list