forked from MapComplete/MapComplete
Fix: fix #2306 by using a cutof of 150m
This commit is contained in:
parent
0a001d3c7d
commit
73f0ffff5d
1 changed files with 16 additions and 9 deletions
|
@ -85,7 +85,7 @@ export class ImageUploadManager {
|
||||||
uploadFinished: this.getCounterFor(this._uploadFinished, featureId),
|
uploadFinished: this.getCounterFor(this._uploadFinished, featureId),
|
||||||
retried: this.getCounterFor(this._uploadRetried, featureId),
|
retried: this.getCounterFor(this._uploadRetried, featureId),
|
||||||
failed: this.getCounterFor(this._uploadFailed, featureId),
|
failed: this.getCounterFor(this._uploadFailed, featureId),
|
||||||
retrySuccess: this.getCounterFor(this._uploadRetriedSuccess, featureId),
|
retrySuccess: this.getCounterFor(this._uploadRetriedSuccess, featureId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ export class ImageUploadManager {
|
||||||
if (sizeInBytes > this._uploader.maxFileSizeInMegabytes * 1000000) {
|
if (sizeInBytes > this._uploader.maxFileSizeInMegabytes * 1000000) {
|
||||||
const error = Translations.t.image.toBig.Subs({
|
const error = Translations.t.image.toBig.Subs({
|
||||||
actual_size: Math.floor(sizeInBytes / 1000000) + "MB",
|
actual_size: Math.floor(sizeInBytes / 1000000) + "MB",
|
||||||
max_size: this._uploader.maxFileSizeInMegabytes + "MB",
|
max_size: this._uploader.maxFileSizeInMegabytes + "MB"
|
||||||
})
|
})
|
||||||
return { error }
|
return { error }
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ export class ImageUploadManager {
|
||||||
properties,
|
properties,
|
||||||
{
|
{
|
||||||
theme: tags?.data?.["_orig_theme"] ?? this._theme.id,
|
theme: tags?.data?.["_orig_theme"] ?? this._theme.id,
|
||||||
changeType: "add-image",
|
changeType: "add-image"
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -168,15 +168,22 @@ export class ImageUploadManager {
|
||||||
if (this._gps.data && !ignoreGps) {
|
if (this._gps.data && !ignoreGps) {
|
||||||
location = [this._gps.data.longitude, this._gps.data.latitude]
|
location = [this._gps.data.longitude, this._gps.data.latitude]
|
||||||
}
|
}
|
||||||
if (location === undefined || location?.some((l) => l === undefined)) {
|
{
|
||||||
feature ??= this._indexedFeatures.featuresById.data.get(featureId)
|
feature ??= this._indexedFeatures.featuresById.data.get(featureId)
|
||||||
if(feature === undefined){
|
if (feature === undefined) {
|
||||||
throw "ImageUploadManager: no feature given and no feature found in the indexedFeature. Cannot upload this image"
|
throw "ImageUploadManager: no feature given and no feature found in the indexedFeature. Cannot upload this image"
|
||||||
}
|
}
|
||||||
location = GeoOperations.centerpointCoordinates(feature)
|
const featureCenterpoint = GeoOperations.centerpointCoordinates(feature)
|
||||||
|
if (location === undefined || location?.some((l) => l === undefined) ||
|
||||||
|
GeoOperations.distanceBetween(location, featureCenterpoint) > 150) {
|
||||||
|
/* GPS location is either unknown or very far away from the photographed location.
|
||||||
|
* Default to the centerpoint
|
||||||
|
*/
|
||||||
|
location = featureCenterpoint
|
||||||
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
;({ key, value, absoluteUrl } = await this._uploader.uploadImage(
|
({ key, value, absoluteUrl } = await this._uploader.uploadImage(
|
||||||
blob,
|
blob,
|
||||||
location,
|
location,
|
||||||
author,
|
author,
|
||||||
|
@ -186,7 +193,7 @@ export class ImageUploadManager {
|
||||||
this.increaseCountFor(this._uploadRetried, featureId)
|
this.increaseCountFor(this._uploadRetried, featureId)
|
||||||
console.error("Could not upload image, trying again:", e)
|
console.error("Could not upload image, trying again:", e)
|
||||||
try {
|
try {
|
||||||
;({ key, value, absoluteUrl } = await this._uploader.uploadImage(
|
({ key, value, absoluteUrl } = await this._uploader.uploadImage(
|
||||||
blob,
|
blob,
|
||||||
location,
|
location,
|
||||||
author,
|
author,
|
||||||
|
@ -202,7 +209,7 @@ export class ImageUploadManager {
|
||||||
ctx: "While uploading an image in the Image Upload Manager",
|
ctx: "While uploading an image in the Image Upload Manager",
|
||||||
featureId,
|
featureId,
|
||||||
author,
|
author,
|
||||||
targetKey,
|
targetKey
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
return undefined
|
return undefined
|
||||||
|
|
Loading…
Reference in a new issue