Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visvalingam-Whyatt simplification #772

Merged
merged 2 commits into from
Oct 19, 2024
Merged

Visvalingam-Whyatt simplification #772

merged 2 commits into from
Oct 19, 2024

Conversation

systemed
Copy link
Owner

@systemed systemed commented Oct 16, 2024

This adds the Visvalingam-Whyatt algorithm as an alternative simplification method.

This works by eliminating those points which create the smallest triangular area. It therefore picks up 'spikes' - long, thin protuberances from the line - which Douglas-Peucker would tolerate. It's often used for coastlines and for landuse polygons.

The code is almost exactly @e-n-f's (MIT-licensed) implementation from tippecanoe, based on a Go original by @paulmach. My contribution is just gluing it into tilemaker!

  • Unlike our Douglas-Peucker implementation, this isn't yet intersection-aware. That's a todo for a future version. As a substitute it calls make_valid after simplifying a multipolygon, which should catch the most egregious self-intersections.
  • It is generally not suitable for roads, especially when combine_below is used. The latter can create V-shaped road polylines, particularly in the case where a dual carriageway merges into a single carriageway. Visvalingam-Whyatt will see that as a spike and eliminate it entirely.
  • Performance is broadly on a par with Douglas-Peucker.
  • I'd like to add more simplification algorithms in the future, so the simplify_algorithm layer parameter is a string rather than a bool.

Douglas-Peucker airfield:

Screenshot 2024-10-16 at 09 27 03

Visvalingam-Whyatt airfield:

Screenshot 2024-10-16 at 09 26 47

Douglas-Peucker coastline:

Screenshot 2024-10-16 at 11 38 16

Visvalingam-Whyatt coastline - note that the inlets have been simplified away:

Screenshot 2024-10-16 at 11 38 27

Running a Europe extract with the ocean layer set to visvalingam seems to be reliable and not produce any leaky tiles that I've found so far, so I'm inclined to change the OMT-compatible JSON accordingly.

@systemed systemed merged commit 13b841d into master Oct 19, 2024
7 checks passed
@systemed systemed deleted the visvalingam branch October 19, 2024 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant