最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Merging intersecting polygons to single polygon - Stack Overflow

programmeradmin1浏览0评论

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
Add a ment  | 

2 Answers 2

Reset to default 3

You 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.

发布评论

评论列表(0)

  1. 暂无评论