mapbox / mapbox/supercluster

getClusters always returns 1 cluster

Open
#188 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
JavaScript
Stars
2.4k
Forks
304
PR merge metrics
No merged PRs in 30d

Description

Its not entirely clear in the docs how getClusters takes the input and generates clusters with it.

What is bbox? Is it the distance of each point in order to include it in a cluster? Is it the bbox of all the points that will be included in the cluster calculation?

What is zoom? How does this variable change the way the clusters are partitioned?

Where can we set the distance required between given points for them to be "clustered"?

I have the following points:

// Outlier
{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[-73.7035824,40.8082369]}}

// Close Grouping
 {"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[-73.6378459,40.7578053]}}
{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[-73.6368516,40.7578852]}}
{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[-73.637478,40.757829]}}
{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[-73.637179,40.7579205]}}

Initial bounds:

[westLng, southLat, eastLng, northLat]

 initBounds [-73.71451368188093, 40.753878070983085, -73.62592031811903, 40.812160916223675]

And I'm calling getCluster every time the map's bounds/zoom change. Ever time it returns one giant cluster when its clear that one of these points is an outlier.

    const superCluster = new Supercluster({
      radius: 40,
      extent: 256,
      maxZoom: 18,
    });

    superCluster.load(markerData);


    const clusterCalc = superCluster.getClusters(
      convertBoundsToBBox(bounds || initialBounds),
      zoom || 2
    );

   // clusterCalc.length always equals 1 regardless of changing border or zoom

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the getClusters entry point and review how bbox, zoom, radius, and extent affect the supplied points. Reproduce the report with the five GeoJSON points, initial bounds, and several zoom values; done means explaining or correcting why the outlier is returned in the same cluster and documenting the relevant behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.