diff --git a/scripts/osm2pgsql/generateBuildDbScript.ts b/scripts/osm2pgsql/generateBuildDbScript.ts index 7ddd217f0..8a727a6a6 100644 --- a/scripts/osm2pgsql/generateBuildDbScript.ts +++ b/scripts/osm2pgsql/generateBuildDbScript.ts @@ -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 = 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 " + diff --git a/src/Models/ThemeConfig/Conversion/Validation.ts b/src/Models/ThemeConfig/Conversion/Validation.ts index f5d9c789b..471f8aa92 100644 --- a/src/Models/ThemeConfig/Conversion/Validation.ts +++ b/src/Models/ThemeConfig/Conversion/Validation.ts @@ -1844,6 +1844,7 @@ export class ValidateThemeEnsemble extends Conversion< { tags: TagsFilter foundInTheme: string[] + isCounted: boolean } > > { @@ -1862,10 +1863,11 @@ export class ValidateThemeEnsemble extends Conversion< string, { tags: TagsFilter - foundInTheme: string[] + foundInTheme: string[], + isCounted: boolean } > { - const idToSource = new Map() + const idToSource = new Map() for (const theme of json) { for (const layer of theme.layers) { @@ -1886,7 +1888,7 @@ export class ValidateThemeEnsemble extends Conversion< const id = layer.id const tags = layer.source.osmTags if (!idToSource.has(id)) { - idToSource.set(id, { tags, foundInTheme: [theme.id] }) + idToSource.set(id, { tags, foundInTheme: [theme.id], isCounted: layer.doCount }) continue } @@ -1895,6 +1897,7 @@ export class ValidateThemeEnsemble extends Conversion< if (oldTags.shadows(tags) && tags.shadows(oldTags)) { // All is good, all is well oldTheme.push(theme.id) + idToSource.get(id).isCounted ||= layer.doCount continue } context.err(