Skip to content

feat(clustering): add AreaClusterProvider for on-demand spatial clustering and 2.72M buildings demo - #1811

Draft
dkhawk wants to merge 2 commits into
feat/supercluster-algorithmfrom
feat/area-cluster-provider
Draft

dkhawk wants to merge 2 commits into
feat/supercluster-algorithmfrom
feat/area-cluster-provider

Conversation

@dkhawk

@dkhawk dkhawk commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Decouples cluster data delivery from upfront in-memory collections by introducing a reactive, area-based callback clustering architecture (AreaClusterProvider). Demonstrates sub-millisecond querying and zero heap exhaustion on a real-world dataset of 2,719,379 building coordinates on Android.

Key Changes

  • AreaClusterProvider<T>: Functional interface invoked by ClusterManager with visible camera LatLngBounds and current zoom level.
  • AreaCluster<T>: Lightweight, immutable Cluster implementation that models both composite clusters (size >= 2) and leaf markers (size == 1).
  • AreaClusterProviderAlgorithm<T>: ScreenBasedAlgorithm that bridges viewport camera bounds to the area provider.
  • ClusterManager.setAreaClusterProvider(...): Convenience method to bind area providers with automatic main-thread projection viewport synchronization.
  • tools/preprocess_buildings.py: Offline Python tool to generate non-overlapping multi-resolution spatial pyramids (.scbin) using greedy radius clustering with spatial hash acceleration.
  • BinarySpatialPyramidStore: Zero-copy, memory-mapped spatial reader that queries latitude-sorted records using binary search in < 1ms.
  • BuildingMegaClusterDemoActivity: Showcase activity with real-time Map, Satellite, and Hybrid layer toggling, custom Hansel & Gretel candy house markers, and clean cluster separation.

dkhawk added 2 commits October 2, 2026 14:09
…ering and 2.72M buildings demo

- Add AreaClusterProvider functional interface and AreaCluster data model to decouple cluster delivery from upfront in-memory collections
- Add AreaClusterProviderAlgorithm ScreenBasedAlgorithm implementation that queries spatial providers using visible camera bounds and zoom level
- Add ClusterManager.setAreaClusterProvider convenience method and automatic viewport bounds propagation
- Add tools/preprocess_buildings.py to build hierarchical multi-zoom spatial pyramids using greedy radius clustering with guaranteed badge separation
- Add BinarySpatialPyramidStore memory-mapping .scbin spatial pyramids with zero-copy kernel page caching and sub-millisecond binary search queries
- Add BuildingMegaClusterDemoActivity showcasing 2,719,379 building coordinates with Hansel & Gretel candy cottage leaf markers and Map/Satellite/Hybrid layers
- Update clustering.api binary compatibility declarations
- Update BinarySpatialPyramidStore to only yield cluster records when size >= 2
- Omit isolated single buildings at low zoom levels (< minZoomForLeafMarkers)
- Enforce shouldRenderAsCluster returns true only for size >= 2, ensuring clusters never display as '1'
- Update bold candy cottage marker and add Map/Satellite/Hybrid layer switcher
@dkhawk
dkhawk requested a review from LoyalAbbas October 2, 2026 20:19
@googlemaps-bot

Copy link
Copy Markdown
Contributor

Code Coverage

Overall Project 58.7% -0.22% 🍏
Files changed 59.59% ❌

Module Coverage
Kover Gradle Plugin XML report for :clustering 45.41% -0.69% ❌
Files
Module File Coverage
Kover Gradle Plugin XML report for :clustering AreaClusterProviderAlgorithm.kt 83.33% -16.67% 🍏
ClusterManager.kt 68.06% -6.61% ❌
AreaCluster.kt 56.7% -43.3% ❌

This branch has not been deployed

No deployments
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.

2 participants