forked from MapComplete/MapComplete
		
	scripts: add a small script to download data from overpass directly
This commit is contained in:
		
							parent
							
								
									0f30cf57db
								
							
						
					
					
						commit
						b90e90ceb8
					
				
					 1 changed files with 24 additions and 0 deletions
				
			
		
							
								
								
									
										24
									
								
								scripts/downloadFromOverpass.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								scripts/downloadFromOverpass.ts
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,24 @@
 | 
				
			||||||
 | 
					import Script from "./Script";
 | 
				
			||||||
 | 
					import {TagUtils} from "../Logic/Tags/TagUtils";
 | 
				
			||||||
 | 
					import {And} from "../Logic/Tags/And";
 | 
				
			||||||
 | 
					import Constants from "../Models/Constants";
 | 
				
			||||||
 | 
					import {ImmutableStore} from "../Logic/UIEventSource";
 | 
				
			||||||
 | 
					import {BBox} from "../Logic/BBox";
 | 
				
			||||||
 | 
					import {Overpass} from "../Logic/Osm/Overpass";
 | 
				
			||||||
 | 
					const fs = require("fs")
 | 
				
			||||||
 | 
					class DownloadFromOverpass extends Script {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    constructor() {
 | 
				
			||||||
 | 
					        super("Downloads data from openstreetmap, will save this as 'export.geojson'. All arguments will be interpreted as key=value pairs");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    async main(args: string[]): Promise<void> {
 | 
				
			||||||
 | 
					        const tags = new And(args.map(k => TagUtils.Tag(k)))
 | 
				
			||||||
 | 
					        const overpass = new Overpass(tags,[], Constants.defaultOverpassUrls[0], new ImmutableStore(500))
 | 
				
			||||||
 | 
					        const [data, _] = await overpass.queryGeoJson(BBox.global)
 | 
				
			||||||
 | 
					        fs.writeFileSync("export.geojson", JSON.stringify(data), "utf8")
 | 
				
			||||||
 | 
					        console.log("Written", data.features.length,"entries")
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					new DownloadFromOverpass().run()
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue