Feature: layer validation system now builds a dependency graph and only updates what is needed, makes "refresh:layeroverview" redundant

This commit is contained in:
Pieter Vander Vennet 2025-04-21 23:53:10 +02:00
parent 1bd060df82
commit fda0bc6b2e
19 changed files with 301 additions and 186 deletions

View file

@ -239,11 +239,11 @@ export class ExpandFilter extends DesugaringStep<LayerConfigJson> {
)
}
const layer = this._state.sharedLayers.get(split[0])
if (layer === undefined) {
if (!layer) {
context.err("Layer '" + split[0] + "' not found")
}
const expectedId = split[1]
const expandedFilter = (<(FilterConfigJson | string)[]>layer.filter).find(
const expandedFilter = (<(FilterConfigJson | string)[]>layer?.filter)?.find(
(f) => typeof f !== "string" && f.id === expectedId
)
if (expandedFilter === undefined) {

View file

@ -380,15 +380,10 @@ export class ExpandTagRendering extends Conversion<
Utils.NoNull(Array.from(state.sharedLayers.keys())),
(s) => s
)
if (state.sharedLayers.size === 0) {
ctx.warn(
"BOOTSTRAPPING. Rerun generate layeroverview. While reusing tagrendering: " +
name +
": layer " +
layerName +
" not found for now, but ignoring as this is a bootstrapping run. "
)
if (candidates.length === 0) {
ctx.err("While reusing a tagRendering: " + name + "; no candidates in layer " + layerName)
} else {
console.error("Bench was not found...")
ctx.err(
": While reusing tagrendering: " +
name +
@ -400,10 +395,15 @@ export class ExpandTagRendering extends Conversion<
}
continue
}
if (layer.source === "special:stub") {
// We are dealing with a looping import, no error is necessary
continue
}
candidates = Utils.NoNull(layer.tagRenderings.map((tr) => tr["id"])).map(
(id) => layerName + "." + id
)
}
candidates = Utils.sortedByLevenshteinDistance(name, candidates, (i) => i)
ctx.err(
"The tagRendering with identifier " +

View file

@ -1048,6 +1048,11 @@ export class PrepareLayer extends Fuse<LayerConfigJson> {
if (json === undefined || json === null) {
throw "Error: prepareLayer got null"
}
if (json.source?.["osmTags"] !== undefined && json.source?.["osmTags"]?.["and"] === undefined) {
json = { ...json }
json.source = <any>{ ...(<object>json.source) }
json.source["osmTags"] = { "and": [json.source["osmTags"]] }
}
return super.convert(json, context)
}
}

View file

@ -78,6 +78,7 @@ export interface LayerConfigJson {
| undefined
| "special"
| "special:library"
| "special:stub" // only used when building looping imports
| {
/**
* question: Which tags must be present on the feature to show it in this layer?