问题描述
我看到了许多解决方案,可以将POINT
中最接近的行转换为X()
和Y()
并进行距离的触发计算...据我所知,这似乎并没有利用空间索引?
I see many solutions for getting the nearest rows from a POINT
to convert to X()
and Y()
and do trig calculations of distances... As I understand, this does not seem to take advantage of the spatial index?
从最常见的意义上讲,如何利用空间索引返回空间POINT
在距中心POINT
半径以内的行?
How do you take advantage of the spatial index, in the most common sense of, returning rows whose spatial POINT
is within a radius from a center POINT
?
换句话说,你如何得到这样的东西-其中LatLng
是存储为POINT的每一行的纬度位置,而CenterPoint
震中
In other words, how do you get something like this - where LatLng
is the lat lng location stored as POINT for each row, and CenterPoint
the epicenter
伪代码查询:SELECT * FROM geotable WHERE d=Distance(LatLng,CenterPoint) < 10 ORDER by d
推荐答案
您可以使用st_distance_sphere
You can use st_distance_sphere
SELECT *
FROM geotable
WHERE st_distance_sphere(POINT(-82.337036, 29.645095 ), POINT(`longitude`, `latitude` ))/1000 < 10
在这里您可以看到工作示例
这篇关于从中心POINT半径内的MySQL POINT空间索引查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!