Add small script to cleanup overpass-exports

This commit is contained in:
pietervdvn 2021-04-21 01:20:14 +02:00
parent f1443e2f49
commit d281968b80

21
scripts/fixGeoJson.ts Normal file
View 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, " "))