forked from MapComplete/MapComplete
Reformat all files with prettier
This commit is contained in:
parent
e22d189376
commit
b541d3eab4
382 changed files with 50893 additions and 35566 deletions
|
@ -1,22 +1,22 @@
|
|||
import * as fs from "fs";
|
||||
import {writeFileSync} from "fs";
|
||||
import ScriptUtils from "../ScriptUtils";
|
||||
import * as fs from "fs"
|
||||
import { writeFileSync } from "fs"
|
||||
import ScriptUtils from "../ScriptUtils"
|
||||
|
||||
function handleFile(file: string, postalCode: number) {
|
||||
|
||||
const geojson = JSON.parse(fs.readFileSync(file, "UTF8"))
|
||||
geojson.properties = {
|
||||
type: "boundary",
|
||||
"boundary": "postal_code",
|
||||
"postal_code": postalCode + ""
|
||||
boundary: "postal_code",
|
||||
postal_code: postalCode + "",
|
||||
}
|
||||
return geojson
|
||||
}
|
||||
|
||||
|
||||
function getKnownPostalCodes(): number[] {
|
||||
return fs.readFileSync("./scripts/postal_code_tools/knownPostalCodes.csv", "UTF8").split("\n")
|
||||
.map(line => Number(line.split(",")[1]))
|
||||
return fs
|
||||
.readFileSync("./scripts/postal_code_tools/knownPostalCodes.csv", "UTF8")
|
||||
.split("\n")
|
||||
.map((line) => Number(line.split(",")[1]))
|
||||
}
|
||||
|
||||
function main(args: string[]) {
|
||||
|
@ -28,27 +28,36 @@ function main(args: string[]) {
|
|||
for (const file of files) {
|
||||
const nameParts = file.split("-")
|
||||
const postalCodeStr = nameParts[nameParts.length - 1]
|
||||
const postalCode = Number(postalCodeStr.substr(0, postalCodeStr.length - ".geojson.convex.geojson".length))
|
||||
const postalCode = Number(
|
||||
postalCodeStr.substr(0, postalCodeStr.length - ".geojson.convex.geojson".length)
|
||||
)
|
||||
if (isNaN(postalCode)) {
|
||||
console.error("Not a number: ", postalCodeStr)
|
||||
continue
|
||||
}
|
||||
if (knownPostals.has(postalCode)) {
|
||||
skipped.push(postalCode)
|
||||
ScriptUtils.erasableLog("Skipping boundary for ", postalCode, "as it is already known - skipped ", skipped.length, "already")
|
||||
ScriptUtils.erasableLog(
|
||||
"Skipping boundary for ",
|
||||
postalCode,
|
||||
"as it is already known - skipped ",
|
||||
skipped.length,
|
||||
"already"
|
||||
)
|
||||
continue
|
||||
}
|
||||
allFiles.push(handleFile(file, postalCode))
|
||||
}
|
||||
|
||||
|
||||
writeFileSync("all_postal_codes_filtered.geojson", JSON.stringify({
|
||||
type: "FeatureCollection",
|
||||
features: allFiles
|
||||
}))
|
||||
|
||||
writeFileSync(
|
||||
"all_postal_codes_filtered.geojson",
|
||||
JSON.stringify({
|
||||
type: "FeatureCollection",
|
||||
features: allFiles,
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
let args = [...process.argv]
|
||||
args.splice(0, 2)
|
||||
main(args)
|
||||
main(args)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue