@open-pioneer/map 1.4.0-dev.20260727093741 → 1.5.0-dev.20260910103330
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +547 -485
- package/LayerFactory.d.ts +1 -1
- package/LayerFactory.js.map +1 -1
- package/MapRegistry.js.map +1 -1
- package/README.md +5 -8
- package/layers/AbstractLayer.d.ts +41 -3
- package/layers/AbstractLayer.js +139 -81
- package/layers/AbstractLayer.js.map +1 -1
- package/layers/AbstractLayerBase.d.ts +2 -2
- package/layers/AbstractLayerBase.js.map +1 -1
- package/layers/GroupLayer.d.ts +2 -1
- package/layers/GroupLayer.js +4 -1
- package/layers/GroupLayer.js.map +1 -1
- package/layers/SimpleLayer.d.ts +1 -1
- package/layers/SimpleLayer.js +1 -1
- package/layers/SimpleLayer.js.map +1 -1
- package/layers/WMSLayer.js +58 -10
- package/layers/WMSLayer.js.map +1 -1
- package/layers/WMTSLayer.d.ts +1 -1
- package/layers/WMTSLayer.js +10 -4
- package/layers/WMTSLayer.js.map +1 -1
- package/layers/group/GroupLayerCollection.d.ts +2 -2
- package/layers/group/GroupLayerCollection.js +1 -1
- package/layers/group/GroupLayerCollection.js.map +1 -1
- package/layers/shared/AddLayerOptions.d.ts +3 -2
- package/layers/shared/LayerConfig.d.ts +2 -0
- package/layers/shared/SublayerBaseType.d.ts +9 -0
- package/layers/shared/SublayersCollection.js.map +1 -1
- package/layers/shared/getRecursiveLayers.d.ts +1 -1
- package/layers/shared/getRecursiveLayers.js +12 -5
- package/layers/shared/getRecursiveLayers.js.map +1 -1
- package/layers/shared/internals.d.ts +4 -2
- package/layers/shared/internals.js +3 -1
- package/layers/shared/internals.js.map +1 -1
- package/layers/unions.js.map +1 -1
- package/layers/wms/WMSSublayer.d.ts +14 -1
- package/layers/wms/WMSSublayer.js +29 -2
- package/layers/wms/WMSSublayer.js.map +1 -1
- package/layers/wms/getAttributions.js.map +1 -1
- package/layers/wms/getLegendUrl.js.map +1 -1
- package/layers/wmts/getAttributions.js.map +1 -1
- package/layers/wmts/getLegendUrl.js.map +1 -1
- package/model/Highlights.js.map +1 -1
- package/model/LayerCollection.js +38 -23
- package/model/LayerCollection.js.map +1 -1
- package/model/MapAttributions.js.map +1 -1
- package/model/MapConfig.d.ts +16 -0
- package/model/MapModel.d.ts +5 -5
- package/model/MapModel.js +4 -4
- package/model/MapModel.js.map +1 -1
- package/model/Overlays.d.ts +2 -2
- package/model/Overlays.js +2 -2
- package/model/Overlays.js.map +1 -1
- package/model/createMapModel.js +57 -2
- package/model/createMapModel.js.map +1 -1
- package/model/getGeometries.js.map +1 -1
- package/package.json +17 -13
- package/ui/DefaultMapProvider.js.map +1 -1
- package/ui/MapAnchor.js.map +1 -1
- package/ui/MapContainer.js +1 -1
- package/ui/MapContainer.js.map +1 -1
- package/ui/MapContainerContext.js.map +1 -1
- package/ui/OverlaysRenderer.js.map +1 -1
- package/ui/computeMapAnchorStyles.js.map +1 -1
- package/ui/hooks/useMapModel.js +2 -2
- package/ui/hooks/useMapModel.js.map +1 -1
- package/utils/fetch.js.map +1 -1
- package/utils/geometry-utils.js.map +1 -1
- package/utils/ol-test-support.js.map +1 -1
- package/utils/projections.js.map +1 -1
- package/utils/sanitize.js.map +1 -1
package/layers/WMTSLayer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WMTSLayer.js","sources":["WMTSLayer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { batch, reactive } from \"@conterra/reactivity-core\";\nimport { createLogger, deprecated, isAbortError } from \"@open-pioneer/core\";\nimport { ImageTile } from \"ol\";\nimport Tile from \"ol/Tile\";\nimport TileState from \"ol/TileState\";\nimport WMTSCapabilities from \"ol/format/WMTSCapabilities\";\nimport TileLayer from \"ol/layer/Tile\";\nimport type TileSourceType from \"ol/source/Tile\";\nimport WMTS, { optionsFromCapabilities, Options as WMTSSourceOptions } from \"ol/source/WMTS\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport type { LayerFactory } from \"../LayerFactory\";\nimport { MapModel } from \"../model/MapModel\";\nimport { InternalConstructorTag } from \"../utils/InternalConstructorTag\";\nimport { fetchText } from \"../utils/fetch\";\nimport { AbstractLayer } from \"./AbstractLayer\";\nimport { LayerConfig } from \"./shared/LayerConfig\";\nimport { ATTACH_TO_MAP, GET_DEPS, LayerConstructor, LayerDependencies } from \"./shared/internals\";\nimport { getAttributions } from \"./wmts/getAttributions\";\nimport { getLegendUrl } from \"./wmts/getLegendUrl\";\n\n/**\n * Configuration options supported by {@link WMTSLayer}.\n *\n * @group Layers\n */\nexport interface WMTSLayerConfig extends LayerConfig {\n /** URL of the WMTS service. */\n url: string;\n\n /** The name of the WMTS layer in the service's capabilities. */\n name: string;\n\n /** The name of the tile matrix set in the service's capabilities. */\n matrixSet: string;\n\n /**\n * Additional source options for the layer's WMTS source.\n *\n * NOTE: These options are intended for advanced configuration:\n * the WMTS Layer manages some of the OpenLayers source options itself.\n */\n sourceOptions?: Partial<WMTSSourceOptions>;\n}\n\nconst LOG = createLogger(sourceId);\n\nconst deprecatedConstructor = deprecated({\n name: \"WMTSLayer constructor\",\n packageName: \"@open-pioneer/map\",\n since: \"v1.0.0\",\n alternative: \"use LayerFactory.create() instead\"\n});\n\n/**\n * Displays an OGC Web Map Tile Service (WMTS).\n *\n * @group Layers\n */\nexport class WMTSLayer extends AbstractLayer {\n #url: string;\n #name: string;\n #matrixSet: string;\n #layer: TileLayer<TileSourceType>;\n #sourceOptions: Partial<WMTSSourceOptions>;\n #olSource = reactive<WMTS>();\n #legend = reactive<string | undefined>();\n\n #loadStarted = false;\n\n readonly #abortController = new AbortController();\n\n /**\n * @deprecated Prefer using {@link LayerFactory.create} instead of calling the constructor directly\n */\n constructor(config: WMTSLayerConfig);\n\n /**\n * NOTE: Do not use this overload. Use {@link LayerFactory.create} instead.\n *\n * @internal\n */\n constructor(\n config: WMTSLayerConfig,\n deps: LayerDependencies,\n internalTag: InternalConstructorTag\n );\n\n constructor(\n config: WMTSLayerConfig,\n deps?: LayerDependencies,\n internalTag?: InternalConstructorTag\n ) {\n if (!internalTag) {\n deprecatedConstructor();\n }\n\n const layer = new TileLayer();\n super(\n {\n ...config,\n olLayer: layer\n },\n deps,\n internalTag\n );\n this.#url = config.url;\n this.#name = config.name;\n this.#layer = layer;\n this.#matrixSet = config.matrixSet;\n this.#sourceOptions = config.sourceOptions ?? {};\n }\n\n destroy(): void {\n this.#abortController.abort();\n super.destroy();\n }\n\n get type() {\n return \"wmts\" as const;\n }\n\n /**\n * Returns the current source associated with this layer as a reactive property.\n *\n * Note that the return type may be expanded in the future with additional source types.\n */\n get olSource(): WMTS | undefined {\n return this.#olSource.value;\n }\n\n /** URL of the WMTS service. */\n override get legend(): string | undefined {\n return this.#legend.value;\n }\n\n override get sublayers(): undefined {\n return undefined;\n }\n\n override get layers(): undefined {\n return undefined;\n }\n\n get url() {\n return this.#url;\n }\n\n /** The name of the WMTS layer in the service's capabilities. */\n get name() {\n return this.#name;\n }\n\n /** The name of the tile matrix set in the service's capabilities. */\n get matrixSet() {\n return this.#matrixSet;\n }\n\n override [ATTACH_TO_MAP](map: MapModel): void {\n super[ATTACH_TO_MAP](map);\n this.#load();\n }\n\n #load() {\n if (this.#loadStarted) {\n return;\n }\n this.#loadStarted = true;\n this.#fetchWMTSCapabilities()\n .then((result: string) => {\n batch(() => {\n this.#initializeWithMetadata(result);\n });\n })\n .catch((error) => {\n if (isAbortError(error)) {\n LOG.debug(`Layer '${this.name}' has been destroyed before fetching the data`);\n return;\n }\n LOG.error(`Failed to initialize WMTS layer '${this.name}'`, error);\n //TODO: how to set the load state to error?\n });\n }\n\n async #fetchWMTSCapabilities(): Promise<string> {\n const httpService = this[GET_DEPS]().httpService;\n return fetchText(this.#url, httpService, this.#abortController.signal);\n }\n\n #initializeWithMetadata(metadata: string) {\n const parser = new WMTSCapabilities();\n const capabilities = parser.read(metadata);\n const options = optionsFromCapabilities(capabilities, {\n layer: this.#name,\n matrixSet: this.#matrixSet\n });\n if (!options) {\n throw new Error(`Layer '${this.#name}' was not found in capabilities`);\n }\n if (options.matrixSet !== this.#matrixSet) {\n throw new Error(`Tile matrix set '${this.#matrixSet}' was not found in capabilities`);\n }\n\n const { attributions: explicitAttributions, ...sourceOptions } = this.#sourceOptions;\n if (sourceOptions.style && sourceOptions.style !== options.style) {\n const styleToUse = this.#existsStyleInCapabilities(capabilities, sourceOptions.style);\n if (!styleToUse) {\n throw new Error(`Style '${sourceOptions.style}' was not found in capabilities`);\n }\n }\n\n const attributions = explicitAttributions ?? getAttributions(capabilities);\n const source = (this.#olSource.value = new WMTS({\n ...options,\n attributions,\n ...sourceOptions,\n tileLoadFunction: (tile, tileUrl) => {\n this.#loadTile(tile, tileUrl);\n }\n }));\n this.#layer.setSource(source);\n\n const activeStyleId = source.getStyle();\n const legendUrl = getLegendUrl(capabilities, this.name, activeStyleId);\n this.#legend.value = legendUrl;\n }\n\n async #loadTile(tile: Tile, tileUrl: string): Promise<void> {\n const httpService = this[GET_DEPS]().httpService;\n try {\n if (!(tile instanceof ImageTile)) {\n throw new Error(\"Only 'ImageTile' is supported for now.\");\n }\n\n const image = tile.getImage();\n if (!isHtmlImage(image)) {\n // Could also be canvas or video\n throw new Error(\"Only <img> tags are supported as tiles for now.\");\n }\n\n const response = await httpService.fetch(tileUrl);\n if (!response.ok) {\n throw new Error(`Tile request failed with status ${response.status}.`);\n }\n\n const blob = await response.blob();\n const objectUrl = URL.createObjectURL(blob);\n const finish = () => {\n // Cleanup object URL after load to prevent memory leaks.\n // https://stackoverflow.com/questions/62473876/openlayers-6-settileloadfunction-documented-example-uses-url-createobjecturld\n URL.revokeObjectURL(objectUrl);\n image.removeEventListener(\"load\", finish);\n image.removeEventListener(\"error\", finish);\n };\n image.addEventListener(\"load\", finish);\n image.addEventListener(\"error\", finish);\n image.src = objectUrl;\n } catch (e) {\n tile.setState(TileState.ERROR);\n if (!isAbortError(e)) {\n LOG.error(\"Failed to load tile\", e);\n }\n }\n }\n\n /* eslint-disable @typescript-eslint/no-explicit-any */\n #existsStyleInCapabilities(capabilities: any, styleToUse: string): boolean {\n // NOTE: we have a style override, check if the style exists in the capabilities\n // the helper optionsFromCapabilities, supports style, too, but uses the Title instead of the Identifier, to find a match in the capabilities\n const layerDesc = capabilities.Contents?.Layer?.find(\n (layer: any) => layer.Identifier === this.#name\n );\n return layerDesc?.Style?.some((style: any) => style.Identifier === styleToUse) ?? false;\n }\n /* eslint-enable @typescript-eslint/no-explicit-any */\n}\n\n// Ensure layer class is assignable to the constructor interface (there is no \"implements\" for the class itself).\n// eslint-disable-next-line no-constant-condition\nif (false) {\n const check: LayerConstructor<WMTSLayerConfig, WMTSLayer> = WMTSLayer;\n void check;\n}\n\nfunction isHtmlImage(htmlElement: HTMLElement | OffscreenCanvas): htmlElement is HTMLImageElement {\n return \"tagName\" in htmlElement && htmlElement.tagName === \"IMG\";\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AA8CA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAEjC,MAAM,wBAAwB,UAAA,CAAW;AAAA,EACrC,IAAA,EAAM,uBAAA;AAAA,EACN,WAAA,EAAa,mBAAA;AAAA,EACb,KAAA,EAAO,QAAA;AAAA,EACP,WAAA,EAAa;AACjB,CAAC,CAAA;AAOM,MAAM,kBAAkB,aAAA,CAAc;AAAA,EACzC,IAAA;AAAA,EACA,KAAA;AAAA,EACA,UAAA;AAAA,EACA,MAAA;AAAA,EACA,cAAA;AAAA,EACA,YAAY,QAAA,EAAe;AAAA,EAC3B,UAAU,QAAA,EAA6B;AAAA,EAEvC,YAAA,GAAe,KAAA;AAAA,EAEN,gBAAA,GAAmB,IAAI,eAAA,EAAgB;AAAA,EAkBhD,WAAA,CACI,MAAA,EACA,IAAA,EACA,WAAA,EACF;AACE,IAAA,IAAI,CAAC,WAAA,EAAa;AAC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,CAAA;AACrC,MAAA,KAAA,CAAM,gBAAA,CAAiB,SAAS,MAAM,CAAA;AACtC,MAAA,KAAA,CAAM,GAAA,GAAM,SAAA;AAAA,IAChB,SAAS,CAAA,EAAG;AACR,MAAA,IAAA,CAAK,QAAA,CAAS,UAAU,KAAK,CAAA;AAC7B,MAAA,IAAI,CAAC,YAAA,CAAa,CAAC,CAAA,EAAG;AAClB,QAAA,GAAA,CAAI,KAAA,CAAM,uBAAuB,CAAC,CAAA;AAAA,MACtC;AAAA,IACJ;AAAA,EACJ;AAAA;AAAA,EAGA,0BAAA,CAA2B,cAAmB,UAAA,EAA6B;AAGvE,IAAA,MAAM,SAAA,GAAY,YAAA,CAAa,QAAA,EAAU,KAAA,EAAO,IAAA;AAAA,MAC5C,CAAC,KAAA,KAAe,KAAA,CAAM,UAAA,KAAe,IAAA,CAAK;AAAA,KAC9C;AACA,IAAA,OAAO,SAAA,EAAW,OAAO,IAAA,CAAK,CAAC,UAAe,KAAA,CAAM,UAAA,KAAe,UAAU,CAAA,IAAK,KAAA;AAAA,EACtF;AAAA;AAEJ;AASA,SAAS,YAAY,WAAA,EAA6E;AAC9F,EAAA,OAAO,SAAA,IAAa,WAAA,IAAe,WAAA,CAAY,OAAA,KAAY,KAAA;AAC/D;;;;"}
|
|
1
|
+
{"version":3,"file":"WMTSLayer.js","sources":["WMTSLayer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { batch, reactive } from \"@conterra/reactivity-core\";\nimport { createLogger, deprecated, isAbortError } from \"@open-pioneer/core\";\nimport { ImageTile } from \"ol\";\nimport WMTSCapabilities from \"ol/format/WMTSCapabilities\";\nimport TileLayer from \"ol/layer/Tile\";\nimport type TileSourceType from \"ol/source/Tile\";\nimport WMTS, { optionsFromCapabilities, Options as WMTSSourceOptions } from \"ol/source/WMTS\";\nimport Tile from \"ol/Tile\";\nimport TileState from \"ol/TileState\";\nimport { sourceId } from \"open-pioneer:source-info\";\n// oxlint-disable-next-line @typescript-eslint/no-unused-vars\nimport type { LayerFactory } from \"../LayerFactory\";\nimport { MapModel } from \"../model/MapModel\";\nimport { fetchText } from \"../utils/fetch\";\nimport { InternalConstructorTag } from \"../utils/InternalConstructorTag\";\nimport { AbstractLayer } from \"./AbstractLayer\";\nimport {\n ATTACH_TO_MAP,\n GET_DEPS,\n LayerConstructor,\n LayerDependencies,\n SET_METADATA_LOAD_INFO\n} from \"./shared/internals\";\nimport { LayerConfig } from \"./shared/LayerConfig\";\nimport { getAttributions } from \"./wmts/getAttributions\";\nimport { getLegendUrl } from \"./wmts/getLegendUrl\";\n\n/**\n * Configuration options supported by {@link WMTSLayer}.\n *\n * @group Layers\n */\nexport interface WMTSLayerConfig extends LayerConfig {\n /** URL of the WMTS service. */\n url: string;\n\n /** The name of the WMTS layer in the service's capabilities. */\n name: string;\n\n /** The name of the tile matrix set in the service's capabilities. */\n matrixSet: string;\n\n /**\n * Additional source options for the layer's WMTS source.\n *\n * NOTE: These options are intended for advanced configuration:\n * the WMTS Layer manages some of the OpenLayers source options itself.\n */\n sourceOptions?: Partial<WMTSSourceOptions>;\n}\n\nconst LOG = createLogger(sourceId);\n\nconst deprecatedConstructor = deprecated({\n name: \"WMTSLayer constructor\",\n packageName: \"@open-pioneer/map\",\n since: \"v1.0.0\",\n alternative: \"use LayerFactory.create() instead\"\n});\n\n/**\n * Displays an OGC Web Map Tile Service (WMTS).\n *\n * @group Layers\n */\nexport class WMTSLayer extends AbstractLayer {\n #url: string;\n #name: string;\n #matrixSet: string;\n #layer: TileLayer<TileSourceType>;\n #sourceOptions: Partial<WMTSSourceOptions>;\n #olSource = reactive<WMTS>();\n #legend = reactive<string | undefined>();\n\n #loadStarted = false;\n\n readonly #abortController = new AbortController();\n\n /**\n * @deprecated Prefer using {@link LayerFactory.create} instead of calling the constructor directly\n */\n constructor(config: WMTSLayerConfig);\n\n /**\n * NOTE: Do not use this overload. Use {@link LayerFactory.create} instead.\n *\n * @internal\n */\n constructor(\n config: WMTSLayerConfig,\n deps: LayerDependencies,\n internalTag: InternalConstructorTag\n );\n\n constructor(\n config: WMTSLayerConfig,\n deps?: LayerDependencies,\n internalTag?: InternalConstructorTag\n ) {\n if (!internalTag) {\n deprecatedConstructor();\n }\n\n const layer = new TileLayer();\n super(\n {\n ...config,\n olLayer: layer\n },\n deps,\n internalTag\n );\n this.#url = config.url;\n this.#name = config.name;\n this.#layer = layer;\n this.#matrixSet = config.matrixSet;\n this.#sourceOptions = config.sourceOptions ?? {};\n }\n\n destroy(): void {\n this.#abortController.abort();\n super.destroy();\n }\n\n get type() {\n return \"wmts\" as const;\n }\n\n /**\n * Returns the current source associated with this layer as a reactive property.\n *\n * Note that the return type may be expanded in the future with additional source types.\n */\n get olSource(): WMTS | undefined {\n return this.#olSource.value;\n }\n\n /** URL of the WMTS service. */\n override get legend(): string | undefined {\n return this.#legend.value;\n }\n\n override get sublayers(): undefined {\n return undefined;\n }\n\n override get layers(): undefined {\n return undefined;\n }\n\n get url() {\n return this.#url;\n }\n\n /** The name of the WMTS layer in the service's capabilities. */\n get name() {\n return this.#name;\n }\n\n /** The name of the tile matrix set in the service's capabilities. */\n get matrixSet() {\n return this.#matrixSet;\n }\n\n override [ATTACH_TO_MAP](map: MapModel): void {\n super[ATTACH_TO_MAP](map);\n this.#load();\n }\n\n #load() {\n if (this.#loadStarted) {\n return;\n }\n this.#loadStarted = true;\n this[SET_METADATA_LOAD_INFO](\"loading\");\n this.#fetchWMTSCapabilities()\n .then((result: string) => {\n batch(() => {\n this.#initializeWithMetadata(result);\n this[SET_METADATA_LOAD_INFO](\"loaded\");\n });\n })\n .catch((error: unknown) => {\n if (isAbortError(error)) {\n LOG.debug(`Layer '${this.name}' has been destroyed before fetching the data`);\n }\n LOG.error(`Failed to initialize WMTS layer '${this.name}'`, error);\n const wrappedError =\n error instanceof Error\n ? error\n : new Error(`Failed to initialize WMTS layer '${this.name}'`);\n this[SET_METADATA_LOAD_INFO]({\n kind: \"error\",\n error: wrappedError\n });\n });\n }\n\n async #fetchWMTSCapabilities(): Promise<string> {\n const httpService = this[GET_DEPS]().httpService;\n return fetchText(this.#url, httpService, this.#abortController.signal);\n }\n\n #initializeWithMetadata(metadata: string) {\n const parser = new WMTSCapabilities();\n const capabilities = parser.read(metadata);\n const options = optionsFromCapabilities(capabilities, {\n layer: this.#name,\n matrixSet: this.#matrixSet\n });\n if (!options) {\n throw new Error(`Layer '${this.#name}' was not found in capabilities`);\n }\n if (options.matrixSet !== this.#matrixSet) {\n throw new Error(`Tile matrix set '${this.#matrixSet}' was not found in capabilities`);\n }\n\n const { attributions: explicitAttributions, ...sourceOptions } = this.#sourceOptions;\n if (sourceOptions.style && sourceOptions.style !== options.style) {\n const styleToUse = this.#existsStyleInCapabilities(capabilities, sourceOptions.style);\n if (!styleToUse) {\n throw new Error(`Style '${sourceOptions.style}' was not found in capabilities`);\n }\n }\n\n const attributions = explicitAttributions ?? getAttributions(capabilities);\n const source = (this.#olSource.value = new WMTS({\n ...options,\n attributions,\n ...sourceOptions,\n tileLoadFunction: (tile, tileUrl) => {\n this.#loadTile(tile, tileUrl);\n }\n }));\n this.#layer.setSource(source);\n\n const activeStyleId = source.getStyle();\n const legendUrl = getLegendUrl(capabilities, this.name, activeStyleId);\n this.#legend.value = legendUrl;\n }\n\n async #loadTile(tile: Tile, tileUrl: string): Promise<void> {\n const httpService = this[GET_DEPS]().httpService;\n try {\n if (!(tile instanceof ImageTile)) {\n throw new Error(\"Only 'ImageTile' is supported for now.\");\n }\n\n const image = tile.getImage();\n if (!isHtmlImage(image)) {\n // Could also be canvas or video\n throw new Error(\"Only <img> tags are supported as tiles for now.\");\n }\n\n const response = await httpService.fetch(tileUrl);\n if (!response.ok) {\n throw new Error(`Tile request failed with status ${response.status}.`);\n }\n\n const blob = await response.blob();\n const objectUrl = URL.createObjectURL(blob);\n const finish = () => {\n // Cleanup object URL after load to prevent memory leaks.\n // https://stackoverflow.com/questions/62473876/openlayers-6-settileloadfunction-documented-example-uses-url-createobjecturld\n URL.revokeObjectURL(objectUrl);\n image.removeEventListener(\"load\", finish);\n image.removeEventListener(\"error\", finish);\n };\n image.addEventListener(\"load\", finish);\n image.addEventListener(\"error\", finish);\n image.src = objectUrl;\n } catch (e) {\n tile.setState(TileState.ERROR);\n if (!isAbortError(e)) {\n LOG.error(\"Failed to load tile\", e);\n }\n }\n }\n\n /* oxlint-disable @typescript-eslint/no-explicit-any */\n #existsStyleInCapabilities(capabilities: any, styleToUse: string): boolean {\n // NOTE: we have a style override, check if the style exists in the capabilities\n // the helper optionsFromCapabilities, supports style, too, but uses the Title instead of the Identifier, to find a match in the capabilities\n const layerDesc = capabilities.Contents?.Layer?.find(\n (layer: any) => layer.Identifier === this.#name\n );\n return layerDesc?.Style?.some((style: any) => style.Identifier === styleToUse) ?? false;\n }\n /* eslint-enable @typescript-eslint/no-explicit-any */\n}\n\n// Ensure layer class is assignable to the constructor interface (there is no \"implements\" for the class itself).\n// oxlint-disable-next-line no-constant-condition\nif (false) {\n const check: LayerConstructor<WMTSLayerConfig, WMTSLayer> = WMTSLayer;\n void check;\n}\n\nfunction isHtmlImage(htmlElement: HTMLElement | OffscreenCanvas): htmlElement is HTMLImageElement {\n return \"tagName\" in htmlElement && htmlElement.tagName === \"IMG\";\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAsDA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAEjC,MAAM,wBAAwB,UAAA,CAAW;AAAA,EACrC,IAAA,EAAM,uBAAA;AAAA,EACN,WAAA,EAAa,mBAAA;AAAA,EACb,KAAA,EAAO,QAAA;AAAA,EACP,WAAA,EAAa;AACjB,CAAC,CAAA;AAOM,MAAM,kBAAkB,aAAA,CAAc;AAAA,EACzC,IAAA;AAAA,EACA,KAAA;AAAA,EACA,UAAA;AAAA,EACA,MAAA;AAAA,EACA,cAAA;AAAA,EACA,YAAY,QAAA,EAAe;AAAA,EAC3B,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A,EAA6E;AAC9F,EAAA,OAAO,SAAA,IAAa,WAAA,IAAe,WAAA,CAAY,OAAA,KAAY,KAAA;AAC/D;;;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InternalConstructorTag } from "../../utils/InternalConstructorTag";
|
|
2
2
|
import { GroupLayer } from "../GroupLayer";
|
|
3
3
|
import { ChildrenCollection } from "../shared/ChildrenCollection";
|
|
4
4
|
import { GET_PARENT, GET_RAW_LAYERS } from "../shared/internals";
|
|
5
|
-
import {
|
|
5
|
+
import { LayerRetrievalOptions, RecursiveRetrievalOptions } from "../shared/LayerRetrievalOptions";
|
|
6
6
|
import { AnyLayer, Layer } from "../unions";
|
|
7
7
|
/**
|
|
8
8
|
* Contains {@link Layer} instances that belong to a {@link GroupLayer}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { assertInternalConstructor } from '../../utils/InternalConstructorTag.js';
|
|
1
2
|
import { getRecursiveLayers } from '../shared/getRecursiveLayers.js';
|
|
2
3
|
import { ATTACH_TO_GROUP, DETACH_FROM_GROUP, GET_RAW_LAYERS, GET_PARENT } from '../shared/internals.js';
|
|
3
|
-
import { assertInternalConstructor } from '../../utils/InternalConstructorTag.js';
|
|
4
4
|
|
|
5
5
|
class GroupLayerCollection {
|
|
6
6
|
#layers;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupLayerCollection.js","sources":["GroupLayerCollection.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport {
|
|
1
|
+
{"version":3,"file":"GroupLayerCollection.js","sources":["GroupLayerCollection.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n assertInternalConstructor,\n InternalConstructorTag\n} from \"../../utils/InternalConstructorTag\";\nimport { AbstractLayer } from \"../AbstractLayer\";\nimport { GroupLayer } from \"../GroupLayer\";\nimport { ChildrenCollection } from \"../shared/ChildrenCollection\";\nimport { getRecursiveLayers } from \"../shared/getRecursiveLayers\";\nimport {\n ATTACH_TO_GROUP,\n DETACH_FROM_GROUP,\n GET_PARENT,\n GET_RAW_LAYERS\n} from \"../shared/internals\";\nimport { LayerRetrievalOptions, RecursiveRetrievalOptions } from \"../shared/LayerRetrievalOptions\";\nimport { AnyLayer, Layer } from \"../unions\";\n\n/**\n * Contains {@link Layer} instances that belong to a {@link GroupLayer}\n *\n * @group Layer Utilities\n */\n// NOTE: adding / removing currently not supported.\n// When adding support for dynamic content, make sure to also updating the layer indexing logic in the map (LayerCollectionImpl).\n// Nested children of a group layer must also be found in id-lookups.\nexport class GroupLayerCollection implements ChildrenCollection<Layer> {\n #layers: Layer[];\n #parent: GroupLayer;\n\n /** @internal */\n constructor(layers: Layer[], parent: GroupLayer, tag: InternalConstructorTag) {\n assertInternalConstructor(tag);\n layers = layers.slice(); // Don't modify the input\n for (const layer of layers) {\n if (layer.isBaseLayer) {\n throw new Error(\n `Layer '${layer.id}' of group '${parent.id}' is marked as base layer. Layers that belong to a group layer cannot be a base layer.`\n );\n }\n layer[ATTACH_TO_GROUP](parent); //attach every layer to the parent group layer\n }\n this.#layers = layers as (Layer & AbstractLayer)[];\n this.#parent = parent;\n }\n\n /**\n * Destroys this collection, all contained layers are detached from their parent group layer\n */\n destroy() {\n for (const layer of this.#layers) {\n layer[DETACH_FROM_GROUP]();\n layer.destroy();\n }\n this.#layers = [];\n }\n\n // Generic method name for consistent interface\n getItems(options?: LayerRetrievalOptions): Layer[] {\n return this.getLayers(options);\n }\n\n /**\n * Returns all layers in this collection\n */\n getLayers(options?: LayerRetrievalOptions | undefined): Layer[] {\n // NOTE: sort options are ignored because layers are always ordered at this time.\n let allLayers = this.#layers.slice();\n\n if (!options?.includeInternalLayers) {\n allLayers = allLayers.filter((l) => !l.internal);\n }\n\n return allLayers;\n }\n\n /**\n * Returns a list of all layers in the collection, including all children (recursively).\n *\n * > Note: This includes base layers by default (see `options.filter`).\n * > Use the `\"base\"` or `\"operational\"` short hand values to filter by base layer or operational layers.\n * >\n * > If the group contains many, deeply nested sub groups, this function could potentially be expensive.\n */\n getRecursiveLayers(options?: RecursiveRetrievalOptions): AnyLayer[] {\n return getRecursiveLayers({\n from: this,\n sortByDisplayOrder: options?.sortByDisplayOrder,\n includeInternalLayers: options?.includeInternalLayers,\n filter: options?.filter\n });\n }\n\n /**\n * Returns a reference to the internal group layer array.\n *\n * NOTE: Do not modify directly!\n *\n * @internal\n */\n [GET_RAW_LAYERS](): Layer[] {\n return this.#layers;\n }\n\n /**\n * Returns the parent group layer that owns this collection.\n *\n * @internal\n */\n [GET_PARENT](): GroupLayer {\n return this.#parent;\n }\n}\n"],"names":[],"mappings":";;;;AA4BO,MAAM,oBAAA,CAA0D;AAAA,EACnE,OAAA;AAAA,EACA,OAAA;AAAA;AAAA,EAGA,WAAA,CAAY,MAAA,EAAiB,MAAA,EAAoB,GAAA,EAA6B;AAC1E,IAAA,yBAAA,CAA0B,GAAG,CAAA;AAC7B,IAAA,MAAA,GAAS,OAAO,KAAA,EAAM;AACtB,IAAA,KAAA,MAAW,SAAS,MAAA,EAAQ;AACxB,MAAA,IAAI,MAAM,WAAA,EAAa;AACnB,QAAA,MAAM,IAAI,KAAA;AAAA,UACN,CAAA,OAAA,EAAU,KAAA,CAAM,EAAE,CAAA,YAAA,EAAe,OAAO,EAAE,CAAA,sFAAA;AAAA,SAC9C;AAAA,MACJ;AACA,MAAA,KAAA,CAAM,eAAe,EAAE,MAAM,CAAA;AAAA,IACjC;AACA,IAAA,IAAA,CAAK,OAAA,GAAU,MAAA;AACf,IAAA,IAAA,CAAK,OAAA,GAAU,MAAA;AAAA,EACnB;AAAA;AAAA;AAAA;AAAA,EAKA,OAAA,GAAU;AACN,IAAA,KAAA,MAAW,KAAA,IAAS,KAAK,OAAA,EAAS;AAC9B,MAAA,KAAA,CAAM,iBAAiB,CAAA,EAAE;AACzB,MAAA,KAAA,CAAM,OAAA,EAAQ;AAAA,IAClB;AACA,IAAA,IAAA,CAAK,UAAU,EAAC;AAAA,EACpB;AAAA;AAAA,EAGA,SAAS,OAAA,EAA0C;AAC/C,IAAA,OAAO,IAAA,CAAK,UAAU,OAAO,CAAA;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA,EAKA,UAAU,OAAA,EAAsD;AAE5D,IAAA,IAAI,SAAA,GAAY,IAAA,CAAK,OAAA,CAAQ,KAAA,EAAM;AAEnC,IAAA,IAAI,CAAC,SAAS,qBAAA,EAAuB;AACjC,MAAA,SAAA,GAAY,UAAU,MAAA,CAAO,CAAC,CAAA,KAAM,CAAC,EAAE,QAAQ,CAAA;AAAA,IACnD;AAEA,IAAA,OAAO,SAAA;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,mBAAmB,OAAA,EAAiD;AAChE,IAAA,OAAO,kBAAA,CAAmB;AAAA,MACtB,IAAA,EAAM,IAAA;AAAA,MACN,oBAAoB,OAAA,EAAS,kBAAA;AAAA,MAC7B,uBAAuB,OAAA,EAAS,qBAAA;AAAA,MAChC,QAAQ,OAAA,EAAS;AAAA,KACpB,CAAA;AAAA,EACL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,CAAC,cAAc,CAAA,GAAa;AACxB,IAAA,OAAO,IAAA,CAAK,OAAA;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,CAAC,UAAU,CAAA,GAAgB;AACvB,IAAA,OAAO,IAAA,CAAK,OAAA;AAAA,EAChB;AACJ;;;;"}
|
|
@@ -19,14 +19,15 @@ export interface AddLayerOptionsBase {
|
|
|
19
19
|
* - "above": Insert the new layer _above_ the specified `reference` layer.
|
|
20
20
|
* - "below": Insert the new layer _below_ the specified `reference` layer.
|
|
21
21
|
* - "topmost": Insert a new layer that is always displayed on top of all layers that were added at `top` (e.g. a highlight layer).
|
|
22
|
+
* - "base": Insert a new layer as a base layer.
|
|
22
23
|
*/
|
|
23
|
-
at: "top" | "bottom" | "above" | "below" | "topmost";
|
|
24
|
+
at: "top" | "bottom" | "above" | "below" | "topmost" | "base";
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
26
27
|
* @group Layer Utilities
|
|
27
28
|
*/
|
|
28
29
|
export interface AddLayerOptionsTopBottom extends AddLayerOptionsBase {
|
|
29
|
-
at: "top" | "bottom" | "topmost";
|
|
30
|
+
at: "top" | "bottom" | "topmost" | "base";
|
|
30
31
|
}
|
|
31
32
|
/**
|
|
32
33
|
* @group Layer Utilities
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LayerLoadState } from "../AbstractLayer";
|
|
1
2
|
import { AbstractLayerBase } from "../AbstractLayerBase";
|
|
2
3
|
import { AnyLayer, Layer, SublayerTypes } from "../unions";
|
|
3
4
|
/**
|
|
@@ -19,4 +20,12 @@ export interface SublayerBaseType extends AbstractLayerBase {
|
|
|
19
20
|
* The parent layer that owns this sublayer.
|
|
20
21
|
*/
|
|
21
22
|
readonly parentLayer: Layer;
|
|
23
|
+
/**
|
|
24
|
+
* The load state of this sublayer (independent of its parent layer).
|
|
25
|
+
*/
|
|
26
|
+
readonly loadState: LayerLoadState;
|
|
27
|
+
/**
|
|
28
|
+
* The error associated with this sublayer, if any.
|
|
29
|
+
*/
|
|
30
|
+
readonly loadError: Error | undefined;
|
|
22
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SublayersCollection.js","sources":["SublayersCollection.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport {\n assertInternalConstructor,\n InternalConstructorTag\n} from \"../../utils/InternalConstructorTag\";\nimport { Sublayer } from \"../unions\";\nimport { ChildrenCollection } from \"./ChildrenCollection\";\nimport { getRecursiveLayers } from \"./getRecursiveLayers\";\nimport { GET_RAW_SUBLAYERS } from \"./internals\";\nimport { LayerRetrievalOptions, RecursiveRetrievalOptions } from \"./LayerRetrievalOptions\";\nimport { SublayerBaseType } from \"./SublayerBaseType\";\n\n/**\n * Contains the sublayers that belong to a {@link Layer} or {@link Sublayer}.\n *\n * @group Layer Utilities\n */\n// NOTE: adding / removing sublayers currently not supported\nexport class SublayersCollection<\n SublayerType extends SublayerBaseType\n> implements ChildrenCollection<SublayerType> {\n #sublayers: SublayerType[];\n\n /** @internal */\n constructor(sublayers: SublayerType[], tag: InternalConstructorTag) {\n assertInternalConstructor(tag);\n this.#sublayers = sublayers;\n }\n\n destroy() {\n for (const layer of this.#sublayers) {\n layer.destroy();\n }\n this.#sublayers = [];\n }\n\n // Generic method name for consistent interface\n getItems(options?: LayerRetrievalOptions): SublayerType[] {\n return this.getSublayers(options);\n }\n\n /**\n * Returns the child sublayers in this collection.\n */\n getSublayers(options?: LayerRetrievalOptions | undefined): SublayerType[] {\n // NOTE: sort options are ignored because layers are always ordered at this time.\n let allLayers = this.#sublayers.slice();\n\n if (!options?.includeInternalLayers) {\n allLayers = allLayers.filter((l) => !l.internal);\n }\n\n return allLayers;\n }\n\n /**\n * Returns a list of all layers in the collection, including all children (recursively).\n *\n * > Note: This includes base layers by default (see `options.filter`).\n * > Use the `\"base\"` or `\"operational\"` short hand values to filter by base layer or operational layers.\n * >\n * > If the collection contains many, deeply nested sublayers, this function could potentially be expensive.\n */\n getRecursiveLayers(options?: RecursiveRetrievalOptions): Sublayer[] {\n return getRecursiveLayers({\n // NOTE: This is safe (but not elegant) because this class does not know about the entire type hierarchy (unions).\n // _Might_ be possible to refactor this class to use the Sublayer union instead in the generic type parameters,\n // but then we might also introduce a cycle in the type definitions, which could be bad (?).\n from: this as unknown as SublayersCollection<Sublayer>,\n sortByDisplayOrder: options?.sortByDisplayOrder,\n includeInternalLayers: options?.includeInternalLayers,\n filter: options?.filter\n }) as Sublayer[]; // we know for sure that all children are sublayers: sublayers do not point to layers\n }\n\n /**\n * Returns a reference to the internal sublayers array.\n *\n * NOTE: Do not modify directly!\n *\n * @internal\n */\n [GET_RAW_SUBLAYERS](): SublayerType[] {\n return this.#sublayers;\n }\n}\n"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"SublayersCollection.js","sources":["SublayersCollection.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n assertInternalConstructor,\n InternalConstructorTag\n} from \"../../utils/InternalConstructorTag\";\nimport { Sublayer } from \"../unions\";\nimport { ChildrenCollection } from \"./ChildrenCollection\";\nimport { getRecursiveLayers } from \"./getRecursiveLayers\";\nimport { GET_RAW_SUBLAYERS } from \"./internals\";\nimport { LayerRetrievalOptions, RecursiveRetrievalOptions } from \"./LayerRetrievalOptions\";\nimport { SublayerBaseType } from \"./SublayerBaseType\";\n\n/**\n * Contains the sublayers that belong to a {@link Layer} or {@link Sublayer}.\n *\n * @group Layer Utilities\n */\n// NOTE: adding / removing sublayers currently not supported\nexport class SublayersCollection<\n SublayerType extends SublayerBaseType\n> implements ChildrenCollection<SublayerType> {\n #sublayers: SublayerType[];\n\n /** @internal */\n constructor(sublayers: SublayerType[], tag: InternalConstructorTag) {\n assertInternalConstructor(tag);\n this.#sublayers = sublayers;\n }\n\n destroy() {\n for (const layer of this.#sublayers) {\n layer.destroy();\n }\n this.#sublayers = [];\n }\n\n // Generic method name for consistent interface\n getItems(options?: LayerRetrievalOptions): SublayerType[] {\n return this.getSublayers(options);\n }\n\n /**\n * Returns the child sublayers in this collection.\n */\n getSublayers(options?: LayerRetrievalOptions | undefined): SublayerType[] {\n // NOTE: sort options are ignored because layers are always ordered at this time.\n let allLayers = this.#sublayers.slice();\n\n if (!options?.includeInternalLayers) {\n allLayers = allLayers.filter((l) => !l.internal);\n }\n\n return allLayers;\n }\n\n /**\n * Returns a list of all layers in the collection, including all children (recursively).\n *\n * > Note: This includes base layers by default (see `options.filter`).\n * > Use the `\"base\"` or `\"operational\"` short hand values to filter by base layer or operational layers.\n * >\n * > If the collection contains many, deeply nested sublayers, this function could potentially be expensive.\n */\n getRecursiveLayers(options?: RecursiveRetrievalOptions): Sublayer[] {\n return getRecursiveLayers({\n // NOTE: This is safe (but not elegant) because this class does not know about the entire type hierarchy (unions).\n // _Might_ be possible to refactor this class to use the Sublayer union instead in the generic type parameters,\n // but then we might also introduce a cycle in the type definitions, which could be bad (?).\n from: this as unknown as SublayersCollection<Sublayer>,\n sortByDisplayOrder: options?.sortByDisplayOrder,\n includeInternalLayers: options?.includeInternalLayers,\n filter: options?.filter\n }) as Sublayer[]; // we know for sure that all children are sublayers: sublayers do not point to layers\n }\n\n /**\n * Returns a reference to the internal sublayers array.\n *\n * NOTE: Do not modify directly!\n *\n * @internal\n */\n [GET_RAW_SUBLAYERS](): SublayerType[] {\n return this.#sublayers;\n }\n}\n"],"names":[],"mappings":";;;;AAoBO,MAAM,mBAAA,CAEiC;AAAA,EAC1C,UAAA;AAAA;AAAA,EAGA,WAAA,CAAY,WAA2B,GAAA,EAA6B;AAChE,IAAA,yBAAA,CAA0B,GAAG,CAAA;AAC7B,IAAA,IAAA,CAAK,UAAA,GAAa,SAAA;AAAA,EACtB;AAAA,EAEA,OAAA,GAAU;AACN,IAAA,KAAA,MAAW,KAAA,IAAS,KAAK,UAAA,EAAY;AACjC,MAAA,KAAA,CAAM,OAAA,EAAQ;AAAA,IAClB;AACA,IAAA,IAAA,CAAK,aAAa,EAAC;AAAA,EACvB;AAAA;AAAA,EAGA,SAAS,OAAA,EAAiD;AACtD,IAAA,OAAO,IAAA,CAAK,aAAa,OAAO,CAAA;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA,EAKA,aAAa,OAAA,EAA6D;AAEtE,IAAA,IAAI,SAAA,GAAY,IAAA,CAAK,UAAA,CAAW,KAAA,EAAM;AAEtC,IAAA,IAAI,CAAC,SAAS,qBAAA,EAAuB;AACjC,MAAA,SAAA,GAAY,UAAU,MAAA,CAAO,CAAC,CAAA,KAAM,CAAC,EAAE,QAAQ,CAAA;AAAA,IACnD;AAEA,IAAA,OAAO,SAAA;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,mBAAmB,OAAA,EAAiD;AAChE,IAAA,OAAO,kBAAA,CAAmB;AAAA;AAAA;AAAA;AAAA,MAItB,IAAA,EAAM,IAAA;AAAA,MACN,oBAAoB,OAAA,EAAS,kBAAA;AAAA,MAC7B,uBAAuB,OAAA,EAAS,qBAAA;AAAA,MAChC,QAAQ,OAAA,EAAS;AAAA,KACpB,CAAA;AAAA,EACL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,CAAC,iBAAiB,CAAA,GAAoB;AAClC,IAAA,OAAO,IAAA,CAAK,UAAA;AAAA,EAChB;AACJ;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ChildrenCollection } from "./ChildrenCollection";
|
|
2
1
|
import { AnyLayer } from "../unions";
|
|
2
|
+
import { ChildrenCollection } from "./ChildrenCollection";
|
|
3
3
|
import { RecursiveRetrievalOptions } from "./LayerRetrievalOptions";
|
|
4
4
|
/** @internal */
|
|
5
5
|
export interface RecursiveLayerOptions<LayerType> extends RecursiveRetrievalOptions {
|
|
@@ -3,10 +3,17 @@ function getRecursiveLayers(options) {
|
|
|
3
3
|
const sortByDisplayOrder = options.sortByDisplayOrder ?? false;
|
|
4
4
|
const includeInternalLayers = options.includeInternalLayers ?? false;
|
|
5
5
|
const result = [];
|
|
6
|
-
gatherRecursiveLayers(
|
|
6
|
+
gatherRecursiveLayers({
|
|
7
|
+
from: options.from,
|
|
8
|
+
filter,
|
|
9
|
+
sortByDisplayOrder,
|
|
10
|
+
includeInternalLayers,
|
|
11
|
+
result
|
|
12
|
+
});
|
|
7
13
|
return result;
|
|
8
14
|
}
|
|
9
|
-
function gatherRecursiveLayers(
|
|
15
|
+
function gatherRecursiveLayers(options) {
|
|
16
|
+
const { from, filter, sortByDisplayOrder, includeInternalLayers, result } = options;
|
|
10
17
|
const layers = from.getItems({
|
|
11
18
|
sortByDisplayOrder,
|
|
12
19
|
includeInternalLayers
|
|
@@ -19,13 +26,13 @@ function gatherRecursiveLayers(from, filter, sortByDisplayOrder, includeInternal
|
|
|
19
26
|
}
|
|
20
27
|
const children = layer.children;
|
|
21
28
|
if (children) {
|
|
22
|
-
gatherRecursiveLayers(
|
|
23
|
-
children,
|
|
29
|
+
gatherRecursiveLayers({
|
|
30
|
+
from: children,
|
|
24
31
|
filter,
|
|
25
32
|
sortByDisplayOrder,
|
|
26
33
|
includeInternalLayers,
|
|
27
34
|
result
|
|
28
|
-
);
|
|
35
|
+
});
|
|
29
36
|
}
|
|
30
37
|
result.push(layer);
|
|
31
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRecursiveLayers.js","sources":["getRecursiveLayers.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport {
|
|
1
|
+
{"version":3,"file":"getRecursiveLayers.js","sources":["getRecursiveLayers.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { AnyLayer } from \"../unions\";\nimport { ChildrenCollection } from \"./ChildrenCollection\";\nimport { RecursiveRetrievalOptions } from \"./LayerRetrievalOptions\";\n\n/** @internal */\nexport interface RecursiveLayerOptions<LayerType> extends RecursiveRetrievalOptions {\n /**\n * Starting point(s) of the recursion.\n * The layers in this collections and their all of their children (recursively) will be included in the result.\n */\n from: ChildrenCollection<LayerType>;\n\n /**\n * If set to `true`, layers will be ordered by their display order:\n * Layers listed first in the returned array are shown _below_ layers listed at a later index.\n *\n * By default, layers are returned in arbitrary order.\n */\n sortByDisplayOrder?: boolean;\n}\n\nexport function getRecursiveLayers<LayerType extends AnyLayer>(\n options: RecursiveLayerOptions<LayerType>\n): AnyLayer[] {\n const filter = options.filter ?? (() => true);\n const sortByDisplayOrder = options.sortByDisplayOrder ?? false;\n const includeInternalLayers = options.includeInternalLayers ?? false;\n const result: AnyLayer[] = [];\n gatherRecursiveLayers({\n from: options.from,\n filter,\n sortByDisplayOrder,\n includeInternalLayers,\n result\n });\n return result;\n}\n\ninterface GatherOptions<LayerType extends AnyLayer> {\n from: ChildrenCollection<LayerType>;\n filter: (layer: AnyLayer) => boolean;\n sortByDisplayOrder: boolean;\n includeInternalLayers: boolean;\n result: AnyLayer[];\n}\n\n// Walks the layer tree recursively and gathers matching layers into the result array.\nfunction gatherRecursiveLayers<LayerType extends AnyLayer>(\n options: GatherOptions<LayerType>\n): void {\n const { from, filter, sortByDisplayOrder, includeInternalLayers, result } = options;\n const layers = from.getItems({\n sortByDisplayOrder: sortByDisplayOrder,\n includeInternalLayers: includeInternalLayers\n });\n for (const layer of layers) {\n if (!filter(layer)) {\n continue;\n } else if (!includeInternalLayers && layer.internal) {\n continue;\n }\n\n const children = layer.children;\n if (children) {\n // Pushes into result as a side effect\n gatherRecursiveLayers({\n from: children,\n filter,\n sortByDisplayOrder,\n includeInternalLayers,\n result\n });\n }\n result.push(layer);\n }\n}\n"],"names":[],"mappings":"AAwBO,SAAS,mBACZ,OAAA,EACU;AACV,EAAA,MAAM,MAAA,GAAS,OAAA,CAAQ,MAAA,KAAW,MAAM,IAAA,CAAA;AACxC,EAAA,MAAM,kBAAA,GAAqB,QAAQ,kBAAA,IAAsB,KAAA;AACzD,EAAA,MAAM,qBAAA,GAAwB,QAAQ,qBAAA,IAAyB,KAAA;AAC/D,EAAA,MAAM,SAAqB,EAAC;AAC5B,EAAA,qBAAA,CAAsB;AAAA,IAClB,MAAM,OAAA,CAAQ,IAAA;AAAA,IACd,MAAA;AAAA,IACA,kBAAA;AAAA,IACA,qBAAA;AAAA,IACA;AAAA,GACH,CAAA;AACD,EAAA,OAAO,MAAA;AACX;AAWA,SAAS,sBACL,OAAA,EACI;AACJ,EAAA,MAAM,EAAE,IAAA,EAAM,MAAA,EAAQ,kBAAA,EAAoB,qBAAA,EAAuB,QAAO,GAAI,OAAA;AAC5E,EAAA,MAAM,MAAA,GAAS,KAAK,QAAA,CAAS;AAAA,IACzB,kBAAA;AAAA,IACA;AAAA,GACH,CAAA;AACD,EAAA,KAAA,MAAW,SAAS,MAAA,EAAQ;AACxB,IAAA,IAAI,CAAC,MAAA,CAAO,KAAK,CAAA,EAAG;AAChB,MAAA;AAAA,IACJ,CAAA,MAAA,IAAW,CAAC,qBAAA,IAAyB,KAAA,CAAM,QAAA,EAAU;AACjD,MAAA;AAAA,IACJ;AAEA,IAAA,MAAM,WAAW,KAAA,CAAM,QAAA;AACvB,IAAA,IAAI,QAAA,EAAU;AAEV,MAAA,qBAAA,CAAsB;AAAA,QAClB,IAAA,EAAM,QAAA;AAAA,QACN,MAAA;AAAA,QACA,kBAAA;AAAA,QACA,qBAAA;AAAA,QACA;AAAA,OACH,CAAA;AAAA,IACL;AACA,IAAA,MAAA,CAAO,KAAK,KAAK,CAAA;AAAA,EACrB;AACJ;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HttpService } from "@open-pioneer/http";
|
|
2
|
-
import { LayerConfig } from "./LayerConfig";
|
|
3
|
-
import { Layer } from "../unions";
|
|
4
2
|
import { InternalConstructorTag } from "../../utils/InternalConstructorTag";
|
|
3
|
+
import { Layer } from "../unions";
|
|
4
|
+
import { LayerConfig } from "./LayerConfig";
|
|
5
5
|
/**
|
|
6
6
|
* Options passed from the layer factory to the layer constructor.
|
|
7
7
|
*
|
|
@@ -42,3 +42,5 @@ export declare const GET_RAW_SUBLAYERS: unique symbol;
|
|
|
42
42
|
export declare const ATTACH_TO_PARENT: unique symbol;
|
|
43
43
|
export declare const SET_LEGEND: unique symbol;
|
|
44
44
|
export declare const LAYER_DEPS: unique symbol;
|
|
45
|
+
export declare const SET_METADATA_LOAD_INFO: unique symbol;
|
|
46
|
+
export declare const DECLARED_AS_BASE_LAYER: unique symbol;
|
|
@@ -26,6 +26,8 @@ const GET_RAW_SUBLAYERS = /* @__PURE__ */ Symbol("GET_RAW_SUBLAYERS");
|
|
|
26
26
|
const ATTACH_TO_PARENT = /* @__PURE__ */ Symbol("ATTACH_TO_PARENT");
|
|
27
27
|
const SET_LEGEND = /* @__PURE__ */ Symbol("SET_LEGEND");
|
|
28
28
|
const LAYER_DEPS = /* @__PURE__ */ Symbol("LAYER_DEPS");
|
|
29
|
+
const SET_METADATA_LOAD_INFO = /* @__PURE__ */ Symbol("SET_METADATA_LOAD_INFO");
|
|
30
|
+
const DECLARED_AS_BASE_LAYER = /* @__PURE__ */ Symbol("DECLARED_AS_BASE_LAYER");
|
|
29
31
|
|
|
30
|
-
export { ATTACH_TO_GROUP, ATTACH_TO_MAP, ATTACH_TO_PARENT, DETACH_FROM_GROUP, DETACH_FROM_MAP, GET_DEPS, GET_PARENT, GET_RAW_LAYERS, GET_RAW_SUBLAYERS, LAYER_DEPS, SET_LEGEND, SET_VISIBLE, getLayerDependencies };
|
|
32
|
+
export { ATTACH_TO_GROUP, ATTACH_TO_MAP, ATTACH_TO_PARENT, DECLARED_AS_BASE_LAYER, DETACH_FROM_GROUP, DETACH_FROM_MAP, GET_DEPS, GET_PARENT, GET_RAW_LAYERS, GET_RAW_SUBLAYERS, LAYER_DEPS, SET_LEGEND, SET_METADATA_LOAD_INFO, SET_VISIBLE, getLayerDependencies };
|
|
31
33
|
//# sourceMappingURL=internals.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internals.js","sources":["internals.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { HttpService } from \"@open-pioneer/http\";\nimport {
|
|
1
|
+
{"version":3,"file":"internals.js","sources":["internals.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { HttpService } from \"@open-pioneer/http\";\nimport {\n InternalConstructorTag,\n INTERNAL_CONSTRUCTOR_TAG\n} from \"../../utils/InternalConstructorTag\";\nimport { Layer } from \"../unions\";\nimport { LayerConfig } from \"./LayerConfig\";\n\n/**\n * Options passed from the layer factory to the layer constructor.\n *\n * @internal\n */\nexport interface LayerDependencies {\n httpService: HttpService;\n}\n\n/**\n * Interface implemented by layer classes (the prototype, not the instance).\n *\n * - `Config`: the options supported or required as construction parameters.\n * - `LayerType`: the type of the resulting layer instance.\n *\n * @internal\n */\nexport interface LayerConstructor<Config extends LayerConfig, LayerType extends Layer> {\n prototype: LayerType;\n new (config: Config, deps: LayerDependencies, tag: InternalConstructorTag): LayerType;\n}\n\n/**\n * Helper function to verify that the correct tag was used.\n *\n * Returns the layer dependencies passed by the layer factory or returns undefined.\n *\n * Throws an error if an invalid tag was provided.\n */\nexport function getLayerDependencies(\n deps: LayerDependencies | undefined,\n tag: InternalConstructorTag | undefined\n): LayerDependencies | undefined {\n if (tag == null) {\n // no tag -> used old constructor overload\n return undefined;\n }\n if (tag !== INTERNAL_CONSTRUCTOR_TAG) {\n throw new Error(\n \"Attempt to call an internal layer constructor. Use the LayerFactory service instead.\"\n );\n }\n if (!deps) {\n // If the correct tag was used, then the dependencies must have been passed by the factory\n throw new Error(\"Internal error: layer dependencies are missing\");\n }\n return deps;\n}\n\n// use symbols for internal functions\nexport const SET_VISIBLE = Symbol(\"SET_VISIBLE\");\nexport const DETACH_FROM_MAP = Symbol(\"DETACH_FROM_MAP\");\nexport const ATTACH_TO_MAP = Symbol(\"ATTACH_TO_MAP\");\nexport const ATTACH_TO_GROUP = Symbol(\"ATTACH_TO_GROUP\");\nexport const DETACH_FROM_GROUP = Symbol(\"DETACH_FROM_GROUP\");\nexport const GET_RAW_LAYERS = Symbol(\"GET_RAW_LAYERS\");\nexport const GET_PARENT = Symbol(\"GET_PARENT\");\nexport const GET_DEPS = Symbol(\"GET_DEPS\");\nexport const GET_RAW_SUBLAYERS = Symbol(\"GET_RAW_SUBLAYERS\");\nexport const ATTACH_TO_PARENT = Symbol(\"ATTACH_TO_PARENT\");\nexport const SET_LEGEND = Symbol(\"SET_LEGEND\");\nexport const LAYER_DEPS = Symbol(\"LAYER_DEPS\");\nexport const SET_METADATA_LOAD_INFO = Symbol(\"SET_METADATA_LOAD_INFO\");\nexport const DECLARED_AS_BASE_LAYER = Symbol(\"DECLARED_AS_BASE_LAYER\");\n"],"names":[],"mappings":";;AAwCO,SAAS,oBAAA,CACZ,MACA,GAAA,EAC6B;AAC7B,EAAA,IAAI,OAAO,IAAA,EAAM;AAEb,IAAA,OAAO,MAAA;AAAA,EACX;AACA,EAAA,IAAI,QAAQ,wBAAA,EAA0B;AAClC,IAAA,MAAM,IAAI,KAAA;AAAA,MACN;AAAA,KACJ;AAAA,EACJ;AACA,EAAA,IAAI,CAAC,IAAA,EAAM;AAEP,IAAA,MAAM,IAAI,MAAM,gDAAgD,CAAA;AAAA,EACpE;AACA,EAAA,OAAO,IAAA;AACX;AAGO,MAAM,WAAA,0BAAqB,aAAa;AACxC,MAAM,eAAA,0BAAyB,iBAAiB;AAChD,MAAM,aAAA,0BAAuB,eAAe;AAC5C,MAAM,eAAA,0BAAyB,iBAAiB;AAChD,MAAM,iBAAA,0BAA2B,mBAAmB;AACpD,MAAM,cAAA,0BAAwB,gBAAgB;AAC9C,MAAM,UAAA,0BAAoB,YAAY;AACtC,MAAM,QAAA,0BAAkB,UAAU;AAClC,MAAM,iBAAA,0BAA2B,mBAAmB;AACpD,MAAM,gBAAA,0BAA0B,kBAAkB;AAClD,MAAM,UAAA,0BAAoB,YAAY;AACtC,MAAM,UAAA,0BAAoB,YAAY;AACtC,MAAM,sBAAA,0BAAgC,wBAAwB;AAC9D,MAAM,sBAAA,0BAAgC,wBAAwB;;;;"}
|
package/layers/unions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unions.js","sources":["unions.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { type LayerBaseType } from \"..\";\nimport { type GroupLayer } from \"./GroupLayer\";\nimport { type SublayerBaseType } from \"./shared/SublayerBaseType\";\nimport { type SimpleLayer } from \"./SimpleLayer\";\nimport { type WMSSublayer } from \"./wms/WMSSublayer\";\nimport { type WMSLayer } from \"./WMSLayer\";\nimport { type WMTSLayer } from \"./WMTSLayer\";\n\n/**\n * Supported layer type identifiers.\n *\n * NOTE: More layer types may be added in future versions.\n *\n * @group Layers\n */\nexport type LayerTypes = \"simple\" | \"wms\" | \"wmts\" | \"group\";\n\n/**\n * Supported sublayer type identifiers.\n *\n * NOTE: More sublayer types may be added in future versions.\n *\n * @group Layers\n */\nexport type SublayerTypes = \"wms-sublayer\";\n\n/**\n * Supported layer type identifiers for both operational layers and sublayers.\n *\n * @group Layers\n */\nexport type AnyLayerTypes = LayerTypes | SublayerTypes;\n\n/**\n * Union type for all layers (extending {@link LayerBaseType}).\n *\n * NOTE: More layer implementations may be added in future versions.\n *\n * @group Layers\n */\nexport type Layer = SimpleLayer | WMSLayer | WMTSLayer | GroupLayer;\n\n/**\n * Union type for all sublayers (extending {@link SublayerBaseType}.\n *\n * NOTE: More sublayer implementations may be added in future versions.\n *\n * @group Layers\n */\nexport type Sublayer = WMSSublayer;\n\n/**\n * Union for all types of layers\n *\n * @group Layers\n */\nexport type AnyLayer = Layer | Sublayer;\n\n/**\n * Type guard for checking if the layer is a {@link Sublayer}.\n *\n * @group Layers\n */\nexport function isSublayer(layer: AnyLayer): layer is Sublayer {\n return \"parentLayer\" in layer;\n}\n\n/**\n * Type guard for checking if the layer is a {@link Layer} (and not a {@link Sublayer}).\n *\n * @group Layers\n */\nexport function isLayer(layer: AnyLayer): layer is Layer {\n return \"olLayer\" in layer;\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"unions.js","sources":["unions.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\n// oxlint-disable-next-line @typescript-eslint/no-unused-vars\nimport { type LayerBaseType } from \"..\";\nimport { type GroupLayer } from \"./GroupLayer\";\n// oxlint-disable-next-line @typescript-eslint/no-unused-vars\nimport { type SublayerBaseType } from \"./shared/SublayerBaseType\";\nimport { type SimpleLayer } from \"./SimpleLayer\";\nimport { type WMSSublayer } from \"./wms/WMSSublayer\";\nimport { type WMSLayer } from \"./WMSLayer\";\nimport { type WMTSLayer } from \"./WMTSLayer\";\n\n/**\n * Supported layer type identifiers.\n *\n * NOTE: More layer types may be added in future versions.\n *\n * @group Layers\n */\nexport type LayerTypes = \"simple\" | \"wms\" | \"wmts\" | \"group\";\n\n/**\n * Supported sublayer type identifiers.\n *\n * NOTE: More sublayer types may be added in future versions.\n *\n * @group Layers\n */\nexport type SublayerTypes = \"wms-sublayer\";\n\n/**\n * Supported layer type identifiers for both operational layers and sublayers.\n *\n * @group Layers\n */\nexport type AnyLayerTypes = LayerTypes | SublayerTypes;\n\n/**\n * Union type for all layers (extending {@link LayerBaseType}).\n *\n * NOTE: More layer implementations may be added in future versions.\n *\n * @group Layers\n */\nexport type Layer = SimpleLayer | WMSLayer | WMTSLayer | GroupLayer;\n\n/**\n * Union type for all sublayers (extending {@link SublayerBaseType}.\n *\n * NOTE: More sublayer implementations may be added in future versions.\n *\n * @group Layers\n */\nexport type Sublayer = WMSSublayer;\n\n/**\n * Union for all types of layers\n *\n * @group Layers\n */\nexport type AnyLayer = Layer | Sublayer;\n\n/**\n * Type guard for checking if the layer is a {@link Sublayer}.\n *\n * @group Layers\n */\nexport function isSublayer(layer: AnyLayer): layer is Sublayer {\n return \"parentLayer\" in layer;\n}\n\n/**\n * Type guard for checking if the layer is a {@link Layer} (and not a {@link Sublayer}).\n *\n * @group Layers\n */\nexport function isLayer(layer: AnyLayer): layer is Layer {\n return \"olLayer\" in layer;\n}\n"],"names":[],"mappings":"AAoEO,SAAS,WAAW,KAAA,EAAoC;AAC3D,EAAA,OAAO,aAAA,IAAiB,KAAA;AAC5B;AAOO,SAAS,QAAQ,KAAA,EAAiC;AACrD,EAAA,OAAO,SAAA,IAAa,KAAA;AACxB;;;;"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { MapModel } from "../../model/MapModel";
|
|
2
|
+
import { InternalConstructorTag } from "../../utils/InternalConstructorTag";
|
|
3
|
+
import type { LayerLoadInfo, LayerLoadState } from "../AbstractLayer";
|
|
2
4
|
import { AbstractLayerBase } from "../AbstractLayerBase";
|
|
3
5
|
import { ATTACH_TO_MAP, ATTACH_TO_PARENT, DETACH_FROM_MAP, SET_LEGEND } from "../shared/internals";
|
|
4
|
-
import { InternalConstructorTag } from "../../utils/InternalConstructorTag";
|
|
5
6
|
import { LayerBaseConfig } from "../shared/LayerConfig";
|
|
6
7
|
import { SublayerBaseType } from "../shared/SublayerBaseType";
|
|
7
8
|
import { SublayersCollection } from "../shared/SublayersCollection";
|
|
@@ -20,6 +21,7 @@ export interface WMSSublayerConfig extends LayerBaseConfig {
|
|
|
20
21
|
/** Configuration for nested sublayers. */
|
|
21
22
|
sublayers?: WMSSublayerConfig[];
|
|
22
23
|
}
|
|
24
|
+
export declare const SET_SUBLAYER_LOAD_INFO: unique symbol;
|
|
23
25
|
/**
|
|
24
26
|
* Represents a sublayer of a {@link WMSLayer}.
|
|
25
27
|
*
|
|
@@ -43,6 +45,11 @@ export declare class WMSSublayer extends AbstractLayerBase implements SublayerBa
|
|
|
43
45
|
get parent(): WMSSublayer | WMSLayer;
|
|
44
46
|
get parentLayer(): WMSLayer;
|
|
45
47
|
get legend(): string | undefined;
|
|
48
|
+
get loadState(): LayerLoadState;
|
|
49
|
+
/**
|
|
50
|
+
* The error (if any) that prevented this sublayer from loading.
|
|
51
|
+
*/
|
|
52
|
+
get loadError(): Error | undefined;
|
|
46
53
|
get visible(): boolean;
|
|
47
54
|
/**
|
|
48
55
|
* Called by the parent layer when it is attached to the map to attach all sublayers.
|
|
@@ -64,6 +71,12 @@ export declare class WMSSublayer extends AbstractLayerBase implements SublayerBa
|
|
|
64
71
|
* @internal
|
|
65
72
|
*/
|
|
66
73
|
[SET_LEGEND](legendUrl: string | undefined): void;
|
|
74
|
+
/**
|
|
75
|
+
* Called by the parent layer once the capabilities have been validated.
|
|
76
|
+
*
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
[SET_SUBLAYER_LOAD_INFO](loadInfo: LayerLoadInfo): void;
|
|
67
80
|
setVisible(newVisibility: boolean): void;
|
|
68
81
|
}
|
|
69
82
|
/**
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { reactive } from '@conterra/reactivity-core';
|
|
2
|
+
import { INTERNAL_CONSTRUCTOR_TAG, assertInternalConstructor } from '../../utils/InternalConstructorTag.js';
|
|
2
3
|
import { AbstractLayerBase } from '../AbstractLayerBase.js';
|
|
3
4
|
import { ATTACH_TO_MAP, GET_RAW_SUBLAYERS, DETACH_FROM_MAP, ATTACH_TO_PARENT, SET_LEGEND } from '../shared/internals.js';
|
|
4
|
-
import { INTERNAL_CONSTRUCTOR_TAG, assertInternalConstructor } from '../../utils/InternalConstructorTag.js';
|
|
5
5
|
import { SublayersCollection } from '../shared/SublayersCollection.js';
|
|
6
6
|
|
|
7
|
+
const SET_SUBLAYER_LOAD_INFO = /* @__PURE__ */ Symbol("SET_SUBLAYER_LOAD_INFO");
|
|
7
8
|
class WMSSublayer extends AbstractLayerBase {
|
|
8
9
|
#parent;
|
|
9
10
|
#parentLayer;
|
|
@@ -11,6 +12,7 @@ class WMSSublayer extends AbstractLayerBase {
|
|
|
11
12
|
#legend = reactive();
|
|
12
13
|
#sublayers;
|
|
13
14
|
#visible;
|
|
15
|
+
#loadInfo = reactive("loaded");
|
|
14
16
|
/**
|
|
15
17
|
* @internal
|
|
16
18
|
*/
|
|
@@ -58,6 +60,23 @@ class WMSSublayer extends AbstractLayerBase {
|
|
|
58
60
|
get legend() {
|
|
59
61
|
return this.#legend.value;
|
|
60
62
|
}
|
|
63
|
+
get loadState() {
|
|
64
|
+
const current = this.#loadInfo.value;
|
|
65
|
+
if (typeof current === "string") {
|
|
66
|
+
return current;
|
|
67
|
+
}
|
|
68
|
+
return current.kind;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The error (if any) that prevented this sublayer from loading.
|
|
72
|
+
*/
|
|
73
|
+
get loadError() {
|
|
74
|
+
const current = this.#loadInfo.value;
|
|
75
|
+
if (typeof current === "object" && "kind" in current && current.kind === "error") {
|
|
76
|
+
return current.error;
|
|
77
|
+
}
|
|
78
|
+
return void 0;
|
|
79
|
+
}
|
|
61
80
|
get visible() {
|
|
62
81
|
return this.#visible.value;
|
|
63
82
|
}
|
|
@@ -109,6 +128,14 @@ class WMSSublayer extends AbstractLayerBase {
|
|
|
109
128
|
[SET_LEGEND](legendUrl) {
|
|
110
129
|
this.#legend.value = legendUrl;
|
|
111
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Called by the parent layer once the capabilities have been validated.
|
|
133
|
+
*
|
|
134
|
+
* @internal
|
|
135
|
+
*/
|
|
136
|
+
[SET_SUBLAYER_LOAD_INFO](loadInfo) {
|
|
137
|
+
this.#loadInfo.value = loadInfo;
|
|
138
|
+
}
|
|
112
139
|
setVisible(newVisibility) {
|
|
113
140
|
this.#visible.value = newVisibility;
|
|
114
141
|
}
|
|
@@ -129,5 +156,5 @@ function constructSublayers(sublayerConfigs = []) {
|
|
|
129
156
|
}
|
|
130
157
|
}
|
|
131
158
|
|
|
132
|
-
export { constructSublayers };
|
|
159
|
+
export { SET_SUBLAYER_LOAD_INFO, constructSublayers };
|
|
133
160
|
//# sourceMappingURL=WMSSublayer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WMSSublayer.js","sources":["WMSSublayer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Reactive, reactive } from \"@conterra/reactivity-core\";\nimport { MapModel } from \"../../model/MapModel\";\nimport { AbstractLayerBase } from \"../AbstractLayerBase\";\nimport {\n ATTACH_TO_MAP,\n ATTACH_TO_PARENT,\n DETACH_FROM_MAP,\n GET_RAW_SUBLAYERS,\n SET_LEGEND\n} from \"../shared/internals\";\nimport {\n assertInternalConstructor,\n INTERNAL_CONSTRUCTOR_TAG,\n InternalConstructorTag\n} from \"../../utils/InternalConstructorTag\";\nimport { LayerBaseConfig } from \"../shared/LayerConfig\";\nimport { SublayerBaseType } from \"../shared/SublayerBaseType\";\nimport { SublayersCollection } from \"../shared/SublayersCollection\";\nimport { WMSLayer } from \"../WMSLayer\";\n\n/**\n * Configuration options to construct the sublayers of a {@link WMSLayer}.\n *\n * @group Layers\n */\nexport interface WMSSublayerConfig extends LayerBaseConfig {\n /**\n * The name of the WMS sublayer in the service's capabilities.\n * Not mandatory, e.g. for WMS group layer. See [WMS spec](https://www.ogc.org/standard/wms/).\n */\n name?: string;\n\n /** Configuration for nested sublayers. */\n sublayers?: WMSSublayerConfig[];\n}\n\n/**\n * Represents a sublayer of a {@link WMSLayer}.\n *\n * @group Layers\n */\nexport class WMSSublayer extends AbstractLayerBase implements SublayerBaseType {\n #parent: WMSSublayer | WMSLayer | undefined;\n #parentLayer: WMSLayer | undefined;\n #name: string | undefined;\n #legend = reactive<string | undefined>();\n #sublayers: SublayersCollection<WMSSublayer>;\n #visible: Reactive<boolean>;\n\n /**\n * @internal\n */\n constructor(config: WMSSublayerConfig, tag: InternalConstructorTag) {\n assertInternalConstructor(tag);\n\n super(config);\n this.#name = config.name;\n this.#visible = reactive(config.visible ?? true);\n this.#sublayers = new SublayersCollection(\n constructSublayers(config.sublayers),\n INTERNAL_CONSTRUCTOR_TAG\n );\n }\n\n override get type() {\n return \"wms-sublayer\" as const;\n }\n\n /**\n * The name of the WMS sublayer in the service's capabilities.\n *\n * Is optional as a WMS group layer in a WMS service does not need to have a name.\n */\n get name(): string | undefined {\n return this.#name;\n }\n\n override get layers(): undefined {\n return undefined;\n }\n\n override get sublayers(): SublayersCollection<WMSSublayer> {\n return this.#sublayers;\n }\n\n override get parent(): WMSSublayer | WMSLayer {\n const parent = this.#parent;\n if (!parent) {\n throw new Error(`WMS sublayer ${this.id} has not been attached to its parent yet.`);\n }\n return parent;\n }\n\n get parentLayer(): WMSLayer {\n const parentLayer = this.#parentLayer;\n if (!parentLayer) {\n throw new Error(`WMS sublayer ${this.id} has not been attached to its parent yet.`);\n }\n return parentLayer;\n }\n\n override get legend(): string | undefined {\n return this.#legend.value;\n }\n\n override get visible(): boolean {\n return this.#visible.value;\n }\n\n /**\n * Called by the parent layer when it is attached to the map to attach all sublayers.\n *\n * @internal\n */\n override [ATTACH_TO_MAP](map: MapModel): void {\n super[ATTACH_TO_MAP](map);\n\n // Recurse into nested sublayers\n for (const sublayer of this.sublayers[GET_RAW_SUBLAYERS]()) {\n sublayer[ATTACH_TO_MAP](map);\n }\n }\n\n /** @internal */\n override [DETACH_FROM_MAP](): void {\n super[DETACH_FROM_MAP]();\n for (const sublayer of this.#sublayers.getSublayers()) {\n sublayer[DETACH_FROM_MAP]();\n }\n }\n\n /**\n * Attaches this sublayer to its parent _layer_ and its immediate parent _layer or sublayer_.\n *\n * @internal\n */\n [ATTACH_TO_PARENT](parentLayer: WMSLayer, parent: WMSLayer | WMSSublayer): void {\n if (this.#parent) {\n throw new Error(\n `WMS sublayer '${this.id}' has already been attached to parent '${this.#parent.id}'`\n );\n }\n this.#parent = parent;\n\n if (this.#parentLayer) {\n throw new Error(\n `WMS sublayer '${this.id}' has already been attached to parent layer '${this.#parentLayer.id}'`\n );\n }\n this.#parentLayer = parentLayer;\n\n // Recurse into nested sublayers\n for (const sublayer of this.sublayers[GET_RAW_SUBLAYERS]()) {\n sublayer[ATTACH_TO_PARENT](parentLayer, this);\n }\n }\n\n /**\n * Called by the parent layer to update the legend on load.\n *\n * @internal\n */\n [SET_LEGEND](legendUrl: string | undefined) {\n this.#legend.value = legendUrl;\n }\n\n override setVisible(newVisibility: boolean): void {\n this.#visible.value = newVisibility;\n }\n}\n\n/**\n * Constructs a tree of wms sublayers from a nested configuration object.\n */\nexport function constructSublayers(sublayerConfigs: WMSSublayerConfig[] = []): WMSSublayer[] {\n const sublayers: WMSSublayer[] = [];\n try {\n for (const sublayerConfig of sublayerConfigs) {\n sublayers.push(new WMSSublayer(sublayerConfig, INTERNAL_CONSTRUCTOR_TAG));\n }\n return sublayers;\n } catch (e) {\n // Ensure previous sublayers are destroyed if a single constructor throws\n while (sublayers.length) {\n const layer = sublayers.pop();\n layer?.destroy();\n }\n throw new Error(\"Failed to construct sublayers.\", { cause: e });\n }\n}\n"],"names":[],"mappings":";;;;;;AA2CO,MAAM,oBAAoB,iBAAA,CAA8C;AAAA,EAC3E,OAAA;AAAA,EACA,YAAA;AAAA,EACA,KAAA;AAAA,EACA,UAAU,QAAA,EAA6B;AAAA,EACvC,UAAA;AAAA,EACA,QAAA;AAAA;AAAA;AAAA;AAAA,EAKA,WAAA,CAAY,QAA2B,GAAA,EAA6B;AAChE,IAAA,yBAAA,CAA0B,GAAG,CAAA;AAE7B,IAAA,KAAA,CAAM,MAAM,CAAA;AACZ,IAAA,IAAA,CAAK,QAAQ,MAAA,CAAO,IAAA;AACpB,IAAA,IAAA,CAAK,QAAA,GAAW,QAAA,CAAS,MAAA,CAAO,OAAA,IAAW,IAAI,CAAA;AAC/C,IAAA,IAAA,CAAK,aAAa,IAAI,mBAAA;AAAA,MAClB,kBAAA,CAAmB,OAAO,SAAS,CAAA;AAAA,MACnC;AAAA,KACJ;AAAA,EACJ;AAAA,EAEA,IAAa,IAAA,GAAO;AAChB,IAAA,OAAO,cAAA;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,IAAI,IAA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AAI;AACA,IAAA,KAAA,MAAW,kBAAkB,eAAA,EAAiB;AAC1C,MAAA,SAAA,CAAU,IAAA,CAAK,IAAI,WAAA,CAAY,cAAA,EAAgB,wBAAwB,CAAC,CAAA;AAAA,IAC5E;AACA,IAAA,OAAO,SAAA;AAAA,EACX,SAAS,CAAA,EAAG;AAER,IAAA,OAAO,UAAU,MAAA,EAAQ;AACrB,MAAA,MAAM,KAAA,GAAQ,UAAU,GAAA,EAAI;AAC5B,MAAA,KAAA,EAAO,OAAA,EAAQ;AAAA,IACnB;AACA,IAAA,MAAM,IAAI,KAAA,CAAM,gCAAA,EAAkC,EAAE,KAAA,EAAO,GAAG,CAAA;AAAA,EAClE;AACJ;;;;"}
|
|
1
|
+
{"version":3,"file":"WMSSublayer.js","sources":["WMSSublayer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Reactive, reactive } from \"@conterra/reactivity-core\";\nimport { MapModel } from \"../../model/MapModel\";\nimport {\n assertInternalConstructor,\n INTERNAL_CONSTRUCTOR_TAG,\n InternalConstructorTag\n} from \"../../utils/InternalConstructorTag\";\nimport type { LayerLoadInfo, LayerLoadState } from \"../AbstractLayer\";\nimport { AbstractLayerBase } from \"../AbstractLayerBase\";\nimport {\n ATTACH_TO_MAP,\n ATTACH_TO_PARENT,\n DETACH_FROM_MAP,\n GET_RAW_SUBLAYERS,\n SET_LEGEND\n} from \"../shared/internals\";\nimport { LayerBaseConfig } from \"../shared/LayerConfig\";\nimport { SublayerBaseType } from \"../shared/SublayerBaseType\";\nimport { SublayersCollection } from \"../shared/SublayersCollection\";\nimport { WMSLayer } from \"../WMSLayer\";\n\n/**\n * Configuration options to construct the sublayers of a {@link WMSLayer}.\n *\n * @group Layers\n */\nexport interface WMSSublayerConfig extends LayerBaseConfig {\n /**\n * The name of the WMS sublayer in the service's capabilities.\n * Not mandatory, e.g. for WMS group layer. See [WMS spec](https://www.ogc.org/standard/wms/).\n */\n name?: string;\n\n /** Configuration for nested sublayers. */\n sublayers?: WMSSublayerConfig[];\n}\n\nexport const SET_SUBLAYER_LOAD_INFO = Symbol(\"SET_SUBLAYER_LOAD_INFO\");\n\n/**\n * Represents a sublayer of a {@link WMSLayer}.\n *\n * @group Layers\n */\nexport class WMSSublayer extends AbstractLayerBase implements SublayerBaseType {\n #parent: WMSSublayer | WMSLayer | undefined;\n #parentLayer: WMSLayer | undefined;\n #name: string | undefined;\n #legend = reactive<string>();\n #sublayers: SublayersCollection<WMSSublayer>;\n #visible: Reactive<boolean>;\n #loadInfo = reactive<LayerLoadInfo>(\"loaded\");\n\n /**\n * @internal\n */\n constructor(config: WMSSublayerConfig, tag: InternalConstructorTag) {\n assertInternalConstructor(tag);\n\n super(config);\n this.#name = config.name;\n this.#visible = reactive(config.visible ?? true);\n this.#sublayers = new SublayersCollection(\n constructSublayers(config.sublayers),\n INTERNAL_CONSTRUCTOR_TAG\n );\n }\n\n override get type() {\n return \"wms-sublayer\" as const;\n }\n\n /**\n * The name of the WMS sublayer in the service's capabilities.\n *\n * Is optional as a WMS group layer in a WMS service does not need to have a name.\n */\n get name(): string | undefined {\n return this.#name;\n }\n\n override get layers(): undefined {\n return undefined;\n }\n\n override get sublayers(): SublayersCollection<WMSSublayer> {\n return this.#sublayers;\n }\n\n override get parent(): WMSSublayer | WMSLayer {\n const parent = this.#parent;\n if (!parent) {\n throw new Error(`WMS sublayer ${this.id} has not been attached to its parent yet.`);\n }\n return parent;\n }\n\n get parentLayer(): WMSLayer {\n const parentLayer = this.#parentLayer;\n if (!parentLayer) {\n throw new Error(`WMS sublayer ${this.id} has not been attached to its parent yet.`);\n }\n return parentLayer;\n }\n\n override get legend(): string | undefined {\n return this.#legend.value;\n }\n\n get loadState(): LayerLoadState {\n const current = this.#loadInfo.value;\n if (typeof current === \"string\") {\n return current;\n }\n return current.kind;\n }\n\n /**\n * The error (if any) that prevented this sublayer from loading.\n */\n get loadError(): Error | undefined {\n const current = this.#loadInfo.value;\n if (typeof current === \"object\" && \"kind\" in current && current.kind === \"error\") {\n return current.error;\n }\n return undefined;\n }\n\n override get visible(): boolean {\n return this.#visible.value;\n }\n\n /**\n * Called by the parent layer when it is attached to the map to attach all sublayers.\n *\n * @internal\n */\n override [ATTACH_TO_MAP](map: MapModel): void {\n super[ATTACH_TO_MAP](map);\n\n // Recurse into nested sublayers\n for (const sublayer of this.sublayers[GET_RAW_SUBLAYERS]()) {\n sublayer[ATTACH_TO_MAP](map);\n }\n }\n\n /** @internal */\n override [DETACH_FROM_MAP](): void {\n super[DETACH_FROM_MAP]();\n for (const sublayer of this.#sublayers.getSublayers()) {\n sublayer[DETACH_FROM_MAP]();\n }\n }\n\n /**\n * Attaches this sublayer to its parent _layer_ and its immediate parent _layer or sublayer_.\n *\n * @internal\n */\n [ATTACH_TO_PARENT](parentLayer: WMSLayer, parent: WMSLayer | WMSSublayer): void {\n if (this.#parent) {\n throw new Error(\n `WMS sublayer '${this.id}' has already been attached to parent '${this.#parent.id}'`\n );\n }\n this.#parent = parent;\n\n if (this.#parentLayer) {\n throw new Error(\n `WMS sublayer '${this.id}' has already been attached to parent layer '${this.#parentLayer.id}'`\n );\n }\n this.#parentLayer = parentLayer;\n\n // Recurse into nested sublayers\n for (const sublayer of this.sublayers[GET_RAW_SUBLAYERS]()) {\n sublayer[ATTACH_TO_PARENT](parentLayer, this);\n }\n }\n\n /**\n * Called by the parent layer to update the legend on load.\n *\n * @internal\n */\n [SET_LEGEND](legendUrl: string | undefined) {\n this.#legend.value = legendUrl;\n }\n\n /**\n * Called by the parent layer once the capabilities have been validated.\n *\n * @internal\n */\n [SET_SUBLAYER_LOAD_INFO](loadInfo: LayerLoadInfo): void {\n this.#loadInfo.value = loadInfo;\n }\n\n override setVisible(newVisibility: boolean): void {\n this.#visible.value = newVisibility;\n }\n}\n\n/**\n * Constructs a tree of wms sublayers from a nested configuration object.\n */\nexport function constructSublayers(sublayerConfigs: WMSSublayerConfig[] = []): WMSSublayer[] {\n const sublayers: WMSSublayer[] = [];\n try {\n for (const sublayerConfig of sublayerConfigs) {\n sublayers.push(new WMSSublayer(sublayerConfig, INTERNAL_CONSTRUCTOR_TAG));\n }\n return sublayers;\n } catch (e) {\n // Ensure previous sublayers are destroyed if a single constructor throws\n while (sublayers.length) {\n const layer = sublayers.pop();\n layer?.destroy();\n }\n throw new Error(\"Failed to construct sublayers.\", { cause: e });\n }\n}\n"],"names":[],"mappings":";;;;;;AAwCO,MAAM,sBAAA,0BAAgC,wBAAwB;AAO9D,MAAM,oBAAoB,iBAAA,CAA8C;AAAA,EAC3E,OAAA;AAAA,EACA,YAAA;AAAA,EACA,KAAA;AAAA,EACA,UAAU,QAAA,EAAiB;AAAA,EAC3B,UAAA;AAAA,EACA,QAAA;AAAA,EACA,SAAA,GAAY,SAAwB,QAAQ,CAAA;AAAA;AAAA;AAAA;AAAA,EAK5C,WAAA,CAAY,QAA2B,GAAA,EAA6B;AAChE,IAAA,yBAAA,CAA0B,GAAG,CAAA;AAE7B,IAAA,KAAA,CAAM,MAAM,CAAA;AACZ,IAAA,IAAA,CAAK,QAAQ,MAAA,CAAO,IAAA;AACpB,IAAA,IAAA,CAAK,QAAA,GAAW,QAAA,CAAS,MAAA,CAAO,OAAA,IAAW,IAAI,CAAA;AAC/C,IAAA,IAAA,CAAK,aAAa,IAAI,mBAAA;AAAA,MAClB,kBAAA,CAAmB,OAAO,SAAS,CAAA;AAAA,MACnC;AAAA,KACJ;AAAA,EACJ;AAAA,EAEA,IAAa,IAAA,GAAO;AAChB,IAAA,OAAO,cAAA;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,IAAI,IAAA,GAA2B;AAC3B,IAAA,OAAO,IAAA,CAAK,KAAA;AAAA,EAChB;AAAA,EAEA,IAAa,MAAA,GAAoB;AAC7B,IAAA,OAAO,MAAA;AAAA,EACX;AAAA,EAEA,IAAa,SAAA,GAA8C;AACvD,IAAA,OAA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;AAAA;AAAA;AAAA;AAAA,EAOA,CAAC,UAAU,CAAA,CAAE,SAAA,EAA+B;AACxC,IAAA,IAAA,CAAK,QAAQ,KAAA,GAAQ,SAAA;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,CAAC,sBAAsB,CAAA,CAAE,QAAA,EAA+B;AACpD,IAAA,IAAA,CAAK,UAAU,KAAA,GAAQ,QAAA;AAAA,EAC3B;AAAA,EAES,WAAW,aAAA,EAA8B;AAC9C,IAAA,IAAA,CAAK,SAAS,KAAA,GAAQ,aAAA;AAAA,EAC1B;AACJ;AAKO,SAAS,kBAAA,CAAmB,eAAA,GAAuC,EAAC,EAAkB;AACzF,EAAA,MAAM,YAA2B,EAAC;AAClC,EAAA,IAAI;AACA,IAAA,KAAA,MAAW,kBAAkB,eAAA,EAAiB;AAC1C,MAAA,SAAA,CAAU,IAAA,CAAK,IAAI,WAAA,CAAY,cAAA,EAAgB,wBAAwB,CAAC,CAAA;AAAA,IAC5E;AACA,IAAA,OAAO,SAAA;AAAA,EACX,SAAS,CAAA,EAAG;AAER,IAAA,OAAO,UAAU,MAAA,EAAQ;AACrB,MAAA,MAAM,KAAA,GAAQ,UAAU,GAAA,EAAI;AAC5B,MAAA,KAAA,EAAO,OAAA,EAAQ;AAAA,IACnB;AACA,IAAA,MAAM,IAAI,KAAA,CAAM,gCAAA,EAAkC,EAAE,KAAA,EAAO,GAAG,CAAA;AAAA,EAClE;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAttributions.js","sources":["getAttributions.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Returns the attribution derived from the WMS service metadata (if any).\n *\n * @param capabilities Parsed service capabilities\n */\n/*
|
|
1
|
+
{"version":3,"file":"getAttributions.js","sources":["getAttributions.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Returns the attribution derived from the WMS service metadata (if any).\n *\n * @param capabilities Parsed service capabilities\n */\n/* oxlint-disable @typescript-eslint/no-explicit-any */\nexport function getAttributions(capabilities: Record<string, any>): string | undefined {\n const service = capabilities?.Service;\n if (!service) {\n return undefined;\n }\n\n const constraints = service.AccessConstraints;\n if (isSet(constraints)) {\n return constraints;\n }\n\n const fees = service.Fees;\n if (isSet(fees)) {\n return fees;\n }\n\n return undefined;\n}\n\nconst NONE = /none/i;\n\nfunction isSet(value: any): value is string {\n return typeof value === \"string\" && !!value && !NONE.test(value);\n}\n\n/* eslint-enable @typescript-eslint/no-explicit-any */\n"],"names":[],"mappings":"AASO,SAAS,gBAAgB,YAAA,EAAuD;AACnF,EAAA,MAAM,UAAU,YAAA,EAAc,OAAA;AAC9B,EAAA,IAAI,CAAC,OAAA,EAAS;AACV,IAAA,OAAO,MAAA;AAAA,EACX;AAEA,EAAA,MAAM,cAAc,OAAA,CAAQ,iBAAA;AAC5B,EAAA,IAAI,KAAA,CAAM,WAAW,CAAA,EAAG;AACpB,IAAA,OAAO,WAAA;AAAA,EACX;AAEA,EAAA,MAAM,OAAO,OAAA,CAAQ,IAAA;AACrB,EAAA,IAAI,KAAA,CAAM,IAAI,CAAA,EAAG;AACb,IAAA,OAAO,IAAA;AAAA,EACX;AAEA,EAAA,OAAO,MAAA;AACX;AAEA,MAAM,IAAA,GAAO,OAAA;AAEb,SAAS,MAAM,KAAA,EAA6B;AACxC,EAAA,OAAO,OAAO,UAAU,QAAA,IAAY,CAAC,CAAC,KAAA,IAAS,CAAC,IAAA,CAAK,IAAA,CAAK,KAAK,CAAA;AACnE;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLegendUrl.js","sources":["getLegendUrl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { createLogger } from \"@open-pioneer/core\";\nimport { sourceId } from \"open-pioneer:source-info\";\n\nconst LOG = createLogger(sourceId);\n\n/**\n * Extracts the legend url from the service capabilities.\n **/\nexport function getLegendUrl(\n //
|
|
1
|
+
{"version":3,"file":"getLegendUrl.js","sources":["getLegendUrl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { createLogger } from \"@open-pioneer/core\";\nimport { sourceId } from \"open-pioneer:source-info\";\n\nconst LOG = createLogger(sourceId);\n\n/**\n * Extracts the legend url from the service capabilities.\n **/\nexport function getLegendUrl(\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n capabilities: Record<string, any>,\n layerName: string\n): string | undefined {\n const capabilitiesContent = capabilities?.Capability;\n const rootLayerCapabilities = capabilitiesContent?.Layer;\n let url: string | undefined = undefined;\n\n /** Recurse search for the current layer within the parsed capabilities service*/\n //oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const searchNestedLayer = (layer: Record<string, any>[]) => {\n for (const currentLayer of layer) {\n // spec. if, a layer has a <Name>, then it is a map layer\n if (currentLayer?.Name === layerName) {\n const activeLayer = currentLayer;\n const styles = activeLayer.Style;\n if (!styles || !styles.length) {\n LOG.debug(\"No style in WMS layer capabilities - giving up.\");\n return;\n }\n // by parsing of the service capabilities, every child inherits the parent's legend\n // therefore, extract the legendURL from the first style object in the array (its own legend)\n const activeStyle = styles[0];\n url = activeStyle.LegendURL?.[0]?.OnlineResource;\n } else if (currentLayer.Layer) {\n searchNestedLayer(currentLayer.Layer);\n }\n }\n };\n if (rootLayerCapabilities) {\n searchNestedLayer(rootLayerCapabilities.Layer);\n }\n return url;\n}\n"],"names":[],"mappings":";;;AAMA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAK1B,SAAS,YAAA,CAEZ,cACA,SAAA,EACkB;AAClB,EAAA,MAAM,sBAAsB,YAAA,EAAc,UAAA;AAC1C,EAAA,MAAM,wBAAwB,mBAAA,EAAqB,KAAA;AACnD,EAAA,IAAI,GAAA,GAA0B,MAAA;AAI9B,EAAA,MAAM,iBAAA,GAAoB,CAAC,KAAA,KAAiC;AACxD,IAAA,KAAA,MAAW,gBAAgB,KAAA,EAAO;AAE9B,MAAA,IAAI,YAAA,EAAc,SAAS,SAAA,EAAW;AAClC,QAAA,MAAM,WAAA,GAAc,YAAA;AACpB,QAAA,MAAM,SAAS,WAAA,CAAY,KAAA;AAC3B,QAAA,IAAI,CAAC,MAAA,IAAU,CAAC,MAAA,CAAO,MAAA,EAAQ;AAC3B,UAAA,GAAA,CAAI,MAAM,iDAAiD,CAAA;AAC3D,UAAA;AAAA,QACJ;AAGA,QAAA,MAAM,WAAA,GAAc,OAAO,CAAC,CAAA;AAC5B,QAAA,GAAA,GAAM,WAAA,CAAY,SAAA,GAAY,CAAC,CAAA,EAAG,cAAA;AAAA,MACtC,CAAA,MAAA,IAAW,aAAa,KAAA,EAAO;AAC3B,QAAA,iBAAA,CAAkB,aAAa,KAAK,CAAA;AAAA,MACxC;AAAA,IACJ;AAAA,EACJ,CAAA;AACA,EAAA,IAAI,qBAAA,EAAuB;AACvB,IAAA,iBAAA,CAAkB,sBAAsB,KAAK,CAAA;AAAA,EACjD;AACA,EAAA,OAAO,GAAA;AACX;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAttributions.js","sources":["getAttributions.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Returns the attribution derived from the WMTS service metadata (if any).\n *\n * @param capabilities Parsed service capabilities\n */\n/*
|
|
1
|
+
{"version":3,"file":"getAttributions.js","sources":["getAttributions.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Returns the attribution derived from the WMTS service metadata (if any).\n *\n * @param capabilities Parsed service capabilities\n */\n/* oxlint-disable @typescript-eslint/no-explicit-any */\nexport function getAttributions(capabilities: Record<string, any>): string | undefined {\n const service = capabilities?.ServiceIdentification;\n if (!service) {\n return undefined;\n }\n\n const constraints = service.AccessConstraints;\n if (isSet(constraints)) {\n return constraints;\n }\n\n const fees = service.Fees;\n if (isSet(fees)) {\n return fees;\n }\n\n return undefined;\n}\n\nconst NONE = /none/i;\n\nfunction isSet(value: any): value is string {\n return typeof value === \"string\" && !!value && !NONE.test(value);\n}\n\n/* eslint-enable @typescript-eslint/no-explicit-any */\n"],"names":[],"mappings":"AASO,SAAS,gBAAgB,YAAA,EAAuD;AACnF,EAAA,MAAM,UAAU,YAAA,EAAc,qBAAA;AAC9B,EAAA,IAAI,CAAC,OAAA,EAAS;AACV,IAAA,OAAO,MAAA;AAAA,EACX;AAEA,EAAA,MAAM,cAAc,OAAA,CAAQ,iBAAA;AAC5B,EAAA,IAAI,KAAA,CAAM,WAAW,CAAA,EAAG;AACpB,IAAA,OAAO,WAAA;AAAA,EACX;AAEA,EAAA,MAAM,OAAO,OAAA,CAAQ,IAAA;AACrB,EAAA,IAAI,KAAA,CAAM,IAAI,CAAA,EAAG;AACb,IAAA,OAAO,IAAA;AAAA,EACX;AAEA,EAAA,OAAO,MAAA;AACX;AAEA,MAAM,IAAA,GAAO,OAAA;AAEb,SAAS,MAAM,KAAA,EAA6B;AACxC,EAAA,OAAO,OAAO,UAAU,QAAA,IAAY,CAAC,CAAC,KAAA,IAAS,CAAC,IAAA,CAAK,IAAA,CAAK,KAAK,CAAA;AACnE;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLegendUrl.js","sources":["getLegendUrl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { createLogger } from \"@open-pioneer/core\";\nimport { sourceId } from \"open-pioneer:source-info\";\n\nconst LOG = createLogger(sourceId);\n\n/*
|
|
1
|
+
{"version":3,"file":"getLegendUrl.js","sources":["getLegendUrl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { createLogger } from \"@open-pioneer/core\";\nimport { sourceId } from \"open-pioneer:source-info\";\n\nconst LOG = createLogger(sourceId);\n\n/* oxlint-disable @typescript-eslint/no-explicit-any */\nexport function getLegendUrl(\n capabilities: Record<string, any>,\n activeLayerId: string | undefined,\n activeStyleId: string | undefined\n): string | undefined {\n const content = capabilities?.Contents;\n const layers = content?.Layer;\n\n let activeLayer = layers?.find((layer: any) => layer?.Identifier === activeLayerId);\n if (!activeLayer) {\n LOG.debug(\"Failed to find the active layer in WMTS layer capabilities.\");\n activeLayer = layers?.[0];\n if (!activeLayer) {\n LOG.debug(\"No layer in WMTS capabilities - giving up.\");\n return undefined;\n }\n }\n\n const styles = activeLayer.Style;\n let activeStyle = styles?.find((style: any) => style?.Identifier === activeStyleId);\n if (!activeStyle) {\n LOG.debug(\"Failed to find active style in WMTS layer.\");\n activeStyle = styles?.[0];\n if (!activeStyle) {\n LOG.debug(\"No style in WMTS layer capabilities - giving up.\");\n return undefined;\n }\n }\n\n const legendUrl = activeStyle.LegendURL?.[0]?.href;\n return legendUrl as string | undefined;\n}\n/* eslint-enable @typescript-eslint/no-explicit-any */\n"],"names":[],"mappings":";;;AAMA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAG1B,SAAS,YAAA,CACZ,YAAA,EACA,aAAA,EACA,aAAA,EACkB;AAClB,EAAA,MAAM,UAAU,YAAA,EAAc,QAAA;AAC9B,EAAA,MAAM,SAAS,OAAA,EAAS,KAAA;AAExB,EAAA,IAAI,cAAc,MAAA,EAAQ,IAAA,CAAK,CAAC,KAAA,KAAe,KAAA,EAAO,eAAe,aAAa,CAAA;AAClF,EAAA,IAAI,CAAC,WAAA,EAAa;AACd,IAAA,GAAA,CAAI,MAAM,6DAA6D,CAAA;AACvE,IAAA,WAAA,GAAc,SAAS,CAAC,CAAA;AACxB,IAAA,IAAI,CAAC,WAAA,EAAa;AACd,MAAA,GAAA,CAAI,MAAM,4CAA4C,CAAA;AACtD,MAAA,OAAO,MAAA;AAAA,IACX;AAAA,EACJ;AAEA,EAAA,MAAM,SAAS,WAAA,CAAY,KAAA;AAC3B,EAAA,IAAI,cAAc,MAAA,EAAQ,IAAA,CAAK,CAAC,KAAA,KAAe,KAAA,EAAO,eAAe,aAAa,CAAA;AAClF,EAAA,IAAI,CAAC,WAAA,EAAa;AACd,IAAA,GAAA,CAAI,MAAM,4CAA4C,CAAA;AACtD,IAAA,WAAA,GAAc,SAAS,CAAC,CAAA;AACxB,IAAA,IAAI,CAAC,WAAA,EAAa;AACd,MAAA,GAAA,CAAI,MAAM,kDAAkD,CAAA;AAC5D,MAAA,OAAO,MAAA;AAAA,IACX;AAAA,EACJ;AAEA,EAAA,MAAM,SAAA,GAAY,WAAA,CAAY,SAAA,GAAY,CAAC,CAAA,EAAG,IAAA;AAC9C,EAAA,OAAO,SAAA;AACX;;;;"}
|