diff --git a/scripts/postal_code_tools/genWallonia.sh b/scripts/postal_code_tools/genWallonia.sh new file mode 100644 index 000000000..ba6e85cb3 --- /dev/null +++ b/scripts/postal_code_tools/genWallonia.sh @@ -0,0 +1,14 @@ +#! /bin/bash + +# Generates data for the wallonia address dataset: convex hulls for postal code outlines, tiled address files for import + +wget https://opendata.bosa.be/download/best/openaddress-bewal.zip +unzip openaddress-bewal.zip +rm openaddress-bewal.zip +mkdir data +mkdir tiles +mv openaddress-bewal.csv data/ +ts-node openaddressestogeojson.ts data/openaddress-bewal.csv data/openaddress --per-postal-code +ts-node openaddressestogeojson.ts data/openaddress-bewal.csv data/openaddress.geojson.nljson +ts-node ../slice.ts data/openaddress.geojson.nljson 14 tiles/ + diff --git a/scripts/postal_code_tools/openaddresses2geojson.ts b/scripts/postal_code_tools/openaddressestogeojson.ts similarity index 92% rename from scripts/postal_code_tools/openaddresses2geojson.ts rename to scripts/postal_code_tools/openaddressestogeojson.ts index 572603fc9..ee87757c6 100644 --- a/scripts/postal_code_tools/openaddresses2geojson.ts +++ b/scripts/postal_code_tools/openaddressestogeojson.ts @@ -1,11 +1,7 @@ import * as fs from "fs"; -import * as readline from "readline"; -import ScriptUtils from "./ScriptUtils"; import {existsSync, writeFileSync} from "fs"; -import {GeoOperations} from "../Logic/GeoOperations"; -import {Utils} from "../Utils"; -import {post} from "jquery"; -import {createECDH} from "crypto"; +import * as readline from "readline"; +import ScriptUtils from "../ScriptUtils"; /** * Converts an open-address CSV file into a big geojson file @@ -35,7 +31,9 @@ async function main(args: string[]) { let failed = 0 let createdFiles : string [] = [] - fs.writeFileSync(outputFile, "") + if(!perPostalCode){ + fs.writeFileSync(outputFile, "") + } // @ts-ignore for await (const line of rl) { i++; @@ -65,6 +63,12 @@ async function main(args: string[]) { let targetFile = outputFile if (perPostalCode) { + if(parsed["postcode"] === ""){ + continue + } + if(isNaN(Number(parsed["postcode"]))){ + continue; + } targetFile = outputFile + "-" + parsed["postcode"] + ".geojson" let isFirst = false if(!existsSync(targetFile)){ diff --git a/scripts/postal_code_tools/prepPostalCodesHulls.ts b/scripts/postal_code_tools/prepPostalCodesHulls.ts index 33a0816a7..c1c81006a 100644 --- a/scripts/postal_code_tools/prepPostalCodesHulls.ts +++ b/scripts/postal_code_tools/prepPostalCodesHulls.ts @@ -1,6 +1,5 @@ import * as fs from "fs"; -import ScriptUtils from "./ScriptUtils"; -import {post} from "jquery"; +import ScriptUtils from "../ScriptUtils"; import {writeFileSync} from "fs"; function handleFile(file: string, postalCode: number) {