Generate an overview of all layers
This commit is contained in:
parent
2bead588fb
commit
df453821c8
1 changed files with 21 additions and 7 deletions
|
@ -39,7 +39,12 @@ export class AllKnownLayouts {
|
||||||
throw "Priviliged layer definition not found: " + id
|
throw "Priviliged layer definition not found: " + id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const allLayers: LayerConfig[] = Array.from(AllKnownLayers.sharedLayers.values())
|
const allLayers: LayerConfig[] = Array.from(AllKnownLayers.sharedLayers.values())
|
||||||
|
.filter(layer => AllKnownLayers.priviliged_layers.indexOf(layer.id) < 0)
|
||||||
|
|
||||||
|
const builtinLayerIds: Set<string> = new Set<string>()
|
||||||
|
allLayers.forEach(l => builtinLayerIds.add(l.id))
|
||||||
|
|
||||||
const themesPerLayer = new Map<string, string[]>()
|
const themesPerLayer = new Map<string, string[]>()
|
||||||
|
|
||||||
|
@ -48,6 +53,9 @@ export class AllKnownLayouts {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for (const layer of layout.layers) {
|
for (const layer of layout.layers) {
|
||||||
|
if (!builtinLayerIds.has(layer.id)) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if (!themesPerLayer.has(layer.id)) {
|
if (!themesPerLayer.has(layer.id)) {
|
||||||
themesPerLayer.set(layer.id, [])
|
themesPerLayer.set(layer.id, [])
|
||||||
}
|
}
|
||||||
|
@ -57,8 +65,9 @@ export class AllKnownLayouts {
|
||||||
|
|
||||||
|
|
||||||
let popularLayerCutoff = 2;
|
let popularLayerCutoff = 2;
|
||||||
const popupalLayers = allLayers.filter((layer) => themesPerLayer.get(layer.id)?.length >= 2)
|
const popuparLayers = allLayers.filter(layer => themesPerLayer.get(layer.id)?.length >= 2)
|
||||||
.filter(layer => AllKnownLayers.priviliged_layers.indexOf(layer.id) < 0)
|
|
||||||
|
const unpopularLayers = allLayers.filter(layer => themesPerLayer.get(layer.id)?.length < 2)
|
||||||
|
|
||||||
return new Combine([
|
return new Combine([
|
||||||
new Title("Special and other useful layers", 1),
|
new Title("Special and other useful layers", 1),
|
||||||
|
@ -68,10 +77,15 @@ export class AllKnownLayouts {
|
||||||
...AllKnownLayers.priviliged_layers
|
...AllKnownLayers.priviliged_layers
|
||||||
.map(id => AllKnownLayers.sharedLayers.get(id))
|
.map(id => AllKnownLayers.sharedLayers.get(id))
|
||||||
.map((l) => l.GenerateDocumentation(themesPerLayer.get(l.id), AllKnownLayers.added_by_default.indexOf(l.id) >= 0, AllKnownLayers.no_include.indexOf(l.id) < 0)),
|
.map((l) => l.GenerateDocumentation(themesPerLayer.get(l.id), AllKnownLayers.added_by_default.indexOf(l.id) >= 0, AllKnownLayers.no_include.indexOf(l.id) < 0)),
|
||||||
new Title("Frequently reused layers", 1),
|
new Title("Normal layers", 1),
|
||||||
|
"The following layers are included in MapComplete",
|
||||||
|
new Title("Frequently reused layers", 2),
|
||||||
"The following layers are used by at least " + popularLayerCutoff + " mapcomplete themes and might be interesting for your custom theme too",
|
"The following layers are used by at least " + popularLayerCutoff + " mapcomplete themes and might be interesting for your custom theme too",
|
||||||
new List(popupalLayers.map(layer => "[" + layer.id + "](#" + layer.id + ")")),
|
new List(popuparLayers.map(layer => "[" + layer.id + "](#" + layer.id + ")")),
|
||||||
...popupalLayers.map((layer) => layer.GenerateDocumentation(themesPerLayer.get(layer.id)))
|
...popuparLayers.map((layer) => layer.GenerateDocumentation(themesPerLayer.get(layer.id))),
|
||||||
|
new List(unpopularLayers.map(layer => "[" + layer.id + "](#" + layer.id + ")")),
|
||||||
|
...unpopularLayers.map(layer => layer.GenerateDocumentation(themesPerLayer.get(layer.id))
|
||||||
|
)
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue