Finish refactoring

This commit is contained in:
pietervdvn 2021-10-15 13:43:11 +02:00
parent eff6b5bfad
commit 71285d34cd
3 changed files with 9 additions and 12 deletions

View file

@ -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;

View file

@ -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(

View file

@ -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;
@ -104,6 +103,8 @@ export default class ShowDataLayer {
}
})
this.update(options)
}
private update(options: ShowDataLayerOptions) {