forked from MapComplete/MapComplete
Fix: attempt to fix panoramax upload, see #2202
This commit is contained in:
parent
8480f9417c
commit
07c1cc0bee
3 changed files with 25 additions and 18 deletions
14
package-lock.json
generated
14
package-lock.json
generated
|
@ -65,7 +65,7 @@
|
||||||
"opening_hours": "^3.6.0",
|
"opening_hours": "^3.6.0",
|
||||||
"osm-auth": "^2.5.0",
|
"osm-auth": "^2.5.0",
|
||||||
"osmtogeojson": "^3.0.0-beta.5",
|
"osmtogeojson": "^3.0.0-beta.5",
|
||||||
"panoramax-js": "^0.3.8",
|
"panoramax-js": "^0.3.9",
|
||||||
"panzoom": "^9.4.3",
|
"panzoom": "^9.4.3",
|
||||||
"papaparse": "^5.3.1",
|
"papaparse": "^5.3.1",
|
||||||
"pg": "^8.11.3",
|
"pg": "^8.11.3",
|
||||||
|
@ -16009,9 +16009,9 @@
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/panoramax-js": {
|
"node_modules/panoramax-js": {
|
||||||
"version": "0.3.8",
|
"version": "0.3.9",
|
||||||
"resolved": "https://registry.npmjs.org/panoramax-js/-/panoramax-js-0.3.8.tgz",
|
"resolved": "https://registry.npmjs.org/panoramax-js/-/panoramax-js-0.3.9.tgz",
|
||||||
"integrity": "sha512-l8bUi+urcdqLjckGcEyDmYyAYCKjwFXpk/En7gpi5x32Nq2r9sHq7obX3Jbk1F7zH4rmpKbVtjS97cKEZr9zHQ==",
|
"integrity": "sha512-CCXSmqwJxZYTxkru1LBAm2O+O/nnm3lwPX/8kLxYCIAZKQSFJsl1DoTkDqm/MLoo/dJOp3LmIVuK7nTM2NRgwA==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ogcapi-js/features": "^1.1.1",
|
"@ogcapi-js/features": "^1.1.1",
|
||||||
"@ogcapi-js/shared": "^1.1.1",
|
"@ogcapi-js/shared": "^1.1.1",
|
||||||
|
@ -32104,9 +32104,9 @@
|
||||||
"version": "1.0.0"
|
"version": "1.0.0"
|
||||||
},
|
},
|
||||||
"panoramax-js": {
|
"panoramax-js": {
|
||||||
"version": "0.3.8",
|
"version": "0.3.9",
|
||||||
"resolved": "https://registry.npmjs.org/panoramax-js/-/panoramax-js-0.3.8.tgz",
|
"resolved": "https://registry.npmjs.org/panoramax-js/-/panoramax-js-0.3.9.tgz",
|
||||||
"integrity": "sha512-l8bUi+urcdqLjckGcEyDmYyAYCKjwFXpk/En7gpi5x32Nq2r9sHq7obX3Jbk1F7zH4rmpKbVtjS97cKEZr9zHQ==",
|
"integrity": "sha512-CCXSmqwJxZYTxkru1LBAm2O+O/nnm3lwPX/8kLxYCIAZKQSFJsl1DoTkDqm/MLoo/dJOp3LmIVuK7nTM2NRgwA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ogcapi-js/features": "^1.1.1",
|
"@ogcapi-js/features": "^1.1.1",
|
||||||
"@ogcapi-js/shared": "^1.1.1",
|
"@ogcapi-js/shared": "^1.1.1",
|
||||||
|
|
|
@ -209,7 +209,7 @@
|
||||||
"opening_hours": "^3.6.0",
|
"opening_hours": "^3.6.0",
|
||||||
"osm-auth": "^2.5.0",
|
"osm-auth": "^2.5.0",
|
||||||
"osmtogeojson": "^3.0.0-beta.5",
|
"osmtogeojson": "^3.0.0-beta.5",
|
||||||
"panoramax-js": "^0.3.8",
|
"panoramax-js": "^0.3.9",
|
||||||
"panzoom": "^9.4.3",
|
"panzoom": "^9.4.3",
|
||||||
"papaparse": "^5.3.1",
|
"papaparse": "^5.3.1",
|
||||||
"pg": "^8.11.3",
|
"pg": "^8.11.3",
|
||||||
|
|
|
@ -10,13 +10,14 @@ import { Store, Stores, UIEventSource } from "../UIEventSource"
|
||||||
import SvelteUIElement from "../../UI/Base/SvelteUIElement"
|
import SvelteUIElement from "../../UI/Base/SvelteUIElement"
|
||||||
import Panoramax_bw from "../../assets/svg/Panoramax_bw.svelte"
|
import Panoramax_bw from "../../assets/svg/Panoramax_bw.svelte"
|
||||||
import Link from "../../UI/Base/Link"
|
import Link from "../../UI/Base/Link"
|
||||||
|
import { Utils } from "../../Utils"
|
||||||
|
|
||||||
|
|
||||||
export default class PanoramaxImageProvider extends ImageProvider {
|
export default class PanoramaxImageProvider extends ImageProvider {
|
||||||
|
|
||||||
public static readonly singleton = new PanoramaxImageProvider()
|
public static readonly singleton = new PanoramaxImageProvider()
|
||||||
private static readonly xyz = new PanoramaxXYZ()
|
private static readonly xyz = new PanoramaxXYZ()
|
||||||
private static defaultPanoramax = new AuthorizedPanoramax(Constants.panoramax.url, Constants.panoramax.token)
|
private static defaultPanoramax = new AuthorizedPanoramax(Constants.panoramax.url, Constants.panoramax.token, 3000)
|
||||||
|
|
||||||
public defaultKeyPrefixes: string[] = ["panoramax"]
|
public defaultKeyPrefixes: string[] = ["panoramax"]
|
||||||
public readonly name: string = "panoramax"
|
public readonly name: string = "panoramax"
|
||||||
|
@ -137,9 +138,7 @@ export default class PanoramaxImageProvider extends ImageProvider {
|
||||||
Stores.Chronic(1500, () =>
|
Stores.Chronic(1500, () =>
|
||||||
hasLoading(source.data),
|
hasLoading(source.data),
|
||||||
).addCallback(_ => {
|
).addCallback(_ => {
|
||||||
console.log("UPdating... ")
|
|
||||||
super.getRelevantUrlsFor(tags, prefixes).then(data => {
|
super.getRelevantUrlsFor(tags, prefixes).then(data => {
|
||||||
console.log("New panoramax data is", data, hasLoading(data))
|
|
||||||
source.set(data)
|
source.set(data)
|
||||||
return !hasLoading(data)
|
return !hasLoading(data)
|
||||||
})
|
})
|
||||||
|
@ -180,25 +179,33 @@ export class PanoramaxUploader implements ImageUploader {
|
||||||
|
|
||||||
let hasDate = false
|
let hasDate = false
|
||||||
let hasGPS = false
|
let hasGPS = false
|
||||||
|
let [lon, lat] = currentGps
|
||||||
|
let datetime = new Date().toISOString()
|
||||||
try {
|
try {
|
||||||
const tags = await ExifReader.load(blob)
|
const tags = await ExifReader.load(blob)
|
||||||
hasDate = tags?.DateTime !== undefined
|
hasDate = tags?.DateTime !== undefined
|
||||||
hasGPS = tags?.GPSLatitude !== undefined && tags?.GPSLongitude !== undefined
|
const [[latD], [latM], [latS, latSDenom]] =<[[number,number],[number,number],[number,number]]> tags?.GPSLatitude.value
|
||||||
|
const [[lonD], [lonM], [lonS, lonSDenom]] =<[[number,number],[number,number],[number,number]]> tags?.GPSLongitude.value
|
||||||
|
lat = latD + latM / 60 + latS / (3600 * latSDenom)
|
||||||
|
lon = lonD + lonM / 60 + lonS / ( 3600 * lonSDenom)
|
||||||
|
|
||||||
|
const [date, time] = tags.DateTime.value[0].split(" ")
|
||||||
|
datetime = new Date(date.replaceAll(":", "-")+"T"+time).toISOString()
|
||||||
|
|
||||||
|
console.log("Tags are", tags)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Could not read EXIF-tags")
|
console.error("Could not read EXIF-tags")
|
||||||
}
|
}
|
||||||
|
|
||||||
let [lon, lat] = currentGps
|
|
||||||
|
|
||||||
const p = this._panoramax
|
const p = this._panoramax
|
||||||
const defaultSequence = (await p.mySequences())[0]
|
const defaultSequence = (await p.mySequences())[0]
|
||||||
|
console.log("Upload options are", lon, lat, datetime)
|
||||||
const img = <ImageData>await p.addImage(blob, defaultSequence, {
|
const img = <ImageData>await p.addImage(blob, defaultSequence, {
|
||||||
// It might seem odd that we set 'undefined' here - keep in mind that, by default, panoramax will use the EXIF-data
|
lon: Utils.Round7(lon),
|
||||||
// We only pass variables as fallback!
|
lat: Utils.Round7(lat),
|
||||||
lat: !hasGPS ? lat : undefined,
|
datetime,
|
||||||
lon: !hasGPS ? lon : undefined,
|
|
||||||
isBlurred: noblur,
|
isBlurred: noblur,
|
||||||
datetime: !hasDate ? new Date().toISOString() : undefined,
|
|
||||||
exifOverride: {
|
exifOverride: {
|
||||||
Artist: author,
|
Artist: author,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue