I'm trying to get the points or landmarks nearest to the result of pgrouting linestring (the shortest path). I'm using OSM map entities and working with planet_osm_point
. Here's my code:
SELECT st_asgeojson( ST_Collect( nearRank.nearGeom ) ) As geojson
FROM ( SELECT ST_Transform( marks.way, 4326 ) as nearGeom, name,
ST_Distance( road, marks.way )/1000.0 AS distance_km
FROM planet_osm_point AS marks,
st_setsrid( ST_GeomFromText('LINESTRING(121.1527761
13.9413653,121.154058 13.9413113,121.1550161
13.9412372,121.1559079 13.9411891)') , 900913 ) as road
WHERE marks.amenity <> '' AND marks.name <> ''
ORDER BY ST_Line_Locate_Point(road, marks.way),
marks.way <-> road LIMIT 15 ) As nearRank
The above sql script is not giving the right nearest nodes along the linestring. The linestring above is the result of pgrouting functions. Is there anyone that can tell me what I have missed? The output should be points representing the landmarks near the shortest path.