chore: automated housekeeping...

This commit is contained in:
Pieter Vander Vennet 2025-04-15 18:18:44 +02:00
parent 79b6927b56
commit 42ded4c1b1
328 changed files with 4062 additions and 1284 deletions

View file

@ -231,7 +231,6 @@ class GenerateSeries extends Script {
const allFiles = readdirSync(targetDir).filter((p) => p.endsWith(".json"))
writeFileSync(targetDir + "/file-overview.json", JSON.stringify(allFiles))
}
}
new GenerateSeries().run()

View file

@ -9,7 +9,6 @@ import xml2js from "xml2js"
export default class ScriptUtils {
public static fixUtils() {
Utils.externalDownloadFunction = ScriptUtils.Download
}
/**

View file

@ -274,7 +274,8 @@ export class GenerateDocs extends Script {
"## How to use",
unitUsage.description,
"Units ",
"## " + layer.id]
"## " + layer.id,
]
for (const unit of layer.units) {
els.push("### " + unit.quantity)
@ -302,7 +303,8 @@ export class GenerateDocs extends Script {
}
this.WriteMarkdownFile("./Docs/builtin_units.md", els.join("\n\n"), [
`assets/layers/unit/unit.json`, `src/Models/ThemeConfig/Json/UnitConfigJson.ts`
`assets/layers/unit/unit.json`,
`src/Models/ThemeConfig/Json/UnitConfigJson.ts`,
])
}

View file

@ -9,12 +9,16 @@ import {
DoesImageExist,
PrevalidateTheme,
ValidateLayer,
ValidateThemeEnsemble
ValidateThemeEnsemble,
} from "../src/Models/ThemeConfig/Conversion/Validation"
import { Translation } from "../src/UI/i18n/Translation"
import { PrepareLayer } from "../src/Models/ThemeConfig/Conversion/PrepareLayer"
import { PrepareTheme } from "../src/Models/ThemeConfig/Conversion/PrepareTheme"
import { Conversion, DesugaringContext, DesugaringStep } from "../src/Models/ThemeConfig/Conversion/Conversion"
import {
Conversion,
DesugaringContext,
DesugaringStep,
} from "../src/Models/ThemeConfig/Conversion/Conversion"
import { Utils } from "../src/Utils"
import Script from "./Script"
import { AllSharedLayers } from "../src/Customizations/AllSharedLayers"

View file

@ -12,33 +12,33 @@ import { Utils } from "../src/Utils"
interface TagInfoEntry {
key: string
description: string
value?: string,
icon_url?: string,
value?: string
icon_url?: string
doc_url?: string
}
interface TagInfoProjectFile {
// data format version, currently always 1, will get updated if there are incompatible changes to the format (required)
data_format: 1,
data_format: 1
// timestamp when project file was updated is not given as it pollutes the github history
project: {
name: string, // name of the project (required)
description: string, // short description of the project (required)
project_url: string, // home page of the project with general information (required)
name: string // name of the project (required)
description: string // short description of the project (required)
project_url: string // home page of the project with general information (required)
doc_url: string // documentation of the project and especially the tags used (optional)
icon_url: string, // project logo, should work in 16x16 pixels on white and light gray backgrounds (optional)
contact_name: string, // contact name, needed for taginfo maintainer (required)
icon_url: string // project logo, should work in 16x16 pixels on white and light gray backgrounds (optional)
contact_name: string // contact name, needed for taginfo maintainer (required)
contact_email: string // contact email, needed for taginfo maintainer (required)
},
}
tags: TagInfoEntry[]
}
interface TagInfoPrototype {
key: string,
value?: string,
shownText: string,
layerName: string,
layer: LayerConfig,
key: string
value?: string
shownText: string
layerName: string
layer: LayerConfig
icon?: string
emoji?: string
trid?: string
@ -56,9 +56,11 @@ function generateLayerUsage(layer: LayerConfig): TagInfoPrototype[] {
const layerName = layer.name.txt
for (const kv of usedTags) {
result.push({
key: kv.k, value: kv.v, layerName,
key: kv.k,
value: kv.v,
layerName,
shownText: "Features with this tag are displayed",
layer
layer,
})
}
@ -81,7 +83,12 @@ function generateLayerUsage(layer: LayerConfig): TagInfoPrototype[] {
const keys = ["image", "panoramax", "mapillary", "wikidata", "wikipedia"]
for (const key of keys) {
result.push({
key, shownText, layerName, layer, emoji: "📷", trid: "images"
key,
shownText,
layerName,
layer,
emoji: "📷",
trid: "images",
})
}
}
@ -90,17 +97,19 @@ function generateLayerUsage(layer: LayerConfig): TagInfoPrototype[] {
const q = tr.question?.txt
const key = tr.freeform?.key
if (key != undefined) {
let descr = "Values of `" + key + "` are shown with \"" + tr.render.txt + "\""
let descr = "Values of `" + key + '` are shown with "' + tr.render.txt + '"'
if (q != undefined) {
descr += " and can be updated. The question is \"" + q + "\""
descr += ' and can be updated. The question is "' + q + '"'
}
result.push(({
key, layerName, shownText: descr,
result.push({
key,
layerName,
shownText: descr,
layer,
icon: !Utils.isEmoji(tr.renderIcon) ? tr.renderIcon : undefined,
emoji: Utils.isEmoji(tr.renderIcon) ? tr.renderIcon : undefined,
trid: tr.id
}))
trid: tr.id,
})
}
for (const mapping of tr.mappings ?? []) {
@ -110,10 +119,12 @@ function generateLayerUsage(layer: LayerConfig): TagInfoPrototype[] {
value: kv.v,
layerName,
layer,
shownText: `${mapping.if.asHumanString()} is displayed as "${mapping.then.txt}"`,
shownText: `${mapping.if.asHumanString()} is displayed as "${
mapping.then.txt
}"`,
icon: !Utils.isEmoji(mapping.icon) ? mapping.icon : undefined,
emoji: Utils.isEmoji(mapping.icon) ? mapping.icon : undefined,
trid: tr.id
trid: tr.id,
})
}
}
@ -147,7 +158,6 @@ function generateTagInfoEntry(layout: ThemeConfig): string {
icon = icon.substring(2)
}
const merged: Map<string, TagInfoPrototype[]> = new Map<string, TagInfoPrototype[]>()
for (const entry of usedTags) {
const key = entry.key + ";" + (entry.value ?? "") + ";" + entry.shownText
@ -166,7 +176,7 @@ function generateTagInfoEntry(layout: ThemeConfig): string {
Array.from(merged.values()).forEach((prototypes: TagInfoPrototype[]) => {
// We use a prototype without condition, as this has a higher chance of being the "root"-layer
const p = prototypes[0]
const layers = prototypes.map(p => p.layerName)
const layers = prototypes.map((p) => p.layerName)
let layerDescr = `layers ${layers.join(", ")}`
if (layers.length === 1) {
@ -178,7 +188,9 @@ function generateTagInfoEntry(layout: ThemeConfig): string {
}
let defaultIcon = undefined
if (p.layer.hasDefaultIcon()) {
defaultIcon = p.layer.mapRendering.map(pr => pr.marker?.at(-1)?.icon?.render?.txt).find(x => x !== undefined)
defaultIcon = p.layer.mapRendering
.map((pr) => pr.marker?.at(-1)?.icon?.render?.txt)
.find((x) => x !== undefined)
}
let value = p.value
if (value === "") {
@ -189,7 +201,7 @@ function generateTagInfoEntry(layout: ThemeConfig): string {
value,
description: p.shownText + " by " + layerDescr,
doc_url,
icon_url: p.icon ?? defaultIcon
icon_url: p.icon ?? defaultIcon,
})
})
@ -201,13 +213,12 @@ function generateTagInfoEntry(layout: ThemeConfig): string {
name: "MapComplete " + layout.title.txt, // name of the project (required)
description: layout.shortDescription.txt, // short description of the project (required)
project_url: "https://mapcomplete.org/" + layout.id, // home page of the project with general information (required)
doc_url:
repo + "src/branch/develop/Docs/Themes", // documentation of the project and especially the tags used (optional)
doc_url: repo + "src/branch/develop/Docs/Themes", // documentation of the project and especially the tags used (optional)
icon_url: "https://mapcomplete.org/" + icon, // project logo, should work in 16x16 pixels on white and light gray backgrounds (optional)
contact_name: "Pieter Vander Vennet", // contact name, needed for taginfo maintainer (required)
contact_email: "info@mapcomplete.org" // contact email, needed for taginfo maintainer (required)
contact_email: "info@mapcomplete.org", // contact email, needed for taginfo maintainer (required)
},
tags: entries
tags: entries,
}
const filename = "mapcomplete_" + layout.id

View file

@ -15,50 +15,34 @@ import { writeFileSync } from "fs"
import { Feature } from "geojson"
class RepairPanoramax extends Script {
private static readonly europe: Feature = {
"type": "Feature",
"properties": {},
"geometry": {
"coordinates": [
private static readonly europe: Feature = {
type: "Feature",
properties: {},
geometry: {
coordinates: [
[
[
-20.091159690050006,
25.773375277790038
],
[
46.12276429398841,
25.773375277790038
],
[
46.12276429398841,
65.41389761819318
],
[
-20.091159690050006,
65.41389761819318
],
[
-20.091159690050006,
25.773375277790038
]
]
[-20.091159690050006, 25.773375277790038],
[46.12276429398841, 25.773375277790038],
[46.12276429398841, 65.41389761819318],
[-20.091159690050006, 65.41389761819318],
[-20.091159690050006, 25.773375277790038],
],
],
"type": "Polygon"
}
type: "Polygon",
},
}
constructor() {
super("See https://source.mapcomplete.org/MapComplete/MapComplete/issues/2372\n" +
"We accidentally added the full image URL instead of the hash due to a bug. This scripts rewrites all")
super(
"See https://source.mapcomplete.org/MapComplete/MapComplete/issues/2372\n" +
"We accidentally added the full image URL instead of the hash due to a bug. This scripts rewrites all"
)
}
async main(args: string[]): Promise<void> {
const keys = ["panoramax", ...Utils.TimesT(10, i => "panoramax:" + i)]
const keys = ["panoramax", ...Utils.TimesT(10, (i) => "panoramax:" + i)]
const overpass = new Overpass(
new Or(
keys.map(k => new RegexTag(k, /^https:\/\/panoramax.mapcomplete.org\/.*/))
),
new Or(keys.map((k) => new RegexTag(k, /^https:\/\/panoramax.mapcomplete.org\/.*/))),
[],
Constants.defaultOverpassUrls[0],
new ImmutableStore(500)
@ -99,7 +83,7 @@ class RepairPanoramax extends Script {
f.properties,
{
theme: "fix",
changeType: "fix"
changeType: "fix",
}
)
allChanges.push(change)