Fix: load external panoramax images

This commit is contained in:
Pieter Vander Vennet 2024-09-28 22:42:56 +02:00
parent 89d31f54bc
commit df9c44aaed
3 changed files with 16 additions and 16 deletions

14
package-lock.json generated
View file

@ -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",

View file

@ -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",

View file

@ -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<ProvidedImage[]> {
if(!Panoramax.isId(value)){
return undefined
}
return [await this.getInfoFor(value).then(r => this.featureToImage(<any>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")