문제

enter image description here

Suppose I have a line AB as MULTIPOINT(52.3641917981 4.87673850395, 52.3821782019 4.90619949605) and a point P as POINT(51.3641917981 2.87673850395) in MYSQL. I want to calculate the shortest distance D between point P and line AB. Please help me regarding this problem.

Thanks in advance.

도움이 되었습니까?

해결책

I'm sure MySQL has the ST_Distance method for ordering by the distance?

order by st_distance(geom1, geom2)

And for calculating the distance, you can reference this blog:

MySqlPerformanceBlog

It shows how to define a user function (haversine) for making the calculations.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top