Skip to content

feat: footprint to tiles (MAPCO-11173)#101

Open
almog8k wants to merge 4 commits into
masterfrom
feat/footprint-to-tiles-MAPCO-11173
Open

feat: footprint to tiles (MAPCO-11173)#101
almog8k wants to merge 4 commits into
masterfrom
feat/footprint-to-tiles-MAPCO-11173

Conversation

@almog8k

@almog8k almog8k commented Jul 22, 2026

Copy link
Copy Markdown
Contributor
Question Answer
New feature
Documentation
Tests added

Further information:
Adds a new geometry-only API that computes, for a footprint (Polygon / MultiPolygon / Feature, holes supported) and an inclusive zoom span, all intersecting tiles on the WGS84 geodetic 2:1 grid — emitted lazily as compressed ITileRanges.

How the algorithm works:
The tile pyramid is a quadtree: tile (z, x, y) contains exactly tiles (z+1, 2x..2x+1, 2y..2y+1), so classifying one coarse tile can settle its entire subtree. Starting from the grid's two zoom-0 root tiles, each visited tile is classified by filtering the footprint's edge list against its bounds (Liang-Barsky clipping):

  • No edges cross, center inside → the boundary doesn't pass through the tile, and a tile is a connected region, so it's uniformly inside. Its whole subtree is emitted arithmetically — one range per zoom level, zero further geometry work. This is how a coarse tile stands in for millions of deep ones.
  • No edges cross, center outside → uniformly outside; the whole subtree is pruned.
  • Edges cross → the boundary passes through, so the tile intersects (a polygon includes its boundary). Emit it and recurse into its 4 children, passing only the surviving edges — the edge list shrinks as the descent converges onto the boundary, keeping deep nodes cheap.

Recursion therefore only follows the footprint's boundary: total geometry work is O(boundary tiles at maxZoom) instead of O(bbox area × zoom levels). Interior bulk and exterior bulk are both settled at the coarsest possible level, which is also why memory stays flat — interior subtrees never get expanded, they're expressed as ranges. Point-in-polygon uses the even-odd ray-casting rule, which makes holes and MultiPolygon parts work with no special casing.

@almog8k almog8k changed the title feat: footprint to tiles (mapco-11173) feat: footprint to tiles (MAPCO-11173) Jul 22, 2026
@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown

🎫 Related Jira Issue: MAPCO-11173

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