diff --git a/Logic/FeatureSource/FeaturePipeline.ts b/Logic/FeatureSource/FeaturePipeline.ts index b0931766a6..e34d882ad3 100644 --- a/Logic/FeatureSource/FeaturePipeline.ts +++ b/Logic/FeatureSource/FeaturePipeline.ts @@ -298,16 +298,13 @@ export default class FeaturePipeline { readonly overpassMaxZoom: UIEventSource, }, useOsmApi: UIEventSource): OverpassFeatureSource { const minzoom = Math.min(...state.layoutToUse.layers.map(layer => layer.minzoom)) - const allUpToDateAndZoomSufficient = state.currentBounds.map(bbox => { + const overpassIsActive = state.currentBounds.map(bbox => { if (bbox === undefined) { - return true - } - if (!this.sufficientlyZoomed?.data) { - return true; + return false } let zoom = state.locationControl.data.zoom if (zoom < minzoom) { - return true; + return false; } if (zoom > 16) { zoom = 16 @@ -315,19 +312,22 @@ export default class FeaturePipeline { if (zoom < 8) { zoom = zoom + 2 } + const range = bbox.containingTileRange(zoom) + if(range.total > 100){ + return false + } const self = this; const allFreshnesses = Tiles.MapRange(range, (x, y) => self.freshnessForVisibleLayers(zoom, x, y)) - return !allFreshnesses.some(freshness => freshness === undefined || freshness < this.oldestAllowedDate) + return allFreshnesses.some(freshness => freshness === undefined || freshness < this.oldestAllowedDate) }, [state.locationControl]) - allUpToDateAndZoomSufficient.addCallbackAndRunD(allUpToDate => console.log("All up to data is: ", allUpToDate)) const self = this; const updater = new OverpassFeatureSource(state, { relationTracker: this.relationTracker, - isActive: useOsmApi.map(b => !b && !allUpToDateAndZoomSufficient.data, [allUpToDateAndZoomSufficient]), + isActive: useOsmApi.map(b => !b && overpassIsActive.data, [overpassIsActive]), onBboxLoaded: ((bbox, date, downloadedLayers) => { Tiles.MapRange(bbox.containingTileRange(self.osmSourceZoomLevel), (x, y) => { downloadedLayers.forEach(layer => { diff --git a/Models/TileRange.ts b/Models/TileRange.ts index 06ce4b765e..7a542a2135 100644 --- a/Models/TileRange.ts +++ b/Models/TileRange.ts @@ -14,6 +14,10 @@ export class Tiles { public static MapRange(tileRange: TileRange, f: (x: number, y: number) => T): T[] { const result: T[] = [] + const total = tileRange.total + if(total > 5000){ + throw "Tilerange too big" + } for (let x = tileRange.xstart; x <= tileRange.xend; x++) { for (let y = tileRange.ystart; y <= tileRange.yend; y++) { const t = f(x, y); @@ -99,12 +103,6 @@ export class Tiles { const ystart = Math.min(t0.y, t1.y) const yend = Math.max(t0.y, t1.y) const total = (1 + xend - xstart) * (1 + yend - ystart) - if(total > 1000){ - console.trace("Detected a big tilerange which'll be iterated over: zoomlevel", zoomlevel, "bounds:", [[lon0, lat0], [lon1, lat1]]) - } - if(total > 10000){ - throw "Tilerange too big" - } return { xstart: xstart, diff --git a/UI/BigComponents/ThemeIntroductionPanel.ts b/UI/BigComponents/ThemeIntroductionPanel.ts index 75c5b6f556..fec58bb29f 100644 --- a/UI/BigComponents/ThemeIntroductionPanel.ts +++ b/UI/BigComponents/ThemeIntroductionPanel.ts @@ -12,7 +12,7 @@ export default class ThemeIntroductionPanel extends Combine { constructor(isShown: UIEventSource) { const layout = State.state.layoutToUse - const languagePicker = LanguagePicker.CreateLanguagePicker(layout.language, Translations.t.general.pickLanguage.Clone()) + const languagePicker = LanguagePicker.CreateLanguagePicker(layout.language, Translations.t.general.pickLanguage.Clone()) const toTheMap = new SubtleButton( undefined, @@ -54,7 +54,7 @@ export default class ThemeIntroductionPanel extends Combine { "

", toTheMap, loginStatus, - layout.descriptionTail.Clone(), + layout.descriptionTail?.Clone(), "
", languagePicker, ...layout.CustomCodeSnippets() diff --git a/UI/ShowDataLayer/ShowDataLayer.ts b/UI/ShowDataLayer/ShowDataLayer.ts index e180cdf5d3..73c78f9455 100644 --- a/UI/ShowDataLayer/ShowDataLayer.ts +++ b/UI/ShowDataLayer/ShowDataLayer.ts @@ -22,6 +22,8 @@ export default class ShowDataLayer { /** * If the selected element triggers, this is used to lookup the correct layer and to open the popup * Used to avoid a lot of callbacks on the selected element + * + * Note: the key of this dictionary is 'feature.properties.id+features.geometry.type' as one feature might have multiple presentations * @private */ private readonly leafletLayersPerId = new Map() @@ -68,7 +70,7 @@ export default class ShowDataLayer { if (self._leafletMap.data === undefined) { return; } - const v = self.leafletLayersPerId.get(selected.properties.id) + const v = self.leafletLayersPerId.get(selected.properties.id+selected.geometry.type) if (v === undefined) { return; } @@ -83,7 +85,7 @@ export default class ShowDataLayer { if (feature.id !== feature.properties.id) { // Probably a feature which has renamed - console.trace("Not opening the popup for", feature) + console.log("Not opening the popup for", feature, "as probably renamed") return; } if (selected.geometry.type === feature.geometry.type // If a feature is rendered both as way and as point, opening one popup might trigger the other to open, which might trigger the one to open again @@ -223,10 +225,6 @@ export default class ShowDataLayer { popup.setContent(`
Rendering
`) leafletLayer.on("popupopen", () => { - if(State.state.selectedElement.data?.properties?.id !== feature.properties.id){ - State.state.selectedElement.setData(feature) - } - if (infobox === undefined) { const tags = State.state.allElements.getEventSourceById(feature.properties.id); infobox = new FeatureInfoBox(tags, layer); @@ -242,11 +240,16 @@ export default class ShowDataLayer { infobox.AttachTo(id) infobox.Activate(); + + + if(State.state.selectedElement.data?.properties?.id !== feature.properties.id){ + // x State.state.selectedElement.setData(feature) + } }); // Add the feature to the index to open the popup when needed - this.leafletLayersPerId.set(feature.properties.id, {feature: feature, leafletlayer: leafletLayer}) + this.leafletLayersPerId.set(feature.properties.id+feature.geometry.type, {feature: feature, leafletlayer: leafletLayer}) } diff --git a/Utils.ts b/Utils.ts index bd5cd62a5a..5c04c95472 100644 --- a/Utils.ts +++ b/Utils.ts @@ -1,5 +1,4 @@ import * as colors from "./assets/colors.json" -import {TileRange} from "./Models/TileRange"; export class Utils { @@ -238,7 +237,7 @@ export class Utils { } return target; } - + static getOrSetDefault(dict: Map, k: K, v: () => V) { let found = dict.get(k); if (found !== undefined) { diff --git a/test.ts b/test.ts index 7dd34cd93e..e20e313f08 100644 --- a/test.ts +++ b/test.ts @@ -1,50 +1,2 @@ -<<<<<<< HEAD -import {Tiles} from "./Models/TileRange"; -import OsmFeatureSource from "./Logic/FeatureSource/TiledFeatureSource/OsmFeatureSource"; -import {Utils} from "./Utils"; import {AllKnownLayouts} from "./Customizations/AllKnownLayouts"; -import LayerConfig from "./Models/ThemeConfig/LayerConfig"; - -const allLayers: LayerConfig[] = [] -const seenIds = new Set() -for (const layoutConfig of AllKnownLayouts.layoutsList) { - if (layoutConfig.hideFromOverview) { - continue - } - for (const layer of layoutConfig.layers) { - if (seenIds.has(layer.id)) { - continue - } - seenIds.add(layer.id) - allLayers.push(layer) - } -} - -console.log("All layer ids", allLayers.map(l => l.id)) - -const src = new OsmFeatureSource({ - backend: "https://www.openstreetmap.org", - handleTile: tile => console.log("Got tile", tile), - allLayers: allLayers -}) -src.LoadTile(16, 33354, 21875).then(geojson => { - console.log("Got geojson", geojson); - Utils.offerContentsAsDownloadableFile(JSON.stringify(geojson), "test.geojson", { - mimetype: "application/vnd.geo+json" - }) -}) -//*/ -======= -import LocationInput from "./UI/Input/LocationInput"; -import Loc from "./Models/Loc"; -import {UIEventSource} from "./Logic/UIEventSource"; - -new LocationInput({ - centerLocation: new UIEventSource({ - lat: 51.1110, - lon: 3.3701, - zoom : 14 - }) -}).SetStyle("height: 500px") - .AttachTo("maindiv"); ->>>>>>> feature/animated-precise-input +import {Translation} from "./UI/i18n/Translation";