From 725a3c37c7039f64a22216c572e819a8b14a0ccc Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Fri, 1 Oct 2021 01:34:59 +0200 Subject: [PATCH] Don't calculate tile bounds if not sufficiently zoomed --- Logic/FeatureSource/FeaturePipeline.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Logic/FeatureSource/FeaturePipeline.ts b/Logic/FeatureSource/FeaturePipeline.ts index 5d5b3e166..b0931766a 100644 --- a/Logic/FeatureSource/FeaturePipeline.ts +++ b/Logic/FeatureSource/FeaturePipeline.ts @@ -82,8 +82,6 @@ export default class FeaturePipeline { const useOsmApi = state.locationControl.map(l => l.zoom > (state.overpassMaxZoom.data ?? 12)) this.relationTracker = new RelationsTracker() - const neededTilesFromOsm = this.getNeededTilesFromOsm() - this.sufficientlyZoomed = state.locationControl.map(location => { if (location?.zoom === undefined) { @@ -94,6 +92,7 @@ export default class FeaturePipeline { } ); + const neededTilesFromOsm = this.getNeededTilesFromOsm(this.sufficientlyZoomed) const perLayerHierarchy = new Map() this.perLayerHierarchy = perLayerHierarchy @@ -260,12 +259,15 @@ export default class FeaturePipeline { return oldestDate } - private getNeededTilesFromOsm(): UIEventSource { + private getNeededTilesFromOsm(isSufficientlyZoomed: UIEventSource): UIEventSource { const self = this return this.state.currentBounds.map(bbox => { if (bbox === undefined) { return } + if (!isSufficientlyZoomed.data) { + return; + } const osmSourceZoomLevel = self.osmSourceZoomLevel const range = bbox.containingTileRange(osmSourceZoomLevel) const tileIndexes = [] @@ -300,6 +302,9 @@ export default class FeaturePipeline { if (bbox === undefined) { return true } + if (!this.sufficientlyZoomed?.data) { + return true; + } let zoom = state.locationControl.data.zoom if (zoom < minzoom) { return true;