Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getClusters always returns 1 cluster #188

Open
jgiunta1 opened this issue Oct 3, 2021 · 1 comment
Open

getClusters always returns 1 cluster #188

jgiunta1 opened this issue Oct 3, 2021 · 1 comment
Labels

Comments

@jgiunta1
Copy link

jgiunta1 commented Oct 3, 2021

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

@jgiunta1
Copy link
Author

jgiunta1 commented Oct 3, 2021

var points = [{
    geometry: {
      type: "Point",
      coordinates: [-73.7035824, 40.8082369]
    },
    properties: {},
    type: "Feature"
  },
  {
    geometry: {
      type: "Point",
      coordinates: [-73.6378459, 40.7578053]
    },
    properties: {},
    type: "Feature"
  },
  {
    geometry: {
      type: "Point",
      coordinates: [-73.6368516, 40.7578852]
    },
    properties: {},
    type: "Feature"
  },
  {
    geometry: {
      type: "Point",
      coordinates: [-73.637478, 40.757829]
    },
    properties: {},
    type: "Feature"
  },
  {
    geometry: {
      type: "Point",
      coordinates: [-73.637179, 40.7579205]
    },
    properties: {},
    type: "Feature"
  },

]

var bbox = [-73.71451368188093,
  40.753878070983085,
   -73.62592031811903,
  40.812160916223675
]

var zoomLevel = 4;

var index = supercluster({
  radius: 40,
  maxZoom: 16
});
index.load(points);
var clusters = index.getClusters(bbox, zoomLevel);

console.log(clusters);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants