[pgrouting-users] arbitrary point path calculation

Stephen Woodbridge woodbri at swoodbridge.com
Mon Jul 27 22:51:40 EDT 2009


Daniel Kastl wrote:
>> >From what i understand from the docs pgRouting can "only" calculate
>> the path between two points it has in the database? As opposed to
>> telling it my start and end coordinates?
>>   
> pgRouting does a shortest path search from A to B, right.
> Other things like find closest bus stop, shop, crossing, road link, etc. 
> from lat/lon you need another query. But it's not difficult. Take a look 
> at the workshops for example.

There are simple queries as Daniel has mentioned that would allow you to 
find the nearest street segment or segment endpoint to and arbitrary 
point(x,y). Like:

select * from vertices_tmp
  where st_expand(setsrid(makepoint(lon,lat),4326), 0.0.13) && the_geom
  order by distance(setsrid(makepoint(lon,lat),4326), the_geom) asc
  limit 1;

or:

select * from segments
  where st_expand(setsrid(makepoint(lon,lat),4326), 0.0.13) && the_geom
  order by distance(setsrid(makepoint(lon,lat),4326), the_geom) asc
  limit 1;

You would still need to trim the first and last segment to the point 
projected onto the segment, but there are functions in postgis that will 
help do that.

>> The use case that i have in mind is to allow users to tell me where
>> they are and where they want to go, the code picking the closest bus
>> stop with connection to a bus station close to where the user wants to
>> go.
>>   
> If a user tells you the address where to start from you need to look up 
> in your table the nearest road link to start with.

Being able to route between various transportation networks only 
requires that you have the data for the various networks and that that 
data is connected appropriately in the sense of a graph.

For example you would need to connect the road network to the parking 
lot and the parking lot to the train station for example. The segments 
would need to reflect the time to park and walk to the station, the time 
to purchase a ticket, etc. Similar considerations would need to be 
thought out about walking, bus stops, etc.

>> Does pgrouting know anything about time tables (taking in account when
>> the buses drive)?

This can probably be done by adding a Boost Graph visitor concept to 
code that is time aware, but as Daniel has noted below it does not 
currently exist. It would also require that one specify a start time and 
date (because some schedules might be date dependent, like weekend, 
mid-week, vs holiday schedules), and some additional information about 
type of route preferences, like bus, train, walk,

This capability is like what google is doing here:
http://www.google.com/intl/en/landing/transit/#mdy

Hope this helps,
   -Steve Woodbridge
    http://imaptools.com/

> No, not yet. It would be nice to have it in pgRouting though.
> 
> Daniel
> 
> _______________________________________________
> Pgrouting-users mailing list
> Pgrouting-users at lists.postlbs.org
> http://lists.postlbs.org/mailman/listinfo/pgrouting-users




More information about the Pgrouting-users mailing list