From 760276922dba78004ab0c928fd301925c76f275f Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Sat, 24 Feb 2024 21:05:46 +0100 Subject: [PATCH] Re-enable osm source in all cases, fix #1798 --- .../FeatureSource/Sources/LayoutSource.ts | 45 +++++++++---------- .../NewPointLocationInput.svelte | 1 + .../InputElement/Helpers/LocationInput.svelte | 2 +- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/Logic/FeatureSource/Sources/LayoutSource.ts b/src/Logic/FeatureSource/Sources/LayoutSource.ts index 60f24ab64..dcb19e089 100644 --- a/src/Logic/FeatureSource/Sources/LayoutSource.ts +++ b/src/Logic/FeatureSource/Sources/LayoutSource.ts @@ -57,38 +57,37 @@ export default class LayoutSource extends FeatureSourceMerger { const nonMvtLayers = osmLayers.filter((l) => !mvtAvailableLayers.has(l.id)) const isLoading = new UIEventSource(false) + + const osmApiSource = LayoutSource.setupOsmApiSource( + osmLayers, + bounds, + zoom, + backend, + featureSwitches, + fullNodeDatabaseSource + ) + nonMvtSources.push(osmApiSource) + + let overpassSource: OverpassFeatureSource = undefined if (nonMvtLayers.length > 0) { console.log( "Layers ", nonMvtLayers.map((l) => l.id), " cannot be fetched from the cache server, defaulting to overpass/OSM-api" ) - const overpassSource = LayoutSource.setupOverpass( - osmLayers, - bounds, - zoom, - featureSwitches - ) - const osmApiSource = LayoutSource.setupOsmApiSource( - osmLayers, - bounds, - zoom, - backend, - featureSwitches, - fullNodeDatabaseSource - ) - nonMvtSources.push(overpassSource, osmApiSource) - - function setIsLoading() { - const loading = overpassSource?.runningQuery?.data || osmApiSource?.isRunning?.data - isLoading.setData(loading) - } - - overpassSource?.runningQuery?.addCallbackAndRun((_) => setIsLoading()) - osmApiSource?.isRunning?.addCallbackAndRun((_) => setIsLoading()) + overpassSource = LayoutSource.setupOverpass(osmLayers, bounds, zoom, featureSwitches) + nonMvtSources.push(overpassSource) supportsForceDownload.push(overpassSource) } + function setIsLoading() { + const loading = overpassSource?.runningQuery?.data || osmApiSource?.isRunning?.data + isLoading.setData(loading) + } + + overpassSource?.runningQuery?.addCallbackAndRun((_) => setIsLoading()) + osmApiSource?.isRunning?.addCallbackAndRun((_) => setIsLoading()) + const geojsonSources: UpdatableFeatureSource[] = geojsonlayers.map((l) => LayoutSource.setupGeojsonSource(l, mapProperties, isDisplayed(l.id)) ) diff --git a/src/UI/BigComponents/NewPointLocationInput.svelte b/src/UI/BigComponents/NewPointLocationInput.svelte index 6f0a69f9a..95d1b72cb 100644 --- a/src/UI/BigComponents/NewPointLocationInput.svelte +++ b/src/UI/BigComponents/NewPointLocationInput.svelte @@ -87,6 +87,7 @@ if (snapToLayers?.length > 0) { const snapSources: FeatureSource[] = [] for (const layerId of snapToLayers ?? []) { + // We assume that the layer contains the data, as the OSM-API-Feature-source should have loaded them, even though the layer might not be displayed const layer: FeatureSourceForLayer = state.perLayer.get(layerId) snapSources.push(layer) if (layer.features === undefined) { diff --git a/src/UI/InputElement/Helpers/LocationInput.svelte b/src/UI/InputElement/Helpers/LocationInput.svelte index a48492136..3aad6bf8f 100644 --- a/src/UI/InputElement/Helpers/LocationInput.svelte +++ b/src/UI/InputElement/Helpers/LocationInput.svelte @@ -66,7 +66,7 @@ if (!rangeIsShown) { new ShowDataLayer(map, { - layer: new LayerConfig(boundsdisplay), + layer: new LayerConfig( boundsdisplay), features: new StaticFeatureSource([ turf.circle(c, maxDistanceInMeters, { units: "meters",