Merge develop

This commit is contained in:
Pieter Vander Vennet 2022-02-14 20:10:49 +01:00
commit 29f6716fa9
209 changed files with 8475 additions and 4933 deletions

View file

@ -7,7 +7,6 @@ import {LayerConfigJson} from "../Models/ThemeConfig/Json/LayerConfigJson";
import xml2js from 'xml2js';
export default class ScriptUtils {
public static fixUtils() {
Utils.externalDownloadFunction = ScriptUtils.DownloadJSON
}
@ -46,7 +45,7 @@ export default class ScriptUtils {
})
}
public static DownloadJSON(url, headers?: any): Promise<any> {
private static DownloadJSON(url, headers?: any): Promise<any> {
return new Promise((resolve, reject) => {
try {
headers = headers ?? {}

View file

@ -25,6 +25,7 @@ cp -r assets/themes/ dist/assets/themes/
cp -r assets/svg/ dist/assets/svg/
cp assets/*.png dist/assets/
cp assets/*.svg dist/assets/
cp assets/generated/*.svg dist/assts/generated/
SRC_MAPS="--no-source-maps"
BRANCH=`git rev-parse --abbrev-ref HEAD`

View file

@ -103,7 +103,7 @@ async function downloadRaw(targetdir: string, r: TileRange, theme: LayoutConfig,
try {
const json = await ScriptUtils.DownloadJSON(url)
const json = await Utils.downloadJson(url)
if ((<string>json.remark ?? "").startsWith("runtime error")) {
console.error("Got a runtime error: ", json.remark)
failed++;
@ -142,7 +142,7 @@ async function downloadExtraData(theme: LayoutConfig)/* : any[] */ {
continue;
}
console.log("Downloading extra data: ", source)
await ScriptUtils.DownloadJSON(source).then(json => allFeatures.push(...json.features))
await Utils.downloadJson(source).then(json => allFeatures.push(...json.features))
}
return allFeatures;
}
@ -355,7 +355,7 @@ function sliceToTiles(allFeatures: FeatureSource, theme: LayoutConfig, relations
}
async function main(args: string[]) {
export async function main(args: string[]) {
console.log("Cache builder started with args ", args.join(", "))
if (args.length < 6) {
@ -389,7 +389,7 @@ async function main(args: string[]) {
}
if (isNaN(lon1)) {
throw "The first number (a longitude) is not a valid number"
throw "The fourth number (a longitude) is not a valid number"
}
@ -458,11 +458,13 @@ async function main(args: string[]) {
let args = [...process.argv]
args.splice(0, 2)
try {
main(args)
.then(() => console.log("All done!"))
.catch(e => console.error("Error building cache:", e));
} catch (e) {
console.error("Error building cache:", e)
}
if (!args[1]?.endsWith("test/TestAll.ts")) {
args.splice(0, 2)
try {
main(args)
.then(() => console.log("All done!"))
.catch(e => console.error("Error building cache:", e));
} catch (e) {
console.error("Error building cache:", e)
}
}

View file

@ -5,7 +5,7 @@ import {Utils} from "../../Utils";
async function main(args: string[]) {
ScriptUtils.fixUtils()
const pointCandidates = JSON.parse(readFileSync(args[0], "utf8"))
const postcodes = JSON.parse(readFileSync(args[1], "utf8"))
const output = args[2] ?? "centralCoordinates.csv"
@ -61,7 +61,7 @@ async function main(args: string[]) {
const depPoints: [number, number][] = Utils.NoNull(await Promise.all(candidates.map(async candidate => {
try {
const result = await ScriptUtils.DownloadJSON(url + "&loc=" + candidate.join("%2C") + "&loc=3.22000%2C51.21577&profile=car.short")
const result = await Utils.downloadJson(url + "&loc=" + candidate.join("%2C") + "&loc=3.22000%2C51.21577&profile=car.short")
const depPoint = result.features.filter(f => f.geometry.type === "LineString")[0].geometry.coordinates[0]
return <[number, number]>[depPoint[0], depPoint[1]] // Drop elevation
} catch (e) {