i need some help with the following:
i have a linestring - geom i have $lat,$lon (using some php syntax)
- i have an osm table with the roads geom, i am trying to get closest point, and then split the road into two parts, by that closest point.
after using the lat,lon and st_closestpoint to retrieve the closest point on that line. the point which will be returned is not necessarily exist in the original linestring points.
ST_ClosestPoint (geom_way, ST_SetSRID (ST_MakePoint($lon, $lat), 4326) ) as closest_point
after that i would like to split the geom(linestring) into two lines by closest_point, and this is where i need help.
i tried using
st_asgeojson (ST_Split (geom_way, ST_ClosestPoint (geom_way, ST_SetSRID (ST_MakePoint($lon, $lat), 4326) )))
but i believe that because the point i use is not on the geom, its not spliting and always returns the entire geom.
if i use a point which exist in the line string, it works well.(but not what i need)
how can i solve this? any solution even if with totally different approach will do.
thanks for your help!