admin管理员组文章数量:1022525
Question :
I want to remove overlaps from existing polygons with javascript.
I guess merging overlapping polygons to single polygon is the easiest way to do this but i don't know how to do this.
Question :
I want to remove overlaps from existing polygons with javascript.
I guess merging overlapping polygons to single polygon is the easiest way to do this but i don't know how to do this.
Share Improve this question edited Apr 13, 2020 at 12:33 Utku asked Nov 3, 2015 at 15:21 UtkuUtku 3004 silver badges19 bronze badges 1
- Just wondering if there is some simpler workaround. Is the main aim trying to get the polygons together as one, or is that a workaround for something else you are trying to achieve, if so, whats that ? – Ian Commented Nov 4, 2015 at 8:22
2 Answers
Reset to default 3You need to implement Vatti's algorithm or use some polygon library which realizes it (or other reliable algo).
Clipper library uses this algorithm, but seems it has not JavaScript binding yet.
Javascript port exists for GPC (sometimes less robust)
Since @MBo's answer is out of date, here is a new answer. The math has already been written down in JavaScript:
- polygon-clipping
- martinez-polygon-clipping
polygonClipping.union(triangle, hexagon, house, diamond)
(from the first package) returns the polygons like in your question.
Question :
I want to remove overlaps from existing polygons with javascript.
I guess merging overlapping polygons to single polygon is the easiest way to do this but i don't know how to do this.
Question :
I want to remove overlaps from existing polygons with javascript.
I guess merging overlapping polygons to single polygon is the easiest way to do this but i don't know how to do this.
Share Improve this question edited Apr 13, 2020 at 12:33 Utku asked Nov 3, 2015 at 15:21 UtkuUtku 3004 silver badges19 bronze badges 1
- Just wondering if there is some simpler workaround. Is the main aim trying to get the polygons together as one, or is that a workaround for something else you are trying to achieve, if so, whats that ? – Ian Commented Nov 4, 2015 at 8:22
2 Answers
Reset to default 3You need to implement Vatti's algorithm or use some polygon library which realizes it (or other reliable algo).
Clipper library uses this algorithm, but seems it has not JavaScript binding yet.
Javascript port exists for GPC (sometimes less robust)
Since @MBo's answer is out of date, here is a new answer. The math has already been written down in JavaScript:
- polygon-clipping
- martinez-polygon-clipping
polygonClipping.union(triangle, hexagon, house, diamond)
(from the first package) returns the polygons like in your question.
本文标签: javascriptMerging intersecting polygons to single polygonStack Overflow
版权声明:本文标题:javascript - Merging intersecting polygons to single polygon - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745554970a2155820.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论