从中心POINT半径内的MySQL POINT空间索引查询 [英] MySQL POINT spatial index query within radius from center POINT

查看:250
本文介绍了从中心POINT半径内的MySQL POINT空间索引查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到了许多解决方案,可以将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空间索引查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆