From df9c44aaed7b2670134e8f9128343022e92c6e8d Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Sat, 28 Sep 2024 22:42:56 +0200 Subject: [PATCH] Fix: load external panoramax images --- package-lock.json | 14 +++++++------- package.json | 2 +- src/Logic/ImageProviders/Panoramax.ts | 16 ++++++++-------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index 62850a967..244e83b8c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -63,7 +63,7 @@ "opening_hours": "^3.6.0", "osm-auth": "^2.5.0", "osmtogeojson": "^3.0.0-beta.5", - "panoramax-js": "^0.1.4", + "panoramax-js": "^0.1.7", "panzoom": "^9.4.3", "papaparse": "^5.3.1", "pbf": "^3.2.1", @@ -15994,9 +15994,9 @@ "license": "MIT" }, "node_modules/panoramax-js": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/panoramax-js/-/panoramax-js-0.1.4.tgz", - "integrity": "sha512-X7plFMH1ndxiiyVFEluDloNiEBH0nEkurCPJ7zAInxbgv21pp/EGFwu3ynmF5ETyyXB9zu0n309juyjTdJ5pnQ==", + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/panoramax-js/-/panoramax-js-0.1.7.tgz", + "integrity": "sha512-G5m0cs+kODGyxmuLI06m+BcQecey2d6zhk+bajUMTkeXqvIIxP+CUS6NKnmN0WyIntd4q91gdGJeOR0Q2I/jeg==", "dependencies": { "@ogcapi-js/features": "^1.1.1", "@ogcapi-js/shared": "^1.1.1", @@ -32056,9 +32056,9 @@ "version": "1.0.0" }, "panoramax-js": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/panoramax-js/-/panoramax-js-0.1.4.tgz", - "integrity": "sha512-X7plFMH1ndxiiyVFEluDloNiEBH0nEkurCPJ7zAInxbgv21pp/EGFwu3ynmF5ETyyXB9zu0n309juyjTdJ5pnQ==", + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/panoramax-js/-/panoramax-js-0.1.7.tgz", + "integrity": "sha512-G5m0cs+kODGyxmuLI06m+BcQecey2d6zhk+bajUMTkeXqvIIxP+CUS6NKnmN0WyIntd4q91gdGJeOR0Q2I/jeg==", "requires": { "@ogcapi-js/features": "^1.1.1", "@ogcapi-js/shared": "^1.1.1", diff --git a/package.json b/package.json index 451e73084..8182bd57f 100644 --- a/package.json +++ b/package.json @@ -205,7 +205,7 @@ "opening_hours": "^3.6.0", "osm-auth": "^2.5.0", "osmtogeojson": "^3.0.0-beta.5", - "panoramax-js": "^0.1.4", + "panoramax-js": "^0.1.7", "panzoom": "^9.4.3", "papaparse": "^5.3.1", "pbf": "^3.2.1", diff --git a/src/Logic/ImageProviders/Panoramax.ts b/src/Logic/ImageProviders/Panoramax.ts index eb73b9636..9536facb6 100644 --- a/src/Logic/ImageProviders/Panoramax.ts +++ b/src/Logic/ImageProviders/Panoramax.ts @@ -1,10 +1,9 @@ import { ImageUploader } from "./ImageUploader" -import { AuthorizedPanoramax, PanoramaxXYZ, ImageData } from "panoramax-js/dist" +import { AuthorizedPanoramax, ImageData, Panoramax, PanoramaxXYZ } from "panoramax-js/dist" import ExifReader from "exifreader" import ImageProvider, { ProvidedImage } from "./ImageProvider" import BaseUIElement from "../../UI/BaseUIElement" import { LicenseInfo } from "./LicenseInfo" -import { Utils } from "../../Utils" import { GeoOperations } from "../GeoOperations" import Constants from "../../Models/Constants" import { Store, Stores, UIEventSource } from "../UIEventSource" @@ -87,9 +86,9 @@ export default class PanoramaxImageProvider extends ImageProvider { } const cached = PanoramaxImageProvider.knownMeta[id] if (cached) { - if(new Date().getTime() - cached.time.getTime() < 1000){ + if (new Date().getTime() - cached.time.getTime() < 1000) { - return { data: cached.data, url: undefined } + return { data: cached.data, url: undefined } } } try { @@ -100,13 +99,14 @@ export default class PanoramaxImageProvider extends ImageProvider { try { return await this.getInfoFromXYZ(id) } catch (e) { - console.debug(e) + console.debug(e) } return undefined } - - public async ExtractUrls(key: string, value: string): Promise { + if(!Panoramax.isId(value)){ + return undefined + } return [await this.getInfoFor(value).then(r => this.featureToImage(r))] } @@ -115,7 +115,7 @@ export default class PanoramaxImageProvider extends ImageProvider { const source = UIEventSource.FromPromise(super.getRelevantUrlsFor(tags, prefixes)) function hasLoading(data: ProvidedImage[]) { - if(data === undefined){ + if (data === undefined) { return true } return data?.some(img => img?.status !== undefined && img?.status !== "ready" && img?.status !== "broken")