如何使用MySQL空间查询来查找X半径内的所有记录?
我在 MySQL 数据库中有一个表,其中包含 POINT 类型的空间几何列。我希望能够在地图中心取一个点,并找到该点 X 英里(或任何距离)内的所有记录。我似乎找不到一个很好的例子或解释来说明如何做到这一点,而不需要深入几何数学。我很高兴走这条路,但首先想尝试用真正的空间数据库来解决它。
I have a table in a MySQL database with a spatial geometry column of type POINT. I'd like to be able to take a point at the center of a map and find all records within X miles (or whatever distance) of it. I can't seem to find a good example or explanation of how to do this that doesn't get heavily into geometric math. I'm happy to go that route, but would first like to try and solve it with a true spatial database.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它不会工作,因为 MySQL 还没有真正实现代码来使其工作。他们只使用边界框查询。
请注意,此处没有列出任何函数:
http: //dev.mysql.com/doc/refman/5.5/en/functions-for-testing-spatial-relations- Between-geometric-objects.html
我建议使用 PostGIS 或 Spatialite 代替。
It won't work because MySQL hasn't actually implemented the code to make this work. They only use bounding box queries.
Notice there are no functions listed here:
http://dev.mysql.com/doc/refman/5.5/en/functions-for-testing-spatial-relations-between-geometric-objects.html
I would reccomend using PostGIS or Spatialite instead.