forked from MapComplete/MapComplete
		
	Merge master
This commit is contained in:
		
						commit
						44c31594b7
					
				
					 98 changed files with 2018 additions and 1589 deletions
				
			
		|  | @ -28,6 +28,7 @@ export class ImageUploadManager { | |||
|     private readonly _osmConnection: OsmConnection | ||||
|     private readonly _changes: Changes | ||||
|     public readonly isUploading: Store<boolean> | ||||
|     private readonly _reportError: (message: (string | Error | XMLHttpRequest), extramessage?: string) => Promise<void> | ||||
| 
 | ||||
|     constructor( | ||||
|         layout: LayoutConfig, | ||||
|  | @ -37,6 +38,7 @@ export class ImageUploadManager { | |||
|         changes: Changes, | ||||
|         gpsLocation: Store<GeolocationCoordinates | undefined>, | ||||
|         allFeatures: IndexedFeatureSource, | ||||
|         reportError: (message: string | Error | XMLHttpRequest, extramessage?: string ) => Promise<void> | ||||
|     ) { | ||||
|         this._uploader = uploader | ||||
|         this._featureProperties = featureProperties | ||||
|  | @ -45,6 +47,7 @@ export class ImageUploadManager { | |||
|         this._changes = changes | ||||
|         this._indexedFeatures = allFeatures | ||||
|         this._gps = gpsLocation | ||||
|         this._reportError = reportError | ||||
| 
 | ||||
|         const failed = this.getCounterFor(this._uploadFailed, "*") | ||||
|         const done = this.getCounterFor(this._uploadFinished, "*") | ||||
|  | @ -165,6 +168,7 @@ export class ImageUploadManager { | |||
|             } catch (e) { | ||||
|                 console.error("Could again not upload image due to", e) | ||||
|                 this.increaseCountFor(this._uploadFailed, featureId) | ||||
|                 await this._reportError(e, JSON.stringify({ctx:"While uploading an image in the Image Upload Manager", featureId, author, targetKey})) | ||||
|                 return undefined | ||||
|             } | ||||
|         } | ||||
|  |  | |||
|  | @ -23,11 +23,14 @@ export default class PanoramaxImageProvider extends ImageProvider { | |||
| 
 | ||||
|     private static knownMeta: Record<string, { data: ImageData, time: Date }> = {} | ||||
| 
 | ||||
|     public SourceIcon(img?: { id: string, url: string, host?: string }, location?: { lon: number; lat: number; }): BaseUIElement { | ||||
|     public SourceIcon(img?: { id: string, url: string, host?: string }, location?: { | ||||
|         lon: number; | ||||
|         lat: number; | ||||
|     }): BaseUIElement { | ||||
|         const p = new Panoramax(img.host) | ||||
|         return new Link(new SvelteUIElement(Panoramax_bw), p.createViewLink({ | ||||
|             imageId: img?.id, | ||||
|             location | ||||
|             location, | ||||
|         }), true) | ||||
|     } | ||||
| 
 | ||||
|  | @ -162,6 +165,7 @@ export default class PanoramaxImageProvider extends ImageProvider { | |||
| 
 | ||||
| export class PanoramaxUploader implements ImageUploader { | ||||
|     private readonly _panoramax: AuthorizedPanoramax | ||||
|     maxFileSizeInMegabytes = 100 * 1000 * 1000 // 100MB
 | ||||
| 
 | ||||
|     constructor(url: string, token: string) { | ||||
|         this._panoramax = new AuthorizedPanoramax(url, token) | ||||
|  | @ -173,15 +177,25 @@ export class PanoramaxUploader implements ImageUploader { | |||
|         absoluteUrl: string | ||||
|     }> { | ||||
|         // https://panoramax.openstreetmap.fr/api/docs/swagger#/
 | ||||
|         const tags = await ExifReader.load(blob) | ||||
|         const hasDate = tags.DateTime !== undefined | ||||
|         const hasGPS = tags.GPSLatitude !== undefined && tags.GPSLongitude !== undefined | ||||
| 
 | ||||
|         const [lon, lat] = currentGps | ||||
|         let tags: ExifReader.Tags = undefined | ||||
|         let hasDate = false | ||||
|         let hasGPS = false | ||||
|         try { | ||||
|             const tags = await ExifReader.load(blob) | ||||
|             hasDate  = tags?.DateTime !== undefined | ||||
|             hasGPS = tags?.GPSLatitude !== undefined && tags?.GPSLongitude !== undefined | ||||
|         } catch (e) { | ||||
|             console.error("Could not read EXIF-tags") | ||||
|         } | ||||
| 
 | ||||
|         let [lon, lat] = currentGps | ||||
| 
 | ||||
|         const p = this._panoramax | ||||
|         const defaultSequence = (await p.mySequences())[0] | ||||
|         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
 | ||||
|             // We only pass variables as fallback!
 | ||||
|             lat: !hasGPS ? lat : undefined, | ||||
|             lon: !hasGPS ? lon : undefined, | ||||
|             isBlurred: noblur, | ||||
|  |  | |||
|  | @ -72,7 +72,7 @@ export class Changes { | |||
|         this.backend = state.osmConnection.Backend() | ||||
|         this._reportError = reportError | ||||
|         this._changesetHandler = new ChangesetHandler( | ||||
|             state.featureSwitches.featureSwitchIsTesting, | ||||
|             state.featureSwitches?.featureSwitchIsTesting ?? new ImmutableStore(false), | ||||
|             state.osmConnection, | ||||
|             state.featureProperties, | ||||
|             this, | ||||
|  | @ -837,7 +837,12 @@ export class Changes { | |||
|             ) | ||||
| 
 | ||||
|             // We keep all the refused changes to try them again
 | ||||
|             this.pendingChanges.setData(refusedChanges.flatMap((c) => c)) | ||||
|             this.pendingChanges.setData(refusedChanges.flatMap((c) => c).filter(c => { | ||||
|                 if(c.id === null || c.id === undefined){ | ||||
|                     return false | ||||
|                 } | ||||
|                 return true | ||||
|             })) | ||||
|         } catch (e) { | ||||
|             console.error( | ||||
|                 "Could not handle changes - probably an old, pending changeset in localstorage with an invalid format; erasing those", | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue