Skip to content

Commit

Permalink
Fix getClusterExpansionZoom for maxZoom (#106)
Browse files Browse the repository at this point in the history
* add failing test

* fix failing test
  • Loading branch information
cherniavskii authored and mourner committed Nov 5, 2018
1 parent 0851f7a commit d26e515
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class SuperCluster {

getClusterExpansionZoom(clusterId) {
let clusterZoom = (clusterId % 32) - 1;
while (clusterZoom < this.options.maxZoom) {
while (clusterZoom <= this.options.maxZoom) {
const children = this.getChildren(clusterId);
clusterZoom++;
if (children.length !== 1) break;
Expand Down
11 changes: 11 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ test('returns cluster expansion zoom', (t) => {
t.end();
});

test('returns cluster expansion zoom for maxZoom', (t) => {
const index = supercluster({
radius: 60,
extent: 256,
maxZoom: 4,
}).load(places.features);

t.same(index.getClusterExpansionZoom(2436), 5);
t.end();
});

test('aggregates cluster properties with reduce', (t) => {
const index = supercluster({
initial: () => ({sum: 0}),
Expand Down

0 comments on commit d26e515

Please sign in to comment.