Example on how to cluster point data on different zoom levels.
Following a discussion on tegola issue #753
Say you have a bunch of points in your provider. You create two layers. First layer uses the center point of a cluster as geometry field. Second layer uses the default geometry field of your points. Then building your map, you use the first layer with the center points of the clusters from zoom level x to y and the second layer from y to z.
docker compose up
Generate 10.000 random points in a definied bounding box (here, Berlin).
See sql/init.sql
.
PGPASSWORD=password psql \
-U user \
-h localhost \
-p 5433 \
-d points \
-a \
-f /sql/init.sql
Open the tegola viewer at http://localhost/8080
and see the result.
The example clusters points in a proximity of 0.001 degree to each other. This is appoximately 111m, depending on where you are at in the world. For better results use another CRS and change the eps
distance value of the provider sql to your liking.
MIT
Benjamin Ramser - @iwpnd. Project Link: https://github.com/iwpnd/tegola-cluster-points
Ying Wang - Generating random test data in PostGIS
Tegola - tegola.io