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 {
|
export class AllKnownLayouts {
|
||||||
public static allKnownLayouts: AllKnownLayoutsLazy = new AllKnownLayoutsLazy()
|
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 { Utils } from "../Utils"
|
||||||
import known_layers from "../assets/generated/known_layers.json"
|
import known_layers from "../assets/generated/known_layers.json"
|
||||||
import { LayerConfigJson } from "../Models/ThemeConfig/Json/LayerConfigJson"
|
import { LayerConfigJson } from "../Models/ThemeConfig/Json/LayerConfigJson"
|
||||||
import { AllKnownLayouts } from "./AllKnownLayouts"
|
|
||||||
export class AllSharedLayers {
|
export class AllSharedLayers {
|
||||||
public static sharedLayers: Map<string, LayerConfig> = AllSharedLayers.getSharedLayers()
|
public static sharedLayers: Map<string, LayerConfig> = AllSharedLayers.getSharedLayers()
|
||||||
public static getSharedLayersConfigs(): Map<string, LayerConfigJson> {
|
public static getSharedLayersConfigs(): Map<string, LayerConfigJson> {
|
||||||
|
@ -35,34 +35,4 @@ export class AllSharedLayers {
|
||||||
|
|
||||||
return sharedLayers
|
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,6 @@ import { QueryParameters } from "./Web/QueryParameters"
|
||||||
import { AllKnownLayouts } from "../Customizations/AllKnownLayouts"
|
import { AllKnownLayouts } from "../Customizations/AllKnownLayouts"
|
||||||
import { FixedUiElement } from "../UI/Base/FixedUiElement"
|
import { FixedUiElement } from "../UI/Base/FixedUiElement"
|
||||||
import { Utils } from "../Utils"
|
import { Utils } from "../Utils"
|
||||||
import Combine from "../UI/Base/Combine"
|
|
||||||
import { SubtleButton } from "../UI/Base/SubtleButton"
|
|
||||||
import BaseUIElement from "../UI/BaseUIElement"
|
|
||||||
import { UIEventSource } from "./UIEventSource"
|
import { UIEventSource } from "./UIEventSource"
|
||||||
import { LocalStorageSource } from "./Web/LocalStorageSource"
|
import { LocalStorageSource } from "./Web/LocalStorageSource"
|
||||||
import LZString from "lz-string"
|
import LZString from "lz-string"
|
||||||
|
@ -16,7 +13,6 @@ import { PrepareTheme } from "../Models/ThemeConfig/Conversion/PrepareTheme"
|
||||||
import licenses from "../assets/generated/license_info.json"
|
import licenses from "../assets/generated/license_info.json"
|
||||||
import TagRenderingConfig from "../Models/ThemeConfig/TagRenderingConfig"
|
import TagRenderingConfig from "../Models/ThemeConfig/TagRenderingConfig"
|
||||||
import { FixImages } from "../Models/ThemeConfig/Conversion/FixImages"
|
import { FixImages } from "../Models/ThemeConfig/Conversion/FixImages"
|
||||||
import Svg from "../Svg"
|
|
||||||
import questions from "../assets/generated/layers/questions.json"
|
import questions from "../assets/generated/layers/questions.json"
|
||||||
import {
|
import {
|
||||||
DoesImageExist,
|
DoesImageExist,
|
||||||
|
|
|
@ -43,7 +43,7 @@ export class ChangesetHandler {
|
||||||
this.userDetails = osmConnection.userDetails
|
this.userDetails = osmConnection.userDetails
|
||||||
this.backend = osmConnection._oauth_config.url
|
this.backend = osmConnection._oauth_config.url
|
||||||
|
|
||||||
if (dryRun) {
|
if (dryRun.data) {
|
||||||
console.log("DRYRUN ENABLED")
|
console.log("DRYRUN ENABLED")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,6 +161,7 @@ export class OsmConnection {
|
||||||
this.userDetails.ping()
|
this.userDetails.ping()
|
||||||
console.log("Logged out")
|
console.log("Logged out")
|
||||||
this.loadingStatus.setData("not-attempted")
|
this.loadingStatus.setData("not-attempted")
|
||||||
|
this.preferencesHandler.preferences.setData(undefined)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import jsPDF, { Matrix } from "jspdf"
|
import jsPDF, { Matrix } from "jspdf"
|
||||||
import { Translation, TypedTranslation } from "../UI/i18n/Translation"
|
import { Translation, TypedTranslation } from "../UI/i18n/Translation"
|
||||||
import { PngMapCreator } from "./pngMapCreator"
|
import { PngMapCreator } from "./pngMapCreator"
|
||||||
import { AllKnownLayouts } from "../Customizations/AllKnownLayouts"
|
|
||||||
import "../../public/assets/fonts/Ubuntu-M-normal.js"
|
import "../../public/assets/fonts/Ubuntu-M-normal.js"
|
||||||
import "../../public/assets/fonts/Ubuntu-L-normal.js"
|
import "../../public/assets/fonts/Ubuntu-L-normal.js"
|
||||||
import "../../public/assets/fonts/UbuntuMono-B-bold.js"
|
import "../../public/assets/fonts/UbuntuMono-B-bold.js"
|
||||||
|
@ -874,7 +873,7 @@ class SvgToPdfPage {
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
}).CreatePng(this.options.freeComponentId, this._state)
|
}).CreatePng(this.options.freeComponentId, this._state)
|
||||||
} else {
|
}/* else {
|
||||||
const match = spec.match(/\$map\(([^)]*)\)$/)
|
const match = spec.match(/\$map\(([^)]*)\)$/)
|
||||||
if (match === null) {
|
if (match === null) {
|
||||||
throw "Invalid mapspec:" + spec
|
throw "Invalid mapspec:" + spec
|
||||||
|
@ -974,7 +973,7 @@ class SvgToPdfPage {
|
||||||
throw "PngCreator did not output anything..."
|
throw "PngCreator did not output anything..."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//*/
|
||||||
svgImage.setAttribute("xlink:href", await SvgToPdfPage.blobToBase64(png))
|
svgImage.setAttribute("xlink:href", await SvgToPdfPage.blobToBase64(png))
|
||||||
smallestRect.parentElement.insertBefore(svgImage, smallestRect)
|
smallestRect.parentElement.insertBefore(svgImage, smallestRect)
|
||||||
await this.prepareElement(svgImage, [], false)
|
await this.prepareElement(svgImage, [], false)
|
||||||
|
@ -1052,11 +1051,6 @@ export class SvgToPdf {
|
||||||
constructor(title: string, pages: string[], options: SvgToPdfOptions) {
|
constructor(title: string, pages: string[], options: SvgToPdfOptions) {
|
||||||
this._title = title
|
this._title = title
|
||||||
options.textSubstitutions = options.textSubstitutions ?? {}
|
options.textSubstitutions = options.textSubstitutions ?? {}
|
||||||
options.textSubstitutions["mapCount"] =
|
|
||||||
"" +
|
|
||||||
Array.from(AllKnownLayouts.allKnownLayouts.values()).filter(
|
|
||||||
(th) => !th.hideFromOverview
|
|
||||||
).length
|
|
||||||
|
|
||||||
const state = new UIEventSource<string>("Initializing...")
|
const state = new UIEventSource<string>("Initializing...")
|
||||||
this.status = state
|
this.status = state
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue