Chore: housekeeping, linting

This commit is contained in:
Pieter Vander Vennet 2025-06-04 00:21:28 +02:00
parent f942529755
commit 30d00eb06d
74 changed files with 998 additions and 623 deletions

View file

@ -13,7 +13,7 @@ export interface ProvidedImage {
/**
* An alternative ID, used to deduplicate some images
*/
alt_id?: string,
alt_id?: string
date?: Date
status?: string | "ready"
/**

View file

@ -98,7 +98,11 @@ export class ImageUploadManager {
const tags = await ExifReader.load(file)
if (tags.ProjectionType.value === "cylindrical") {
return { error: new Translation({ en: "Cylindrical images (typically created by a Panorama-app) are not supported" }) }
return {
error: new Translation({
en: "Cylindrical images (typically created by a Panorama-app) are not supported",
}),
}
}
return true
@ -125,7 +129,6 @@ export class ImageUploadManager {
ignoreGPS: boolean | false
}
): void {
const tags: OsmTags = tagsStore.data
const featureId = <OsmId | NoteId>tags.id
@ -290,7 +293,7 @@ export class ImageUploadManager {
let absoluteUrl: string
try {
({ key, value, absoluteUrl } = await this._uploader.uploadImage(
;({ key, value, absoluteUrl } = await this._uploader.uploadImage(
blob,
location,
author,

View file

@ -196,7 +196,10 @@ export class Mapillary extends ImageProvider {
try {
license.date = new Date(date)
} catch (e) {
console.warn("Could not parse captured_at date from mapillary image. The date is:", date)
console.warn(
"Could not parse captured_at date from mapillary image. The date is:",
date
)
}
return license
}

View file

@ -28,7 +28,8 @@ export default class PanoramaxImageProvider extends ImageProvider {
* const match = url.match(PanoramaxImageProvider.isDirectLink)
* match[1] // => "e931ce57-4591-4dd5-aa4c-595e89c37e84"
*/
public static readonly isDirectLink = /https:\/\/panoramax.mapcomplete.org\/api\/pictures\/([0-9a-f-]+)\/(hd)|(sd)|(thumb).jpg/
public static readonly isDirectLink =
/https:\/\/panoramax.mapcomplete.org\/api\/pictures\/([0-9a-f-]+)\/(hd)|(sd)|(thumb).jpg/
public defaultKeyPrefixes: string[] = ["panoramax", "image"]
public readonly name: string = "panoramax"
@ -51,7 +52,7 @@ export default class PanoramaxImageProvider extends ImageProvider {
new SvelteUIElement(Panoramax_bw),
p.createViewLink({
imageId: img?.id,
location
location,
}),
true
)
@ -65,14 +66,14 @@ export default class PanoramaxImageProvider extends ImageProvider {
const p = new Panoramax(host)
return p.createViewLink({
imageId: img?.id,
location
location,
})
}
public addKnownMeta(meta: ImageData, url?: string) {
PanoramaxImageProvider.knownMeta[meta.id] = {
data: Promise.resolve({ data: meta, url }),
time: new Date()
time: new Date(),
}
}
@ -125,7 +126,7 @@ export default class PanoramaxImageProvider extends ImageProvider {
status: meta.properties["geovisio:status"],
rotation: Number(meta.properties["view:azimuth"]),
isSpherical: meta.properties.exif["Xmp.GPano.ProjectionType"] === "equirectangular",
date: new Date(meta.properties.datetime)
date: new Date(meta.properties.datetime),
}
}
@ -156,7 +157,7 @@ export default class PanoramaxImageProvider extends ImageProvider {
const promise: Promise<{ data: ImageData; url: string }> = this.getInfoForUncached(id)
PanoramaxImageProvider.knownMeta[id] = {
time: new Date(),
data: promise
data: promise,
}
return await promise
}
@ -215,7 +216,7 @@ export default class PanoramaxImageProvider extends ImageProvider {
return {
artist: meta.data.providers.at(-1).name, // We take the last provider, as that one probably contain the username of the uploader
date: new Date(meta.data.properties["datetime"]),
licenseShortName: meta.data.properties["geovisio:license"]
licenseShortName: meta.data.properties["geovisio:license"],
}
}
@ -247,8 +248,8 @@ export default class PanoramaxImageProvider extends ImageProvider {
properties: {
url,
northOffset,
pitchOffset
}
pitchOffset,
},
}
}
}
@ -263,7 +264,6 @@ export class PanoramaxUploader implements ImageUploader {
this.panoramax = new AuthorizedPanoramax(url, token)
}
async uploadImage(
blob: File,
currentGps: [number, number],
@ -287,13 +287,12 @@ export class PanoramaxUploader implements ImageUploader {
throw "Unsupported image format: cylindrical images (panorama images) are currently not supported"
}
if (tags?.GPSLatitude?.value && tags?.GPSLongitude?.value) {
const [[latD], [latM], [latS, latSDenom]] = <
[[number, number], [number, number], [number, number]]
>tags?.GPSLatitude?.value
>tags?.GPSLatitude?.value
const [[lonD], [lonM], [lonS, lonSDenom]] = <
[[number, number], [number, number], [number, number]]
>tags?.GPSLongitude?.value
>tags?.GPSLongitude?.value
const exifLat = latD + latM / 60 + latS / (3600 * latSDenom)
const exifLon = lonD + lonM / 60 + lonS / (3600 * lonSDenom)
@ -335,9 +334,7 @@ export class PanoramaxUploader implements ImageUploader {
} else {
datetime = exifDatetime.toISOString()
}
}
} catch (e) {
console.warn("Could not read EXIF-tags due to", e)
}
@ -356,7 +353,7 @@ export class PanoramaxUploader implements ImageUploader {
indexInSequence: sequence["stats:items"].count + 1, // stats:items is '1'-indexed, so .count is also the last index
exifOverride: {
Artist: author,
}
},
}
if (progress) {
options.onProgress = (e: ProgressEvent) => {
@ -373,7 +370,7 @@ export class PanoramaxUploader implements ImageUploader {
return {
key: "panoramax",
value: img.id,
absoluteUrl: img.assets.hd.href
absoluteUrl: img.assets.hd.href,
}
}
}