From 4602df30469b57a57b9b8e1b8c6cc5c70ff901d7 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Wed, 9 Aug 2023 14:18:06 +0200 Subject: [PATCH] Fix: add safety check to not overuse the OSM-api --- src/Logic/FeatureSource/Sources/OsmFeatureSource.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Logic/FeatureSource/Sources/OsmFeatureSource.ts b/src/Logic/FeatureSource/Sources/OsmFeatureSource.ts index 31616f439..1475744e9 100644 --- a/src/Logic/FeatureSource/Sources/OsmFeatureSource.ts +++ b/src/Logic/FeatureSource/Sources/OsmFeatureSource.ts @@ -72,6 +72,11 @@ export default class OsmFeatureSource extends FeatureSourceMerger { return } + if (neededTiles.total > 100) { + console.error("Too much tiles to download!") + return + } + this.isRunning.setData(true) try { const tileNumbers = Tiles.MapRange(neededTiles, (x, y) => { @@ -133,7 +138,6 @@ export default class OsmFeatureSource extends FeatureSourceMerger { } private async LoadTile(z: number, x: number, y: number): Promise { - console.log("OsmFeatureSource: loading ", z, x, y, "from", this._backend) if (z >= 22) { throw "This is an absurd high zoom level" } @@ -145,6 +149,7 @@ export default class OsmFeatureSource extends FeatureSourceMerger { if (this._downloadedTiles.has(index)) { return } + console.log("OsmFeatureSource: loading ", z, x, y, "from", this._backend) this._downloadedTiles.add(index) const bbox = BBox.fromTile(z, x, y)