forked from MapComplete/MapComplete
Feature: more or less working version of clustering, clusters of multiple layers are joined
This commit is contained in:
parent
5bc8f11d24
commit
0048c091d0
9 changed files with 143 additions and 65 deletions
|
|
@ -3,9 +3,9 @@ import type { AddLayerObject, Map as MlMap } from "maplibre-gl"
|
|||
import { GeoJSONSource } from "maplibre-gl"
|
||||
import { ShowDataLayerOptions } from "./ShowDataLayerOptions"
|
||||
import LayerConfig from "../../Models/ThemeConfig/LayerConfig"
|
||||
import { FeatureSource, FeatureSourceForLayer } from "../../Logic/FeatureSource/FeatureSource"
|
||||
import { FeatureSource } from "../../Logic/FeatureSource/FeatureSource"
|
||||
import { BBox } from "../../Logic/BBox"
|
||||
import { Feature } from "geojson"
|
||||
import { Feature, Geometry } from "geojson"
|
||||
import LineRenderingConfig from "../../Models/ThemeConfig/LineRenderingConfig"
|
||||
import { Utils } from "../../Utils"
|
||||
import * as range_layer from "../../../assets/layers/range/range.json"
|
||||
|
|
@ -16,7 +16,7 @@ import { TagsFilter } from "../../Logic/Tags/TagsFilter"
|
|||
import { LayerConfigJson } from "../../Models/ThemeConfig/Json/LayerConfigJson"
|
||||
import { PointRenderingLayer } from "./PointRenderingLayer"
|
||||
import { ClusteringFeatureSource } from "../../Logic/FeatureSource/TiledFeatureSource/ClusteringFeatureSource"
|
||||
import summaryLayer from "../../../public/assets/generated/layers/summary.json"
|
||||
import { OsmTags } from "../../Models/OsmFeature"
|
||||
|
||||
class LineRenderingLayer {
|
||||
/**
|
||||
|
|
@ -361,7 +361,7 @@ export default class ShowDataLayer {
|
|||
layers: LayerConfig[],
|
||||
options?: Partial<Omit<ShowDataLayerOptions, "features" | "layer">>
|
||||
) {
|
||||
const perLayer: PerLayerFeatureSourceSplitter<FeatureSourceForLayer> =
|
||||
const perLayer =
|
||||
new PerLayerFeatureSourceSplitter(
|
||||
layers.filter((l) => l.source !== null).map((l) => new FilteredLayer(l)),
|
||||
features,
|
||||
|
|
@ -379,10 +379,10 @@ export default class ShowDataLayer {
|
|||
})
|
||||
}
|
||||
|
||||
perLayer.forEach((fs) => {
|
||||
perLayer.forEach((features) => {
|
||||
new ShowDataLayer(mlmap, {
|
||||
layer: fs.layer.layerDef,
|
||||
features: fs,
|
||||
layer: features.layer.layerDef,
|
||||
features,
|
||||
...(options ?? {}),
|
||||
})
|
||||
})
|
||||
|
|
@ -396,14 +396,10 @@ export default class ShowDataLayer {
|
|||
const clustering = new ClusteringFeatureSource(feats, state.mapProperties.zoom.map(z => z + 2),
|
||||
options.layer.id,
|
||||
{
|
||||
cutoff: 2,
|
||||
cutoff: 7,
|
||||
showSummaryAt: "tilecenter"
|
||||
})
|
||||
new ShowDataLayer(mlmap, {
|
||||
features: clustering.summaryPoints,
|
||||
layer: new LayerConfig(<LayerConfigJson>(<unknown>summaryLayer), "summaryLayer")
|
||||
// doShowLayer: this.mapProperties.zoom.map((z) => z < maxzoom),
|
||||
})
|
||||
|
||||
return clustering
|
||||
}
|
||||
new ShowDataLayer(mlmap, options)
|
||||
|
|
@ -411,7 +407,7 @@ export default class ShowDataLayer {
|
|||
|
||||
public static showRange(
|
||||
map: Store<MlMap>,
|
||||
features: FeatureSource,
|
||||
features: FeatureSource<Feature<Geometry, OsmTags>>,
|
||||
doShowLayer?: Store<boolean>
|
||||
): ShowDataLayer {
|
||||
return new ShowDataLayer(map, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue