[postgis-users] Path to closest neighbor

Stephen Woodbridge woodbri at swoodbridge.com
Sun Nov 29 06:46:16 PST 2009


Make sure you are use x=longitude, y=latitude and -180 < x < 180. 
A;though it seems likely that you may have that correct depending on 
where you are located, on the southern tip of India?

-Steve

Nalin C wrote:
> 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
>>
>>
> 




More information about the postgis-users mailing list