计算 2 个 MKPolygons 的并集
我正在使用多边形 MKOverlays 开发地图应用程序。我需要合并(联合)重叠的多边形。
有一个众所周知的算法可以做到这一点吗?是否有任何免费的现有库/实现可以帮助进行此类几何操作?
我找到了 GEOS 库,但显然它的许可条款不允许在不分发源代码的情况下使用。还有其他人使用这个库吗?如果是,我在哪里可以找到将其包含在我的 Xcode 项目中的方法。
I am working on map applications with polygon MKOverlays. I have a requirement to merge (union) overlapping polygons.
Is there a well known algorithm to do this? Are there any free existing libraries/implementations that help with such geometry operations?
I have found the GEOS library, but apparently its licensing terms disallow use without distributing your source code. Is anyone else using this library. If yes, where can I find the way to include this in my Xcode project.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我所知道的唯一免费库是 -
Clipper:
http://angusj.com/delphi/clipper.php
增强多边形:
http://www.boost.org/doc/libs /1_47_0/libs/polygon/doc/index.htm
增强几何体:
http://trac.osgeo.org/ggl/
The only free libraries I'm aware of are -
Clipper:
http://angusj.com/delphi/clipper.php
Boost Polygon:
http://www.boost.org/doc/libs/1_47_0/libs/polygon/doc/index.htm
Boost Geometry:
http://trac.osgeo.org/ggl/
尝试gpc。他们拥有多个许可证。他们的页面上还列出了类似的库。
Try gpc. They have several licences. Also there are similar libraries listed on their page.
有一个很棒的库 RSClipperWrapper 它基本上是 剪辑器。他们的网站内甚至还有一个很棒的库比较:
TL;DR,免费库,无错误且快速。
一些注意事项:
CGPoint
但不用担心,你可以通过 lat /长入其中,它将完成工作(经过测试和验证)。为了方便起见,我编写了一个扩展,这样我们就可以传递一个自定义的
Polygon
数组并获取合并的多边形 - 如果您使用MKPolygon
或其他类型,那么不要忘记调整您的类型:There is a great library RSClipperWrapper which is basically a wrapper for Clipper. There is even a great library comparison inside their website:
TL;DR, free library, error free and fast.
A few notes:
CGPoint
but fear not, you can pass lat/long into it and it will get the job done (tested and verified).For convinice I've written an extension so we can just pass a custom
Polygon
array and get the merged polygons - if you're usingMKPolygon
or other type then don't forget adjust your type: