[postgis-users] Path to closest neighbor

Nalin C nalinchandrawansha at gmail.com
Sat Nov 28 23:16:27 PST 2009


Hi Steve,

Thank you for the quick reply.

I observed that the results returned by :

select name, the_geom from hospitals order by
distance_sphere(setsrid(makepoint(79.877778, 6.914722), 4326), the_geom) asc
limit 3; 

are not the closest hospitals to the given accident point. I'm not sure what
has gone wrong.


Thanks,

Nalin



Stephen Woodbridge wrote:
> 
> Nalin C wrote:
>> Hi,
>> 
>> I have two tables for roads and hospitals. I'm looking for suitable
>> pgrouting function(s) for following scenario.
>> 
>> Given the accident point (in point geometry), finding the least distant
>> hospital and draw the path.
>> 
>> Following functionality is needed.
>> 
>> 1. One end of the drawn path needs to start from in front of the closest
>> hospital (which is in hospitals table).
>> 2. Path needs to stop from the accident point on road.
>> 
>> I'm new to pgrouting and appreciate your help.
> 
> You have a few discrete tasks. Assuming you have the location of the 
> accident:
> 
> 1) Select say the three closest hospitals based on straight line 
> distance. (x,y) is the location of the accident.
> 
> select name, the_geom from hospitals where order by 
> distance_sphere(setsrid(makepoint(x,y), 4326), the_geom) asc limit 3;
> 
> 2) then use pgRouting to use the Hospital location as start and the 
> accident as end and comput the routes
> 
> 3) compare the routed distances and select the shortest.
> 
> -Steve W
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> 

-- 
View this message in context: http://old.nabble.com/Path-to-closest-neighbor-tp26559254p26559836.html
Sent from the PostGIS - User mailing list archive at Nabble.com.




More information about the postgis-users mailing list