systemed / tilemaker

Make OpenStreetMap vector tiles without the stack
https://tilemaker.org/
Other
1.44k stars 229 forks source link

Avoid creating small artefacts when scaling #602

Closed systemed closed 9 months ago

systemed commented 9 months ago

When we scale geometries from projected lat / lon to vector tile coordinates, we often create small spikes and self-intersecting triangles/squares, particularly on intricate geometries like coastlines at lower zoom levels. Although the simplify operation does a good job of removing these, we stand a better chance of producing valid geometries if we don't create these artefacts in the first place.

This PR uses a naive algorithm to minimise the chance of small artefacts. When scaling, for each point, it checks the last five points to see if it duplicates any of them. If so, we backtrack to that point and discard the intervening points.

This appears to fix geometry issues in Andros and the Hebrides. Output tilesize is very slightly reduced and there's no discernible impact on runtimes.