From 9574259e759d8503aa6a17a28e61a2ef3edcf3da Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Wed, 2 Mar 2022 16:00:02 +0100 Subject: [PATCH] First attempt to use less resources --- .../Sources/FilteringFeatureSource.ts | 2 +- .../NewGeometryFromChangesFeatureSource.ts | 4 ++-- Logic/State/FeaturePipelineState.ts | 20 ++++++++++++++++--- UI/ShowDataLayer/ShowDataLayer.ts | 6 ++++++ 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/Logic/FeatureSource/Sources/FilteringFeatureSource.ts b/Logic/FeatureSource/Sources/FilteringFeatureSource.ts index 5609bfed6..1d049568a 100644 --- a/Logic/FeatureSource/Sources/FilteringFeatureSource.ts +++ b/Logic/FeatureSource/Sources/FilteringFeatureSource.ts @@ -49,7 +49,7 @@ export default class FilteringFeatureSource implements FeatureSourceForLayer, Ti self.update() }) - this._is_dirty.stabilized(250).addCallbackAndRunD(dirty => { + this._is_dirty.stabilized(1000).addCallbackAndRunD(dirty => { if (dirty) { self.update() } diff --git a/Logic/FeatureSource/Sources/NewGeometryFromChangesFeatureSource.ts b/Logic/FeatureSource/Sources/NewGeometryFromChangesFeatureSource.ts index ee2bd2cf4..232cd3113 100644 --- a/Logic/FeatureSource/Sources/NewGeometryFromChangesFeatureSource.ts +++ b/Logic/FeatureSource/Sources/NewGeometryFromChangesFeatureSource.ts @@ -54,8 +54,8 @@ export class NewGeometryFromChangesFeatureSource implements FeatureSource { // In _most_ of the cases, this means that this _isn't_ a new object // However, when a point is snapped to an already existing point, we have to create a representation for this point! // For this, we introspect the change - if (allElementStorage.has(change.id)) { - // const currentTags = allElementStorage.getEventSourceById(change.id).data + if (allElementStorage.has(change.type + "/" + change.id)) { + // The current point already exists, we don't have to do anything here continue; } console.debug("Detected a reused point") diff --git a/Logic/State/FeaturePipelineState.ts b/Logic/State/FeaturePipelineState.ts index 62f461605..798079340 100644 --- a/Logic/State/FeaturePipelineState.ts +++ b/Logic/State/FeaturePipelineState.ts @@ -12,6 +12,9 @@ import {BBox} from "../BBox"; import FeatureInfoBox from "../../UI/Popup/FeatureInfoBox"; import {FeatureSourceForLayer, Tiled} from "../FeatureSource/FeatureSource"; import MetaTagRecalculator from "../FeatureSource/Actors/MetaTagRecalculator"; +import ScrollableFullScreen from "../../UI/Base/ScrollableFullScreen"; +import BaseUIElement from "../../UI/BaseUIElement"; +import LayerConfig from "../../Models/ThemeConfig/LayerConfig"; export default class FeaturePipelineState extends MapState { @@ -21,7 +24,8 @@ export default class FeaturePipelineState extends MapState { public readonly featurePipeline: FeaturePipeline; private readonly featureAggregator: TileHierarchyAggregator; private readonly metatagRecalculator: MetaTagRecalculator - + private readonly popups : Map = new Map(); + constructor(layoutToUse: LayoutConfig) { super(layoutToUse); @@ -48,7 +52,8 @@ export default class FeaturePipelineState extends MapState { self.metatagRecalculator.registerSource(source) } } - + + function registerSource(source: FeatureSourceForLayer & Tiled) { clusterCounter.addTile(source) @@ -117,7 +122,7 @@ export default class FeaturePipelineState extends MapState { doShowLayer: doShowFeatures, selectedElement: self.selectedElement, state: self, - popup: (tags, layer) => new FeatureInfoBox(tags, layer, self) + popup: (tags, layer) => self.CreatePopup(tags, layer) } ) } @@ -134,6 +139,15 @@ export default class FeaturePipelineState extends MapState { this.AddClusteringToMap(this.leafletMap) } + + public CreatePopup(tags:any , layer: LayerConfig): ScrollableFullScreen{ + if(this.popups.has(tags.id)){ + return this.popups.get(tags.id) + } + const popup = new FeatureInfoBox(tags, layer, this) + this.popups.set(tags.id, popup) + return popup + } /** * Adds the cluster-tiles to the given map diff --git a/UI/ShowDataLayer/ShowDataLayer.ts b/UI/ShowDataLayer/ShowDataLayer.ts index bd9d6490e..dd50db6ad 100644 --- a/UI/ShowDataLayer/ShowDataLayer.ts +++ b/UI/ShowDataLayer/ShowDataLayer.ts @@ -46,6 +46,12 @@ export default class ShowDataLayer { private readonly showDataLayerid: number; private readonly createPopup: (tags: any, layer: LayerConfig) => ScrollableFullScreen + /** + * Creates a datalayer. + * + * If 'createPopup' is set, this function is called every time that 'popupOpen' is called + * @param options + */ constructor(options: ShowDataLayerOptions & { layerToShow: LayerConfig }) { this._leafletMap = options.leafletMap; this.showDataLayerid = ShowDataLayer.dataLayerIds;