| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  | import { ChangeDescription } from "./ChangeDescription" | 
					
						
							|  |  |  | import OsmChangeAction from "./OsmChangeAction" | 
					
						
							| 
									
										
										
										
											2021-10-13 03:09:37 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | export default class ChangeLocationAction extends OsmChangeAction { | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |     private readonly _id: number | 
					
						
							|  |  |  |     private readonly _newLonLat: [number, number] | 
					
						
							|  |  |  |     private readonly _meta: { theme: string; reason: string } | 
					
						
							| 
									
										
										
										
											2021-10-14 01:16:38 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |     constructor( | 
					
						
							|  |  |  |         id: string, | 
					
						
							|  |  |  |         newLonLat: [number, number], | 
					
						
							|  |  |  |         meta: { | 
					
						
							|  |  |  |             theme: string | 
					
						
							|  |  |  |             reason: string | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     ) { | 
					
						
							|  |  |  |         super(id, true) | 
					
						
							| 
									
										
										
										
											2021-10-14 01:16:38 +02:00
										 |  |  |         if (!id.startsWith("node/")) { | 
					
						
							|  |  |  |             throw "Invalid ID: only 'node/number' is accepted" | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         this._id = Number(id.substring("node/".length)) | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         this._newLonLat = newLonLat | 
					
						
							|  |  |  |         this._meta = meta | 
					
						
							| 
									
										
										
										
											2021-10-13 03:09:37 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-01-26 21:40:38 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-29 17:21:20 +02:00
										 |  |  |     protected async CreateChangeDescriptions(): Promise<ChangeDescription[]> { | 
					
						
							| 
									
										
										
										
											2021-10-14 01:16:38 +02:00
										 |  |  |         const d: ChangeDescription = { | 
					
						
							|  |  |  |             changes: { | 
					
						
							|  |  |  |                 lat: this._newLonLat[1], | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                 lon: this._newLonLat[0], | 
					
						
							| 
									
										
										
										
											2021-10-14 01:16:38 +02:00
										 |  |  |             }, | 
					
						
							|  |  |  |             type: "node", | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |             id: this._id, | 
					
						
							|  |  |  |             meta: { | 
					
						
							| 
									
										
										
										
											2021-10-14 01:16:38 +02:00
										 |  |  |                 changeType: "move", | 
					
						
							|  |  |  |                 theme: this._meta.theme, | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                 specialMotivation: this._meta.reason, | 
					
						
							|  |  |  |             }, | 
					
						
							| 
									
										
										
										
											2021-10-14 01:16:38 +02:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return [d] | 
					
						
							| 
									
										
										
										
											2021-10-13 03:09:37 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  | } |