Skip to content

Commit

Permalink
fix getLeaves for null-property features
Browse files Browse the repository at this point in the history
Closes #46
  • Loading branch information
mourner committed Aug 29, 2017
1 parent 72b1107 commit a8ea1d9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ SuperCluster.prototype = {
for (var i = 0; i < children.length; i++) {
var props = children[i].properties;

if (props.cluster) {
if (props && props.cluster) {
if (skipped + props.point_count <= offset) {
// skip the whole cluster
skipped += props.point_count;
Expand Down
14 changes: 14 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ test('returns leaves of a cluster', function (t) {
t.end();
});

test('getLeaves handles null-property features', function (t) {
var index = supercluster().load(places.features.concat([{
type: 'Feature',
properties: null,
geometry: {
type: 'Point',
coordinates: [-79.04411780507252, 43.08771393436908]
}
}]));
var leaves = index.getLeaves(0, 0, 1, 6);
t.equal(leaves[0].properties, null);
t.end();
});

test('returns cluster expansion zoom', function (t) {
var index = supercluster().load(places.features);
t.same(index.getClusterExpansionZoom(0, 0), 1);
Expand Down

0 comments on commit a8ea1d9

Please sign in to comment.