From a0793b0b5e7fef3e418300ed1c7bf8033dfa8adf Mon Sep 17 00:00:00 2001 From: Symmetricity <184246+Symmetricity@users.noreply.github.com> Date: Thu, 28 May 2026 14:33:31 +0200 Subject: [PATCH] Fix shapefile z6 index 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 --- src/shp_mem_tiles.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/shp_mem_tiles.cpp b/src/shp_mem_tiles.cpp index 2af52e14..b417423e 100644 --- a/src/shp_mem_tiles.cpp +++ b/src/shp_mem_tiles.cpp @@ -82,7 +82,7 @@ bool ShpMemTiles::mayIntersect(const std::string& layerName, const Box& box) con uint32_t z6x = x / (1u << (spatialIndexZoom - CLUSTER_ZOOM)); uint32_t z6y = y / (1u << (spatialIndexZoom - CLUSTER_ZOOM)); - auto& bitvec = sparseLayerVector[z6x * CLUSTER_ZOOM + z6y]; + auto& bitvec = sparseLayerVector[z6x * CLUSTER_ZOOM_WIDTH + z6y]; uint32_t divisor = 1u << (spatialIndexZoom - CLUSTER_ZOOM); uint64_t index = 2u * ((x - z6x * divisor) * divisor + (y - z6y * divisor)); @@ -214,7 +214,7 @@ void ShpMemTiles::StoreGeometry( uint32_t z6x = x / (1u << (spatialIndexZoom - CLUSTER_ZOOM)); uint32_t z6y = y / (1u << (spatialIndexZoom - CLUSTER_ZOOM)); - uint32_t sparseIndex = z6x * CLUSTER_ZOOM + z6y; + uint32_t sparseIndex = z6x * CLUSTER_ZOOM_WIDTH + z6y; auto& bitvec = sparseLayerVector[sparseIndex]; if (bitvec.empty())