Fix shapefile z6 index#904
Open
Symmetricity wants to merge 1 commit into
Open
Conversation
The shapefile sparse tile bitmap is stored as a flattened z6 grid. The existing index multiplied z6x by CLUSTER_ZOOM, which aliases unrelated z6 cells because CLUSTER_ZOOM is the zoom level, not the grid width. Use CLUSTER_ZOOM_WIDTH for both writing and reading the bitmap index so each z6 cell maps to a distinct sparse vector. Co-authored-by: Codex <noreply@openai.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is AI generated.
Summary
CLUSTER_ZOOMwithCLUSTER_ZOOM_WIDTHin the flattened z6 indexcalculation
Background
ShpMemTilesstores an indexed shapefile bitmap in a sparse outer vector withone entry per z6 tile. The comments describe the outer vector as a z6 grid.
Two lookup paths flattened that grid with:
CLUSTER_ZOOMis the zoom level, not the width of the z6 grid. At z6 the gridwidth is
1 << 6, exposed asCLUSTER_ZOOM_WIDTH. Multiplying by the zoomlevel aliases unrelated z6 cells into the same sparse bitmap slot.
I checked the history around the sparse shapefile bitmap. I found the memory
and lazy-refinement rationale for the bitmap, but not a rationale for using the
zoom value as the row stride.
Change
Use
CLUSTER_ZOOM_WIDTHas the row stride in both:ShpMemTiles::mayIntersect()ShpMemTiles::StoreGeometry()The bitmap layout, lazy refinement behavior, and memory model are otherwise
unchanged.
Expected Behavior
Indexed shapefile intersection checks should no longer share bitmap state
between unrelated z6 cells. This can prevent false positives or false negatives
caused by aliasing and should make shapefile-backed output more consistent with
the intended spatial index.
The memory footprint of the outer sparse vector is unchanged; this changes
which existing slot is used, not the number of slots.
Testing
git diff --checkctest --output-on-failure(no CMake tests are registered in this repo)