From 6727bde8488873088e56d6292818ccf8bfcd9152 Mon Sep 17 00:00:00 2001 From: Denis Date: Thu, 6 Jul 2017 11:22:00 -0400 Subject: [PATCH] Add ClusterProperties to Cluster --- types/supercluster/index.d.ts | 6 ++++-- types/supercluster/supercluster-tests.ts | 17 ++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/types/supercluster/index.d.ts b/types/supercluster/index.d.ts index 98a3b247c6..6d3e6c3895 100644 --- a/types/supercluster/index.d.ts +++ b/types/supercluster/index.d.ts @@ -80,14 +80,16 @@ declare namespace supercluster { cluster_id?: number; point_count?: number; point_count_abbreviated?: number; + sum?: number; + [key: string]: any; } interface Cluster extends Point { - properties: any; + properties: ClusterProperties; } interface TileFeature { type: 1; geometry: Array<[number, number]>; - tags: any; + tags: ClusterProperties; } interface Tile { features: TileFeatures; diff --git a/types/supercluster/supercluster-tests.ts b/types/supercluster/supercluster-tests.ts index 21aa4506f5..267d2df4fd 100644 --- a/types/supercluster/supercluster-tests.ts +++ b/types/supercluster/supercluster-tests.ts @@ -1,19 +1,17 @@ import * as supercluster from 'supercluster'; -import {Point, Points, Cluster, ClusterProperties} from 'supercluster'; +import {Point} from 'supercluster'; -const point1: Cluster = { +const point1: Point = { type: 'Feature', - properties: { - foo: 'fesf' - }, - geometry: { type: 'Point', coordinates: [0, 0] } + properties: {}, + geometry: { type: 'Point', coordinates: [10, 20] } }; const point2: Point = { type: 'Feature', properties: {}, - geometry: { type: 'Point', coordinates: [0, 0] } + geometry: { type: 'Point', coordinates: [20, 30] } }; -const points: Points = [point1, point2]; +const points = [point1, point2]; const index = supercluster({ radius: 40, @@ -22,7 +20,8 @@ const index = supercluster({ log: true }); index.load(points); -index.getClusters([-180, -85, 180, 85], 2); +const clusters = index.getClusters([-180, -85, 180, 85], 2); +clusters[0].properties.cluster_id; index.getTile(0, 0, 0); index.getChildren(0, 0); index.getLeaves(0, 0, 10, 5);