forked from MapComplete/MapComplete
Feature: first version of clustering at low zoom levels, filters don't update yet (WIP)
This commit is contained in:
parent
4e033a93a5
commit
8360ab9a8b
11 changed files with 562 additions and 262 deletions
81
test/Logic/FeatureSource/ClusteringFeatureSource.spec.ts
Normal file
81
test/Logic/FeatureSource/ClusteringFeatureSource.spec.ts
Normal file
|
@ -0,0 +1,81 @@
|
|||
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<Point> = {
|
||||
"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)
|
||||
|
||||
|
||||
|
||||
|
||||
})
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue