« Return to Thread: Select Point near Polyline Postgis

Select Point near Polyline Postgis

by anhtin :: Rate this Message:

Reply to Author | View in Thread

hi all
I am developing a web application. i am using Mapserver and Postgis
I have a question below
if i want to click one point on map to select the nearest point on the nearest polyline from the point i clicked. How can i do?
Notes: The point I clicked is converted to X,Y coordinate (295149 2315499)

could you show me the sql command in postgis.
1. How can i select the nearest  polyline on the click point.
2. How can  i select the the nearest point on the selected nearest polyline.



Somebody suggest that I should search the polyline nearest on the click point by the script below

SELECT * FROM mainroad WHERE GeomFromText('POINT(517651 2121421)', 42102) &&
the_geom
 AND distance(the_geom,
GeomFromText('POINT(517651 2121421)', 42102)) < 200000

however,  sometime it has no result because the distance from point to polyline is larger than 200000.

 « Return to Thread: Select Point near Polyline Postgis