简体   繁体   English

MySQL地理空间查询

[英]MySQL geo-spatial query

After some research, it appears that ST_Contains determines whether the second argument is present inside the first argument as a polygon.经过一些研究,似乎 ST_Contains 确定第二个参数是否作为多边形存在于第一个参数中。

What function is available for querying all points inside a polygon from a points table?什么函数可用于从点表中查询多边形内的所有点?

Here is an example of spatial query in MySql where I retrieve all points (features to be drawn on a map) inside a rectangle:这是 MySql 中的空间查询示例,我在其中检索矩形内的所有点(要在地图上绘制的要素):

SELECT * FROM `features` 
WHERE CONTAINS(GeomFromText('POLYGON((6.71813 45.25942,
7.42126 45.25942,
7.42126 45.02695,
6.71813 45.02695,
6.71813 45.25942))'), coord);

field features.coord is of type point (see https://dev.mysql.com/doc/refman/5.7/en/spatial-datatypes.html )字段features.coord是类型(参见https://dev.mysql.com/doc/refman/5.7/en/spatial-datatypes.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM