forked from MapComplete/MapComplete
Performance: Remove 'AllKnownLayouts' as much as possible
This commit is contained in:
parent
0e4cce59ea
commit
0f60977b6d
7 changed files with 27 additions and 64 deletions
|
|
@ -49,14 +49,4 @@ export class AllKnownLayoutsLazy {
|
|||
|
||||
export class AllKnownLayouts {
|
||||
public static allKnownLayouts: AllKnownLayoutsLazy = new AllKnownLayoutsLazy()
|
||||
|
||||
static AllPublicLayers() {
|
||||
const layers = [].concat(
|
||||
...this.allKnownLayouts
|
||||
.values()
|
||||
.filter((layout) => !layout.hideFromOverview)
|
||||
.map((layout) => layout.layers)
|
||||
)
|
||||
return layers
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import LayerConfig from "../Models/ThemeConfig/LayerConfig"
|
|||
import { Utils } from "../Utils"
|
||||
import known_layers from "../assets/generated/known_layers.json"
|
||||
import { LayerConfigJson } from "../Models/ThemeConfig/Json/LayerConfigJson"
|
||||
import { AllKnownLayouts } from "./AllKnownLayouts"
|
||||
|
||||
export class AllSharedLayers {
|
||||
public static sharedLayers: Map<string, LayerConfig> = AllSharedLayers.getSharedLayers()
|
||||
public static getSharedLayersConfigs(): Map<string, LayerConfigJson> {
|
||||
|
|
@ -35,34 +35,4 @@ export class AllSharedLayers {
|
|||
|
||||
return sharedLayers
|
||||
}
|
||||
|
||||
public static AllPublicLayers(options?: {
|
||||
includeInlineLayers: true | boolean
|
||||
}): LayerConfig[] {
|
||||
const allLayers: LayerConfig[] = []
|
||||
const seendIds = new Set<string>()
|
||||
AllSharedLayers.sharedLayers.forEach((layer, key) => {
|
||||
seendIds.add(key)
|
||||
allLayers.push(layer)
|
||||
})
|
||||
if (options?.includeInlineLayers ?? true) {
|
||||
const publicLayouts = Array.from(AllKnownLayouts.allKnownLayouts.values()).filter(
|
||||
(l) => !l.hideFromOverview
|
||||
)
|
||||
for (const layout of publicLayouts) {
|
||||
if (layout.hideFromOverview) {
|
||||
continue
|
||||
}
|
||||
for (const layer of layout.layers) {
|
||||
if (seendIds.has(layer.id)) {
|
||||
continue
|
||||
}
|
||||
seendIds.add(layer.id)
|
||||
allLayers.push(layer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return allLayers
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue