forked from MapComplete/MapComplete
"working"
This commit is contained in:
parent
8fc56f7487
commit
cc0c925b81
27 changed files with 4743 additions and 17591 deletions
|
@ -13,14 +13,14 @@ async function main(args: string[]) {
|
|||
|
||||
const alreadyLoaded = new Set<number>()
|
||||
if (existsSync(output)) {
|
||||
const lines = readFileSync(output, "UTF8").split("\n")
|
||||
const lines = readFileSync(output, { encoding: "utf8" }).split("\n")
|
||||
lines.shift()
|
||||
lines.forEach((line) => {
|
||||
const postalCode = Number(line.split(",")[0])
|
||||
alreadyLoaded.add(postalCode)
|
||||
})
|
||||
} else {
|
||||
writeFileSync(output, "postal_code,lon,lat\n", "UTF-8")
|
||||
writeFileSync(output, "postal_code,lon,lat\n", { encoding: "utf8" })
|
||||
}
|
||||
|
||||
for (const boundary of postcodes.features) {
|
||||
|
@ -104,7 +104,7 @@ async function main(args: string[]) {
|
|||
" are ",
|
||||
JSON.stringify(depPoints)
|
||||
)
|
||||
appendFileSync(output, [postcode, ...depPoints[0]].join(", ") + "\n", "UTF-8")
|
||||
appendFileSync(output, [postcode, ...depPoints[0]].join(", ") + "\n", { encoding: "utf8" })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import { writeFileSync } from "fs"
|
|||
import ScriptUtils from "../ScriptUtils"
|
||||
|
||||
function handleFile(file: string, postalCode: number) {
|
||||
const geojson = JSON.parse(fs.readFileSync(file, "UTF8"))
|
||||
const geojson = JSON.parse(fs.readFileSync(file, { encoding: "utf8" }))
|
||||
geojson.properties = {
|
||||
type: "boundary",
|
||||
boundary: "postal_code",
|
||||
|
@ -14,7 +14,7 @@ function handleFile(file: string, postalCode: number) {
|
|||
|
||||
function getKnownPostalCodes(): number[] {
|
||||
return fs
|
||||
.readFileSync("./scripts/postal_code_tools/knownPostalCodes.csv", "UTF8")
|
||||
.readFileSync("./scripts/postal_code_tools/knownPostalCodes.csv", { encoding: "utf8" })
|
||||
.split("\n")
|
||||
.map((line) => Number(line.split(",")[1]))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue