Full code cleanup
This commit is contained in:
parent
8e6ee8c87f
commit
bd21212eba
246 changed files with 19418 additions and 11729 deletions
|
@ -53,7 +53,7 @@ export default class ScriptUtils {
|
|||
try {
|
||||
headers = headers ?? {}
|
||||
headers.accept = "application/json"
|
||||
console.log("ScriptUtils.DownloadJson(", url.substring(0,40), url.length > 40 ? "...":"" ,")")
|
||||
console.log("ScriptUtils.DownloadJson(", url.substring(0, 40), url.length > 40 ? "..." : "", ")")
|
||||
const urlObj = new URL(url)
|
||||
https.get({
|
||||
host: urlObj.host,
|
||||
|
|
|
@ -2,15 +2,14 @@
|
|||
* This script attempt to automatically fix some basic issues when a theme from the custom generator is loaded
|
||||
*/
|
||||
import {Utils} from "../Utils"
|
||||
Utils.runningFromConsole = true;
|
||||
import {readFileSync, writeFileSync} from "fs";
|
||||
import SmallLicense from "../Models/smallLicense";
|
||||
import AllKnownLayers from "../Customizations/AllKnownLayers";
|
||||
import ScriptUtils from "./ScriptUtils";
|
||||
import AllImageProviders from "../Logic/ImageProviders/AllImageProviders";
|
||||
import {LayoutConfigJson} from "../Models/ThemeConfig/Json/LayoutConfigJson";
|
||||
import LayerConfig from "../Models/ThemeConfig/LayerConfig";
|
||||
|
||||
Utils.runningFromConsole = true;
|
||||
|
||||
|
||||
ScriptUtils.fixUtils()
|
||||
|
|
|
@ -86,9 +86,9 @@ async function downloadRaw(targetdir: string, r: TileRange, theme: LayoutConfig,
|
|||
}
|
||||
const runningSeconds = (new Date().getTime() - startTime) / 1000
|
||||
const resting = failed + (r.total - downloaded)
|
||||
const perTile= (runningSeconds / (downloaded - skipped))
|
||||
const estimated =Math.floor(resting * perTile)
|
||||
console.log("total: ", downloaded, "/", r.total, "failed: ", failed, "skipped: ", skipped, "running time: ",Utils.toHumanTime(runningSeconds)+"s", "estimated left: ", Utils.toHumanTime(estimated), "("+Math.floor(perTile)+"s/tile)")
|
||||
const perTile = (runningSeconds / (downloaded - skipped))
|
||||
const estimated = Math.floor(resting * perTile)
|
||||
console.log("total: ", downloaded, "/", r.total, "failed: ", failed, "skipped: ", skipped, "running time: ", Utils.toHumanTime(runningSeconds) + "s", "estimated left: ", Utils.toHumanTime(estimated), "(" + Math.floor(perTile) + "s/tile)")
|
||||
|
||||
const boundsArr = Tiles.tile_bounds(r.zoomlevel, x, y)
|
||||
const bounds = {
|
||||
|
@ -106,13 +106,13 @@ async function downloadRaw(targetdir: string, r: TileRange, theme: LayoutConfig,
|
|||
if ((<string>json.remark ?? "").startsWith("runtime error")) {
|
||||
console.error("Got a runtime error: ", json.remark)
|
||||
failed++;
|
||||
}else if (json.elements.length === 0) {
|
||||
} else if (json.elements.length === 0) {
|
||||
console.log("Got an empty response! Writing anyway")
|
||||
}
|
||||
|
||||
|
||||
console.log("Got the response - writing to ", filename)
|
||||
writeFileSync(filename, JSON.stringify(json, null, " "));
|
||||
|
||||
console.log("Got the response - writing to ", filename)
|
||||
writeFileSync(filename, JSON.stringify(json, null, " "));
|
||||
} catch (err) {
|
||||
console.log(url)
|
||||
console.log("Could not download - probably hit the rate limit; waiting a bit. (" + err + ")")
|
||||
|
@ -180,7 +180,7 @@ function sliceToTiles(allFeatures: FeatureSource, theme: LayoutConfig, relations
|
|||
function handleLayer(source: FeatureSourceForLayer) {
|
||||
const layer = source.layer.layerDef;
|
||||
const targetZoomLevel = layer.source.geojsonZoomLevel ?? 0
|
||||
|
||||
|
||||
const layerId = layer.id
|
||||
if (layer.source.isOsmCacheLayer !== true) {
|
||||
return;
|
||||
|
@ -245,11 +245,11 @@ function sliceToTiles(allFeatures: FeatureSource, theme: LayoutConfig, relations
|
|||
writeFileSync(path, JSON.stringify(perX))
|
||||
|
||||
// And, if needed, to create a points-only layer
|
||||
if(pointsOnlyLayers.indexOf(layer.id) >= 0){
|
||||
if (pointsOnlyLayers.indexOf(layer.id) >= 0) {
|
||||
const features = source.features.data.map(f => f.feature)
|
||||
const points = features.map(feature => GeoOperations.centerpoint(feature))
|
||||
console.log("Writing points overview for ", layerId)
|
||||
const targetPath = targetdir+"_"+layerId+"_points.geojson"
|
||||
const targetPath = targetdir + "_" + layerId + "_points.geojson"
|
||||
// This is the geojson file containing all features for this tile
|
||||
writeFileSync(targetPath, JSON.stringify({
|
||||
type: "FeatureCollection",
|
||||
|
@ -270,7 +270,6 @@ function sliceToTiles(allFeatures: FeatureSource, theme: LayoutConfig, relations
|
|||
}
|
||||
|
||||
|
||||
|
||||
async function main(args: string[]) {
|
||||
|
||||
if (args.length == 0) {
|
||||
|
@ -284,12 +283,12 @@ async function main(args: string[]) {
|
|||
const lon0 = Number(args[4])
|
||||
const lat1 = Number(args[5])
|
||||
const lon1 = Number(args[6])
|
||||
|
||||
|
||||
let generatePointLayersFor = []
|
||||
if(args[7] == "--generate-point-overview"){
|
||||
if (args[7] == "--generate-point-overview") {
|
||||
generatePointLayersFor = args[8].split(",")
|
||||
}
|
||||
|
||||
|
||||
|
||||
const tileRange = Tiles.TileRangeBetween(zoomlevel, lat0, lon0, lat1, lon1)
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
import {Utils} from "../Utils";
|
||||
|
||||
Utils.runningFromConsole = true;
|
||||
import SpecialVisualizations from "../UI/SpecialVisualizations";
|
||||
import SimpleMetaTagger from "../Logic/SimpleMetaTagger";
|
||||
import Combine from "../UI/Base/Combine";
|
||||
|
@ -9,12 +7,13 @@ import ValidatedTextField from "../UI/Input/ValidatedTextField";
|
|||
import BaseUIElement from "../UI/BaseUIElement";
|
||||
import Translations from "../UI/i18n/Translations";
|
||||
import {writeFileSync} from "fs";
|
||||
import State from "../State";
|
||||
import {QueryParameters} from "../Logic/Web/QueryParameters";
|
||||
import LayoutConfig from "../Models/ThemeConfig/LayoutConfig";
|
||||
import Minimap from "../UI/Base/Minimap";
|
||||
import FeatureSwitchState from "../Logic/State/FeatureSwitchState";
|
||||
|
||||
Utils.runningFromConsole = true;
|
||||
|
||||
|
||||
function WriteFile(filename, html: string | BaseUIElement, autogenSource: string[]): void {
|
||||
writeFileSync(filename, new Combine([Translations.W(html),
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
import {Utils} from "../Utils";
|
||||
// We HAVE to mark this while importing
|
||||
Utils.runningFromConsole = true;
|
||||
import {existsSync, mkdirSync, readFileSync, writeFile, writeFileSync} from "fs";
|
||||
import Locale from "../UI/i18n/Locale";
|
||||
import Translations from "../UI/i18n/Translations";
|
||||
|
@ -9,6 +7,8 @@ import Constants from "../Models/Constants";
|
|||
import * as all_known_layouts from "../assets/generated/known_layers_and_themes.json"
|
||||
import {LayoutConfigJson} from "../Models/ThemeConfig/Json/LayoutConfigJson";
|
||||
import LayoutConfig from "../Models/ThemeConfig/LayoutConfig";
|
||||
// We HAVE to mark this while importing
|
||||
Utils.runningFromConsole = true;
|
||||
|
||||
|
||||
const sharp = require('sharp');
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import {Utils} from "../Utils";
|
||||
Utils.runningFromConsole = true;
|
||||
import {AllKnownLayouts} from "../Customizations/AllKnownLayouts";
|
||||
import Locale from "../UI/i18n/Locale";
|
||||
import {Translation} from "../UI/i18n/Translation";
|
||||
|
@ -7,6 +6,8 @@ import {readFileSync, writeFileSync} from "fs";
|
|||
import LayoutConfig from "../Models/ThemeConfig/LayoutConfig";
|
||||
import LayerConfig from "../Models/ThemeConfig/LayerConfig";
|
||||
|
||||
Utils.runningFromConsole = true;
|
||||
|
||||
|
||||
/**
|
||||
* Generates all the files in "Docs/TagInfo". These are picked up by the taginfo project, showing a link to the mapcomplete theme if the key is used
|
||||
|
|
|
@ -31,8 +31,8 @@ class TranslationPart {
|
|||
if (!translations.hasOwnProperty(translationsKey)) {
|
||||
continue;
|
||||
}
|
||||
if(translationsKey == "then"){
|
||||
throw "Suspicious translation at "+context
|
||||
if (translationsKey == "then") {
|
||||
throw "Suspicious translation at " + context
|
||||
}
|
||||
const v = translations[translationsKey]
|
||||
if (typeof (v) != "string") {
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
|
||||
import ScriptUtils from "./ScriptUtils";
|
||||
import {writeFileSync} from "fs";
|
||||
import {LayerConfigJson} from "../Models/ThemeConfig/Json/LayerConfigJson";
|
||||
import LineRenderingConfigJson from "../Models/ThemeConfig/Json/LineRenderingConfigJson";
|
||||
import LegacyJsonConvert from "../Models/ThemeConfig/LegacyJsonConvert";
|
||||
|
||||
/*
|
||||
|
@ -12,12 +9,12 @@ import LegacyJsonConvert from "../Models/ThemeConfig/LegacyJsonConvert";
|
|||
|
||||
const layerFiles = ScriptUtils.getLayerFiles();
|
||||
for (const layerFile of layerFiles) {
|
||||
LegacyJsonConvert. fixLayerConfig(layerFile.parsed)
|
||||
LegacyJsonConvert.fixLayerConfig(layerFile.parsed)
|
||||
writeFileSync(layerFile.path, JSON.stringify(layerFile.parsed, null, " "))
|
||||
}
|
||||
|
||||
const themeFiles = ScriptUtils.getThemeFiles()
|
||||
for (const themeFile of themeFiles) {
|
||||
LegacyJsonConvert.fixThemeConfig(themeFile.parsed)
|
||||
LegacyJsonConvert.fixThemeConfig(themeFile.parsed)
|
||||
writeFileSync(themeFile.path, JSON.stringify(themeFile.parsed, null, " "))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue