Scripts: generate db does not index some layers anymore if they are uncounted
This commit is contained in:
parent
e7e515364c
commit
58fd99625d
2 changed files with 27 additions and 5 deletions
|
@ -190,10 +190,25 @@ class GenerateBuildDbScript extends Script {
|
||||||
}
|
}
|
||||||
|
|
||||||
async main(args: string[]) {
|
async main(args: string[]) {
|
||||||
const allNeededLayers = new ValidateThemeEnsemble().convertStrict(
|
const allLayers = new ValidateThemeEnsemble().convertStrict(
|
||||||
AllKnownLayouts.allKnownLayouts.values()
|
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[] = []
|
const generators: GenerateLayerLua[] = []
|
||||||
|
|
||||||
allNeededLayers.forEach(({ tags, foundInTheme }, layerId) => {
|
allNeededLayers.forEach(({ tags, foundInTheme }, layerId) => {
|
||||||
|
@ -210,6 +225,10 @@ class GenerateBuildDbScript extends Script {
|
||||||
const path = "build_db.lua"
|
const path = "build_db.lua"
|
||||||
fs.writeFileSync(path, script, "utf-8")
|
fs.writeFileSync(path, script, "utf-8")
|
||||||
console.log("Written", path)
|
console.log("Written", path)
|
||||||
|
console.log(
|
||||||
|
"Following layers are _not_ indexed as they are not counted:",
|
||||||
|
notCounted.join(", ")
|
||||||
|
)
|
||||||
console.log(
|
console.log(
|
||||||
allNeededLayers.size +
|
allNeededLayers.size +
|
||||||
" layers will be created with 3 tables each. Make sure to set 'max_connections' to at least " +
|
" layers will be created with 3 tables each. Make sure to set 'max_connections' to at least " +
|
||||||
|
|
|
@ -1844,6 +1844,7 @@ export class ValidateThemeEnsemble extends Conversion<
|
||||||
{
|
{
|
||||||
tags: TagsFilter
|
tags: TagsFilter
|
||||||
foundInTheme: string[]
|
foundInTheme: string[]
|
||||||
|
isCounted: boolean
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
> {
|
> {
|
||||||
|
@ -1862,10 +1863,11 @@ export class ValidateThemeEnsemble extends Conversion<
|
||||||
string,
|
string,
|
||||||
{
|
{
|
||||||
tags: TagsFilter
|
tags: TagsFilter
|
||||||
foundInTheme: string[]
|
foundInTheme: string[],
|
||||||
|
isCounted: boolean
|
||||||
}
|
}
|
||||||
> {
|
> {
|
||||||
const idToSource = new Map<string, { tags: TagsFilter; foundInTheme: string[] }>()
|
const idToSource = new Map<string, { tags: TagsFilter; foundInTheme: string[], isCounted: boolean }>()
|
||||||
|
|
||||||
for (const theme of json) {
|
for (const theme of json) {
|
||||||
for (const layer of theme.layers) {
|
for (const layer of theme.layers) {
|
||||||
|
@ -1886,7 +1888,7 @@ export class ValidateThemeEnsemble extends Conversion<
|
||||||
const id = layer.id
|
const id = layer.id
|
||||||
const tags = layer.source.osmTags
|
const tags = layer.source.osmTags
|
||||||
if (!idToSource.has(id)) {
|
if (!idToSource.has(id)) {
|
||||||
idToSource.set(id, { tags, foundInTheme: [theme.id] })
|
idToSource.set(id, { tags, foundInTheme: [theme.id], isCounted: layer.doCount })
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1895,6 +1897,7 @@ export class ValidateThemeEnsemble extends Conversion<
|
||||||
if (oldTags.shadows(tags) && tags.shadows(oldTags)) {
|
if (oldTags.shadows(tags) && tags.shadows(oldTags)) {
|
||||||
// All is good, all is well
|
// All is good, all is well
|
||||||
oldTheme.push(theme.id)
|
oldTheme.push(theme.id)
|
||||||
|
idToSource.get(id).isCounted ||= layer.doCount
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
context.err(
|
context.err(
|
||||||
|
|
Loading…
Reference in a new issue