go-spatial / tegola

Tegola is a Mapbox Vector Tile server written in Go
http://tegola.io/
MIT License
1.29k stars 196 forks source link

Point clustering #753

Closed zakjan closed 2 years ago

zakjan commented 3 years ago

Is it possible to implement server-side point clustering with Tegola, for use cases with high point count and low zoom level?

Currently it's possible with custom implemented Node.js service using supercluster and vt-pbf, connected to PostGIS data source. I'm looking for an out-of-the-box solution.

ARolek commented 3 years ago

@zakjan I have not had to do clustering server-side yet, but it looks like the functions you need are availalbe in PostGIS. Have you played with ST_ClusterDBSCAN yet?

If you do dive into using this function, I would be interested in seeing the solution you come up with as I think it could help others. I'm happy to help with the research if need be.

edtjones commented 2 years ago

@zakjan did you ever get anywhere with serverside clustering? I would love to hear your progress if you did.

iwpnd commented 2 years ago

Definitely possible.

Say you have a bunch of points in your provider. You create two layers.

  1. layer uses the center point of a cluster as geometry field
  2. 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.

For static geometry data I suggest to create the cluster center points and store them in the database. For infrequently changing point data I suggest caching and for frequently changing data I suggest either a big database instance or another approach.

edtjones commented 2 years ago

@iwpnd thats a really clever idea! I’ve got relatively static data AND a big database server, so I think I can cache these clusters in the db and judiciously update with triggers. Thanks for the insight! 🙂

iwpnd commented 2 years ago

@ARolek @edtjones I created an example over at iwpnd/tegola-cluster-points. I didn't really bother with performance here but from what I can see, this seems viable.

edtjones commented 2 years ago

Wow - great! Thanks Ben.

On 5 Feb 2022, at 15:36, Ben @.***> wrote:

 I created an example over at iwpnd/tegola-cluster-points. I didn't really bother with performance here but from I can see, this seems viable.

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.

ARolek commented 2 years ago

I'm going to close this issue for now. Thanks for helping @iwpnd