From d281968b8058848038d30ca938e9751490d733b8 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Wed, 21 Apr 2021 01:20:14 +0200 Subject: [PATCH] Add small script to cleanup overpass-exports --- scripts/fixGeoJson.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 scripts/fixGeoJson.ts diff --git a/scripts/fixGeoJson.ts b/scripts/fixGeoJson.ts new file mode 100644 index 000000000..d6c8e5e58 --- /dev/null +++ b/scripts/fixGeoJson.ts @@ -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, " ")) \ No newline at end of file