forked from MapComplete/MapComplete
		
	Further development of split-road feature; refactoring of change-handling
This commit is contained in:
		
							parent
							
								
									dc4cdda3b5
								
							
						
					
					
						commit
						96ecded0b9
					
				
					 37 changed files with 967 additions and 568 deletions
				
			
		
							
								
								
									
										44
									
								
								Logic/Osm/Actions/CreateNewNodeAction.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								Logic/Osm/Actions/CreateNewNodeAction.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,44 @@ | |||
| import {Tag} from "../../Tags/Tag"; | ||||
| import OsmChangeAction from "./OsmChangeAction"; | ||||
| import {Changes} from "../Changes"; | ||||
| import {ChangeDescription} from "./ChangeDescription"; | ||||
| import {And} from "../../Tags/And"; | ||||
| 
 | ||||
| export default class CreateNewNodeAction implements OsmChangeAction { | ||||
| 
 | ||||
|     private readonly _basicTags: Tag[]; | ||||
|     private readonly _lat: number; | ||||
|     private readonly _lon: number; | ||||
| 
 | ||||
|     constructor(basicTags: Tag[], lat: number, lon: number) { | ||||
|         this._basicTags = basicTags; | ||||
|         this._lat = lat; | ||||
|         this._lon = lon; | ||||
|     } | ||||
| 
 | ||||
|     Perform(changes: Changes): ChangeDescription[] { | ||||
|         const id = changes.getNewID() | ||||
|         const properties = { | ||||
|             id: "node/" + id | ||||
|         } | ||||
|         for (const kv of this._basicTags) { | ||||
|             if (typeof kv.value !== "string") { | ||||
|                 throw "Invalid value: don't use a regex in a preset" | ||||
|             } | ||||
|             properties[kv.key] = kv.value; | ||||
|         } | ||||
| 
 | ||||
|         return [{ | ||||
|             tags: new And(this._basicTags).asChange(properties), | ||||
|             type: "node", | ||||
|             id: id, | ||||
|             changes:{ | ||||
|                 lat: this._lat, | ||||
|                 lon: this._lon | ||||
|             } | ||||
|         }] | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue