mapbox / supercluster

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

NodeLink map visualization #229

Closed sjoerdvink99 closed 1 year ago

sjoerdvink99 commented 1 year ago

I am currently working on a nodelink map visualization with deck.gl and supercluster for which I need the underlying node ids in the cluster. I want to do this by adding an ids array to each cluster. Next I am attaching edges to nodes based on these ids. However, certain node id's are in more than one cluster preventing me from finding the correct clusters to attach edges to. Any ideas on how to fix this such that a node can only be in a single cluster? The current implementation looks like this:

if (rebuildIndex) {
      const index = new Supercluster({
        radius: 40,
        maxZoom: 16,
        map: (props) => ({ ids: [props.id] }),
        reduce: (accumulated, props) => {
          accumulated.ids.push(...props.ids);
          return accumulated;
        },
      });
      index.load(
        props.graph.data.nodes.map((node) => ({
          geometry: { coordinates: node.attributes.coordinates },
          properties: node,
        }))
      );
      this.setState({ index });
    }
mourner commented 1 year ago

Can you set up a minimal live test case (just Supercluster, without any other frameworks) demonstrating id duplication?