MySQL中给定半径内的查询点 [英] Query points within a given radius in MySQL

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

问题描述

我创建了以下MySQL表来存储纬度/经度坐标以及每个点的名称:

I have created the following MySQL table to store latitude/longitude coordinates along with a name for each point:

CREATE TABLE `points` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(128) NOT NULL,
  `location` point NOT NULL,
  PRIMARY KEY (`id`),
  SPATIAL KEY `location` (`location`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;

我正在尝试查询:


  • 给定点的 n英里半径内的所有点;

  • 每个返回点距给定点的距离

我发现的所有示例都提及使用最小边界矩形(MBR)而不是半径。

All of the examples I have found refer to using a minimum bounding rectangle (MBR) rather than a radius. The table contains approximately 1 million points, so this need needs to be as efficient as possible.

推荐答案

非常感谢您的回答。

我最终在 http://www.movable-type.co.uk/scripts/latlong-db.html

这篇关于MySQL中给定半径内的查询点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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