Distance between POINT and LINESTRING
Posted by:
Omar Garro
Date: December 04, 2020 06:48AM
Hi,
how can I run a query to calculate the minimum distance between a POINT(lat lng) and a LINESTRING and the filter results where that distance is less than xxx meters ?
I am trying with:
SELECT ST_Distance(
ST_GeomFromText( 'POINT(-34.647958 -58.388129)', 3857),
ST_GeomFromText( geometry_fld, 3857)
) as Distance2
FROM `sec_cab_fo`
HAVING Distance2 < 200
But it seems to be returning bad inaccurate results
gemotry_fld is a Linestring field. It contains something like this:
LINESTRING (
-34.5976965433552 -58.483349327765,
-34.5976879214475 -58.4832948928198,
-34.5978127817356 -58.4828331022848,
-34.5975919709953 -58.4829059127938,
-34.5974830787817 -58.4832033974371,
-34.5966875141324 -58.4839039527997,
-34.5966531026929 -58.4838060055857,
-34.5966888038735 -58.4836719190874,
-34.5966522003641 -58.4836282139431,
-34.5968243496615 -58.4833544201464,
-34.5966164990581 -58.4833768839409
)
My version of mysql is 8.0.21