使用Google Maps API v3相交多边形和折线 [英] intersecting polygons and polylines, using google maps API v3

查看:111
本文介绍了使用Google Maps API v3相交多边形和折线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个动态创建的多边形和折线.现在,我需要检查它们是否彼此相交.

I have a polygon and polyline created dynamically. Now I need to check whether they both intersect each other or not.

我该如何实现?谷歌搜索没有提供令人满意的结果.

How do I achieve this? Googling hasn't provided any satisfactory results.

谢谢 丹尼尔

推荐答案

您需要遍历第一条多边形/折线的每个线段,并检查它是否与第二条多边形/折线的每个线段相交.如果一个相交,则两个几何相交.

You need to iterate over each segment of the first polygon/polyline and check if it intersects each segment of the second polygon/polyline. If one intersects, there the two geometries intersect.

如果您不需要考虑测地线,则可以在此处查看建议的实现:

If you don't need to take into account geodesic lines, you can take a look at the suggested implementations here: How do you detect where two line segments intersect? (there is also a Javascript implementation that may suit your needs: https://github.com/pgkelley4/line-segments-intersect/blob/master/js/line-segments-intersect.js)

这篇关于使用Google Maps API v3相交多边形和折线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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