question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using getLeaves randomly throws 'No cluster with the specified id'.

See original GitHub issue

I’m using supercluster in a website where- whenever a user moves the map (mapbox-gl), the frontend sends a request to the backend with map bounds and current zoom level. I create a index using const index = Supercluster({options}).load(points). What I want to achieve is whenever the frontend requests for features on the backend, the backend should find clusters inside the given bounds (I’m already able to achieve this) and then get 1 feature from the cluster and send it back to the fronted.

So here’s the problem whenever I use index.getLeaves(cluster_id, 1) Supercluster randomly throws the Error No Cluster with the specified Id It works for some clusters but it doesn’t for others. This behavior is not expected. It will be great if you can help.

Here is a test case-

let index = new Supercluster({
	radius: 20,
	extent: 256,
	maxZoom: 23,
	minPoints: 2,
});
index.load(features); //load features

//This function runs whenever the frontend requests for features
getCluster(bounds, zoom){
    let clusters = clusterIndex.getClusters(bounds, zoom); //Array of clusters
    let features = [];
    clusters.forEach((cluster) => {
        if (!cluster) return;
        let feature = clusterIndex.getLeaves(cluster.id, 1); //randomly throws No cluster with the specified Id, 
        //I also tried 'cluster.properties.cluster_id' it still didn't work
        features.push(feature[0]);
    });
    return features;
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mournercommented, Dec 24, 2020

@sarveshkolte getClusters returns both clusters and individual unclustered points (that have no neighbors), have you tried checking cluster.properties.cluster === true before fetching leaves for it?

0reactions
mournercommented, Dec 24, 2020

No worries, glad it worked!

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-mapbox-gl supercluster not returning correct features
Clicking some clusters throws a run-time error: 'No cluster with the specified id'. Any idea why no features or the wrong features are...
Read more >
supercluster: Versions | Openbase
Possibly breaking: adjusted generated cluster id values to make sure there are no collisions when combined with generateId .
Read more >
Common CHANGES.txt - Apache Hadoop
FsShell setfacl can throw ArrayIndexOutOfBoundsException when no perm is specified. (Stephen Chu and Sathish Gurram via cnauroth) HADOOP-10780.
Read more >
Diff - gerrit - Google Git
+ If none branches are specified then link:config-gerrit.html#gerrit. ... -293,12 +293,12 @@ External IDs are stored as Git Notes in the `All-Users` ...
Read more >
gerrit - Git at Google
Merge branch 'stable-2.13' * stable-2.13: Do not assume DB down if change to ... -88,7 +88,7 @@ Login using the other identity can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found