Add small script to cleanup overpass-exports
This commit is contained in:
parent
f1443e2f49
commit
d281968b80
1 changed files with 21 additions and 0 deletions
21
scripts/fixGeoJson.ts
Normal file
21
scripts/fixGeoJson.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
|
||||
|
||||
// Loads a geojson file downloaded from overpass, renames "@id" to "id" and deletes "@relations"
|
||||
|
||||
import {readFileSync, writeFileSync} from "fs";
|
||||
|
||||
const source = process.argv[2] ?? "~/Downloads/export.json"
|
||||
console.log("Fixing up ", source)
|
||||
const contents = readFileSync(source, "UTF8");
|
||||
const f = JSON.parse(contents);
|
||||
let i = 0
|
||||
for (const feature of f.features) {
|
||||
if(feature.properties == undefined){
|
||||
continue
|
||||
}
|
||||
feature.properties["id"] = feature.properties["@id"]
|
||||
feature.properties["@id"] = undefined
|
||||
feature.properties["@relations"] = undefined
|
||||
}
|
||||
|
||||
writeFileSync(source+".fixed", JSON.stringify(f, null, " "))
|
Loading…
Reference in a new issue