简体   繁体   English

MySQL:在一定半径内找到多边形

[英]Mysql: find polygon within certain radius

In my database I have polygons stored. 在我的数据库中,我存储了多边形。 Now I need to search all the polygons that are within a certain radius. 现在,我需要搜索特定半径内的所有多边形。 Even if the polygon is only a small part inside the region, then it should be included inside the results (so once there is a minimal match, there is a match). 即使多边形仅是区域内的一小部分,也应将其包括在结果内(因此,一旦存在最小匹配,就存在匹配)。

What is the best way to do this? 做这个的最好方式是什么? I have been thinking about creating another polygon and search everything that intersects this, but don't know if this is a valid method? 我一直在考虑创建另一个多边形并搜索与此相交的所有内容,但不知道这是否是有效方法?

Yes, I think it is the best approach. 是的,我认为这是最好的方法。 You can create a polygon using ST_BUFFER and then you can use ST_INTERSECT to find if polygons will intersect your polygon. 您可以使用ST_BUFFER创建多边形,然后可以使用ST_INTERSECT查找多边形是否会与您的多边形相交。

May be you can also do it using ST_DISTANCE . 也许您也可以使用ST_DISTANCE做到这一点 It will calculate minimum distance of a point from polygon. 它将计算点到多边形的最小距离。

Select ST_DISTANCE(polygons,POINT(x, y)) as distance, polygon_id from your_polygon_table WHERE distance <= 10 

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

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