mapbox / mapbox/supercluster

Handle invalid input more gracefully

Open
#128 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Some of my zoom levels are returning an empty list cluster, while other zoom levels are properly returning a list of clusters.

![Screen Shot 2019-07-04 at 4 02 45 PM](https://user-images.githubusercontent.com/9806858/60686350-2d02d280-9e76-11e9-94de-6ff9379b4747.png)

```javascript

const index = new Supercluster({
radius: 200,
maxZoom: 16,
});
index.load(markers);
const clusterResponse = {};

const ZOOM_LEVELS = [9, 10, 11, 12, 13, 14, 15];
ZOOM_LEVELS.forEach((zoomLevel) => {
const clusters = index.getClusters([-180, -85, 180, 85], zoomLevel);
clusterResponse[zoomLevel.toString()] = clusters
.map(cluster => ({
id: cluster.id || cluster.properties.id,
count: cluster.properties.cluster ? cluster.properties.point_count : 1,
longitude: cluster.geometry.coordinates[0],
latitude: cluster.geometry.coordinates[1],
}));
});
```

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 by reproducing the example in issue #128 with the supplied markers, world-spanning bounds, and zoom levels 9–15. Inspect the getClusters entry point and compare its returned values at the failing zoom levels. Done means the reported input no longer produces an unexpected empty cluster list, with regression coverage for the case.

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
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.