[pgrouting-users] implement directions

Hi guys,

Can someone point to me some links or information about implement driving directions in a pgrouting project?

Thanks

Em 30-07-2012 17:54, Pedro Costa escreveu:

Hi guys,

Can someone point to me some links or information about implement driving directions in a pgrouting project?

Thanks

With driving directions i mean information about the select route like "turn right" ...

On 7/30/2012 9:57 AM, Pedro Costa wrote:

Em 30-07-2012 17:54, Pedro Costa escreveu:

Hi guys,
Can someone point to me some links or information about implement
driving directions in a pgrouting project?

With driving directions i mean information about the select route like
"turn right" ...

http://postgis.refractions.net/pipermail/postgis-users/2007-November/017768.html

That's what I was going to use as a start, when I get to that phase of our routing system. The "left" or "right" would be the difference between the two lines' azimuth: if the difference is positive, and more than 0.15 radians then it's a slight right, more than .50 radians it's a sharp right, if the difference is negative then it's a left, if the difference is <0.15 radians in either direction then it's not even a turn that I care to mention, ....

But I'm sure someone has developed and documented more of the math here, beyond these first steps. I'm sure I'll be asking a few questions along these lines, in a few weeks when I get to that phase.

--
Greg Allensworth, Web GIS Developer
BS A+ Network+ Security+ Linux+ Server+
GreenInfo Network - Information and Mapping in the Public Interest
564 Market Street, Suite 510 San Francisco CA 94104
PH: 415-979-0343 x302 FX: 415-979-0371 email: gregor@greeninfo.org
Web: www.GreenInfo.org www.MapsPortal.org

Subscribe to MapLines, our e-newsletter, at www.GreenInfo.org

On 7/30/2012 1:24 PM, Greg Allensworth wrote:

On 7/30/2012 9:57 AM, Pedro Costa wrote:

Em 30-07-2012 17:54, Pedro Costa escreveu:

Hi guys,
Can someone point to me some links or information about implement
driving directions in a pgrouting project?

With driving directions i mean information about the select route like
"turn right" ...

http://postgis.refractions.net/pipermail/postgis-users/2007-November/017768.html

That's what I was going to use as a start, when I get to that phase of
our routing system. The "left" or "right" would be the difference
between the two lines' azimuth: if the difference is positive, and more
than 0.15 radians then it's a slight right, more than .50 radians it's a
sharp right, if the difference is negative then it's a left, if the
difference is <0.15 radians in either direction then it's not even a
turn that I care to mention, ....

But I'm sure someone has developed and documented more of the math here,
beyond these first steps. I'm sure I'll be asking a few questions along
these lines, in a few weeks when I get to that phase.

Hi Guys,

I have written a lot about this and implemented it for various projects. Here is a google search that should find most of what I have written:

https://www.google.com/search?q=woodbridge+pgrouting+driving+directions

Start by reading some of these and if you have questions I am willing to help. The big issue with writing a "generic" solution is that it really needs to be customized around the data you are using. The pgrouting part gives you a list of edges, the driving directions starts with this list of edges and then has to analyze things like are the names the same on adjacent edges so you can compress the edges into a single maneuver, when you get to an intersection, do the analysis that Greg mentions to explicate the instruction, etc.

If you want to see an integrated example of it look at:

http://gis.imaptools.com/routing/leaddog/?zoom=11&lat=33.86651&lon=35.51184&layers=B0TTTF&start=35.493583%2033.826664&stop=35.565174%2033.864285&method=STS&lang=eng

You might think about this as a family of functions like

-- basic pgrouting query, returns edge ids
select * from shortest_path(...);

-- convert route edge ids into maneuvers
select * from maneuvers(shortest_path(...));

-- convert maneuvers into textual directions
select * from explicate(maneuvers(shortest_path(...)));

The maneuvers are generic definition of an instruction. The explication can then be a table driven instruction generation based on a fixed set of maneuvers. If you want to have multi language support like my example above, you just change the table from English template to say French, German, Arabic, etc.

Hope this helps,
   -Steve

Thank you for helping me Stephen and Greg.

I'm searching a code example of doing that but i don't find yet...
Do you know something? In wiki pages i don't find...
I'm working with my own data (pedestrian mode) but if someone point me examples with other type (such osm) would be great to start

Thanks

Em 30-07-2012 19:09, Stephen Woodbridge escreveu:

On 7/30/2012 1:24 PM, Greg Allensworth wrote:

On 7/30/2012 9:57 AM, Pedro Costa wrote:

Em 30-07-2012 17:54, Pedro Costa escreveu:

Hi guys,
Can someone point to me some links or information about implement
driving directions in a pgrouting project?

With driving directions i mean information about the select route like
"turn right" ...

http://postgis.refractions.net/pipermail/postgis-users/2007-November/017768.html

That's what I was going to use as a start, when I get to that phase of
our routing system. The "left" or "right" would be the difference
between the two lines' azimuth: if the difference is positive, and more
than 0.15 radians then it's a slight right, more than .50 radians it's a
sharp right, if the difference is negative then it's a left, if the
difference is <0.15 radians in either direction then it's not even a
turn that I care to mention, ....

But I'm sure someone has developed and documented more of the math here,
beyond these first steps. I'm sure I'll be asking a few questions along
these lines, in a few weeks when I get to that phase.

Hi Guys,

I have written a lot about this and implemented it for various projects. Here is a google search that should find most of what I have written:

https://www.google.com/search?q=woodbridge+pgrouting+driving+directions

Start by reading some of these and if you have questions I am willing to help. The big issue with writing a "generic" solution is that it really needs to be customized around the data you are using. The pgrouting part gives you a list of edges, the driving directions starts with this list of edges and then has to analyze things like are the names the same on adjacent edges so you can compress the edges into a single maneuver, when you get to an intersection, do the analysis that Greg mentions to explicate the instruction, etc.

If you want to see an integrated example of it look at:

http://gis.imaptools.com/routing/leaddog/?zoom=11&lat=33.86651&lon=35.51184&layers=B0TTTF&start=35.493583%2033.826664&stop=35.565174%2033.864285&method=STS&lang=eng

You might think about this as a family of functions like

-- basic pgrouting query, returns edge ids
select * from shortest_path(...);

-- convert route edge ids into maneuvers
select * from maneuvers(shortest_path(...));

-- convert maneuvers into textual directions
select * from explicate(maneuvers(shortest_path(...)));

The maneuvers are generic definition of an instruction. The explication can then be a table driven instruction generation based on a fixed set of maneuvers. If you want to have multi language support like my example above, you just change the table from English template to say French, German, Arabic, etc.

Hope this helps,
  -Steve
_______________________________________________
Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users

Hi Guys,

I began to work on directions but i have a few questions:

A) I see that the result of pgrouting query returns the lines in route order so I
  have a column with street names and i want to get the name of the first line to make a instruction like that:

"Start the journey by' + 'street name of the first line'

Do you know how I can select the name of the first line?

B) I'm trying to determine the bearing for instructions like 'turn right' or 'turn left 'but here's my question based on image attached (example). The black line are the network and the yellow the route.
To measure bearing with points, I think i have to do with the first point of line one and with the last point of line two right?
If i try to determine the bearing of point 1 to point 2 the result will be 0 right? Despite, in reality, we have to make a route of 90 degrees of line one to line two.
I'm thinking right? Can someone help me with that?

I hope that you understand my questions.

Thanks

Em 30-07-2012 19:09, Stephen Woodbridge escreveu:

On 7/30/2012 1:24 PM, Greg Allensworth wrote:

On 7/30/2012 9:57 AM, Pedro Costa wrote:

Em 30-07-2012 17:54, Pedro Costa escreveu:

Hi guys,
Can someone point to me some links or information about implement
driving directions in a pgrouting project?

With driving directions i mean information about the select route like
"turn right" ...

http://postgis.refractions.net/pipermail/postgis-users/2007-November/017768.html

That's what I was going to use as a start, when I get to that phase of
our routing system. The "left" or "right" would be the difference
between the two lines' azimuth: if the difference is positive, and more
than 0.15 radians then it's a slight right, more than .50 radians it's a
sharp right, if the difference is negative then it's a left, if the
difference is <0.15 radians in either direction then it's not even a
turn that I care to mention, ....

But I'm sure someone has developed and documented more of the math here,
beyond these first steps. I'm sure I'll be asking a few questions along
these lines, in a few weeks when I get to that phase.

Hi Guys,

I have written a lot about this and implemented it for various projects. Here is a google search that should find most of what I have written:

https://www.google.com/search?q=woodbridge+pgrouting+driving+directions

Start by reading some of these and if you have questions I am willing to help. The big issue with writing a "generic" solution is that it really needs to be customized around the data you are using. The pgrouting part gives you a list of edges, the driving directions starts with this list of edges and then has to analyze things like are the names the same on adjacent edges so you can compress the edges into a single maneuver, when you get to an intersection, do the analysis that Greg mentions to explicate the instruction, etc.

If you want to see an integrated example of it look at:

http://gis.imaptools.com/routing/leaddog/?zoom=11&lat=33.86651&lon=35.51184&layers=B0TTTF&start=35.493583%2033.826664&stop=35.565174%2033.864285&method=STS&lang=eng

You might think about this as a family of functions like

-- basic pgrouting query, returns edge ids
select * from shortest_path(...);

-- convert route edge ids into maneuvers
select * from maneuvers(shortest_path(...));

-- convert maneuvers into textual directions
select * from explicate(maneuvers(shortest_path(...)));

The maneuvers are generic definition of an instruction. The explication can then be a table driven instruction generation based on a fixed set of maneuvers. If you want to have multi language support like my example above, you just change the table from English template to say French, German, Arabic, etc.

Hope this helps,
  -Steve
_______________________________________________
Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users

bearing.png

On 7/31/2012 10:39 AM, Pedro Costa wrote:

Hi Guys,

I began to work on directions but i have a few questions:

A) I see that the result of pgrouting query returns the lines in route
order so I
  have a column with street names and i want to get the name of the
first line to make a instruction like that:

"Start the journey by' + 'street name of the first line'

Do you know how I can select the name of the first line?

You do this with a join back to your original table based on the edge id.

So if shortest_path(..) returns a records with fields like, edgeid, nodeid, cost then a query like:

select a.*, b.name
   from shortest_path(..) a, myedges b
  where a.edgeid=b.edgeid;

B) I'm trying to determine the bearing for instructions like 'turn
right' or 'turn left 'but here's my question based on image attached
(example). The black line are the network and the yellow the route.
To measure bearing with points, I think i have to do with the first
point of line one and with the last point of line two right?
If i try to determine the bearing of point 1 to point 2 the result will
be 0 right? Despite, in reality, we have to make a route of 90 degrees
of line one to line two.
I'm thinking right? Can someone help me with that?

You have to evaluate it at every intersection, not just p1 and p2.

-Steve W

I hope that you understand my questions.

Thanks

Em 30-07-2012 19:09, Stephen Woodbridge escreveu:

On 7/30/2012 1:24 PM, Greg Allensworth wrote:

On 7/30/2012 9:57 AM, Pedro Costa wrote:

Em 30-07-2012 17:54, Pedro Costa escreveu:

Hi guys,
Can someone point to me some links or information about implement
driving directions in a pgrouting project?

With driving directions i mean information about the select route like
"turn right" ...

http://postgis.refractions.net/pipermail/postgis-users/2007-November/017768.html

That's what I was going to use as a start, when I get to that phase of
our routing system. The "left" or "right" would be the difference
between the two lines' azimuth: if the difference is positive, and more
than 0.15 radians then it's a slight right, more than .50 radians it's a
sharp right, if the difference is negative then it's a left, if the
difference is <0.15 radians in either direction then it's not even a
turn that I care to mention, ....

But I'm sure someone has developed and documented more of the math here,
beyond these first steps. I'm sure I'll be asking a few questions along
these lines, in a few weeks when I get to that phase.

Hi Guys,

I have written a lot about this and implemented it for various
projects. Here is a google search that should find most of what I have
written:

https://www.google.com/search?q=woodbridge+pgrouting+driving+directions

Start by reading some of these and if you have questions I am willing
to help. The big issue with writing a "generic" solution is that it
really needs to be customized around the data you are using. The
pgrouting part gives you a list of edges, the driving directions
starts with this list of edges and then has to analyze things like are
the names the same on adjacent edges so you can compress the edges
into a single maneuver, when you get to an intersection, do the
analysis that Greg mentions to explicate the instruction, etc.

If you want to see an integrated example of it look at:

http://gis.imaptools.com/routing/leaddog/?zoom=11&lat=33.86651&lon=35.51184&layers=B0TTTF&start=35.493583%2033.826664&stop=35.565174%2033.864285&method=STS&lang=eng

You might think about this as a family of functions like

-- basic pgrouting query, returns edge ids
select * from shortest_path(...);

-- convert route edge ids into maneuvers
select * from maneuvers(shortest_path(...));

-- convert maneuvers into textual directions
select * from explicate(maneuvers(shortest_path(...)));

The maneuvers are generic definition of an instruction. The
explication can then be a table driven instruction generation based on
a fixed set of maneuvers. If you want to have multi language support
like my example above, you just change the table from English template
to say French, German, Arabic, etc.

Hope this helps,
  -Steve
_______________________________________________
Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users

_______________________________________________
Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users

Em 31-07-2012 15:50, Stephen Woodbridge escreveu:

You have to evaluate it at every intersection

ok thanks. But with the table 'vertices_tmp'?

May be when i finished this i can post in the wiki because we don't have code about this...

I'm confused.

How i evalute the bearing for every intersection?There is a lot of possibilities by point right?

Em 31-07-2012 16:03, Pedro Costa escreveu:

Em 31-07-2012 15:50, Stephen Woodbridge escreveu:

You have to evaluate it at every intersection

ok thanks. But with the table 'vertices_tmp'?

May be when i finished this i can post in the wiki because we don't have code about this...

On 7/31/2012 11:12 AM, Pedro Costa wrote:

I'm confused.

How i evalute the bearing for every intersection?There is a lot of
possibilities by point right?

Sorry for the crude character graphics:

       c d
        \ |
         \|
a--------b-------e
          |\
          | -----f
         /
        g

Consider this complex intersections with lots of spokes. If your route is from a-b to one of the spokes and you need to get the edge b-? then compute the heading. But if a-b and b-? have the same name then you can compress these to edges into one virtual edge a-b-?, if the name changes at the intersection then you need to compute the turn maneuver.

You will have to write a stored procedure to do this. Because the number of edges in will not be the number of maneuvers out because you want to compress edges with the same name other wise you will have in directions like:

continue on main st
turn right on foo st
etc

-Steve

Em 31-07-2012 16:03, Pedro Costa escreveu:

Em 31-07-2012 15:50, Stephen Woodbridge escreveu:

You have to evaluate it at every intersection

ok thanks. But with the table 'vertices_tmp'?

May be when i finished this i can post in the wiki because we don't
have code about this...

_______________________________________________
Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users