Skip to content

Fix shapefile z6 index#904

Open
Symmetricity wants to merge 1 commit into
systemed:masterfrom
Symmetricity:fix/shapefile-z6-index
Open

Fix shapefile z6 index#904
Symmetricity wants to merge 1 commit into
systemed:masterfrom
Symmetricity:fix/shapefile-z6-index

Conversation

@Symmetricity
Copy link
Copy Markdown
Contributor

This PR is AI generated.

Summary

  • fixes the sparse shapefile bitmap index so each z6 tile uses a distinct slot
  • replaces CLUSTER_ZOOM with CLUSTER_ZOOM_WIDTH in the flattened z6 index
    calculation

Background

ShpMemTiles stores an indexed shapefile bitmap in a sparse outer vector with
one entry per z6 tile. The comments describe the outer vector as a z6 grid.

Two lookup paths flattened that grid with:

z6x * CLUSTER_ZOOM + z6y

CLUSTER_ZOOM is the zoom level, not the width of the z6 grid. At z6 the grid
width is 1 << 6, exposed as CLUSTER_ZOOM_WIDTH. Multiplying by the zoom
level 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_WIDTH as 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 --check
  • RelWithDebInfo CMake configure/build
  • ctest --output-on-failure (no CMake tests are registered in this repo)

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>
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