[pgrouting-users] Question about driving directions

Daniel Kastl daniel at georepublic.de
Wed Oct 19 18:22:40 EDT 2011


Thank you!
If you have some example and want to share it, you're welcome to add it to
the website, which has it's repository here:
https://github.com/pgRouting/website ... and/or add some sample code to this
repository: https://github.com/pgRouting/pgrouting-contrib

Even if it may be specific for some particular data, I'm sure a lot of users
would appreciate.

Daniel


On Thu, Oct 20, 2011 at 4:47 AM, John Williams <jdwilliams1982 at gmail.com>wrote:

> Thanks Steve... I really appreciate it. That did the trick. When I test
> this and get the code cleaned up I'll post it online for anyone who is
> interested.
>
>
> On Wed, Oct 19, 2011 at 1:06 PM, Stephen Woodbridge <
> woodbri at swoodbridge.com> wrote:
>
>> On 10/19/2011 11:50 AM, John Williams wrote:
>>
>>> I'm trying to implement text-based driving directions in PHP and I've
>>> run into a little issue. I've read online that you have to check each
>>> segment as you loop through them and make sure the endpoints are lined
>>> up with the direction that you're traveling, but I'm still confused on
>>> how to do this. Right now I'm pulling source and target from the ways
>>> table. Then, if the current segment's target does not equal the next
>>> segment's source I flip the lat/lon values. Can anyone give me a
>>> simplified explanation of how to go about doing this? Thanks...
>>>
>>
>> The key to this is to get the first segment correct. So in pseudocode:
>>
>> ## check first segment
>> if (seg[0][source] == seg[1][source] or
>>    seg[0][source] == seg[1][target]) ) then
>>  seg[0] = flipsegment(seg[0]);
>> end if
>>
>> ## check the rest of the segments
>> for (i=1; i<count(seg); i++) {
>>  if (seg[i-1][target] == seg[i][target]) then
>>    seg[i] = flipsegment(seg[i]);
>>  end if
>> end for
>>
>> so flipsegment needs to swap source and target AND needs to reverse the
>> order of the points in the linestring.
>>
>> -Steve
>> ______________________________**_________________
>> Pgrouting-users mailing list
>> Pgrouting-users at lists.osgeo.**org <Pgrouting-users at lists.osgeo.org>
>> http://lists.osgeo.org/**mailman/listinfo/pgrouting-**users<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
>
>


-- 
Georepublic UG & Georepublic Japan
eMail: daniel.kastl at georepublic.de
Web: http://georepublic.de
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/pgrouting-users/attachments/20111020/5404efa3/attachment.html


More information about the Pgrouting-users mailing list