-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CARTO: ClusterTileLayer #8957
Merged
Merged
CARTO: ClusterTileLayer #8957
Conversation
This file contains 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
donmccurdy
reviewed
Jun 18, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The demo runs very smoothly on my tests — not a blip in the framerate graph! 🚀
My one concern is that we might want to be specific and strict about what the 'weight' means, as that will appear in map legends and be difficult to redefine later.
donmccurdy
approved these changes
Jun 19, 2024
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.
Background
Implementation of custom layer for CARTO module to allow display of a QuadbinTileLayer as a cluster layer.
Screen.Recording.2024-06-18.at.14.39.24.mov
Implementation
The core layer is a extended
TileLayer
which rather than rendering a subLayer per tile, collects the visible tiles and re-aggregates the data into clusters. This is quick to do due to the use of the quadbin spatial index.The resulting aggregated data is rendered using a
GeoJsonLayer
to easily allow styling of the clusters with a circle, text & icon using a familiar, typed API. For this a conversion to theGeoJsonLayer
binary data format is required, but this isn't too expensive as we are only dealing with point data.Property aggregation
The properties present in the source quadbin data are re-agggregated by inspecting their name, e.g.
population_min
will be automatically aggregated using theMIN
operation, so a cluster will be able to know what the minimum value is for all the cell which it contains. In addition to the re-aggregated properties, the count and stats are available when styling a cluster.Ahead of time aggregation
When the
clusterLevel
is sufficiently high, it is often possible for the layer to update the clusters as the zoom level changes before the data is fetched from the server. This gives the impression of responsiveness, as the data is effectively loaded in the background. Thanks to thegetPosition
accessor it is possible to know where to place each cluster precisely, avoiding the jittery movement of clusters when higher/lower resolution data is fetchedStats
When the tiles are being aggregated, each of the properties in the cells, (which is eventually present in the cluster) is also aggregated across all the visible data, to easily allow normalization during styling (see example below)
Props
The layer adds three new props to control the aggregation:
getPosition
called on each quadbin tile to determine the average positiongetWeight
called on each quadbin tile to determine the weight (often will be the count)clusterLevel
controls the size of the clustersIn addition, all the
GeoJsonLayer
props for styling point data are availableExample
Change List
ClusterTileLayer
cluster-utils
for aggregating the quadbin datafetchMap
integration (for review only)style
helpers (will break out into another PR)