Skip to content

Store large circle sets by place, so a zoomed-in tile reads only the blocks round it - #46

Merged
wf9a5m75 merged 1 commit into
developfrom
feat/spatial-circle-blocks
Nov 13, 2026
Merged

wf9a5m75 merged 1 commit into
developfrom
feat/spatial-circle-blocks

Conversation

@wf9a5m75

Copy link
Copy Markdown
Contributor

The same change as MapConductor/js-sdk-core#48, for Android.

Cause

  • The circle file kept its records in list order: 512 to a block, 48 blocks cached.
  • So a tile's circles lay in most of the file. With the national antenna set, an NYC z12 tile needed 436 of 1,414 blocks; stored by place it needs 32.

Change

  • CircleTileSet writes the file in Z-order of each circle's z12 cell. It uses a stable radix sort of 24-bit keys (StorageOrder.sortedBy), and the key is the same as js-sdk-core's (StorageOrder.mortonCellKey).
  • Indices stay the list's (draw order, updates, activation). The storage translates them (storageOrder). The grid index build, its box checks and forEachRecord walk the file in storage order.
  • forEachRecord calls come in storage order, and k says which index each one is. The GPU recording keeps the drawn-last circle per dot pixel and adds circles in list order (DeferredCircles).
  • Updates that compact the file keep the order.

Measured: Pixel 5a, 9 tiles drawn on the GPU from the real antenna data, two rounds each.

9 tiles List order By place
NYC z8 605–735 ms 240–349 ms
NYC z10 509–529 ms 204–242 ms
NYC z12 566–742 ms 265–292 ms
NYC z14 603–622 ms 467–471 ms
Chicago z10 347–357 ms 89–105 ms
Chicago z12 260–264 ms 102–110 ms

At z14 the per-tile cost (draw and encode) dominates, so the gain there is smaller.

Tests

  • Unit tests (447 pass):
    • reads by index stay correct when stored by place;
    • a region's records come from at most the two blocks they straddle, against 4 in list order;
    • compaction keeps the mapping;
    • the grid gives the same answers and reads boxes in storage order;
    • the radix sort is stable.
  • Device (Pixel 5a): ShapeTileGpuDeviceTest now also checks that a file stored by place gives the same GPU tile as index order (0 differing pixels) and matches the canvas. CircleTileFileDeviceTest passes.
  • apiCheck passes: the new types are internal.

…blocks round it

The circle file kept its records in list order, 512 to a block with 48 blocks
cached, so a tile's circles lay in most of the file: on the national antenna set a
z12 tile over New York needed 436 of 1,414 blocks.

CircleTileSet now writes the file in Z-order of each circle's z12 cell (a stable
radix sort of 24-bit keys, the same key as js-sdk-core). Indices stay the list's:
the storage translates them, and the grid index, its box checks and forEachRecord
walk the storage order. The GPU recording keeps the drawn-last circle per dot
pixel and adds the circles in list order.
@wf9a5m75
wf9a5m75 merged commit 84574bf into develop Nov 13, 2026
2 checks passed
wf9a5m75 added a commit to MapConductor/android-sdk that referenced this pull request Nov 13, 2026
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