Well, you might want to look into this query then and see if you can find the issue. If you have a reasonable number of hospitals then just list them all like:

select name,
       astext(the_geom),
       distance_sphere(setsrid(makepoint(x,y), 4326), the_geom) as dist
  from hospitals
 order by
       distance_sphere(setsrid(makepoint(x,y), 4326), the_geom) asc;

Distance should be in meters. You might want to validate the the hospitals are entered at the correct positions. Computing the distance is pretty basic stuff, it is probably a problem with the data.

-Steve

Nalin C wrote:
Ya, it's near the southern tip of India, a point in Sri Lanka. x, y has been
given correct. I used 4326 as the SRID.


Stephen Woodbridge wrote:
You need to read up on pgRouting and probably join the pgRouting list

http://pgrouting.postlbs.org/
http://lists.postlbs.org/mailman/listinfo/pgrouting-users

-Steve

Nalin C wrote:
Also, can you please suggest me the functions that can be used for points
2
and 3 ? I'm totally a newbie to postgis.
In point 2, it would be great if the path can start from in front of the
hospital, instead a vertex in roads table.



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
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users


_______________________________________________
postgis-users mailing list
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users




_______________________________________________
postgis-users mailing list
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users

Reply via email to