[pgrouting-users] implement directions
Stephen Woodbridge
woodbri at swoodbridge.com
Tue Jul 31 07:50:28 PDT 2012
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 at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/pgrouting-users
>
>
>
> _______________________________________________
> Pgrouting-users mailing list
> Pgrouting-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/pgrouting-users
>
More information about the Pgrouting-users
mailing list