Way to much fixes and improvements
This commit is contained in:
parent
e68d9d99a5
commit
5ed0bb431c
41 changed files with 1244 additions and 402 deletions
|
@ -184,16 +184,18 @@ export class FilteredLayer {
|
|||
idsFromOverpass.add(feature.properties.id);
|
||||
fusedFeatures.push(feature);
|
||||
}
|
||||
this._dataFromOverpass = fusedFeatures;
|
||||
|
||||
console.log("New elements are ", this._newElements)
|
||||
for (const feature of this._newElements) {
|
||||
if (idsFromOverpass.has(feature.properties.id)) {
|
||||
if (!idsFromOverpass.has(feature.properties.id)) {
|
||||
// This element is not yet uploaded or not yet visible in overpass
|
||||
// We include it in the layer
|
||||
fusedFeatures.push(feature);
|
||||
console.log("Adding ", feature," to fusedFeatures")
|
||||
}
|
||||
}
|
||||
|
||||
this._dataFromOverpass = fusedFeatures;
|
||||
|
||||
// We use a new, fused dataset
|
||||
data = {
|
||||
|
|
|
@ -4,6 +4,7 @@ import {FilteredLayer} from "./FilteredLayer";
|
|||
import {Bounds} from "./Bounds";
|
||||
import {Overpass} from "./Osm/Overpass";
|
||||
import {State} from "../State";
|
||||
import {LayerDefinition} from "../Customizations/LayerDefinition";
|
||||
|
||||
export class LayerUpdater {
|
||||
|
||||
|
@ -27,7 +28,7 @@ export class LayerUpdater {
|
|||
const self = this;
|
||||
|
||||
this.sufficentlyZoomed = State.state.locationControl.map(location => {
|
||||
let minzoom = Math.min(...state.layoutToUse.data.layers.map(layer => layer.minzoom ?? 18));
|
||||
let minzoom = Math.min(...state.layoutToUse.data.layers.map(layer => (layer as LayerDefinition).minzoom ?? 18));
|
||||
return location.zoom >= minzoom;
|
||||
}, [state.layoutToUse]
|
||||
);
|
||||
|
@ -49,6 +50,9 @@ export class LayerUpdater {
|
|||
const filters: TagsFilter[] = [];
|
||||
state = state ?? State.state;
|
||||
for (const layer of state.layoutToUse.data.layers) {
|
||||
if(typeof(layer) === "string"){
|
||||
continue;
|
||||
}
|
||||
if (state.locationControl.data.zoom < layer.minzoom) {
|
||||
console.log("Not loading layer ", layer.id, " as it needs at least ", layer.minzoom, "zoom")
|
||||
continue;
|
||||
|
|
|
@ -36,9 +36,8 @@ export class UIEventSource<T>{
|
|||
});
|
||||
|
||||
for (const possibleSource of possibleSources) {
|
||||
possibleSource.addCallback(() => {
|
||||
possibleSource?.addCallback(() => {
|
||||
sink.setData(source.data?.data);
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -86,5 +85,25 @@ export class UIEventSource<T>{
|
|||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public stabilized(millisToStabilize) : UIEventSource<T>{
|
||||
|
||||
const newSource = new UIEventSource<T>(this.data);
|
||||
|
||||
let currentCallback = 0;
|
||||
this.addCallback(latestData => {
|
||||
currentCallback++;
|
||||
const thisCallback = currentCallback;
|
||||
window.setTimeout(() => {
|
||||
if(thisCallback === currentCallback){
|
||||
newSource.setData(latestData);
|
||||
}
|
||||
}, millisToStabilize)
|
||||
});
|
||||
|
||||
return newSource;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue