import { FeatureCollection, Point } from "geojson" import { describe, it } from "vitest" import StaticFeatureSource from "../../../src/Logic/FeatureSource/Sources/StaticFeatureSource" import { ClusteringFeatureSource } from "../../../src/Logic/FeatureSource/TiledFeatureSource/ClusteringFeatureSource" import { UIEventSource } from "../../../src/Logic/UIEventSource" import { expect } from "chai" const points: FeatureCollection = { "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": {name: "a"}, "geometry": { "coordinates": [ 9.759318139161195, 55.56552169756637 ], "type": "Point" } }, { "type": "Feature", "properties": {name: "b"}, "geometry": { "coordinates": [ 9.759768615515327, 55.56569930560951 ], "type": "Point" } }, { "type": "Feature", "properties": {name: "c"}, "geometry": { "coordinates": [ 9.75879327221594, 55.56569229478089 ], "type": "Point" } }, { "type": "Feature", "properties": {name: "d"}, "geometry": { "coordinates": [ 9.759380131319915, 55.56507066300628 ], "type": "Point" } } ] } describe("ClusteringFeatureSource", () => { it("smallTest", () => { const source = new StaticFeatureSource(points.features) const zoom = new UIEventSource(19) // On zoomlevel 19, all points are in a different tile const clusteringSource = new ClusteringFeatureSource(source, zoom, "test", { cutoff: 2, dontClusterAboveZoom: 100 }) expect(clusteringSource.summaryPoints.features.data.length).to.eq(0) expect(clusteringSource.features.data.length).to.eq(4) zoom.set(13) const summary = clusteringSource.summaryPoints.features.data expect(summary.length).to.eq(1) expect(summary[0].properties["total_metric"]).to.eq("4") expect(clusteringSource.features.data.length).to.eq(0) }) })