UI: don't allow cylindrical images for now, see #2424

This commit is contained in:
Pieter Vander Vennet 2025-06-02 16:08:55 +02:00
parent 10e0262a0d
commit b9293dc2c9
5 changed files with 80 additions and 75 deletions

View file

@ -13,6 +13,7 @@ import ImageUploadQueue, { ImageUploadArguments } from "./ImageUploadQueue"
import { GeoOperations } from "../GeoOperations"
import NoteCommentElement from "../../UI/Popup/Notes/NoteCommentElement"
import OsmObjectDownloader from "../Osm/OsmObjectDownloader"
import ExifReader from "exifreader"
/**
* The ImageUploadManager has a
@ -81,7 +82,7 @@ export class ImageUploadManager {
this._reportError = reportError
}
public canBeUploaded(file: File): true | { error: Translation } {
public async canBeUploaded(file: File): Promise<true | { error: Translation }> {
const sizeInBytes = file.size
if (sizeInBytes > this._uploader.maxFileSizeInMegabytes * 1000000) {
const error = Translations.t.image.toBig.Subs({
@ -94,12 +95,19 @@ export class ImageUploadManager {
if (ext !== "jpg" && ext !== "jpeg") {
return { error: new Translation({ en: "Only JPG-files are allowed" }) }
}
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 true
}
/**
* Uploads the given image, applies the correct title and license for the known user.
* Will then add this image to the OSM-feature or the OSM-note automatically, based on the ID of the feature.
* Does _not_ check 'canBeUploaded'
* Note: the image will actually be added to the queue. If the image-upload fails, this will be attempted when visiting MC again
* @param file a jpg file to upload
* @param tagsStore The tags of the feature
@ -117,10 +125,6 @@ export class ImageUploadManager {
ignoreGPS: boolean | false
}
): void {
const canBeUploaded = this.canBeUploaded(file)
if (canBeUploaded !== true) {
throw canBeUploaded.error
}
const tags: OsmTags = tagsStore.data
const featureId = <OsmId | NoteId>tags.id
@ -286,7 +290,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,