Skip to content

Simplify buildings algorithm#918

Merged
systemed merged 2 commits into
masterfrom
simplify_buildings
Jun 21, 2026
Merged

Simplify buildings algorithm#918
systemed merged 2 commits into
masterfrom
simplify_buildings

Conversation

@systemed

Copy link
Copy Markdown
Owner

This adds a specialised simplification algorithm for buildings, which aims to preserve their rectilinear nature while reducing vertices. You can try it out using a layer config like this:

"building": { "minzoom": 13, "maxzoom": 14, "combine_polygons_below": 15,
              "simplify_algorithm": "buildings", "simplify_below": 15, "simplify_level": 0.0001 }

It works best with combine_polygons_below. Typical output is like this:

image

from this source data:

image

The algorithm was developed in Ruby, and ported to C++ with the help of Claude.

Performance is moderate - there are some opportunities for optimisation (such as replacing atan2 with a faster implementation), but given that the main impact is from combine_polygons_below anyway, this isn't a massive deal.

@systemed

Copy link
Copy Markdown
Owner Author

Additional commit now optimises union_many by using an rtree to only join adjoining polygons.

@systemed

Copy link
Copy Markdown
Owner Author

Some very rough timings based on running Oxfordshire on an old Mac mini:

no combine, no simplify:  15.19 real   36.76 user   1.89 sys   22085632
no combine, simplify:     22.28 real   38.77 user   3.13 sys   22216704
old combine, no simplify: 65.96 real  129.22 user   3.95 sys   21233664
old combine, simplify:    67.17 real  127.34 user   4.15 sys   20840448
new combine, no simplify: 18.38 real   44.76 user   1.67 sys   21233664
new combine, simplify:    19.97 real   43.63 user   2.35 sys   20709376

@systemed systemed merged commit 42d8b8a into master Jun 21, 2026
11 of 12 checks passed
@systemed systemed deleted the simplify_buildings branch June 21, 2026 19:59
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