Merge master

This commit is contained in:
Pieter Vander Vennet 2024-04-02 19:07:11 +02:00
commit 890816d2dd
424 changed files with 40595 additions and 3354 deletions

View file

@ -30,6 +30,7 @@ import { LayerConfigJson } from "../src/Models/ThemeConfig/Json/LayerConfigJson"
import { Utils } from "../src/Utils"
import { TagUtils } from "../src/Logic/Tags/TagUtils"
import Script from "./Script"
import { Changes } from "../src/Logic/Osm/Changes"
/**
* Converts a markdown-file into a .json file, which a walkthrough/slideshow element can use
@ -180,6 +181,10 @@ export class GenerateDocs extends Script {
"src/UI/InputElement/Validators.ts",
])
this.WriteFile("./Docs/ChangesetMeta.md", Changes.getDocs(), [
"src/Logic/Osm/Changes.ts",
"src/Logic/Osm/ChangesetHandler.ts",
])
new WikiPageGenerator().generate()
console.log("Generated docs")
@ -239,7 +244,7 @@ export class GenerateDocs extends Script {
}
private generateHotkeyDocs() {
new ThemeViewState(new LayoutConfig(<any>bookcases))
new ThemeViewState(new LayoutConfig(<any>bookcases), new Set())
this.WriteFile("./Docs/Hotkeys.md", Hotkeys.generateDocumentation(), [])
}
@ -314,9 +319,6 @@ export class GenerateDocs extends Script {
const themesPerLayer = new Map<string, string[]>()
for (const layout of Array.from(AllKnownLayouts.allKnownLayouts.values())) {
if (layout.hideFromOverview) {
continue
}
for (const layer of layout.layers) {
if (!builtinLayerIds.has(layer.id)) {
// This is an inline layer

View file

@ -40,6 +40,26 @@ export class GenerateFavouritesLayer extends Script {
}
}
async main(args: string[]): Promise<void> {
console.log("Generating the favourite layer: stealing _all_ tagRenderings")
const proto = this.readLayer("favourite/favourite.proto.json")
this.addTagRenderings(proto)
this.addTitle(proto)
proto.titleIcons = this.generateTitleIcons()
const targetContent = JSON.stringify(proto, null, " ")
const path = "./assets/layers/favourite/favourite.json"
if (existsSync(path)) {
if (readFileSync(path, "utf8") === targetContent) {
console.log(
"Already existing favourite layer is identical to the generated one, not writing"
)
return
}
}
console.log("Written favourite layer to", path)
writeFileSync(path, targetContent)
}
private sortMappings(mappings: MappingConfigJson[]): MappingConfigJson[] {
const sortedMappings: MappingConfigJson[] = [...mappings]
sortedMappings.sort((a, b) => {
@ -200,6 +220,10 @@ export class GenerateFavouritesLayer extends Script {
if (titleIcon["labels"]?.indexOf("defaults") >= 0) {
continue
}
if (titleIcon.id === "iconsdefaults") {
continue
}
if (titleIcon.id === "rating") {
if (!seenTitleIcons.has("rating")) {
titleIcons.unshift(...iconsLibrary.get("rating"))
@ -302,26 +326,6 @@ export class GenerateFavouritesLayer extends Script {
}
}
async main(args: string[]): Promise<void> {
console.log("Generating the favourite layer: stealing _all_ tagRenderings")
const proto = this.readLayer("favourite/favourite.proto.json")
this.addTagRenderings(proto)
this.addTitle(proto)
proto.titleIcons = this.generateTitleIcons()
const targetContent = JSON.stringify(proto, null, " ")
const path = "./assets/layers/favourite/favourite.json"
if (existsSync(path)) {
if (readFileSync(path, "utf8") === targetContent) {
console.log(
"Already existing favourite layer is identical to the generated one, not writing"
)
return
}
}
console.log("Written favourite layer to", path)
writeFileSync(path, targetContent)
}
private readLayer(path: string): LayerConfigJson {
try {
return JSON.parse(readFileSync("./assets/layers/" + path, "utf8"))

View file

@ -95,7 +95,7 @@ export default class GenerateImageAnalysis extends Script {
if (fs.existsSync(targetPath)) {
return false
}
const attribution = await Imgur.singleton.DownloadAttribution(image)
const attribution = await Imgur.singleton.DownloadAttribution({ url: image, })
if ((attribution.artist ?? "") === "") {
// This is an invalid attribution. We save the raw response as well
@ -215,7 +215,7 @@ export default class GenerateImageAnalysis extends Script {
skipped++
} else {
try {
attribution = await Imgur.singleton.DownloadAttribution(image)
attribution = await Imgur.singleton.DownloadAttribution({ url: image })
await ScriptUtils.sleep(500)
writeFileSync(cachedView, JSON.stringify(attribution))
dloaded++

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,18 @@
import { writeFileSync } from "fs"
import Script from "./Script"
import sunny from "../public/assets/sunny.json"
export class GenerateSunnyUnlabeled extends Script {
constructor() {
super("Generates 'sunny-unlabeled.json' based on sunny.json")
}
async main(args: string[]): Promise<void> {
const unlabeled = { "#":"AUTOMATICALLY GENERATED! Do not edit.", ...sunny }
unlabeled.name = unlabeled.name+"-unlabeled"
unlabeled.layers = sunny.layers.filter(l => l.type !== "symbol" || !l.layout["text-field"])
writeFileSync("public/assets/sunny-unlabeled.json", JSON.stringify(unlabeled, null, " "))
}
}
new GenerateSunnyUnlabeled().run()

View file

@ -342,6 +342,9 @@ function isTranslation(tr: any): boolean {
if (tr["#"] === "no-translations") {
return false
}
if (tr["special"]) {
return false
}
for (const key in tr) {
if (typeof tr[key] !== "string") {
return false

View file

@ -190,10 +190,25 @@ class GenerateBuildDbScript extends Script {
}
async main(args: string[]) {
const allNeededLayers = new ValidateThemeEnsemble().convertStrict(
const allLayers = new ValidateThemeEnsemble().convertStrict(
AllKnownLayouts.allKnownLayouts.values()
)
if (allLayers.size === 0) {
throw "No layers found at all"
}
const notCounted: string[] = []
const allNeededLayers: Map<string, { tags: TagsFilter; foundInTheme: string[] }> = new Map<
string,
{ tags: TagsFilter; foundInTheme: string[] }
>()
for (const key of allLayers.keys()) {
const layer = allLayers.get(key)
if (layer.isCounted) {
allNeededLayers.set(key, layer)
} else {
notCounted.push(key)
}
}
const generators: GenerateLayerLua[] = []
allNeededLayers.forEach(({ tags, foundInTheme }, layerId) => {
@ -210,6 +225,10 @@ class GenerateBuildDbScript extends Script {
const path = "build_db.lua"
fs.writeFileSync(path, script, "utf-8")
console.log("Written", path)
console.log(
"Following layers are _not_ indexed as they are not counted:",
notCounted.join(", ")
)
console.log(
allNeededLayers.size +
" layers will be created with 3 tables each. Make sure to set 'max_connections' to at least " +

View file

@ -0,0 +1,12 @@
#! /bin/bash
cd ~/Downloads
for F in *.osm.pbf
do
LATEST="$F"
done
mv "$LATEST" ~/data/planet-latest.osm.pbf
cd ~/data
osm2pgsql -O flex -S build_db.lua -s --flat-nodes=import-help-file -d postgresql://user:password@localhost:5444/mapcomplete-cache planet-latest.osm.pbf
echo "on_data_downloaded.sh has finished!"

8
scripts/osm2pgsql/update.sh Executable file
View file

@ -0,0 +1,8 @@
#! /bin/bash
npm run init
npm run generate
npm run refresh:layeroverview
npm run generate:buildDbScript
mv build_db.sh ~/data/
transmission-cli https://planet.osm.org/pbf/planet-latest.osm.pbf.torrent -f ./on_data_downloaded.sh &>nohup_transmission.log

View file

@ -18,7 +18,7 @@ npm run prep:layeroverview &&
npm run generate && # includes a single "refresh:layeroverview". Resetting the files is unnecessary as they are not in there in the first place
npm run generate:mapcomplete-changes-theme &&
npm run refresh:layeroverview && # run refresh:layeroverview a second time to propagate all calls
npm run refresh:layeroverview && # run refresh:layeroverview a third time to fix some issues with the favourite layer all calls
npm run generate:layeroverview && # run refresh:layeroverview a third time to fix some issues with the favourite layer all calls
npm run generate:layouts