2023-06-14 20:39:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  {  OsmNode ,  OsmObject ,  OsmRelation ,  OsmWay  }  from  "./OsmObject"  
						 
					
						
							
								
									
										
										
										
											2024-09-27 03:04:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  {  ImmutableStore ,  Store ,  UIEventSource  }  from  "../UIEventSource"  
						 
					
						
							
								
									
										
										
										
											2021-01-02 19:09:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  Constants  from  "../../Models/Constants"  
						 
					
						
							
								
									
										
										
										
											2021-07-15 20:47:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  OsmChangeAction  from  "./Actions/OsmChangeAction"  
						 
					
						
							
								
									
										
										
										
											2023-06-14 20:39:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  {  ChangeDescription ,  ChangeDescriptionTools  }  from  "./Actions/ChangeDescription"  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  {  Utils  }  from  "../../Utils"  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  {  LocalStorageSource  }  from  "../Web/LocalStorageSource"  
						 
					
						
							
								
									
										
										
										
											2021-10-22 14:01:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  SimpleMetaTagger  from  "../SimpleMetaTagger"  
						 
					
						
							
								
									
										
										
										
											2023-06-14 20:39:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  {  FeatureSource ,  IndexedFeatureSource  }  from  "../FeatureSource/FeatureSource"  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  {  GeoLocationPointProperties  }  from  "../State/GeoLocationState"  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  {  GeoOperations  }  from  "../GeoOperations"  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  {  ChangesetHandler ,  ChangesetTag  }  from  "./ChangesetHandler"  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  {  OsmConnection  }  from  "./OsmConnection"  
						 
					
						
							
								
									
										
										
										
											2023-04-20 03:58:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  OsmObjectDownloader  from  "./OsmObjectDownloader"  
						 
					
						
							
								
									
										
										
										
											2024-03-13 00:01:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  ChangeLocationAction  from  "./Actions/ChangeLocationAction"  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  ChangeTagAction  from  "./Actions/ChangeTagAction"  
						 
					
						
							
								
									
										
										
										
											2024-07-09 13:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  DeleteAction  from  "./Actions/DeleteAction"  
						 
					
						
							
								
									
										
										
										
											2024-07-12 03:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  MarkdownUtils  from  "../../Utils/MarkdownUtils"  
						 
					
						
							
								
									
										
										
										
											2024-09-27 03:04:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  FeaturePropertiesStore  from  "../FeatureSource/Actors/FeaturePropertiesStore"  
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  {  Feature ,  Point  }  from  "geojson"  
						 
					
						
							
								
									
										
										
										
											2020-06-24 00:35:19 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-01-03 03:09:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								/ * *  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  Handles  all  changes  made  to  OSM . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  Needs  an  authenticator  via  OsmConnection 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * / 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-15 20:47:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								export  class  Changes  {  
						 
					
						
							
								
									
										
										
										
											2021-09-22 05:02:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    public  readonly  pendingChanges : UIEventSource < ChangeDescription [ ] >  = 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-17 02:10:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        LocalStorageSource . getParsed < ChangeDescription [ ] > ( "pending-changes" ,  [ ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-22 05:02:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    public  readonly  allChanges  =  new  UIEventSource < ChangeDescription [ ] > ( undefined ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-16 16:06:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    public  readonly  state :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        allElements? : IndexedFeatureSource 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        osmConnection : OsmConnection 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-27 03:04:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        featureSwitches ? :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            featureSwitchMorePrivacy? : Store < boolean > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-16 16:06:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 21:40:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    public  readonly  extraComment : UIEventSource < string >  =  new  UIEventSource ( undefined ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-20 03:58:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    public  readonly  backend : string 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-01 02:52:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    public  readonly  isUploading  =  new  UIEventSource ( false ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-16 13:38:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    public  readonly  errors  =  new  UIEventSource < string [ ] > ( [ ] ,  "upload-errors" ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    private  readonly  historicalUserLocations? : FeatureSource < Feature < Point ,  GeoLocationPointProperties > > 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-24 12:15:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    private  _nextId : number  =  0  // Newly assigned ID's are negative
 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-09 00:05:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    private  readonly  previouslyCreated : OsmObject [ ]  =  [ ] 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-22 14:01:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    private  readonly  _leftRightSensitive : boolean 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-15 01:51:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    public  readonly  _changesetHandler : ChangesetHandler 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-24 12:01:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    private  readonly  _reportError ? :  ( string :  string  |  Error ,  extramessage? : string )  = >  void 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 05:19:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-13 02:05:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    constructor ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-27 03:04:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        state :  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-23 05:01:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            featureSwitches ? :  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-27 03:04:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                featureSwitchMorePrivacy? : Store < boolean > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                featureSwitchIsTesting? : Store < boolean > 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-19 14:44:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            osmConnection : OsmConnection 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            reportError ? :  ( error : string )  = >  void 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            featureProperties? : FeaturePropertiesStore 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            historicalUserLocations? : FeatureSource < Feature < Point ,  GeoLocationPointProperties > > 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-27 03:04:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            allElements? : IndexedFeatureSource 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } , 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-23 05:01:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        leftRightSensitive : boolean  =  false 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-13 02:05:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-22 14:01:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . _leftRightSensitive  =  leftRightSensitive 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-22 05:02:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // We keep track of all changes just as well
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this . allChanges . setData ( [ . . . this . pendingChanges . data ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-22 16:07:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // If a pending change contains a negative ID, we save that
 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-25 11:54:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . _nextId  =  Math . min ( - 1 ,  . . . ( this . pendingChanges . data ? . map ( ( pch )  = >  pch . id  ? ?  0 )  ? ?  [ ] ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-19 14:44:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( isNaN ( this . _nextId )  &&  state . reportError  !==  undefined )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            state . reportError ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                "Got a NaN as nextID. Pending changes IDs are:"  + 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                this . pendingChanges . data ? . map ( ( pch )  = >  pch ? . id ) . join ( "." ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-19 14:44:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-25 11:54:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            this . _nextId  =  - 100 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-13 02:05:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . state  =  state 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-20 03:58:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . backend  =  state . osmConnection . Backend ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-23 05:01:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . _reportError  =  state . reportError 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-26 05:58:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . _changesetHandler  =  new  ChangesetHandler ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-09 22:55:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            state . featureSwitches ? . featureSwitchIsTesting  ? ?  new  ImmutableStore ( false ) , 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-26 05:58:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            state . osmConnection , 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-26 19:15:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            state . featureProperties , 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-20 15:12:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            this , 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-02 12:48:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ( e ,  extramessage : string )  = >  this . _reportError ( e ,  extramessage ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-16 00:14:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-24 19:21:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . historicalUserLocations  =  state . historicalUserLocations 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 23:35:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // Note: a changeset might be reused which was opened just before and might have already used some ids
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // This doesn't matter however, as the '-1' is per piecewise upload, not global per changeset
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-15 20:47:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-19 14:44:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    public  static  createTestObject ( ) :  Changes  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-27 03:04:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  new  Changes ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            osmConnection : new  OsmConnection ( ) , 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-19 14:44:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            featureSwitches :  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                featureSwitchIsTesting : new  ImmutableStore ( true ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-27 03:04:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 00:18:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    public  static  async  createChangesetXMLForJosm ( actions : OsmChangeAction [ ] ,  osmConnection? : OsmConnection ) :  Promise < string >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        osmConnection  ? ? =  new  OsmConnection ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  changes  =  new  Changes ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            osmConnection 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  descriptions : ChangeDescription [ ]  =  [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  ( const  action  of  actions )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            descriptions . push ( . . . await  action . Perform ( changes ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  downloader  =  new  OsmObjectDownloader ( osmConnection . Backend ( ) ,  undefined ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  downloaded : OsmObject [ ]  =  [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  ( const  action  of  actions )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            const  osmObj  =  await  downloader . DownloadObjectAsync ( action . mainObjectId ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( osmObj  ===  "deleted" )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                continue 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            downloaded . push ( osmObj ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  Changes . buildChangesetXML ( "" ,  changes . CreateChangesetObjects ( descriptions ,  downloaded ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    / * * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     *  Creates  a  changeset 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     *  @param  csId  either  the  ID - number  of  the  changeset ,  or  an  empty  string  ( e . g .  when  uploading  with  JOSM ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     *  @param  allChanges  use  ' new  Changes ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * / 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-24 12:01:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    static  buildChangesetXML ( 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 00:18:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        csId : number  |  string , 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-22 14:13:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        allChanges :  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-09 00:05:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            modifiedObjects : OsmObject [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            newObjects : OsmObject [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            deletedObjects : OsmObject [ ] 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-02 12:48:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-09 00:05:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ) :  string  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-15 20:47:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  changedElements  =  allChanges . modifiedObjects  ? ?  [ ] 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-18 14:52:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  newElements  =  allChanges . newObjects  ? ?  [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  deletedElements  =  allChanges . deletedObjects  ? ?  [ ] 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-15 20:47:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        let  changes  =  ` <osmChange version='0.6' generator='Mapcomplete  ${ Constants . vNumber } '> ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( newElements . length  >  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            changes  += 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                "\n<create>\n"  + 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 00:18:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                newElements . map ( ( e )  = >  e . ChangesetXML ( ""  +  csId ) ) . join ( "\n" )  + 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-15 20:47:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                "</create>" 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-24 00:35:19 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-15 20:47:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( changedElements . length  >  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            changes  += 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                "\n<modify>\n"  + 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 00:18:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                changedElements . map ( ( e )  = >  e . ChangesetXML ( ""  +  csId ) ) . join ( "\n" )  + 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-15 20:47:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                "\n</modify>" 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-24 00:35:19 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-27 18:44:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-07-15 20:47:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( deletedElements . length  >  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            changes  += 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-04 03:12:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                "\n<delete>\n"  + 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 00:18:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                deletedElements . map ( ( e )  = >  e . ChangesetXML ( ""  +  csId ) ) . join ( "\n" )  + 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-04 03:12:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                "\n</delete>" 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-06 19:42:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-27 11:11:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-07-15 20:47:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        changes  +=  "</osmChange>" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  changes 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-24 00:35:19 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-12 03:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    public  static  getDocs ( ) :  string  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-13 00:01:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        function  addSource ( items : any [ ] ,  src : string )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            items . forEach ( ( i )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                i [ "source" ]  =  src 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  items 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-17 18:42:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-03-13 00:01:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  metatagsDocs :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            key? : string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            value? : string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            docs : string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            changeType? : string [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            specialMotivation? : boolean 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            source? : string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } [ ]  =  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            . . . addSource ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        key :  "comment" , 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        docs :  "The changeset comment. Will be a fixed string, mentioning the theme" 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-13 00:01:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        key :  "theme" , 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        docs :  "The name of the theme that was used to create this change. " 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-13 00:01:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        key :  "source" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        value :  "survey" , 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        docs :  "The contributor had their geolocation enabled while making changes" 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-13 00:01:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        key :  "change_within_{distance}" , 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        docs :  "If the contributor enabled their geolocation, this will hint how far away they were from the objects they edited. This gives an indication of proximity and if they truly surveyed or were armchair-mapping" 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-13 00:01:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        key :  "change_over_{distance}" , 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        docs :  "If the contributor enabled their geolocation, this will hint how far away they were from the objects they edited. If they were over 5000m away, the might have been armchair-mapping" 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-13 00:01:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        key :  "created_by" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        value :  "MapComplete <version>" , 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        docs :  "The piece of software used to create this changeset; will always start with MapComplete, followed by the version number" 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-13 00:01:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        key :  "locale" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        value :  "en|nl|de|..." , 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        docs :  "The code of the language that the contributor used MapComplete in. Hints what language the user speaks." 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-13 00:01:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        key :  "host" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        value :  "https://mapcomplete.org/<theme>" , 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        docs :  "The URL that the contributor used to make changes. One can see the used instance with this" 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-13 00:01:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        key :  "imagery" , 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        docs :  "The identifier of the used background layer, this will probably be an identifier from the [editor layer index](https://github.com/osmlab/editor-layer-index)" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-13 00:01:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                ] , 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-02 12:48:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                "default" 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-13 00:01:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            . . . addSource ( ChangeTagAction . metatags ,  "ChangeTag" ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            . . . addSource ( ChangeLocationAction . metatags ,  "ChangeLocation" ) , 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            . . . addSource ( DeleteAction . metatags ,  "DeleteAction" ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-13 00:01:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            // TODO
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            / * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            . . . DeleteAction . metatags , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            . . . LinkImageAction . metatags , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            . . . OsmChangeAction . metatags , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            . . . RelationSplitHandler . metatags , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            . . . ReplaceGeometryAction . metatags , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            . . . SplitAction . metatags , * / 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ] 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-12 03:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            "# Metatags on a changeset" , 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-13 00:01:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            "You might encounter the following metatags on a changeset:" , 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-12 03:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            MarkdownUtils . table ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-13 00:01:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                [ "key" ,  "value" ,  "explanation" ,  "source" ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                metatagsDocs . map ( ( {  key ,  value ,  docs ,  source ,  changeType ,  specialMotivation  } )  = >  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    key  ? ?  changeType ? . join ( ", " )  ? ?  "" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    value , 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-17 18:42:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    [ 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-13 00:01:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        docs , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        specialMotivation 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            ?  "This might give a reason per modified node or way" 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                            :  "" 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-12 03:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    ] . join ( "\n" ) , 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    source 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-02 12:48:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-12 03:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ] . join ( "\n\n" ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-03-13 00:01:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-15 01:51:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    public  static  GetNeededIds ( changes : ChangeDescription [ ] )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-15 20:47:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  Utils . Dedup ( changes . filter ( ( c )  = >  c . id  >=  0 ) . map ( ( c )  = >  c . type  +  "/"  +  c . id ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-10 13:47:53 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-09 00:05:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    / * * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     *  Returns  a  new  ID  and  updates  the  value  for  the  next  ID 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * / 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    public  getNewID() { 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-24 12:15:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // See #2082. We check for previous rewritings, as a remapping might be from a previous session
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        do  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this . _nextId -- 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-02 12:48:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        }  while  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this . _changesetHandler . _remappings . has ( "node/"  +  this . _nextId )  || 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this . _changesetHandler . _remappings . has ( "way/"  +  this . _nextId )  || 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this . _changesetHandler . _remappings . has ( "relation/"  +  this . _nextId ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-24 12:15:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  this . _nextId 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-09 00:05:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    / * * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     *  Uploads  all  the  pending  changes  in  one  go . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     *  Triggered  by  the  'PendingChangeUploader' - actor  in  Actors 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * / 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-14 02:50:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    public  async  flushChanges ( flushreason : string  =  undefined ) :  Promise < void >  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-09 00:05:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( this . pendingChanges . data . length  ===  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( this . isUploading . data )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            console . log ( "Is already uploading... Abort" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-17 19:28:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-20 00:09:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        console . log ( "Uploading changes due to: " ,  flushreason ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-09 00:05:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . isUploading . setData ( true ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-12 02:59:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        try  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-26 01:06:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            await  this . flushChangesAsync ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-12 02:59:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            this . isUploading . setData ( false ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-26 01:06:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            console . log ( "Changes flushed" ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-16 13:38:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            this . errors . setData ( [ ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-12 02:59:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        }  catch  ( e )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-20 15:12:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            this . _reportError ( e ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-12 02:59:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            this . isUploading . setData ( false ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-16 13:38:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            this . errors . data . push ( e ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this . errors . ping ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-12 02:59:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            console . error ( "Flushing changes failed due to" ,  e ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 23:35:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 21:40:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    public  async  applyAction ( action : OsmChangeAction ) :  Promise < void >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  changeDescriptions  =  await  action . Perform ( this ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-21 10:52:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  remapped  =  ChangeDescriptionTools . rewriteAllIds ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            changeDescriptions , 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-02 12:48:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            this . _changesetHandler . _remappings 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 21:40:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-21 10:52:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        remapped [ 0 ] . meta . distanceToObject  =  this . calculateDistanceToChanges ( action ,  remapped ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-17 18:42:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . applyChanges ( remapped ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 21:40:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    public  applyChanges ( changes : ChangeDescription [ ] )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this . pendingChanges . data . push ( . . . changes ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this . pendingChanges . ping ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this . allChanges . data . push ( . . . changes ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this . allChanges . ping ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-09 01:49:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-20 03:58:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    public  CreateChangesetObjects ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        changes : ChangeDescription [ ] , 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-24 12:15:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        downloadedOsmObjects : OsmObject [ ] , 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-24 01:50:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ignoreNoCreate : boolean  =  false 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-20 03:58:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ) :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        newObjects : OsmObject [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        modifiedObjects : OsmObject [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        deletedObjects : OsmObject [ ] 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-24 00:56:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    }  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  Changes . createChangesetObjectsStatic ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            changes , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            downloadedOsmObjects , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ignoreNoCreate , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this . previouslyCreated 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-23 18:41:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-23 18:41:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    public  static  createChangesetObjectsStatic ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        changes : ChangeDescription [ ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        downloadedOsmObjects : OsmObject [ ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ignoreNoCreate : boolean  =  false , 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-24 00:56:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        previouslyCreated : OsmObject [ ] 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-23 18:41:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ) :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        newObjects : OsmObject [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        modifiedObjects : OsmObject [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        deletedObjects : OsmObject [ ] 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-20 03:58:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    }  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-17 18:42:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        / * * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								         *  This  is  a  rather  complicated  method  which  does  a  lot  of  stuff . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								         * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								         *  Our  main  important  data  is  ` state `  and  ` objects `  which  will  determine  what  is  returned . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								         *  First  init  all  those  states ,  then  we  actually  apply  the  changes . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								         *  At  last ,  we  sort  them  for  easy  handling ,  which  is  rather  boring 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								         * / 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // ------------------ INIT -------------------------
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        / * * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								         *  Keeps  track  of  every  object  what  actually  happened  with  it 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								         * / 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-20 03:58:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  states : Map < string ,  "unchanged"  |  "created"  |  "modified"  |  "deleted" >  =  new  Map ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-17 18:42:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        / * * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								         *  Keeps  track  of  the  _new_  state  of  the  objects ,  how  they  should  end  up  on  the  database 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								         * / 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  objects : Map < string ,  OsmObject >  =  new  Map < string ,  OsmObject > ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-20 03:58:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  ( const  o  of  downloadedOsmObjects )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            objects . set ( o . type  +  "/"  +  o . id ,  o ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            states . set ( o . type  +  "/"  +  o . id ,  "unchanged" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-23 18:41:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        for  ( const  o  of  previouslyCreated )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-20 03:58:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            objects . set ( o . type  +  "/"  +  o . id ,  o ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            states . set ( o . type  +  "/"  +  o . id ,  "unchanged" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-17 18:42:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // -------------- APPLY INTERMEDIATE CHANGES -----------------
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-20 03:58:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        for  ( const  change  of  changes )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            let  changed  =  false 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            const  id  =  change . type  +  "/"  +  change . id 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( ! objects . has ( id ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                // The object hasn't been seen before, so it doesn't exist yet and is newly created by its very definition
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( change . id  >=  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    // Might be a failed fetch for simply this object
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    throw  "Did not get an object that should be known: "  +  id 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( change . changes  ===  undefined )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    // This object is a change to a newly created object. However, we have not seen the creation changedescription yet!
 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-02 12:48:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    if  ( ignoreNoCreate )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-24 01:50:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        continue 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-17 18:42:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    throw  "Not a creation of the object: "  +  JSON . stringify ( change ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-20 03:58:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                // This is a new object that should be created
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                states . set ( id ,  "created" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                let  osmObj : OsmObject  =  undefined 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                switch  ( change . type )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-04 02:25:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    case  "node" :  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-20 03:58:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        const  n  =  new  OsmNode ( change . id ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        n . lat  =  change . changes [ "lat" ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        n . lon  =  change . changes [ "lon" ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        osmObj  =  n 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        break 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-04 02:25:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    case  "way" :  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-20 03:58:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        const  w  =  new  OsmWay ( change . id ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        w . nodes  =  change . changes [ "nodes" ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        osmObj  =  w 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        break 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-04 02:25:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    case  "relation" :  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-20 03:58:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        const  r  =  new  OsmRelation ( change . id ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        r . members  =  change . changes [ "members" ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        osmObj  =  r 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        break 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-04 02:25:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-09 13:39:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        throw  "Got an invalid change.type: "  +  change . type 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-20 03:58:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( osmObj  ===  undefined )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    throw  "Hmm? This is a bug" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                objects . set ( id ,  osmObj ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-23 18:41:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                previouslyCreated . push ( osmObj ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-20 03:58:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            const  state  =  states . get ( id ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( change . doDelete )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( state  ===  "created" )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    states . set ( id ,  "unchanged" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    states . set ( id ,  "deleted" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            const  obj  =  objects . get ( id ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // Apply tag changes
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            for  ( const  kv  of  change . tags  ? ?  [ ] )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                const  k  =  kv . k 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                let  v  =  kv . v 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( v  ===  "" )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    v  =  undefined 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                const  oldV  =  obj . tags [ k ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( oldV  ===  v )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    continue 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                obj . tags [ k ]  =  v 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                changed  =  true 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( change . changes  !==  undefined )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                switch  ( change . type )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-04 02:25:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    case  "node" :  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-01 02:52:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        const  nlat  =  Utils . Round7 ( change . changes . lat ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        const  nlon  =  Utils . Round7 ( change . changes . lon ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-20 03:58:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        const  n  =  < OsmNode > obj 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        if  ( n . lat  !==  nlat  ||  n . lon  !==  nlon )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            n . lat  =  nlat 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            n . lon  =  nlon 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            changed  =  true 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        break 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-04 02:25:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    case  "way" :  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-20 03:58:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        const  nnodes  =  change . changes [ "nodes" ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        const  w  =  < OsmWay > obj 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        if  ( ! Utils . Identical ( nnodes ,  w . nodes ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            w . nodes  =  nnodes 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            changed  =  true 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        break 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-04 02:25:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    case  "relation" :  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-20 03:58:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        const  nmembers :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            type :  "node"  |  "way"  |  "relation" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            ref : number 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            role : string 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        } [ ]  =  change . changes [ "members" ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        const  r  =  < OsmRelation > obj 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        if  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            ! Utils . Identical ( nmembers ,  r . members ,  ( a ,  b )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                return  a . role  ===  b . role  &&  a . type  ===  b . type  &&  a . ref  ===  b . ref 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            } ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            r . members  =  nmembers 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            changed  =  true 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        break 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-04 02:25:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-20 03:58:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( changed  &&  states . get ( id )  ===  "unchanged" )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                states . set ( id ,  "modified" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-17 18:42:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // ----------------- SORT OBJECTS -------------------
 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-20 03:58:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  result  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            newObjects :  [ ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            modifiedObjects :  [ ] , 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            deletedObjects :  [ ] 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-20 03:58:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        objects . forEach ( ( v ,  id )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            const  state  =  states . get ( id ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( state  ===  "created" )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                result . newObjects . push ( v ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( state  ===  "modified" )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                result . modifiedObjects . push ( v ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( state  ===  "deleted" )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                result . deletedObjects . push ( v ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-14 13:53:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ! ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                result . newObjects . length  ===  0  && 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                result . modifiedObjects . length  ===  0  && 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                result . deletedObjects . length  ===  0 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-09 20:38:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            console . debug ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                "Calculated the pending changes: " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                result . newObjects . length , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                "new; " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                result . modifiedObjects . length , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                "modified;" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                result . deletedObjects . length , 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-02 12:48:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                "deleted" 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-09 20:38:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-20 03:58:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  result 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 05:19:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    private  calculateDistanceToChanges ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        change : OsmChangeAction , 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-02 12:48:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        changeDescriptions : ChangeDescription [ ] 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-16 01:46:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  locations  =  this . historicalUserLocations ? . features ? . data 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-25 00:48:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( locations  ===  undefined )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // No state loaded or no locations -> we can't calculate...
 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-09 01:49:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 05:19:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! change . trackStatistics )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-09 01:49:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            // Probably irrelevant, such as a new helper node
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-16 16:06:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( this . state . featureSwitches . featureSwitchMorePrivacy ? . data )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-06 14:23:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 21:40:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-09 01:49:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  now  =  new  Date ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-25 00:48:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  recentLocationPoints  =  locations 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-09 01:49:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            . filter ( ( feat )  = >  feat . geometry . type  ===  "Point" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            . filter ( ( feat )  = >  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                const  visitTime  =  new  Date ( feat . properties . date ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-09 01:49:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                // In seconds
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                const  diff  =  ( now . getTime ( )  -  visitTime . getTime ( ) )  /  1000 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return  diff  <  Constants . nearbyVisitTime 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 05:19:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( recentLocationPoints . length  ===  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-09 01:49:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            // Probably no GPS enabled/no fix
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 05:19:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-09 01:49:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // The applicable points, contain information in their properties about location, time and GPS accuracy
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // They are all GeoLocationPointProperties
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // We walk every change and determine the closest distance possible
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // Only if the change itself does _not_ contain any coordinates, we fall back and search the original feature in the state
 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 05:19:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  changedObjectCoordinates :  [ number ,  number ] [ ]  =  [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-13 20:58:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            const  feature  =  this . state . allElements ? . featuresById ? . data . get ( change . mainObjectId ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( feature  !==  undefined )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                changedObjectCoordinates . push ( GeoOperations . centerpointCoordinates ( feature ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-09 01:49:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-03 00:44:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-09 01:49:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        for  ( const  changeDescription  of  changeDescriptions )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 05:19:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            const  chng : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                |  {  lat : number ;  lon : number  } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                |  {  coordinates :  [ number ,  number ] [ ]  } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                |  {  members  }  =  changeDescription . changes 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( chng  ===  undefined )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-09 01:49:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                continue 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 05:19:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( chng [ "lat" ]  !==  undefined )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                changedObjectCoordinates . push ( [ chng [ "lat" ] ,  chng [ "lon" ] ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( chng [ "coordinates" ]  !==  undefined )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                changedObjectCoordinates . push ( . . . chng [ "coordinates" ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-03 00:44:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-09 02:03:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  Math . min ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            . . . changedObjectCoordinates . map ( ( coor )  = > 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-09 01:49:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                Math . min ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    . . . recentLocationPoints . map ( ( gpsPoint )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        const  otherCoor  =  GeoOperations . centerpointCoordinates ( gpsPoint ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 18:39:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        return  GeoOperations . distanceBetween ( coor ,  otherCoor ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-02 12:48:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    } ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-09 01:49:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 05:19:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-04 03:12:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    / * * 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-09 13:39:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     *  Gets  a  single ,  fresh  version  of  the  requested  osmObject  with  some  error  handling 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * / 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    private  async  getOsmObject ( id : string ,  downloader : OsmObjectDownloader )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        try  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            try  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                // Important: we do **not** cache this request, we _always_ need a fresh version!
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                const  osmObj  =  await  downloader . DownloadObjectAsync ( id ,  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return  {  id ,  osmObj  } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }  catch  ( e )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-21 10:52:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                const  msg  = 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    "Could not download OSM-object "  + 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-09 13:39:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    id  + 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " trying again before dropping it from the changes ("  + 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    e  + 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    ")" 
							 
						 
					
						
							
								
									
										
										
										
											2024-12-13 14:45:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                // this._reportError(msg) // We don't report this yet, might be a temporary fluke
 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-04 02:25:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                console . log ( msg ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-09 13:39:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                const  osmObj  =  await  downloader . DownloadObjectAsync ( id ,  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return  {  id ,  osmObj  } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }  catch  ( e )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-21 10:52:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            const  msg  = 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                "Could not download OSM-object "  +  id  +  " dropping it from the changes ("  +  e  +  ")" 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-09 13:39:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            this . _reportError ( msg ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this . errors . data . push ( e ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this . errors . ping ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  undefined 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-31 11:10:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    public  fragmentChanges ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-21 10:52:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        pending : ChangeDescription [ ] , 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-02 12:48:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        objects : OsmObject [ ] 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-21 10:52:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ) :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        refused : ChangeDescription [ ] 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-17 18:42:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        toUpload : ChangeDescription [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  refused : ChangeDescription [ ]  =  [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  toUpload : ChangeDescription [ ]  =  [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // All ids which have an 'update'
 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-21 10:52:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  createdIds  =  new  Set ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-02 12:48:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            pending . filter ( ( cd )  = >  cd . changes  !==  undefined ) . map ( ( cd )  = >  cd . id ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-21 10:52:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        pending . forEach ( ( c )  = >  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-17 18:42:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( c . id  <  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( createdIds . has ( c . id ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    toUpload . push ( c ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-09 16:55:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    this . _reportError ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-21 10:52:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        ` Got an orphaned change. The 'creation'-change description for  ${ c . type } / ${ c . id }  got lost. Permanently dropping this change: `  + 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        JSON . stringify ( c ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-21 10:52:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-17 18:42:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-21 10:52:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            const  matchFound  =  ! ! objects . find ( ( o )  = >  o . id  ===  c . id  &&  o . type  ===  c . type ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-17 18:42:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( matchFound )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                toUpload . push ( c ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-14 13:53:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                console . log ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    "Refusing change about "  + 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    c . type  + 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    "/"  + 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    c . id  + 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    " as not in the objects. No internet?" 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-14 13:53:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-17 18:42:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                refused . push ( c ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-21 10:52:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  {  refused ,  toUpload  } 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-17 18:42:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-09 13:39:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    / * * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     *  Upload  the  selected  changes  to  OSM .  This  is  typically  called  with  changes  for  a  single  theme 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     *  @return  pending  changes  which  could  not  be  uploaded  for  some  reason ;  undefined  or  empty  array  if  successful 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-04 03:12:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     * / 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-17 19:28:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    private  async  flushSelectChanges ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        pending : ChangeDescription [ ] , 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        openChangeset : UIEventSource < {  id : number ,  opened : number  } > 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-09 13:39:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ) :  Promise < ChangeDescription [ ] >  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-04 03:12:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  neededIds  =  Changes . GetNeededIds ( pending ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-24 12:01:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        / *   D o w n l o a d   t h e   l a t e s t   v e r s i o n   o f   t h e   O S M - o b j e c t s 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-02 12:48:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								         *   We  _do  not_  pass  in  the  Changes  object  itself  -  we  want  the  data  from  OSM  directly  in  order  to  apply  the  changes 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								         * / 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-20 03:58:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  downloader  =  new  OsmObjectDownloader ( this . backend ,  undefined ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-02 12:48:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  osmObjects  =  Utils . NoNull ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            await  Promise . all < {  id : string ;  osmObj : OsmObject  |  "deleted"  } > ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                neededIds . map ( ( id )  = >  this . getOsmObject ( id ,  downloader ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-20 03:58:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-24 12:01:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // Drop changes to deleted items
 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-14 20:39:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        for  ( const  {  osmObj ,  id  }  of  osmObjects )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-20 03:58:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( osmObj  ===  "deleted" )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                pending  =  pending . filter ( ( ch )  = >  ch . type  +  "/"  +  ch . id  !==  id ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  objects  =  osmObjects 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            . filter ( ( obj )  = >  obj . osmObj  !==  "deleted" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            . map ( ( obj )  = >  < OsmObject > obj . osmObj ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-29 16:38:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( this . _leftRightSensitive )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-20 03:58:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            objects . forEach ( ( obj )  = >  SimpleMetaTagger . removeBothTagging ( obj . tags ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-22 14:01:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-29 16:38:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-08 01:27:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( pending . length  ==  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            console . log ( "No pending changes..." ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-09 13:39:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return  undefined 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-08 01:27:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-24 12:01:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  metatags  =  this . buildChangesetTags ( pending ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        let  {  toUpload ,  refused  }  =  this . fragmentChanges ( pending ,  objects ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( toUpload . length  ===  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  refused 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        await  this . _changesetHandler . UploadChangeset ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ( csId ,  remappings )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( remappings . size  >  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    toUpload  =  toUpload . map ( ( ch )  = > 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-02 12:48:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        ChangeDescriptionTools . rewriteIds ( ch ,  remappings ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-24 12:01:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                const  changes :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    newObjects : OsmObject [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    modifiedObjects : OsmObject [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    deletedObjects : OsmObject [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                }  =  this . CreateChangesetObjects ( toUpload ,  objects ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 00:18:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                return  Changes . buildChangesetXML ( csId ,  changes ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-24 12:01:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            metatags , 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-02 12:48:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            openChangeset 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-24 12:01:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        console . log ( "Upload successful! Refused changes are" ,  refused ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  refused 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    / * * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     *  Builds  all  the  changeset  tags ,  such  as  ` theme=cyclofix; answer=42; add-image: 5 ` ,  . . . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * / 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    private  buildChangesetTags ( pending : ChangeDescription [ ] )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // Build statistics for the changeset tags
 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-29 16:38:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  perType  =  Array . from ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            Utils . Hist ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                pending 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    . filter ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        ( descr )  = > 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-02 12:48:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                            descr . meta . changeType  !==  undefined  &&  descr . meta . changeType  !==  null 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-02 12:48:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    . map ( ( descr )  = >  descr . meta . changeType ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-29 16:38:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ( [ key ,  count ] )  = >  ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                key : key , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                value : count , 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                aggregate : true 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-02 12:48:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-04 03:12:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  motivations  =  pending 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            . filter ( ( descr )  = >  descr . meta . specialMotivation  !==  undefined ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            . map ( ( descr )  = >  ( { 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-29 16:38:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                key : descr.meta.changeType  +  ":"  +  descr . type  +  "/"  +  descr . id , 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                value : descr.meta.specialMotivation 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-04 03:12:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 05:19:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-09 01:49:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  distances  =  Utils . NoNull ( pending . map ( ( descr )  = >  descr . meta . distanceToObject ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        distances . sort ( ( a ,  b )  = >  a  -  b ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-09 13:48:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  perBinCount  =  Constants . distanceToChangeObjectBins . map ( ( )  = >  0 ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-09 01:49:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        let  j  =  0 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  maxDistances  =  Constants . distanceToChangeObjectBins 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 05:19:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        for  ( let  i  =  0 ;  i  <  maxDistances . length ;  i ++ )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-09 01:49:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            const  maxDistance  =  maxDistances [ i ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // distances is sorted in ascending order, so as soon as one is to big, all the resting elements will be bigger too
 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 05:19:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            while  ( j  <  distances . length  &&  distances [ j ]  <  maxDistance )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                perBinCount [ i ] ++ 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-09 01:49:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                j ++ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  perBinMessage  =  Utils . NoNull ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            perBinCount . map ( ( count ,  i )  = >  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 05:19:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                if  ( count  ===  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-09 01:49:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    return  undefined 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 05:19:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                const  maxD  =  maxDistances [ i ] 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 18:41:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                let  key  =  ` change_within_ ${ maxD } m ` 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 05:19:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                if  ( maxD  ===  Number . MAX_VALUE )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-12 18:41:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    key  =  ` change_over_ ${ maxDistances [ i  -  1 ] } m ` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-09 01:49:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                return  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 05:19:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    key , 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-09 01:49:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    value : count , 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    aggregate : true 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-09 01:49:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-02 12:48:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 05:19:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-09 01:49:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // This method is only called with changedescriptions for this theme
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  theme  =  pending [ 0 ] . meta . theme 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-13 02:05:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        let  comment  =  "Adding data with #MapComplete for theme #"  +  theme 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 21:40:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( this . extraComment . data  !==  undefined )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            comment  +=  "\n\n"  +  this . extraComment . data 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-13 02:05:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 21:40:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-05 05:19:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  metatags : ChangesetTag [ ]  =  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            { 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-04 03:12:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                key :  "comment" , 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                value : comment 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-04 03:12:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            { 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-29 16:38:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                key :  "theme" , 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                value : theme 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-04 03:12:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            . . . perType , 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-09 01:49:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            . . . motivations , 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            . . . perBinMessage 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-04 03:12:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ] 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-24 12:01:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  metatags 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-04 03:12:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-14 02:50:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    private  async  flushChangesAsync ( ) :  Promise < void >  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 23:35:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        try  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-03 21:53:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            // At last, we build the changeset and upload
 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-04 02:25:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            const  pending  =  this . pendingChanges . data 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-29 16:38:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-04 03:12:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            const  pendingPerTheme  =  new  Map < string ,  ChangeDescription [ ] > ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            for  ( const  changeDescription  of  pending )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                const  theme  =  changeDescription . meta . theme 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-29 16:38:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                if  ( ! pendingPerTheme . has ( theme ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-04 03:12:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    pendingPerTheme . set ( theme ,  [ ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                pendingPerTheme . get ( theme ) . push ( changeDescription ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-29 16:38:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-09 13:39:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            const  refusedChanges : ChangeDescription [ ] [ ]  =  await  Promise . all ( 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-26 21:40:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                Array . from ( pendingPerTheme ,  async  ( [ theme ,  pendingChanges ] )  = >  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-29 16:38:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    try  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        const  openChangeset  =  this . state . osmConnection . getCurrentChangesetFor ( theme ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-14 02:50:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        console . log ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            "Using current-open-changeset-"  + 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-06 19:17:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                            theme  + 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            " from the preferences, got "  + 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            openChangeset . data 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-14 02:50:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-04 02:25:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        const  refused  =  await  this . flushSelectChanges ( pendingChanges ,  openChangeset ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-09 13:39:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        if  ( ! refused )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-16 13:38:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                            this . errors . setData ( [ ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        } 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-09 13:39:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        return  refused 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-29 16:38:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    }  catch  ( e )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-20 15:12:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        this . _reportError ( e ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-29 16:38:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        console . error ( "Could not upload some changes:" ,  e ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-16 13:38:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        this . errors . data . push ( e ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        this . errors . ping ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-09 13:39:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        return  pendingChanges 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-04 03:12:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-02 12:48:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-29 16:38:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-09 13:39:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            // We keep all the refused changes to try them again
 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-19 14:44:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            this . pendingChanges . setData ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                refusedChanges 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    . flatMap ( ( c )  = >  c ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    . filter ( ( c )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        if  ( c . id  ===  null  ||  c . id  ===  undefined )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            return  false 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        return  true 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 23:35:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        }  catch  ( e )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            console . error ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                "Could not handle changes - probably an old, pending changeset in localstorage with an invalid format; erasing those" , 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-02 12:48:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                e 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 23:35:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-16 13:38:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            this . errors . data . push ( e ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this . errors . ping ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-04 02:25:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            this . pendingChanges . setData ( [ ] ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-29 16:38:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        }  finally  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-04 02:25:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            this . isUploading . setData ( false ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 23:35:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-09 00:05:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-24 00:35:19 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}