From 71285d34cd94579f91c0ceb98db217876c0ade3f Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Fri, 15 Oct 2021 13:43:11 +0200 Subject: [PATCH] Finish refactoring --- Logic/FeatureSource/Sources/GeoJsonSource.ts | 7 ++----- Logic/State/FeaturePipelineState.ts | 7 +++---- UI/ShowDataLayer/ShowDataLayer.ts | 7 ++++--- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Logic/FeatureSource/Sources/GeoJsonSource.ts b/Logic/FeatureSource/Sources/GeoJsonSource.ts index 81785c14b..be93dedc7 100644 --- a/Logic/FeatureSource/Sources/GeoJsonSource.ts +++ b/Logic/FeatureSource/Sources/GeoJsonSource.ts @@ -68,13 +68,10 @@ export default class GeoJsonSource implements FeatureSourceForLayer, Tiled { const self = this; Utils.downloadJson(url) .then(json => { - if(json.elements === undefined || json.elements === null){ - return; - } - if (json.elements === [] && json.remarks.indexOf("runtime error") > 0) { - self.onFail("Runtime error (timeout)", url) + if(json.features === undefined || json.features === null){ return; } + const time = new Date(); const newFeatures: { feature: any, freshness: Date } [] = [] let i = 0; diff --git a/Logic/State/FeaturePipelineState.ts b/Logic/State/FeaturePipelineState.ts index d6a096796..33124f844 100644 --- a/Logic/State/FeaturePipelineState.ts +++ b/Logic/State/FeaturePipelineState.ts @@ -1,6 +1,5 @@ import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig"; import FeaturePipeline from "../FeatureSource/FeaturePipeline"; -import State from "../../State"; import {Tiles} from "../../Models/TileRange"; import ShowDataLayer from "../../UI/ShowDataLayer/ShowDataLayer"; import {TileHierarchyAggregator} from "../../UI/ShowDataLayer/TileHierarchyAggregator"; @@ -37,13 +36,13 @@ export default class FeaturePipelineState extends MapState { // Do show features indicates if the 'showDataLayer' should be shown const doShowFeatures = source.features.map( f => { - const z = State.state.locationControl.data.zoom + const z = self.locationControl.data.zoom if (!source.layer.isDisplayed.data) { return false; } - const bounds = State.state.currentBounds.data + const bounds = self.currentBounds.data if (bounds === undefined) { // Map is not yet displayed return false; @@ -86,7 +85,7 @@ export default class FeaturePipelineState extends MapState { return true - }, [State.state.currentBounds, source.layer.isDisplayed] + }, [this.currentBounds, source.layer.isDisplayed] ) new ShowDataLayer( diff --git a/UI/ShowDataLayer/ShowDataLayer.ts b/UI/ShowDataLayer/ShowDataLayer.ts index d59bb5cbd..245619a72 100644 --- a/UI/ShowDataLayer/ShowDataLayer.ts +++ b/UI/ShowDataLayer/ShowDataLayer.ts @@ -6,7 +6,6 @@ import LayerConfig from "../../Models/ThemeConfig/LayerConfig"; import FeatureInfoBox from "../Popup/FeatureInfoBox"; import {ShowDataLayerOptions} from "./ShowDataLayerOptions"; import {ElementStorage} from "../../Logic/ElementStorage"; -import Hash from "../../Logic/Web/Hash"; export default class ShowDataLayer { @@ -48,13 +47,13 @@ export default class ShowDataLayer { this.allElements = options.allElements; const self = this; - options.leafletMap.addCallbackAndRunD(_ => { + options.leafletMap.addCallback(_ => { self.update(options) } ); features.addCallback(_ => self.update(options)); - options.doShowLayer?.addCallbackAndRun(doShow => { + options.doShowLayer?.addCallback(doShow => { const mp = options.leafletMap.data; if (mp == undefined) { return; @@ -103,6 +102,8 @@ export default class ShowDataLayer { leafletLayer.openPopup() } }) + + this.update(options) }