mapbox / supercluster

A very fast geospatial point clustering library for browsers and Node.
ISC License
2.12k stars 300 forks source link

Right way to use supercluster with dynamic data #237

Closed giovanni-bertoncelli closed 10 months ago

giovanni-bertoncelli commented 1 year ago

Hi, first of all thank you for the great job, supercluster is a very useful and well crafted library! I use supercluster with a dynamic set of Points, there are two different cases in which the set of Points may change and re-trigger a clustering:

  1. When I change the bbox of my map I download from an API all the Points in that bounding box and trigger a clustering
  2. When I receive from a live broker some update on a current bounding box point a new clustering operation is triggered.

I was wondering which is the right way to use supercluster in this case:

  1. Keeping the same index and calling load each time I have to trigger the clustering (though I'm not sure this does not causes memory leaks)
  2. Redeclare each time the index and loading the points

I'm also using the "fly to cluster" feature. Since it may happen that during a clustering operation and before the clustering is complete a user may fly to a cluster how can I be sure that the cluster exists before all the clusters change and there is no way to find the zoom level required?

Another question: if I re-use the same index is there any way to cache points between two load calls?

Steve7394 commented 10 months ago

is there any suggestion? this is useful for some fleet management system

giovanni-bertoncelli commented 10 months ago

@Steve7394 I've been waiting for 5 months for some kind of reply... 😞

mourner commented 10 months ago

Sorry for the late reply.

Supercluster in general isn't very well suited to dynamic cases. It was designed from the ground up for static cases. It may work well in specific cases still, but I don't think any improvements can be made for that category of cases.

giovanni-bertoncelli commented 10 months ago

Ok thank you @mourner . Any suggestion for some library more suited for this use case?

jlumsden-mts commented 8 months ago

I came across this question after finding we had a memory leak in our application due to calling load repeatedly on a single Supercluster instance.

This leak went away when we recreated a new Supercluster each time prior to calling load. Using v8.0.1.

Have not had a chance to dig into this further.