Skip to content

fix: keep clipped slices of large polygons when filtering by area (#763) - #967

Open
dktue wants to merge 2 commits into
systemed:masterfrom
dktue:fix/area-filter-763
Open

dktue wants to merge 2 commits into
systemed:masterfrom
dktue:fix/area-filter-763

Conversation

@dktue

@dktue dktue commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Fixes #763, as agreed there (option 3, without the store-time minzoom part).

filter_area measured each polygon part after it was clipped to the tile. A large polygon crossing a tile edge with only a small slice in the next tile lost that slice, which leaves a straight-edged gap along the tile border.

RemovePartsBelowSize now drops a small outer polygon or inner ring only when its size on this tile is its real size, or when it can't be seen here anyway:

  • it lies strictly inside the tile's clipping box, so clipping didn't cut it (the clip box used in buildWayGeometry is never smaller than clippingBox, also at the end zoom), or
  • it lies entirely outside the tile itself, in the buffer. It isn't rendered in this tile, and the neighbouring tile decides on its own.

Small slices cut by clipping that reach into the tile are kept. Inner rings need the same check because fast_clip clips them separately, so a cut hole stays an inner ring.

Known remaining inaccuracy, as discussed: a small island of a large multipolygon that crosses a tile edge is kept on both sides.

Results

The shipped OpenMapTiles config only uses filter_area on ocean, so its output barely changes (Canary Islands: 3 more water rings at z10 and 2 at z11, everything else identical).

Finland, with filter_below: 12, filter_area: 0.5 added to water, landuse and landcover (master vs this PR):

layer zoom outer rings area
landcover z9 141,766 → 146,443 +0.14%
landcover z11 347,235 → 394,725 +0.28%
landuse z9 3,392 → 3,773 +1.6%
landuse z10 7,900 → 9,523 +1.8%
water z11 57,856 → 65,245 +0.03%
  • Inner rings are unchanged (one more at z11 in landcover and water).
  • Tile count is identical (645,169); tile data grows by 1.0 MB of 960 MB (+0.11%).
  • Run time is the same as master (554 s vs 542 s, 4 threads).

Makefile unit tests pass.

🤖 Generated with Claude Code

@dktue

dktue commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Before/after of two of the tiles with the largest difference (Finland, test config from the description). Left master, right this PR. Each tile is clipped to its own square, as a renderer draws it; dashed lines are tile borders.

Enlarged: the centre tile plus 64 px of its neighbours.

z10 tile 582/296 (Helsinki), 41 more landuse outer rings in the centre tile:
crop-landuse-z10-582-296

z11 tile 1150/589 (Turku), 95 more landcover outer rings in the centre tile:
crop-landcover-z11-1150-589

The same two places as 3×3 tile blocks:
landuse-z10-582-296
landcover-z11-1150-589

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.

Better area filtering

1 participant