"working"

This commit is contained in:
wjtje 2023-01-15 23:28:02 +01:00 committed by Pieter Vander Vennet
parent 8fc56f7487
commit cc0c925b81
27 changed files with 4743 additions and 17591 deletions

View file

@ -147,7 +147,7 @@ export default class OsmFeatureSource {
this.rawDataHandlers.forEach((handler) => this.rawDataHandlers.forEach((handler) =>
handler(osmJson, Tiles.tile_index(z, x, y)) handler(osmJson, Tiles.tile_index(z, x, y))
) )
const geojson = <FeatureCollection<any, { id: string }>>OsmToGeoJson.default( const geojson = <FeatureCollection<any, { id: string }>>OsmToGeoJson(
osmJson, osmJson,
// @ts-ignore // @ts-ignore
{ {

View file

@ -7,7 +7,7 @@ import { RegexTag } from "./RegexTag"
import SubstitutingTag from "./SubstitutingTag" import SubstitutingTag from "./SubstitutingTag"
import { Or } from "./Or" import { Or } from "./Or"
import { TagConfigJson } from "../../Models/ThemeConfig/Json/TagConfigJson" import { TagConfigJson } from "../../Models/ThemeConfig/Json/TagConfigJson"
import { isRegExp } from "util" // import { isRegExp } from "util"
import * as key_counts from "../../assets/key_totals.json" import * as key_counts from "../../assets/key_totals.json"
type Tags = Record<string, string> type Tags = Record<string, string>
@ -94,13 +94,14 @@ export class TagUtils {
if (allowRegex && tagsFilter instanceof RegexTag) { if (allowRegex && tagsFilter instanceof RegexTag) {
const key = tagsFilter.key const key = tagsFilter.key
if (isRegExp(key)) { // TODO: Fixme
console.error( // if (isRegExp(key)) {
"Invalid type to flatten the multiAnswer: key is a regex too", // console.error(
tagsFilter // "Invalid type to flatten the multiAnswer: key is a regex too",
) // tagsFilter
throw "Invalid type to FlattenMultiAnswer" // )
} // throw "Invalid type to FlattenMultiAnswer"
// }
const keystr = <string>key const keystr = <string>key
if (keyValues[keystr] === undefined) { if (keyValues[keystr] === undefined) {
keyValues[keystr] = [] keyValues[keystr] = []

View file

@ -1,4 +1,4 @@
import * as mangrove from "mangrove-reviews" // import * as mangrove from "mangrove-reviews"
import { UIEventSource } from "../UIEventSource" import { UIEventSource } from "../UIEventSource"
import { Review } from "./Review" import { Review } from "./Review"
import { Utils } from "../../Utils" import { Utils } from "../../Utils"
@ -15,13 +15,13 @@ export class MangroveIdentity {
if (str === "") { if (str === "") {
return return
} }
mangrove.jwkToKeypair(JSON.parse(str)).then((keypair) => { // mangrove.jwkToKeypair(JSON.parse(str)).then((keypair) => {
self.keypair = keypair // self.keypair = keypair
mangrove.publicToPem(keypair.publicKey).then((pem) => { // mangrove.publicToPem(keypair.publicKey).then((pem) => {
console.log("Identity loaded") // console.log("Identity loaded")
self.kid.setData(pem) // self.kid.setData(pem)
}) // })
}) // })
}) })
try { try {
if (!Utils.runningFromConsole && (mangroveIdentity.data ?? "") === "") { if (!Utils.runningFromConsole && (mangroveIdentity.data ?? "") === "") {
@ -42,12 +42,12 @@ export class MangroveIdentity {
throw "Identity already defined - not creating a new one" throw "Identity already defined - not creating a new one"
} }
const self = this const self = this
mangrove.generateKeypair().then((keypair) => { // mangrove.generateKeypair().then((keypair) => {
self.keypair = keypair // self.keypair = keypair
mangrove.keypairToJwk(keypair).then((jwk) => { // mangrove.keypairToJwk(keypair).then((jwk) => {
self._mangroveIdentity.setData(JSON.stringify(jwk)) // self._mangroveIdentity.setData(JSON.stringify(jwk))
}) // })
}) // })
} }
} }
@ -127,39 +127,39 @@ export default class MangroveReviews {
this._lastUpdate = new Date() this._lastUpdate = new Date()
const self = this const self = this
mangrove // mangrove
.getReviews({ sub: this.GetSubjectUri() }) // .getReviews({ sub: this.GetSubjectUri() })
.then((data) => { // .then((data) => {
const reviews = [] // const reviews = []
const reviewsByUser = [] // const reviewsByUser = []
for (const review of data.reviews) { // for (const review of data.reviews) {
const r = review.payload // const r = review.payload
console.log( // console.log(
"PublicKey is ", // "PublicKey is ",
self._mangroveIdentity.kid.data, // self._mangroveIdentity.kid.data,
"reviews.kid is", // "reviews.kid is",
review.kid // review.kid
) // )
const byUser = self._mangroveIdentity.kid.map( // const byUser = self._mangroveIdentity.kid.map(
(data) => data === review.signature // (data) => data === review.signature
) // )
const rev: Review = { // const rev: Review = {
made_by_user: byUser, // made_by_user: byUser,
date: new Date(r.iat * 1000), // date: new Date(r.iat * 1000),
comment: r.opinion, // comment: r.opinion,
author: r.metadata.nickname, // author: r.metadata.nickname,
affiliated: r.metadata.is_affiliated, // affiliated: r.metadata.is_affiliated,
rating: r.rating, // percentage points // rating: r.rating, // percentage points
} // }
;(rev.made_by_user ? reviewsByUser : reviews).push(rev) // ;(rev.made_by_user ? reviewsByUser : reviews).push(rev)
} // }
self._reviews.setData(reviewsByUser.concat(reviews)) // self._reviews.setData(reviewsByUser.concat(reviews))
}) // })
.catch((e) => { // .catch((e) => {
console.error("Could not download review for ", e) // console.error("Could not download review for ", e)
}) // })
return this._reviews return this._reviews
} }
@ -192,13 +192,13 @@ export default class MangroveReviews {
this._reviews.ping() this._reviews.ping()
} }
} else { } else {
mangrove.signAndSubmitReview(this._mangroveIdentity.keypair, payload).then(() => { // mangrove.signAndSubmitReview(this._mangroveIdentity.keypair, payload).then(() => {
if (callback) { // if (callback) {
callback() // callback()
} // }
this._reviews.data.push(r) // this._reviews.data.push(r)
this._reviews.ping() // this._reviews.ping()
}) // })
} }
} }
} }

View file

@ -72,7 +72,7 @@
</div> </div>
<script src="./all_themes_index.ts"></script> <script type="module" src="./all_themes_index.ts"></script>
<script async data-goatcounter="https://pietervdvn.goatcounter.com/count" src="//gc.zgo.at/count.js"></script> <script async data-goatcounter="https://pietervdvn.goatcounter.com/count" src="//gc.zgo.at/count.js"></script>
<script> <script>

22023
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -6,7 +6,9 @@
"bugs": "https://github.com/pietervdvn/MapComplete/issues", "bugs": "https://github.com/pietervdvn/MapComplete/issues",
"homepage": "https://mapcomplete.osm.be", "homepage": "https://mapcomplete.osm.be",
"main": "index.js", "main": "index.js",
"type": "module",
"scripts": { "scripts": {
"vitedev": "vite",
"start": "npm run generate:layeroverview && npm run strt", "start": "npm run generate:layeroverview && npm run strt",
"strt": "export NODE_OPTIONS=--max_old_space_size=8364 && parcel serve *.html UI/** Logic/** assets/*.json assets/svg/* assets/templates/* assets/generated/* assets/layers/*/*.svg assets/layers/*/*/*/*.svg assets/layers/*/*.jpg assets/layers/*/*.png assets/layers/*/*.css assets/tagRenderings/*.json assets/themes/*/*.svg assets/themes/*/*.ttf assets/themes/*/*/*.ttf assets/themes/*/*.otf assets/themes/*/*/*.otf assets/themes/*/*.css assets/themes/*/*.jpg assets/themes/*/*.woff assets/themes/*/*.png vendor/* vendor/*/* assets/tagRenderings/*.svg", "strt": "export NODE_OPTIONS=--max_old_space_size=8364 && parcel serve *.html UI/** Logic/** assets/*.json assets/svg/* assets/templates/* assets/generated/* assets/layers/*/*.svg assets/layers/*/*/*/*.svg assets/layers/*/*.jpg assets/layers/*/*.png assets/layers/*/*.css assets/tagRenderings/*.json assets/themes/*/*.svg assets/themes/*/*.ttf assets/themes/*/*/*.ttf assets/themes/*/*.otf assets/themes/*/*/*.otf assets/themes/*/*.css assets/themes/*/*.jpg assets/themes/*/*.woff assets/themes/*/*.png vendor/* vendor/*/* assets/tagRenderings/*.svg",
"strttest": "export NODE_OPTIONS=--max_old_space_size=8364 && parcel serve test.html assets/templates/*.svg assets/templates/fonts/*.ttf", "strttest": "export NODE_OPTIONS=--max_old_space_size=8364 && parcel serve test.html assets/templates/*.svg assets/templates/fonts/*.ttf",
@ -92,7 +94,6 @@
"leaflet-simple-map-screenshoter": "^0.4.5", "leaflet-simple-map-screenshoter": "^0.4.5",
"libphonenumber-js": "^1.10.8", "libphonenumber-js": "^1.10.8",
"lz-string": "^1.4.4", "lz-string": "^1.4.4",
"mangrove-reviews": "^0.1.3",
"opening_hours": "^3.6.0", "opening_hours": "^3.6.0",
"osm-auth": "^1.0.2", "osm-auth": "^1.0.2",
"osmtogeojson": "^3.0.0-beta.5", "osmtogeojson": "^3.0.0-beta.5",
@ -116,7 +117,7 @@
"@types/leaflet-providers": "^1.2.0", "@types/leaflet-providers": "^1.2.0",
"@types/lz-string": "^1.3.34", "@types/lz-string": "^1.3.34",
"@types/mocha": "^9.1.0", "@types/mocha": "^9.1.0",
"@types/node": "^7.10.14", "@types/node": "^18.11.18",
"@types/papaparse": "^5.3.1", "@types/papaparse": "^5.3.1",
"@types/prompt-sync": "^4.1.0", "@types/prompt-sync": "^4.1.0",
"@types/wikidata-sdk": "^6.1.0", "@types/wikidata-sdk": "^6.1.0",
@ -126,7 +127,6 @@
"dependency-cruiser": "^10.4.0", "dependency-cruiser": "^10.4.0",
"fs": "0.0.1-security", "fs": "0.0.1-security",
"mocha": "^9.2.2", "mocha": "^9.2.2",
"parcel": "^1.2.4",
"prettier": "2.7.1", "prettier": "2.7.1",
"read-file": "^0.2.0", "read-file": "^0.2.0",
"sharp": "^0.30.5", "sharp": "^0.30.5",
@ -134,6 +134,7 @@
"ts2json-schema": "^1.4.0", "ts2json-schema": "^1.4.0",
"tslint": "^6.1.3", "tslint": "^6.1.3",
"tslint-no-circular-imports": "^0.7.0", "tslint-no-circular-imports": "^0.7.0",
"typescript": "^4.7.4" "typescript": "^4.7.4",
"vite": "^4.0.4"
} }
} }

View file

@ -1,5 +1,5 @@
import * as fs from "fs" // import * as fs from "fs"
import { existsSync, lstatSync, readdirSync, readFileSync } from "fs" // import { existsSync, lstatSync, readdirSync, readFileSync } from "fs"
import { Utils } from "../Utils" import { Utils } from "../Utils"
import * as https from "https" import * as https from "https"
import { LayoutConfigJson } from "../Models/ThemeConfig/Json/LayoutConfigJson" import { LayoutConfigJson } from "../Models/ThemeConfig/Json/LayoutConfigJson"
@ -19,21 +19,21 @@ export default class ScriptUtils {
* @param maxDepth * @param maxDepth
*/ */
public static readDirRecSync(path, maxDepth = 999): string[] { public static readDirRecSync(path, maxDepth = 999): string[] {
const result = [] const result: string[] = []
if (maxDepth <= 0) { if (maxDepth <= 0) {
return [] return []
} }
for (const entry of readdirSync(path)) { // for (const entry of readdirSync(path)) {
const fullEntry = path + "/" + entry // const fullEntry = path + "/" + entry
const stats = lstatSync(fullEntry) // const stats = lstatSync(fullEntry)
if (stats.isDirectory()) { // if (stats.isDirectory()) {
// Subdirectory // // Subdirectory
// @ts-ignore // // @ts-ignore
result.push(...ScriptUtils.readDirRecSync(fullEntry, maxDepth - 1)) // result.push(...ScriptUtils.readDirRecSync(fullEntry, maxDepth - 1))
} else { // } else {
result.push(fullEntry) // result.push(fullEntry)
} // }
} // }
return result return result
} }
@ -78,7 +78,8 @@ export default class ScriptUtils {
.filter((path) => path.indexOf("license_info.json") < 0) .filter((path) => path.indexOf("license_info.json") < 0)
.map((path) => { .map((path) => {
try { try {
const contents = readFileSync(path, "UTF8") // const contents = readFileSync(path, { encoding: "utf8" })
const contents = ""
if (contents === "") { if (contents === "") {
throw "The file " + path + " is empty, did you properly save?" throw "The file " + path + " is empty, did you properly save?"
} }
@ -101,7 +102,8 @@ export default class ScriptUtils {
public static getThemeFiles(): { parsed: LayoutConfigJson; path: string }[] { public static getThemeFiles(): { parsed: LayoutConfigJson; path: string }[] {
return this.getThemePaths().map((path) => { return this.getThemePaths().map((path) => {
try { try {
const contents = readFileSync(path, "UTF8") // const contents = readFileSync(path, { encoding: "utf8" })
const contents = ""
if (contents === "") { if (contents === "") {
throw "The file " + path + " is empty, did you properly save?" throw "The file " + path + " is empty, did you properly save?"
} }
@ -122,20 +124,25 @@ export default class ScriptUtils {
} }
public static async ReadSvg(path: string): Promise<any> { public static async ReadSvg(path: string): Promise<any> {
if (!existsSync(path)) { // if (!existsSync(path)) {
throw "File not found: " + path // throw "File not found: " + path
} // }
const root = await xml2js.parseStringPromise(readFileSync(path, "UTF8")) // const root = await xml2js.parseStringPromise(readFileSync(path, { encoding: "utf8" }))
return root.svg // return root.svg
return ""
} }
public static ReadSvgSync(path: string, callback: (svg: any) => void): any { public static ReadSvgSync(path: string, callback: (svg: any) => void): any {
xml2js.parseString(readFileSync(path, "UTF8"), { async: false }, (err, root) => { // xml2js.parseString(
if (err) { // readFileSync(path, { encoding: "utf8" }),
throw err // { async: false },
} // (err, root) => {
callback(root["svg"]) // if (err) {
}) // throw err
// }
// callback(root["svg"])
// }
// )
} }
private static async DownloadJSON(url: string, headers?: any): Promise<any> { private static async DownloadJSON(url: string, headers?: any): Promise<any> {

View file

@ -54,9 +54,9 @@ function main(args: string[]): void {
) )
return return
} }
const reference = JSON.parse(readFileSync("./langs/en.json", "UTF8")) const reference = JSON.parse(readFileSync("./langs/en.json", { encoding: "utf8" }))
const path = `./langs/${l}.json` const path = `./langs/${l}.json`
const file = JSON.parse(readFileSync(path, "UTF8")) const file = JSON.parse(readFileSync(path, { encoding: "utf8" }))
fixSection(file[sectionName], reference[sectionName], l) fixSection(file[sectionName], reference[sectionName], l)
writeFileSync(path, JSON.stringify(file, null, " ") + "\n") writeFileSync(path, JSON.stringify(file, null, " ") + "\n")
} }

View file

@ -51,7 +51,7 @@ function rewrite(obj, key) {
const stuff = fs.readFileSync( const stuff = fs.readFileSync(
"/home/pietervdvn/Documents/Freelance/ToerismeVlaanderen 2021-09/TeImporteren/allchannels-bike_rental.json", "/home/pietervdvn/Documents/Freelance/ToerismeVlaanderen 2021-09/TeImporteren/allchannels-bike_rental.json",
"UTF8" { encoding: "utf8" }
) )
const data: any[] = JSON.parse(stuff) const data: any[] = JSON.parse(stuff)

View file

@ -138,7 +138,7 @@ async function main(wipeCache = false) {
console.log("Reusing the cached file") console.log("Reusing the cached file")
} }
const data = JSON.parse(readFileSync(cacheFile, "UTF8")) const data = JSON.parse(readFileSync(cacheFile, { encoding: "utf8" }))
const perId = WikidataUtils.extractLanguageData(data, WikidataUtils.languageRemapping) const perId = WikidataUtils.extractLanguageData(data, WikidataUtils.languageRemapping)
const nativeList = getNativeList(perId) const nativeList = getNativeList(perId)
writeFileSync("./assets/language_native.json", JSON.stringify(nativeList, null, " ")) writeFileSync("./assets/language_native.json", JSON.stringify(nativeList, null, " "))

View file

@ -15,7 +15,7 @@ function main(args) {
const spec = args[1] const spec = args[1]
const output = args[2] const output = args[2]
const data = JSON.parse(fs.readFileSync(path, "UTF8")) const data = JSON.parse(fs.readFileSync(path, { encoding: "utf8" }))
let filter: TagsFilter let filter: TagsFilter
try { try {
filter = TagUtils.Tag(JSON.parse(spec)) filter = TagUtils.Tag(JSON.parse(spec))

View file

@ -63,7 +63,7 @@ function main() {
const path = args[0] const path = args[0]
const iconClass = args[1] ?? "small" const iconClass = args[1] ?? "small"
const targetFile = args[2] ?? path + ".autoconverted.json" const targetFile = args[2] ?? path + ".autoconverted.json"
const parsed = JSON.parse(readFileSync(path, "UTF8")) const parsed = JSON.parse(readFileSync(path, { encoding: "utf8" }))
const converted = new ConvertImagesToIcon(iconClass).convertStrict( const converted = new ConvertImagesToIcon(iconClass).convertStrict(
parsed, parsed,
"While running the fixImagesInTagRenderings-script" "While running the fixImagesInTagRenderings-script"

View file

@ -99,7 +99,7 @@ function WalkScheme<T>(
function extractMeta(typename: string, path: string) { function extractMeta(typename: string, path: string) {
const themeSchema = JSON.parse( const themeSchema = JSON.parse(
readFileSync("./Docs/Schemas/" + typename + ".schema.json", "UTF-8") readFileSync("./Docs/Schemas/" + typename + ".schema.json", { encoding: "utf8" })
) )
const withTypes = WalkScheme((schemePart) => { const withTypes = WalkScheme((schemePart) => {
if (schemePart.description === undefined) { if (schemePart.description === undefined) {
@ -126,7 +126,7 @@ function main() {
for (const path of allSchemas) { for (const path of allSchemas) {
const dir = path.substring(0, path.lastIndexOf("/")) const dir = path.substring(0, path.lastIndexOf("/"))
const name = path.substring(path.lastIndexOf("/"), path.length - "JSC.ts".length) const name = path.substring(path.lastIndexOf("/"), path.length - "JSC.ts".length)
let content = readFileSync(path, "UTF-8") let content = readFileSync(path, { encoding: "utf8" })
content = content.substring("export default ".length) content = content.substring("export default ".length)
let parsed = JSON.parse(content) let parsed = JSON.parse(content)
parsed["additionalProperties"] = false parsed["additionalProperties"] = false
@ -137,7 +137,7 @@ function main() {
def["additionalProperties"] = false def["additionalProperties"] = false
} }
} }
writeFileSync(dir + "/" + name + ".schema.json", JSON.stringify(parsed, null, " "), "UTF8") writeFileSync(dir + "/" + name + ".schema.json", JSON.stringify(parsed, null, " "), { encoding: "utf8" })
} }
extractMeta("LayoutConfigJson", "layoutconfigmeta") extractMeta("LayoutConfigJson", "layoutconfigmeta")

View file

@ -212,7 +212,7 @@ function loadAllTiles(
} }
// We read the raw OSM-file and convert it to a geojson // We read the raw OSM-file and convert it to a geojson
const rawOsm = JSON.parse(readFileSync(filename, "UTF8")) const rawOsm = JSON.parse(readFileSync(filename, { encoding: "utf8" }))
// Create and save the geojson file - which is the main chunk of the data // Create and save the geojson file - which is the main chunk of the data
const geojson = OsmToGeoJson.default(rawOsm) const geojson = OsmToGeoJson.default(rawOsm)

View file

@ -138,7 +138,7 @@ export default class GenerateImageAnalysis extends Script {
if (!file.endsWith(".json")) { if (!file.endsWith(".json")) {
continue continue
} }
const attr = <LicenseInfo>JSON.parse(fs.readFileSync(file, "UTF8")) const attr = <LicenseInfo>JSON.parse(fs.readFileSync(file, { encoding: "utf8" }))
const license = attr.licenseShortName const license = attr.licenseShortName
if (license === undefined || attr.artist === undefined) { if (license === undefined || attr.artist === undefined) {

View file

@ -125,7 +125,7 @@ class LayerOverviewUtils {
writeFileSync( writeFileSync(
"./assets/generated/theme_overview.json", "./assets/generated/theme_overview.json",
JSON.stringify(sorted, null, " "), JSON.stringify(sorted, null, " "),
"UTF8" { encoding: "utf8" }
) )
} }
@ -136,7 +136,7 @@ class LayerOverviewUtils {
writeFileSync( writeFileSync(
`${LayerOverviewUtils.themePath}${theme.id}.json`, `${LayerOverviewUtils.themePath}${theme.id}.json`,
JSON.stringify(theme, null, " "), JSON.stringify(theme, null, " "),
"UTF8" { encoding: "utf8" }
) )
} }
@ -147,7 +147,7 @@ class LayerOverviewUtils {
writeFileSync( writeFileSync(
`${LayerOverviewUtils.layerPath}${layer.id}.json`, `${LayerOverviewUtils.layerPath}${layer.id}.json`,
JSON.stringify(layer, null, " "), JSON.stringify(layer, null, " "),
"UTF8" { encoding: "utf8" }
) )
} }
@ -219,7 +219,7 @@ class LayerOverviewUtils {
continue continue
} }
const contents = readFileSync(path, "UTF8") const contents = readFileSync(path, { encoding: "utf8" })
if (contents.indexOf("data:image/png;") >= 0) { if (contents.indexOf("data:image/png;") >= 0) {
console.warn("The SVG at " + path + " is a fake SVG: it contains PNG data!") console.warn("The SVG at " + path + " is a fake SVG: it contains PNG data!")
errCount++ errCount++
@ -283,7 +283,7 @@ class LayerOverviewUtils {
const proto: LayoutConfigJson = JSON.parse( const proto: LayoutConfigJson = JSON.parse(
readFileSync( readFileSync(
"./assets/themes/mapcomplete-changes/mapcomplete-changes.proto.json", "./assets/themes/mapcomplete-changes/mapcomplete-changes.proto.json",
"UTF8" { encoding: "utf8" }
) )
) )
const protolayer = <LayerConfigJson>( const protolayer = <LayerConfigJson>(

View file

@ -22,7 +22,7 @@ function generateLicenseInfos(paths: string[]): SmallLicense[] {
const licenses = [] const licenses = []
for (const path of paths) { for (const path of paths) {
try { try {
const parsed = JSON.parse(readFileSync(path, "UTF-8")) const parsed = JSON.parse(readFileSync(path, { encoding: "utf8" }))
if (Array.isArray(parsed)) { if (Array.isArray(parsed)) {
const l: SmallLicense[] = parsed const l: SmallLicense[] = parsed
for (const smallLicens of l) { for (const smallLicens of l) {
@ -242,7 +242,7 @@ function createFullLicenseOverview(licensePaths: string[]) {
if (!existsSync(licensePath)) { if (!existsSync(licensePath)) {
continue continue
} }
const licenses = <SmallLicense[]>JSON.parse(readFileSync(licensePath, "UTF-8")) const licenses = <SmallLicense[]>JSON.parse(readFileSync(licensePath, { encoding: "utf8" }))
for (const license of licenses) { for (const license of licenses) {
validateLicenseInfo(license) validateLicenseInfo(license)
const dir = licensePath.substring(0, licensePath.length - "license_info.json".length) const dir = licensePath.substring(0, licensePath.length - "license_info.json".length)

View file

@ -176,7 +176,7 @@ function generateTagInfoEntry(layout: LayoutConfig): any {
function generateProjectsOverview(files: string[]) { function generateProjectsOverview(files: string[]) {
try { try {
const tagInfoList = "../taginfo-projects/project_list.txt" const tagInfoList = "../taginfo-projects/project_list.txt"
let projectList = readFileSync(tagInfoList, "UTF8") let projectList = readFileSync(tagInfoList, { encoding: "utf8" })
.split("\n") .split("\n")
.filter((entry) => entry.indexOf("mapcomplete_") < 0) .filter((entry) => entry.indexOf("mapcomplete_") < 0)
.concat( .concat(

View file

@ -12,7 +12,7 @@ class TranslationPart {
const files = ScriptUtils.readDirRecSync(path, 1).filter((file) => file.endsWith(".json")) const files = ScriptUtils.readDirRecSync(path, 1).filter((file) => file.endsWith(".json"))
const rootTranslation = new TranslationPart() const rootTranslation = new TranslationPart()
for (const file of files) { for (const file of files) {
const content = JSON.parse(readFileSync(file, "UTF8")) const content = JSON.parse(readFileSync(file, { encoding: "utf8" }))
rootTranslation.addTranslation(file.substr(0, file.length - ".json".length), content) rootTranslation.addTranslation(file.substr(0, file.length - ".json".length), content)
} }
return rootTranslation return rootTranslation

View file

@ -9,7 +9,7 @@ import ScriptUtils from "./ScriptUtils"
function makeConvex(file) { function makeConvex(file) {
ScriptUtils.erasableLog("Handling", file) ScriptUtils.erasableLog("Handling", file)
const geoJson = JSON.parse(fs.readFileSync(file, "UTF8")) const geoJson = JSON.parse(fs.readFileSync(file, { encoding: "utf8" }))
const convex = GeoOperations.convexHull(geoJson, { concavity: 2 }) const convex = GeoOperations.convexHull(geoJson, { concavity: 2 })
if (convex.properties === undefined) { if (convex.properties === undefined) {
convex.properties = {} convex.properties = {}

View file

@ -11,7 +11,7 @@ function main(args) {
const path = args[0] const path = args[0]
const key = args[1] const key = args[1]
const data = JSON.parse(fs.readFileSync(path, "UTF8")) const data = JSON.parse(fs.readFileSync(path, { encoding: "utf8" }))
const perProperty = new Map<string, any[]>() const perProperty = new Map<string, any[]>()
console.log("Partitioning", data.features.length, "features") console.log("Partitioning", data.features.length, "features")

View file

@ -13,14 +13,14 @@ async function main(args: string[]) {
const alreadyLoaded = new Set<number>() const alreadyLoaded = new Set<number>()
if (existsSync(output)) { if (existsSync(output)) {
const lines = readFileSync(output, "UTF8").split("\n") const lines = readFileSync(output, { encoding: "utf8" }).split("\n")
lines.shift() lines.shift()
lines.forEach((line) => { lines.forEach((line) => {
const postalCode = Number(line.split(",")[0]) const postalCode = Number(line.split(",")[0])
alreadyLoaded.add(postalCode) alreadyLoaded.add(postalCode)
}) })
} else { } 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) { for (const boundary of postcodes.features) {
@ -104,7 +104,7 @@ async function main(args: string[]) {
" are ", " are ",
JSON.stringify(depPoints) JSON.stringify(depPoints)
) )
appendFileSync(output, [postcode, ...depPoints[0]].join(", ") + "\n", "UTF-8") appendFileSync(output, [postcode, ...depPoints[0]].join(", ") + "\n", { encoding: "utf8" })
} }
} }

View file

@ -3,7 +3,7 @@ import { writeFileSync } from "fs"
import ScriptUtils from "../ScriptUtils" import ScriptUtils from "../ScriptUtils"
function handleFile(file: string, postalCode: number) { 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 = { geojson.properties = {
type: "boundary", type: "boundary",
boundary: "postal_code", boundary: "postal_code",
@ -14,7 +14,7 @@ function handleFile(file: string, postalCode: number) {
function getKnownPostalCodes(): number[] { function getKnownPostalCodes(): number[] {
return fs return fs
.readFileSync("./scripts/postal_code_tools/knownPostalCodes.csv", "UTF8") .readFileSync("./scripts/postal_code_tools/knownPostalCodes.csv", { encoding: "utf8" })
.split("\n") .split("\n")
.map((line) => Number(line.split(",")[1])) .map((line) => Number(line.split(",")[1]))
} }

View file

@ -7609,7 +7609,7 @@ describe("GenerateCache", () => {
]) ])
await ScriptUtils.sleep(250) await ScriptUtils.sleep(250)
const birdhides = JSON.parse( const birdhides = JSON.parse(
readFileSync(dir + "np-cache/natuurpunt_birdhide_12_2085_1368.geojson", "UTF8") readFileSync(dir + "np-cache/natuurpunt_birdhide_12_2085_1368.geojson", { encoding: "utf8" })
) )
expect(birdhides.features.length).deep.equal(5) expect(birdhides.features.length).deep.equal(5)
expect( expect(

View file

@ -79,7 +79,7 @@
<div id="leafletDiv"></div> <div id="leafletDiv"></div>
<script src="./index.ts"></script> <script type="module" src="./index.ts"></script>
<script async data-goatcounter="https://pietervdvn.goatcounter.com/count" src="//gc.zgo.at/count.js"></script> <script async data-goatcounter="https://pietervdvn.goatcounter.com/count" src="//gc.zgo.at/count.js"></script>
<script> <script>

View file

@ -1,18 +1,19 @@
{ {
"compilerOptions": { "compilerOptions": {
"module": "commonjs", "target": "ESNext",
"target": "es5", "useDefineForClassFields": true,
"sourceMap": true, "module": "ESNext",
"lib": ["ESNext", "DOM"],
"moduleResolution": "Node",
"strict": true,
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": true,
"esModuleInterop": true, "esModuleInterop": true,
"lib": [ "noEmit": true,
"DOM", "noUnusedLocals": true,
"es5", "noUnusedParameters": true,
"scripthost", "noImplicitReturns": true,
"es2015.collection" "skipLibCheck": true
]
}, },
"exclude": [ "exclude": ["node_modules"]
"node_modules"
]
} }

5
vite.config.js Normal file
View file

@ -0,0 +1,5 @@
/** @type {import('vite').UserConfig} */
export default {
// config options
optimizeDeps: ["util"],
}