tilezen / mapbox-vector-tile

Python package for encoding & decoding Mapbox Vector Tiles
MIT License
240 stars 47 forks source link

Union inners in blocks when making valid #92

Closed zerebubuth closed 7 years ago

zerebubuth commented 7 years ago

The process of making a polygon valid would start with an outer ring for the polygon and subtract each inner one-by-one, checking that the result stayed valid. This allowed us to reject each individual inner if it would make the polygon invalid.

Unfortunately, this process is very slow when there are 1,000s of inners. When there are many inners, it switches to grouping and unioning blocks of inners together, which reduces the number of times that the expensive "difference" operation is called. This can reduce MVT generation time down from hours to minutes. For example, 9/270/185 went down from 4h to 75s.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.09%) to 97.26% when pulling 40547f29b6e551b488f22f52bf9a8a682b4a3bf1 on zerebubuth/union-in-blocks into 564da8c6751297c3842184c1ed17a53ebe44ff4a on master.