@open-pioneer/map 0.8.0 → 0.9.0-dev.20250220091855

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 CHANGED
@@ -1,5 +1,56 @@
1
1
  # @open-pioneer/map
2
2
 
3
+ ## 0.9.0-dev.20250220091855
4
+
5
+ ### Minor Changes
6
+
7
+ - f327eec: Deprecate `mapModel.layers.getAllLayers()`.
8
+ Use `mapModel.layers.getLayers()` instead.
9
+ The name of `getAllLayers()` is misleading because it does not recurse into nested layers.
10
+ - f327eec: Add function `getRecursiveLayers()` to `LayerCollection`, `SublayerCollection` and `GroupLayerCollection` in `@open-pioneer/map`
11
+
12
+ Compared to `getLayers` and `getOperationalLayers`, `getRecursiveLayer` returns all (nested) child and sub layers of a collection.
13
+ The property `options.filter` can be used to exclude layers (and their child layers) from the result. For `LayerCollection`, `getRecursiveLayers()` provides the predefined filters `base` and `operational` to return either base layers or operation layers only.
14
+
15
+ The function might be costly if the hierarchy of layers is deeply nested because the layer tree has to be traversed recursively.
16
+ In some scenarios using `options.filter` could be used to improve the performance because it is not necessary to traverse the layer tree completely if some layers are excluded.
17
+
18
+ Example (using GroupLayerCollection):
19
+
20
+ ```typescript
21
+ const grouplayer = new GroupLayer({
22
+ id: "group",
23
+ title: "group test",
24
+ layers: [
25
+ new SimpleLayer({
26
+ id: "member",
27
+ title: "group member",
28
+ olLayer: olLayer1
29
+ }),
30
+ new GroupLayer({
31
+ id: "subgroup",
32
+ title: "subgroup test",
33
+ layers: [
34
+ new SimpleLayer({
35
+ id: "subgroupmember",
36
+ title: "subgroup member",
37
+ olLayer: olLayer2
38
+ })
39
+ ]
40
+ })
41
+ ]
42
+ });
43
+
44
+ // Returns only the layer "member" because the provided filter function excludes "subgroup" and (implicitly) its child "subgroupmember".
45
+ const layers = grouplayer.layers.getRecursiveLayers({
46
+ filter: (layer) => layer.id !== "subgroup"
47
+ });
48
+ ```
49
+
50
+ ### Patch Changes
51
+
52
+ - 209eb8e: Added a configuration option to disable fetching of WMS service capabilities.
53
+
3
54
  ## 0.8.0
4
55
 
5
56
  ### Minor Changes
package/api/MapModel.d.ts CHANGED
@@ -3,8 +3,8 @@ import type OlMap from "ol/Map";
3
3
  import type OlView from "ol/View";
4
4
  import type OlBaseLayer from "ol/layer/Base";
5
5
  import type { ExtentConfig } from "./MapConfig";
6
- import type { AnyLayer, Layer } from "./layers";
7
- import type { LayerRetrievalOptions } from "./shared";
6
+ import type { AnyLayer, ChildrenCollection, Layer } from "./layers";
7
+ import type { LayerRetrievalOptions, RecursiveRetrievalOptions } from "./shared";
8
8
  import type { Geometry } from "ol/geom";
9
9
  import type { BaseFeature } from "./BaseFeature";
10
10
  import type { StyleLike } from "ol/style/Style";
@@ -133,8 +133,12 @@ export interface MapModel extends EventSource<MapModelEvents> {
133
133
  /**
134
134
  * Returns the current scale of the map.
135
135
  *
136
- * Technically, this is the _denominator_ of the current scale.
137
- * In order to display it, use a format like `1:${scale}`.
136
+ * The scale is a value derived from the current `center`, `resolution` and `projection` of the map.
137
+ * The scale will change when the map is zoomed in our out, but depending on the projection, it may also
138
+ * change when the map is _panned_.
139
+ *
140
+ * > NOTE: Technically, this is the _denominator_ of the current scale.
141
+ * > In order to display it, use a format like `1:${scale}`.
138
142
  */
139
143
  readonly scale: number | undefined;
140
144
  /**
@@ -177,7 +181,7 @@ export interface MapModel extends EventSource<MapModelEvents> {
177
181
  /**
178
182
  * Contains the layers known to a {@link MapModel}.
179
183
  */
180
- export interface LayerCollection {
184
+ export interface LayerCollection extends ChildrenCollection<Layer> {
181
185
  /**
182
186
  * Returns all configured base layers.
183
187
  */
@@ -195,6 +199,35 @@ export interface LayerCollection {
195
199
  * Returns true if the given layer has been successfully activated.
196
200
  */
197
201
  activateBaseLayer(id: string | undefined): boolean;
202
+ /**
203
+ * Returns a list of operational layers, starting from the root of the map's layer hierarchy.
204
+ * The returned list includes top level layers only. Use {@link getRecursiveLayers()} to retrieve (nested) child layers.
205
+ */
206
+ getOperationalLayers(options?: LayerRetrievalOptions): Layer[];
207
+ /**
208
+ * Returns a list of layers known to this collection. This includes base layers and operational layers.
209
+ * The returned list includes top level layers only. Use {@link getRecursiveLayers()} to retrieve (nested) child layers.
210
+ *
211
+ * @deprecated Use {@link getLayers()}, {@link getOperationalLayers()} or {@link getRecursiveLayers()} instead.
212
+ * This method name is misleading since it does not recurse into child layers.
213
+ */
214
+ getAllLayers(options?: LayerRetrievalOptions): Layer[];
215
+ /**
216
+ * Returns a list of layers known to this collection. This includes base layers and operational layers.
217
+ * The returned list includes top level layers only. Use {@link getRecursiveLayers()} to retrieve (nested) child layers.
218
+ */
219
+ getLayers(options?: LayerRetrievalOptions): Layer[];
220
+ /**
221
+ * Returns a list of all layers in this collection, including all children (recursively).
222
+ *
223
+ * > Note: This includes base layers by default (see `options.filter`).
224
+ * > Use the `"base"` or `"operational"` short hand values to filter by base layer or operational layers.
225
+ * >
226
+ * > If the layer hierachy is deeply nested, this function could potentially be expensive.
227
+ */
228
+ getRecursiveLayers(options?: Omit<RecursiveRetrievalOptions, "filter"> & {
229
+ filter?: "base" | "operational" | ((layer: AnyLayer) => boolean);
230
+ }): AnyLayer[];
198
231
  /**
199
232
  * Adds a new layer to the map.
200
233
  *
@@ -203,18 +236,10 @@ export interface LayerCollection {
203
236
  * NOTE: by default, the new layer will be shown on _top_ of all existing layers.
204
237
  */
205
238
  addLayer(layer: Layer): void;
206
- /**
207
- * Returns all operational layers.
208
- */
209
- getOperationalLayers(options?: LayerRetrievalOptions): Layer[];
210
239
  /**
211
240
  * Returns the layer identified by the `id` or undefined, if no such layer exists.
212
241
  */
213
242
  getLayerById(id: string): AnyLayer | undefined;
214
- /**
215
- * Returns all layers known to this collection.
216
- */
217
- getAllLayers(options?: LayerRetrievalOptions): Layer[];
218
243
  /**
219
244
  * Removes a layer identified by the `id` from the map.
220
245
  *
@@ -1,6 +1,6 @@
1
1
  import type { Group } from "ol/layer";
2
- import type { LayerRetrievalOptions } from "../shared";
3
- import type { ChildrenCollection, Layer, LayerBaseType, LayerConfig } from "./base";
2
+ import type { LayerRetrievalOptions, RecursiveRetrievalOptions } from "../shared";
3
+ import type { AnyLayer, ChildrenCollection, Layer, LayerBaseType, LayerConfig } from "./base";
4
4
  /**
5
5
  * Configuration options to construct a {@link GroupLayer}.
6
6
  */
@@ -41,6 +41,15 @@ export interface GroupLayerCollection extends ChildrenCollection<Layer> {
41
41
  * Returns all layers in this collection
42
42
  */
43
43
  getLayers(options?: LayerRetrievalOptions): Layer[];
44
+ /**
45
+ * Returns a list of all layers in the collection, including all children (recursively).
46
+ *
47
+ * > Note: This includes base layers by default (see `options.filter`).
48
+ * > Use the `"base"` or `"operational"` short hand values to filter by base layer or operational layers.
49
+ * >
50
+ * > If the group contains many, deeply nested sub groups, this function could potentially be expensive.
51
+ */
52
+ getRecursiveLayers(options?: RecursiveRetrievalOptions): AnyLayer[];
44
53
  }
45
54
  export interface GroupLayerConstructor {
46
55
  prototype: GroupLayer;
@@ -1 +1 @@
1
- {"version":3,"file":"GroupLayer.js","sources":["GroupLayer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport type { Group } from \"ol/layer\";\nimport { GroupLayerImpl } from \"../../model/layers/GroupLayerImpl\";\nimport type { LayerRetrievalOptions } from \"../shared\";\nimport type { ChildrenCollection, Layer, LayerBaseType, LayerConfig } from \"./base\";\n\n/**\n * Configuration options to construct a {@link GroupLayer}.\n */\nexport interface GroupLayerConfig extends LayerConfig {\n /**\n * List of layers that belong to the new group layer.\n *\n * The group layer takes ownership of the given layers: they will be destroyed when the parent is destroyed.\n * A layer must have a unique parent: it can only be added to the map or a single group layer.\n */\n layers: Layer[];\n}\n\n/**\n * Represents a group of layers.\n *\n * A group layer contains a collection of {@link Layer} children.\n * Groups can be nested to form a hierarchy.\n */\nexport interface GroupLayer extends LayerBaseType {\n readonly type: \"group\";\n\n /**\n * Layers contained in this group.\n */\n readonly layers: GroupLayerCollection;\n\n /**\n * Raw OpenLayers group instance.\n *\n * **Warning:** Do not manipulate the collection of layers in this group directly, changes are not synchronized!\n */\n readonly olLayer: Group;\n\n readonly sublayers: undefined;\n}\n\n/**\n * Contains {@link Layer} instances that belong to a {@link GroupLayer}\n */\nexport interface GroupLayerCollection extends ChildrenCollection<Layer> {\n /**\n * Returns all layers in this collection\n */\n getLayers(options?: LayerRetrievalOptions): Layer[];\n}\n\nexport interface GroupLayerConstructor {\n prototype: GroupLayer;\n\n /** Creates a new {@link GroupLayer}. */\n new (config: GroupLayerConfig): GroupLayer;\n}\n\nexport const GroupLayer: GroupLayerConstructor = GroupLayerImpl;\n"],"names":[],"mappings":";;AA6DO,MAAM,UAAoC,GAAA;;;;"}
1
+ {"version":3,"file":"GroupLayer.js","sources":["GroupLayer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport type { Group } from \"ol/layer\";\nimport { GroupLayerImpl } from \"../../model/layers/GroupLayerImpl\";\nimport type { LayerRetrievalOptions, RecursiveRetrievalOptions } from \"../shared\";\nimport type { AnyLayer, ChildrenCollection, Layer, LayerBaseType, LayerConfig } from \"./base\";\n\n/**\n * Configuration options to construct a {@link GroupLayer}.\n */\nexport interface GroupLayerConfig extends LayerConfig {\n /**\n * List of layers that belong to the new group layer.\n *\n * The group layer takes ownership of the given layers: they will be destroyed when the parent is destroyed.\n * A layer must have a unique parent: it can only be added to the map or a single group layer.\n */\n layers: Layer[];\n}\n\n/**\n * Represents a group of layers.\n *\n * A group layer contains a collection of {@link Layer} children.\n * Groups can be nested to form a hierarchy.\n */\nexport interface GroupLayer extends LayerBaseType {\n readonly type: \"group\";\n\n /**\n * Layers contained in this group.\n */\n readonly layers: GroupLayerCollection;\n\n /**\n * Raw OpenLayers group instance.\n *\n * **Warning:** Do not manipulate the collection of layers in this group directly, changes are not synchronized!\n */\n readonly olLayer: Group;\n\n readonly sublayers: undefined;\n}\n\n/**\n * Contains {@link Layer} instances that belong to a {@link GroupLayer}\n */\nexport interface GroupLayerCollection extends ChildrenCollection<Layer> {\n /**\n * Returns all layers in this collection\n */\n getLayers(options?: LayerRetrievalOptions): Layer[];\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}\n\nexport interface GroupLayerConstructor {\n prototype: GroupLayer;\n\n /** Creates a new {@link GroupLayer}. */\n new (config: GroupLayerConfig): GroupLayer;\n}\n\nexport const GroupLayer: GroupLayerConstructor = GroupLayerImpl;\n"],"names":[],"mappings":";;AAuEO,MAAM,UAAoC,GAAA;;;;"}
@@ -15,6 +15,13 @@ export interface WMSLayerConfig extends LayerConfig {
15
15
  * the WMS Layer manages some of the OpenLayers source options itself.
16
16
  */
17
17
  sourceOptions?: Partial<WMSSourceOptions>;
18
+ /**
19
+ * Whether to automatically fetch capabilities from the service when needed (default: `true`).
20
+ *
21
+ * Setting this to `false` can be useful as a performance optimization when capabilities are not really required by the application.
22
+ * Note that this will disable some features of the WMS layer: for example, the legend URL will not be available.
23
+ */
24
+ fetchCapabilities?: boolean;
18
25
  }
19
26
  /**
20
27
  * Configuration options to construct the sublayers of a WMS layer.
@@ -1 +1 @@
1
- {"version":3,"file":"WMSLayer.js","sources":["WMSLayer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport type { Options as WMSSourceOptions } from \"ol/source/ImageWMS\";\nimport { WMSLayerImpl } from \"../../model/layers/WMSLayerImpl\";\nimport type {\n LayerBaseConfig,\n SublayersCollection,\n LayerConfig,\n LayerBaseType,\n SublayerBaseType\n} from \"./base\";\n\n/**\n * Configuration options to construct a WMS layer.\n */\nexport interface WMSLayerConfig extends LayerConfig {\n /** URL of the WMS service. */\n url: string;\n\n /** Configures the layer's sublayers. */\n sublayers?: WMSSublayerConfig[];\n\n /**\n * Additional source options for the layer's WMS source.\n *\n * NOTE: These options are intended for advanced configuration:\n * the WMS Layer manages some of the OpenLayers source options itself.\n */\n sourceOptions?: Partial<WMSSourceOptions>;\n}\n\n/**\n * Configuration options to construct the sublayers of a WMS layer.\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/** Represents a WMS layer. */\nexport interface WMSLayer extends LayerBaseType {\n readonly type: \"wms\";\n\n readonly sublayers: SublayersCollection<WMSSublayer>;\n readonly layers: undefined;\n\n /** The URL of the WMS service that was used during layer construction. */\n readonly url: string;\n}\n\n/** Represents a WMS sublayer */\nexport interface WMSSublayer extends SublayerBaseType {\n readonly type: \"wms-sublayer\";\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 readonly name: string | undefined;\n}\n\n/**\n * Constructor for {@link WMSLayer}.\n */\nexport interface WMSLayerConstructor {\n prototype: WMSLayer;\n\n /** Creates a new {@link WMSLayer}. */\n new (config: WMSLayerConfig): WMSLayer;\n}\n\nexport const WMSLayer: WMSLayerConstructor = WMSLayerImpl;\n"],"names":[],"mappings":";;AA6EO,MAAM,QAAgC,GAAA;;;;"}
1
+ {"version":3,"file":"WMSLayer.js","sources":["WMSLayer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport type { Options as WMSSourceOptions } from \"ol/source/ImageWMS\";\nimport { WMSLayerImpl } from \"../../model/layers/WMSLayerImpl\";\nimport type {\n LayerBaseConfig,\n SublayersCollection,\n LayerConfig,\n LayerBaseType,\n SublayerBaseType\n} from \"./base\";\n\n/**\n * Configuration options to construct a WMS layer.\n */\nexport interface WMSLayerConfig extends LayerConfig {\n /** URL of the WMS service. */\n url: string;\n\n /** Configures the layer's sublayers. */\n sublayers?: WMSSublayerConfig[];\n\n /**\n * Additional source options for the layer's WMS source.\n *\n * NOTE: These options are intended for advanced configuration:\n * the WMS Layer manages some of the OpenLayers source options itself.\n */\n sourceOptions?: Partial<WMSSourceOptions>;\n\n /**\n * Whether to automatically fetch capabilities from the service when needed (default: `true`).\n *\n * Setting this to `false` can be useful as a performance optimization when capabilities are not really required by the application.\n * Note that this will disable some features of the WMS layer: for example, the legend URL will not be available.\n */\n fetchCapabilities?: boolean;\n}\n\n/**\n * Configuration options to construct the sublayers of a WMS layer.\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/** Represents a WMS layer. */\nexport interface WMSLayer extends LayerBaseType {\n readonly type: \"wms\";\n\n readonly sublayers: SublayersCollection<WMSSublayer>;\n readonly layers: undefined;\n\n /** The URL of the WMS service that was used during layer construction. */\n readonly url: string;\n}\n\n/** Represents a WMS sublayer */\nexport interface WMSSublayer extends SublayerBaseType {\n readonly type: \"wms-sublayer\";\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 readonly name: string | undefined;\n}\n\n/**\n * Constructor for {@link WMSLayer}.\n */\nexport interface WMSLayerConstructor {\n prototype: WMSLayer;\n\n /** Creates a new {@link WMSLayer}. */\n new (config: WMSLayerConfig): WMSLayer;\n}\n\nexport const WMSLayer: WMSLayerConstructor = WMSLayerImpl;\n"],"names":[],"mappings":";;AAqFO,MAAM,QAAgC,GAAA;;;;"}
@@ -1,11 +1,11 @@
1
1
  import type { EventSource } from "@open-pioneer/core";
2
2
  import type OlBaseLayer from "ol/layer/Base";
3
3
  import type { MapModel } from "../MapModel";
4
- import type { LayerRetrievalOptions } from "../shared";
4
+ import type { LayerRetrievalOptions, RecursiveRetrievalOptions } from "../shared";
5
+ import type { GroupLayer, GroupLayerCollection } from "./GroupLayer";
5
6
  import type { SimpleLayer } from "./SimpleLayer";
6
7
  import type { WMSLayer, WMSSublayer } from "./WMSLayer";
7
8
  import type { WMTSLayer } from "./WMTSLayer";
8
- import type { GroupLayer, GroupLayerCollection } from "./GroupLayer";
9
9
  /** Events emitted by the {@link Layer} and other layer types. */
10
10
  export interface LayerBaseEvents {
11
11
  "destroy": void;
@@ -81,7 +81,9 @@ export interface AnyLayerBaseType<AdditionalEvents = {}> extends EventSource<Lay
81
81
  */
82
82
  readonly visible: boolean;
83
83
  /**
84
- * LegendURL from the service capabilities, if available.
84
+ * Legend URL from the service capabilities, if available.
85
+ *
86
+ * Note: this property may be expanded upon in the future, e.g. to support more variants than just image URLs.
85
87
  */
86
88
  readonly legend: string | undefined;
87
89
  /**
@@ -216,6 +218,15 @@ export interface SublayersCollection<SublayerType = Sublayer> extends ChildrenCo
216
218
  * Returns the child sublayers in this collection.
217
219
  */
218
220
  getSublayers(options?: LayerRetrievalOptions): SublayerType[];
221
+ /**
222
+ * Returns a list of all layers in the collection, including all children (recursively).
223
+ *
224
+ * > Note: This includes base layers by default (see `options.filter`).
225
+ * > Use the `"base"` or `"operational"` short hand values to filter by base layer or operational layers.
226
+ * >
227
+ * > If the collection contains many, deeply nested sublayers, this function could potentially be expensive.
228
+ */
229
+ getRecursiveLayers(options?: RecursiveRetrievalOptions): Sublayer[];
219
230
  }
220
231
  /**
221
232
  * Union type for all layers (extending {@link LayerBaseType})
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","sources":["base.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport type { EventSource } from \"@open-pioneer/core\";\nimport type OlBaseLayer from \"ol/layer/Base\";\nimport type { MapModel } from \"../MapModel\";\nimport type { LayerRetrievalOptions } from \"../shared\";\nimport type { SimpleLayer } from \"./SimpleLayer\";\nimport type { WMSLayer, WMSSublayer } from \"./WMSLayer\";\nimport type { WMTSLayer } from \"./WMTSLayer\";\nimport type { GroupLayer, GroupLayerCollection } from \"./GroupLayer\";\n\n/** Events emitted by the {@link Layer} and other layer types. */\nexport interface LayerBaseEvents {\n \"destroy\": void;\n}\n\n/** The load state of a layer. */\nexport type LayerLoadState = \"not-loaded\" | \"loading\" | \"loaded\" | \"error\";\n\n/** Custom function to check the state of a layer and returning a \"loaded\" or \"error\". */\nexport type HealthCheckFunction = (layer: Layer) => Promise<\"loaded\" | \"error\">;\n\n/**\n * Configuration options supported by all layer types (layers and sublayers).\n */\nexport interface LayerBaseConfig {\n /**\n * The unique id of this layer.\n * Defaults to a generated id.\n */\n id?: string;\n\n /**\n * The human-readable title of this layer.\n */\n title: string;\n\n /**\n * The human-readable description of this layer.\n * Defaults to an empty string.\n */\n description?: string;\n\n /**\n * Whether this layer should initially be visible.\n * Defaults to `true`.\n */\n visible?: boolean;\n\n /**\n * Additional attributes for this layer.\n * These can be arbitrary values.\n */\n attributes?: Record<string | symbol, unknown>;\n}\n\n/**\n * Interface shared by all layer types (operational layers and sublayers).\n *\n * Instances of this interface cannot be constructed directly; use a real layer\n * class such as {@link SimpleLayer} instead.\n */\nexport interface AnyLayerBaseType<AdditionalEvents = {}>\n extends EventSource<LayerBaseEvents & AdditionalEvents> {\n /**\n * Identifies the type of this layer.\n */\n readonly type: AnyLayerTypes;\n\n /** The map this layer belongs to. */\n readonly map: MapModel;\n\n /**\n * The direct parent of this layer instance, used for sublayers or for layers in a group layer.\n *\n * The property shall be undefined if the layer is not a sublayer or member of a group layer.\n */\n readonly parent: AnyLayer | undefined;\n\n /**\n * The unique id of this layer within its map model.\n *\n * NOTE: layer ids may not be globally unique: layers that belong\n * to different map models may have the same id.\n */\n readonly id: string;\n\n /** The human-readable title of this layer. */\n readonly title: string;\n\n /** The human-readable description of this layer. May be empty. */\n readonly description: string;\n\n /**\n * Whether the layer is visible or not.\n *\n * NOTE: The model's visible state may do more than influence the raw OpenLayers's visibility property.\n * Future versions may completely remove invisible layers from the OpenLayer's map under some circumstances.\n */\n readonly visible: boolean;\n\n /**\n * LegendURL from the service capabilities, if available.\n */\n readonly legend: string | undefined;\n\n /**\n * The direct children of this layer.\n *\n * The children may either be a set of operational layers (e.g. for a group layer) or a set of sublayers, or `undefined`.\n *\n * See also {@link layers} and {@link sublayers}.\n */\n readonly children: ChildrenCollection<AnyLayer> | undefined;\n\n /**\n * If this layer is a group layer this property contains a collection of all layers that a members to the group.\n *\n * The property shall be `undefined` if it is not a group layer.\n *\n * The properties `layers` and `sublayers` are mutually exclusive.\n */\n readonly layers: GroupLayerCollection | undefined;\n\n /**\n * The collection of child sublayers for this layer. Sublayers are layers that cannot exist without an appropriate parent layer.\n *\n * Layers that can never have any sublayers may not have a `sublayers` collection.\n *\n * The properties `layers` and `sublayers` are mutually exclusive.\n */\n readonly sublayers: SublayersCollection | undefined;\n\n /**\n * Additional attributes associated with this layer.\n */\n readonly attributes: Readonly<Record<string | symbol, unknown>>;\n\n /**\n * Updates the title of this layer.\n */\n setTitle(newTitle: string): void;\n\n /**\n * Updates the description of this layer.\n */\n setDescription(newDescription: string): void;\n\n /**\n * Updates the visibility of this layer to the new value.\n *\n * NOTE: The visibility of base layers cannot be changed through this method.\n * Call {@link LayerCollection.activateBaseLayer} instead.\n */\n setVisible(newVisibility: boolean): void;\n\n /**\n * Updates the attributes of this layer.\n * Values in `newAttributes` are merged into the existing ones (i.e. via `Object.assign`).\n */\n updateAttributes(newAttributes: Record<string | symbol, unknown>): void;\n\n /**\n * Deletes the attribute of this layer.\n */\n deleteAttribute(deleteAttribute: string | symbol): void;\n}\n\n/**\n * Configuration options supported by all operational layer types.\n */\nexport interface LayerConfig extends LayerBaseConfig {\n /**\n * Whether this layer is a base layer or not.\n * Only one base layer can be active at a time.\n *\n * Defaults to `false`.\n */\n isBaseLayer?: boolean;\n\n /**\n * Optional property to check the availability of the layer.\n * It is possible to provide either a URL which indicates the state of the service (2xx response meaning \"ok\")\n * or a {@link HealthCheckFunction} performing a custom check and returning the state.\n */\n healthCheck?: string | HealthCheckFunction;\n}\n\n/**\n * Represents an operational layer in the map.\n *\n * Instances of this interface cannot be constructed directly; use a real layer\n * class such as {@link SimpleLayer} instead.\n */\nexport interface LayerBaseType<AdditionalEvents = {}> extends AnyLayerBaseType<AdditionalEvents> {\n /**\n * Identifies the type of this layer.\n */\n readonly type: LayerTypes;\n\n /**\n * The load state of a layer.\n */\n readonly loadState: LayerLoadState;\n\n /**\n * The raw OpenLayers layer.\n */\n readonly olLayer: OlBaseLayer;\n\n /**\n * True if this layer is a base layer.\n *\n * Only one base layer can be visible at a time.\n */\n readonly isBaseLayer: boolean;\n}\n\n/**\n * Represents a sublayer of another layer.\n */\nexport interface SublayerBaseType extends AnyLayerBaseType {\n /**\n * Identifies the type of this sublayer.\n */\n readonly type: SublayerTypes;\n\n /**\n * The direct parent of this layer instance.\n * This can either be the parent layer or another sublayer.\n */\n readonly parent: AnyLayer;\n\n /**\n * The parent layer that owns this sublayer.\n */\n readonly parentLayer: Layer;\n}\n\n/**\n * Contains the children of a layer.\n */\nexport interface ChildrenCollection<LayerType> {\n /**\n * Returns the items in this collection.\n */\n getItems(options?: LayerRetrievalOptions): LayerType[];\n}\n\n/**\n * Contains the sublayers that belong to a {@link Layer} or {@link Sublayer}.\n */\nexport interface SublayersCollection<SublayerType = Sublayer>\n extends ChildrenCollection<SublayerType> {\n /**\n * Returns the child sublayers in this collection.\n */\n getSublayers(options?: LayerRetrievalOptions): SublayerType[];\n}\n\n/**\n * Union type for all layers (extending {@link LayerBaseType})\n */\nexport type Layer = SimpleLayer | WMSLayer | WMTSLayer | GroupLayer;\nexport type LayerTypes = Layer[\"type\"];\n\n/**\n * Union type for all sublayers (extending {@link SublayerBaseType}\n */\nexport type Sublayer = WMSSublayer;\nexport type SublayerTypes = Sublayer[\"type\"];\n\n/**\n * Union for all types of layers\n */\nexport type AnyLayer = Layer | Sublayer;\nexport type AnyLayerTypes = AnyLayer[\"type\"];\n\n/**\n * Type guard for checking if the layer is a {@link Sublayer}.\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 */\nexport function isLayer(layer: AnyLayer): layer is Layer {\n return \"olLayer\" in layer;\n}\n"],"names":[],"mappings":"AAyRO,SAAS,WAAW,KAAoC,EAAA;AAC3D,EAAA,OAAO,aAAiB,IAAA,KAAA,CAAA;AAC5B,CAAA;AAKO,SAAS,QAAQ,KAAiC,EAAA;AACrD,EAAA,OAAO,SAAa,IAAA,KAAA,CAAA;AACxB;;;;"}
1
+ {"version":3,"file":"base.js","sources":["base.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport type { EventSource } from \"@open-pioneer/core\";\nimport type OlBaseLayer from \"ol/layer/Base\";\nimport type { MapModel } from \"../MapModel\";\nimport type { LayerRetrievalOptions, RecursiveRetrievalOptions } from \"../shared\";\nimport type { GroupLayer, GroupLayerCollection } from \"./GroupLayer\";\nimport type { SimpleLayer } from \"./SimpleLayer\";\nimport type { WMSLayer, WMSSublayer } from \"./WMSLayer\";\nimport type { WMTSLayer } from \"./WMTSLayer\";\n\n/** Events emitted by the {@link Layer} and other layer types. */\nexport interface LayerBaseEvents {\n \"destroy\": void;\n}\n\n/** The load state of a layer. */\nexport type LayerLoadState = \"not-loaded\" | \"loading\" | \"loaded\" | \"error\";\n\n/** Custom function to check the state of a layer and returning a \"loaded\" or \"error\". */\nexport type HealthCheckFunction = (layer: Layer) => Promise<\"loaded\" | \"error\">;\n\n/**\n * Configuration options supported by all layer types (layers and sublayers).\n */\nexport interface LayerBaseConfig {\n /**\n * The unique id of this layer.\n * Defaults to a generated id.\n */\n id?: string;\n\n /**\n * The human-readable title of this layer.\n */\n title: string;\n\n /**\n * The human-readable description of this layer.\n * Defaults to an empty string.\n */\n description?: string;\n\n /**\n * Whether this layer should initially be visible.\n * Defaults to `true`.\n */\n visible?: boolean;\n\n /**\n * Additional attributes for this layer.\n * These can be arbitrary values.\n */\n attributes?: Record<string | symbol, unknown>;\n}\n\n/**\n * Interface shared by all layer types (operational layers and sublayers).\n *\n * Instances of this interface cannot be constructed directly; use a real layer\n * class such as {@link SimpleLayer} instead.\n */\nexport interface AnyLayerBaseType<AdditionalEvents = {}>\n extends EventSource<LayerBaseEvents & AdditionalEvents> {\n /**\n * Identifies the type of this layer.\n */\n readonly type: AnyLayerTypes;\n\n /** The map this layer belongs to. */\n readonly map: MapModel;\n\n /**\n * The direct parent of this layer instance, used for sublayers or for layers in a group layer.\n *\n * The property shall be undefined if the layer is not a sublayer or member of a group layer.\n */\n readonly parent: AnyLayer | undefined;\n\n /**\n * The unique id of this layer within its map model.\n *\n * NOTE: layer ids may not be globally unique: layers that belong\n * to different map models may have the same id.\n */\n readonly id: string;\n\n /** The human-readable title of this layer. */\n readonly title: string;\n\n /** The human-readable description of this layer. May be empty. */\n readonly description: string;\n\n /**\n * Whether the layer is visible or not.\n *\n * NOTE: The model's visible state may do more than influence the raw OpenLayers's visibility property.\n * Future versions may completely remove invisible layers from the OpenLayer's map under some circumstances.\n */\n readonly visible: boolean;\n\n /**\n * Legend URL from the service capabilities, if available.\n *\n * Note: this property may be expanded upon in the future, e.g. to support more variants than just image URLs.\n */\n readonly legend: string | undefined;\n\n /**\n * The direct children of this layer.\n *\n * The children may either be a set of operational layers (e.g. for a group layer) or a set of sublayers, or `undefined`.\n *\n * See also {@link layers} and {@link sublayers}.\n */\n readonly children: ChildrenCollection<AnyLayer> | undefined;\n\n /**\n * If this layer is a group layer this property contains a collection of all layers that a members to the group.\n *\n * The property shall be `undefined` if it is not a group layer.\n *\n * The properties `layers` and `sublayers` are mutually exclusive.\n */\n readonly layers: GroupLayerCollection | undefined;\n\n /**\n * The collection of child sublayers for this layer. Sublayers are layers that cannot exist without an appropriate parent layer.\n *\n * Layers that can never have any sublayers may not have a `sublayers` collection.\n *\n * The properties `layers` and `sublayers` are mutually exclusive.\n */\n readonly sublayers: SublayersCollection | undefined;\n\n /**\n * Additional attributes associated with this layer.\n */\n readonly attributes: Readonly<Record<string | symbol, unknown>>;\n\n /**\n * Updates the title of this layer.\n */\n setTitle(newTitle: string): void;\n\n /**\n * Updates the description of this layer.\n */\n setDescription(newDescription: string): void;\n\n /**\n * Updates the visibility of this layer to the new value.\n *\n * NOTE: The visibility of base layers cannot be changed through this method.\n * Call {@link LayerCollection.activateBaseLayer} instead.\n */\n setVisible(newVisibility: boolean): void;\n\n /**\n * Updates the attributes of this layer.\n * Values in `newAttributes` are merged into the existing ones (i.e. via `Object.assign`).\n */\n updateAttributes(newAttributes: Record<string | symbol, unknown>): void;\n\n /**\n * Deletes the attribute of this layer.\n */\n deleteAttribute(deleteAttribute: string | symbol): void;\n}\n\n/**\n * Configuration options supported by all operational layer types.\n */\nexport interface LayerConfig extends LayerBaseConfig {\n /**\n * Whether this layer is a base layer or not.\n * Only one base layer can be active at a time.\n *\n * Defaults to `false`.\n */\n isBaseLayer?: boolean;\n\n /**\n * Optional property to check the availability of the layer.\n * It is possible to provide either a URL which indicates the state of the service (2xx response meaning \"ok\")\n * or a {@link HealthCheckFunction} performing a custom check and returning the state.\n */\n healthCheck?: string | HealthCheckFunction;\n}\n\n/**\n * Represents an operational layer in the map.\n *\n * Instances of this interface cannot be constructed directly; use a real layer\n * class such as {@link SimpleLayer} instead.\n */\nexport interface LayerBaseType<AdditionalEvents = {}> extends AnyLayerBaseType<AdditionalEvents> {\n /**\n * Identifies the type of this layer.\n */\n readonly type: LayerTypes;\n\n /**\n * The load state of a layer.\n */\n readonly loadState: LayerLoadState;\n\n /**\n * The raw OpenLayers layer.\n */\n readonly olLayer: OlBaseLayer;\n\n /**\n * True if this layer is a base layer.\n *\n * Only one base layer can be visible at a time.\n */\n readonly isBaseLayer: boolean;\n}\n\n/**\n * Represents a sublayer of another layer.\n */\nexport interface SublayerBaseType extends AnyLayerBaseType {\n /**\n * Identifies the type of this sublayer.\n */\n readonly type: SublayerTypes;\n\n /**\n * The direct parent of this layer instance.\n * This can either be the parent layer or another sublayer.\n */\n readonly parent: AnyLayer;\n\n /**\n * The parent layer that owns this sublayer.\n */\n readonly parentLayer: Layer;\n}\n\n/**\n * Contains the children of a layer.\n */\nexport interface ChildrenCollection<LayerType> {\n /**\n * Returns the items in this collection.\n */\n getItems(options?: LayerRetrievalOptions): LayerType[];\n}\n\n/**\n * Contains the sublayers that belong to a {@link Layer} or {@link Sublayer}.\n */\nexport interface SublayersCollection<SublayerType = Sublayer>\n extends ChildrenCollection<SublayerType> {\n /**\n * Returns the child sublayers in this collection.\n */\n getSublayers(options?: LayerRetrievalOptions): SublayerType[];\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}\n\n/**\n * Union type for all layers (extending {@link LayerBaseType})\n */\nexport type Layer = SimpleLayer | WMSLayer | WMTSLayer | GroupLayer;\nexport type LayerTypes = Layer[\"type\"];\n\n/**\n * Union type for all sublayers (extending {@link SublayerBaseType}\n */\nexport type Sublayer = WMSSublayer;\nexport type SublayerTypes = Sublayer[\"type\"];\n\n/**\n * Union for all types of layers\n */\nexport type AnyLayer = Layer | Sublayer;\nexport type AnyLayerTypes = AnyLayer[\"type\"];\n\n/**\n * Type guard for checking if the layer is a {@link Sublayer}.\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 */\nexport function isLayer(layer: AnyLayer): layer is Layer {\n return \"olLayer\" in layer;\n}\n"],"names":[],"mappings":"AAqSO,SAAS,WAAW,KAAoC,EAAA;AAC3D,EAAA,OAAO,aAAiB,IAAA,KAAA,CAAA;AAC5B,CAAA;AAKO,SAAS,QAAQ,KAAiC,EAAA;AACrD,EAAA,OAAO,SAAa,IAAA,KAAA,CAAA;AACxB;;;;"}
package/api/shared.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { AnyLayer } from "./layers";
1
2
  /** These options can be used by some APIs returning an array of layers (or sublayers). */
2
3
  export interface LayerRetrievalOptions {
3
4
  /**
@@ -8,3 +9,11 @@ export interface LayerRetrievalOptions {
8
9
  */
9
10
  sortByDisplayOrder?: boolean;
10
11
  }
12
+ /** These options can be used when recursively retrieving layers from a collection. */
13
+ export interface RecursiveRetrievalOptions extends LayerRetrievalOptions {
14
+ /**
15
+ * Optional filter function to determine whether a layer should be included in the result.
16
+ * Return `false` to exclude a layer (and all its children) from the result.
17
+ */
18
+ filter?: (layer: AnyLayer) => boolean;
19
+ }
@@ -20,7 +20,12 @@ export declare class LayerCollectionImpl implements LayerCollection {
20
20
  getActiveBaseLayer(): Layer | undefined;
21
21
  activateBaseLayer(id: string | undefined): boolean;
22
22
  getOperationalLayers(options?: LayerRetrievalOptions): Layer[];
23
+ getItems(options?: LayerRetrievalOptions): Layer[];
24
+ getLayers(options?: LayerRetrievalOptions): Layer[];
23
25
  getAllLayers(options?: LayerRetrievalOptions): Layer[];
26
+ getRecursiveLayers({ filter, sortByDisplayOrder }?: LayerRetrievalOptions & {
27
+ filter?: "base" | "operational" | ((layer: AnyLayer) => boolean);
28
+ }): AnyLayer[];
24
29
  getLayerById(id: string): AnyLayer | undefined;
25
30
  removeLayerById(id: string): void;
26
31
  getLayerByRawInstance(layer: OlBaseLayer): Layer | undefined;
@@ -1,6 +1,7 @@
1
1
  import { reactiveSet, reactive, batch } from '@conterra/reactivity-core';
2
2
  import { createLogger } from '@open-pioneer/core';
3
3
  import { AbstractLayer } from './AbstractLayer.js';
4
+ import { getRecursiveLayers } from './getRecursiveLayers.js';
4
5
 
5
6
  const LOG = createLogger("map:LayerCollection");
6
7
  const BASE_LAYER_Z = 0;
@@ -61,15 +62,46 @@ class LayerCollectionImpl {
61
62
  return true;
62
63
  }
63
64
  getOperationalLayers(options) {
64
- return this.getAllLayers(options).filter((layer) => !layer.isBaseLayer);
65
+ return this.getLayers(options).filter((layer) => !layer.isBaseLayer);
65
66
  }
66
- getAllLayers(options) {
67
+ getItems(options) {
68
+ return this.getLayers(options);
69
+ }
70
+ getLayers(options) {
67
71
  const layers = Array.from(this.#topLevelLayers.values());
68
72
  if (options?.sortByDisplayOrder) {
69
73
  sortLayersByDisplayOrder(layers);
70
74
  }
71
75
  return layers;
72
76
  }
77
+ getAllLayers(options) {
78
+ return this.getLayers(options);
79
+ }
80
+ getRecursiveLayers({
81
+ filter,
82
+ sortByDisplayOrder
83
+ } = {}) {
84
+ let filterFunc;
85
+ if (typeof filter === "function") {
86
+ filterFunc = filter;
87
+ } else if (typeof filter === "string") {
88
+ const filterType = filter;
89
+ const topLevelFilter = (layer) => {
90
+ return filterType === "base" ? layer.isBaseLayer : !layer.isBaseLayer;
91
+ };
92
+ filterFunc = (layer) => {
93
+ if (!layer.parent && "isBaseLayer" in layer) {
94
+ return topLevelFilter(layer);
95
+ }
96
+ return true;
97
+ };
98
+ }
99
+ return getRecursiveLayers({
100
+ from: this,
101
+ filter: filterFunc,
102
+ sortByDisplayOrder
103
+ });
104
+ }
73
105
  getLayerById(id) {
74
106
  return this.#layersById.get(id);
75
107
  }
@@ -1 +1 @@
1
- {"version":3,"file":"LayerCollectionImpl.js","sources":["LayerCollectionImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { batch, reactive, reactiveSet } from \"@conterra/reactivity-core\";\nimport { createLogger } from \"@open-pioneer/core\";\nimport OlBaseLayer from \"ol/layer/Base\";\nimport { Layer, LayerCollection, LayerRetrievalOptions, AnyLayer, Sublayer } from \"../api\";\nimport { AbstractLayer } from \"./AbstractLayer\";\nimport { AbstractLayerBase } from \"./AbstractLayerBase\";\nimport { MapModelImpl } from \"./MapModelImpl\";\n\nconst LOG = createLogger(\"map:LayerCollection\");\n\nconst BASE_LAYER_Z = 0;\nconst OPERATION_LAYER_INITIAL_Z = 1;\n\ntype LayerType = AbstractLayer & Layer;\ntype LayerBaseType = (AbstractLayerBase & Layer) | (AbstractLayerBase & Sublayer);\n\n/**\n * Z index for layers that should always be rendered on top of all other layers.\n * Note that this is an internal, unstable property!\n *\n * @internal\n */\nexport const TOPMOST_LAYER_Z = 9999999;\n\n/**\n * Manages the (top-level) content of the map.\n */\nexport class LayerCollectionImpl implements LayerCollection {\n #map: MapModelImpl;\n\n /** Top level layers (base layers, operational layers). No sublayers. */\n #topLevelLayers = reactiveSet<LayerType>();\n\n /** Index of _all_ layer instances, including sublayers. */\n #layersById = new Map<string, LayerBaseType>();\n\n /** Reverse index of _all_ layers that have an associated OpenLayers layer. */\n #layersByOlLayer: WeakMap<OlBaseLayer, LayerType> = new WeakMap();\n\n /** Currently active base layer. */\n #activeBaseLayer = reactive<LayerType>();\n\n /** next z-index for operational layer. currently just auto-increments. */\n #nextIndex = OPERATION_LAYER_INITIAL_Z;\n\n constructor(map: MapModelImpl) {\n this.#map = map;\n }\n\n destroy() {\n // Collection is destroyed together with the map, there is no need to clean up the olMap\n for (const layer of this.#layersById.values()) {\n layer.destroy();\n }\n this.#topLevelLayers.clear();\n this.#layersById.clear();\n this.#activeBaseLayer.value = undefined;\n }\n\n addLayer(layer: Layer): void {\n checkLayerInstance(layer);\n\n layer.__attachToMap(this.#map);\n this.#addLayer(layer);\n }\n\n getBaseLayers(): Layer[] {\n return this.getAllLayers().filter((layer) => layer.isBaseLayer);\n }\n\n getActiveBaseLayer(): Layer | undefined {\n return this.#activeBaseLayer.value;\n }\n\n activateBaseLayer(id: string | undefined): boolean {\n let newBaseLayer = undefined;\n if (id != null) {\n newBaseLayer = this.#layersById.get(id);\n if (!(newBaseLayer instanceof AbstractLayer)) {\n LOG.warn(`Cannot activate base layer '${id}: layer has an invalid type.'`);\n return false;\n }\n if (!newBaseLayer) {\n LOG.warn(`Cannot activate base layer '${id}': layer is unknown.`);\n return false;\n }\n if (!newBaseLayer.isBaseLayer) {\n LOG.warn(`Cannot activate base layer '${id}': layer is not a base layer.`);\n return false;\n }\n }\n\n this.#updateBaseLayer(newBaseLayer);\n return true;\n }\n\n getOperationalLayers(options?: LayerRetrievalOptions): Layer[] {\n return this.getAllLayers(options).filter((layer) => !layer.isBaseLayer);\n }\n\n getAllLayers(options?: LayerRetrievalOptions): Layer[] {\n const layers = Array.from(this.#topLevelLayers.values());\n if (options?.sortByDisplayOrder) {\n sortLayersByDisplayOrder(layers);\n }\n return layers;\n }\n\n getLayerById(id: string): AnyLayer | undefined {\n return this.#layersById.get(id);\n }\n\n removeLayerById(id: string): void {\n const model = this.#layersById.get(id);\n if (!model) {\n LOG.isDebug() && LOG.debug(`Cannot remove layer '${id}': layer is unknown.`);\n return;\n }\n\n this.#removeLayer(model);\n }\n\n getLayerByRawInstance(layer: OlBaseLayer): Layer | undefined {\n return this.#layersByOlLayer?.get(layer);\n }\n\n /**\n * Adds the given layer to the map and all relevant indices.\n */\n #addLayer(model: LayerType) {\n this.#indexLayer(model);\n\n const olLayer = model.olLayer;\n if (model.isBaseLayer) {\n olLayer.setZIndex(BASE_LAYER_Z);\n if (!this.#activeBaseLayer.value && model.visible) {\n this.#updateBaseLayer(model);\n } else {\n model.__setVisible(false);\n }\n } else {\n olLayer.setZIndex(this.#nextIndex++);\n model.__setVisible(model.visible);\n }\n\n this.#topLevelLayers.add(model);\n this.#map.olMap.addLayer(olLayer);\n }\n\n /**\n * Removes the given layer from the map and all relevant indices.\n * The layer will be destroyed.\n */\n #removeLayer(model: LayerType | LayerBaseType) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if (!this.#topLevelLayers.has(model as any)) {\n LOG.warn(\n `Cannot remove layer '${model.id}': only top level layers can be removed at this time.`\n );\n return;\n }\n\n if (!(model instanceof AbstractLayer)) {\n throw new Error(\n `Internal error: expected top level layer to be an instance of AbstractLayer.`\n );\n }\n\n this.#map.olMap.removeLayer(model.olLayer);\n this.#topLevelLayers.delete(model);\n this.#unIndexLayer(model);\n if (this.#activeBaseLayer.value === model) {\n const newBaselayer = this.getBaseLayers()[0];\n if (newBaselayer) {\n checkLayerInstance(newBaselayer);\n }\n this.#updateBaseLayer(newBaselayer);\n }\n model.destroy();\n }\n\n #updateBaseLayer(model: LayerType | undefined) {\n if (this.#activeBaseLayer.value === model) {\n return;\n }\n\n if (LOG.isDebug()) {\n const getId = (model: AbstractLayer | undefined) => {\n return model ? `'${model.id}'` : undefined;\n };\n\n LOG.debug(\n `Switching active base layer from ${getId(this.#activeBaseLayer.value)} to ${getId(model)}`\n );\n }\n\n batch(() => {\n this.#activeBaseLayer.value?.__setVisible(false);\n this.#activeBaseLayer.value = model;\n model?.__setVisible(true);\n });\n }\n\n /**\n * Index the layer and all its children.\n */\n #indexLayer(model: LayerType) {\n // layer id -> layer (or sublayer)\n const registrations: [string, OlBaseLayer | undefined][] = [];\n const visit = (model: LayerType | (AbstractLayerBase & Sublayer)) => {\n const id = model.id;\n const olLayer = \"olLayer\" in model ? model.olLayer : undefined;\n if (this.#layersById.has(id)) {\n throw new Error(\n `Layer id '${id}' is not unique. Either assign a unique id yourself ` +\n `or skip configuring 'id' for an automatically generated id.`\n );\n }\n if (olLayer && this.#layersByOlLayer.has(olLayer)) {\n throw new Error(`OlLayer used by layer '${id}' has already been used in map.`);\n }\n\n // Register this layer with the maps.\n this.#layersById.set(id, model);\n if (olLayer) {\n this.#layersByOlLayer.set(olLayer, model as LayerType); // ol is present --> not a sublayer\n }\n registrations.push([id, olLayer]);\n\n // Recurse into nested children.\n for (const layer of model.layers?.__getRawLayers() ?? []) {\n visit(layer);\n }\n for (const sublayer of model.sublayers?.__getRawSublayers() ?? []) {\n visit(sublayer);\n }\n };\n\n try {\n visit(model);\n } catch (e) {\n // If any error happens, undo the indexing.\n // This way we don't leave a partially indexed layer tree behind.\n for (const [id, olLayer] of registrations) {\n this.#layersById.delete(id);\n if (olLayer) {\n this.#layersByOlLayer.delete(olLayer);\n }\n }\n throw e;\n }\n }\n\n /**\n * Removes index entries for the given layer and all its children.\n */\n #unIndexLayer(model: AbstractLayer) {\n const visit = (model: AbstractLayer | AbstractLayerBase) => {\n if (\"olLayer\" in model) {\n this.#layersByOlLayer.delete(model.olLayer);\n }\n this.#layersById.delete(model.id);\n\n for (const layer of model.layers?.__getRawLayers() ?? []) {\n visit(layer);\n }\n\n for (const sublayer of model.sublayers?.__getRawSublayers() ?? []) {\n visit(sublayer);\n }\n };\n visit(model);\n }\n}\n\nfunction sortLayersByDisplayOrder(layers: Layer[]) {\n layers.sort((left, right) => {\n // currently layers are added with increasing z-index (base layers: 0), so\n // ordering by z-index is automatically the correct display order.\n const leftZ = left.olLayer.getZIndex() ?? 1;\n const rightZ = right.olLayer.getZIndex() ?? 1;\n return leftZ - rightZ;\n });\n}\n\nfunction checkLayerInstance(object: Layer): asserts object is Layer & AbstractLayer {\n if (!(object instanceof AbstractLayer)) {\n throw new Error(\n `Layer is not a valid layer instance. Use one of the classes provided by the map package instead.`\n );\n }\n}\n"],"names":["model"],"mappings":";;;;AAUA,MAAM,GAAA,GAAM,aAAa,qBAAqB,CAAA,CAAA;AAE9C,MAAM,YAAe,GAAA,CAAA,CAAA;AACrB,MAAM,yBAA4B,GAAA,CAAA,CAAA;AAW3B,MAAM,eAAkB,GAAA,QAAA;AAKxB,MAAM,mBAA+C,C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AAOA,CAAAA,MAAAA,CAAM,EAAE,CAAA,CAAA;AAEhC,MAAA,KAAA,MAAW,SAASA,MAAM,CAAA,MAAA,EAAQ,cAAe,EAAA,IAAK,EAAI,EAAA;AACtD,QAAA,KAAA,CAAM,KAAK,CAAA,CAAA;AAAA,OACf;AAEA,MAAA,KAAA,MAAW,YAAYA,MAAM,CAAA,SAAA,EAAW,iBAAkB,EAAA,IAAK,EAAI,EAAA;AAC/D,QAAA,KAAA,CAAM,QAAQ,CAAA,CAAA;AAAA,OAClB;AAAA,KACJ,CAAA;AACA,IAAA,KAAA,CAAM,KAAK,CAAA,CAAA;AAAA,GACf;AACJ,CAAA;AAEA,SAAS,yBAAyB,MAAiB,EAAA;AAC/C,EAAO,MAAA,CAAA,IAAA,CAAK,CAAC,IAAA,EAAM,KAAU,KAAA;AAGzB,IAAA,MAAM,KAAQ,GAAA,IAAA,CAAK,OAAQ,CAAA,SAAA,EAAe,IAAA,CAAA,CAAA;AAC1C,IAAA,MAAM,MAAS,GAAA,KAAA,CAAM,OAAQ,CAAA,SAAA,EAAe,IAAA,CAAA,CAAA;AAC5C,IAAA,OAAO,KAAQ,GAAA,MAAA,CAAA;AAAA,GAClB,CAAA,CAAA;AACL,CAAA;AAEA,SAAS,mBAAmB,MAAwD,EAAA;AAChF,EAAI,IAAA,EAAE,kBAAkB,aAAgB,CAAA,EAAA;AACpC,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,CAAA,gGAAA,CAAA;AAAA,KACJ,CAAA;AAAA,GACJ;AACJ;;;;"}
1
+ {"version":3,"file":"LayerCollectionImpl.js","sources":["LayerCollectionImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { batch, reactive, reactiveSet } from \"@conterra/reactivity-core\";\nimport { createLogger } from \"@open-pioneer/core\";\nimport OlBaseLayer from \"ol/layer/Base\";\nimport { Layer, LayerCollection, LayerRetrievalOptions, AnyLayer, Sublayer } from \"../api\";\nimport { AbstractLayer } from \"./AbstractLayer\";\nimport { AbstractLayerBase } from \"./AbstractLayerBase\";\nimport { MapModelImpl } from \"./MapModelImpl\";\nimport { getRecursiveLayers } from \"./getRecursiveLayers\";\n\nconst LOG = createLogger(\"map:LayerCollection\");\n\nconst BASE_LAYER_Z = 0;\nconst OPERATION_LAYER_INITIAL_Z = 1;\n\ntype LayerType = AbstractLayer & Layer;\ntype LayerBaseType = (AbstractLayerBase & Layer) | (AbstractLayerBase & Sublayer);\n\n/**\n * Z index for layers that should always be rendered on top of all other layers.\n * Note that this is an internal, unstable property!\n *\n * @internal\n */\nexport const TOPMOST_LAYER_Z = 9999999;\n\n/**\n * Manages the (top-level) content of the map.\n */\nexport class LayerCollectionImpl implements LayerCollection {\n #map: MapModelImpl;\n\n /** Top level layers (base layers, operational layers). No sublayers. */\n #topLevelLayers = reactiveSet<LayerType>();\n\n /** Index of _all_ layer instances, including sublayers. */\n #layersById = new Map<string, LayerBaseType>();\n\n /** Reverse index of _all_ layers that have an associated OpenLayers layer. */\n #layersByOlLayer: WeakMap<OlBaseLayer, LayerType> = new WeakMap();\n\n /** Currently active base layer. */\n #activeBaseLayer = reactive<LayerType>();\n\n /** next z-index for operational layer. currently just auto-increments. */\n #nextIndex = OPERATION_LAYER_INITIAL_Z;\n\n constructor(map: MapModelImpl) {\n this.#map = map;\n }\n\n destroy() {\n // Collection is destroyed together with the map, there is no need to clean up the olMap\n for (const layer of this.#layersById.values()) {\n layer.destroy();\n }\n this.#topLevelLayers.clear();\n this.#layersById.clear();\n this.#activeBaseLayer.value = undefined;\n }\n\n addLayer(layer: Layer): void {\n checkLayerInstance(layer);\n\n layer.__attachToMap(this.#map);\n this.#addLayer(layer);\n }\n\n getBaseLayers(): Layer[] {\n return this.getAllLayers().filter((layer) => layer.isBaseLayer);\n }\n\n getActiveBaseLayer(): Layer | undefined {\n return this.#activeBaseLayer.value;\n }\n\n activateBaseLayer(id: string | undefined): boolean {\n let newBaseLayer = undefined;\n if (id != null) {\n newBaseLayer = this.#layersById.get(id);\n if (!(newBaseLayer instanceof AbstractLayer)) {\n LOG.warn(`Cannot activate base layer '${id}: layer has an invalid type.'`);\n return false;\n }\n if (!newBaseLayer) {\n LOG.warn(`Cannot activate base layer '${id}': layer is unknown.`);\n return false;\n }\n if (!newBaseLayer.isBaseLayer) {\n LOG.warn(`Cannot activate base layer '${id}': layer is not a base layer.`);\n return false;\n }\n }\n\n this.#updateBaseLayer(newBaseLayer);\n return true;\n }\n\n getOperationalLayers(options?: LayerRetrievalOptions): Layer[] {\n return this.getLayers(options).filter((layer) => !layer.isBaseLayer);\n }\n\n getItems(options?: LayerRetrievalOptions): Layer[] {\n return this.getLayers(options);\n }\n\n getLayers(options?: LayerRetrievalOptions): Layer[] {\n const layers = Array.from(this.#topLevelLayers.values());\n if (options?.sortByDisplayOrder) {\n sortLayersByDisplayOrder(layers);\n }\n return layers;\n }\n\n getAllLayers(options?: LayerRetrievalOptions): Layer[] {\n return this.getLayers(options);\n }\n\n getRecursiveLayers({\n filter,\n sortByDisplayOrder\n }: LayerRetrievalOptions & {\n filter?: \"base\" | \"operational\" | ((layer: AnyLayer) => boolean);\n } = {}): AnyLayer[] {\n let filterFunc;\n if (typeof filter === \"function\") {\n filterFunc = filter;\n } else if (typeof filter === \"string\") {\n const filterType = filter;\n const topLevelFilter = (layer: Layer) => {\n return filterType === \"base\" ? layer.isBaseLayer : !layer.isBaseLayer;\n };\n filterFunc = (layer: AnyLayer) => {\n if (!layer.parent && \"isBaseLayer\" in layer) {\n return topLevelFilter(layer);\n }\n // For nested children, include them all.\n return true;\n };\n }\n\n return getRecursiveLayers({\n from: this,\n filter: filterFunc,\n sortByDisplayOrder\n });\n }\n\n getLayerById(id: string): AnyLayer | undefined {\n return this.#layersById.get(id);\n }\n\n removeLayerById(id: string): void {\n const model = this.#layersById.get(id);\n if (!model) {\n LOG.isDebug() && LOG.debug(`Cannot remove layer '${id}': layer is unknown.`);\n return;\n }\n\n this.#removeLayer(model);\n }\n\n getLayerByRawInstance(layer: OlBaseLayer): Layer | undefined {\n return this.#layersByOlLayer?.get(layer);\n }\n\n /**\n * Adds the given layer to the map and all relevant indices.\n */\n #addLayer(model: LayerType) {\n this.#indexLayer(model);\n\n const olLayer = model.olLayer;\n if (model.isBaseLayer) {\n olLayer.setZIndex(BASE_LAYER_Z);\n if (!this.#activeBaseLayer.value && model.visible) {\n this.#updateBaseLayer(model);\n } else {\n model.__setVisible(false);\n }\n } else {\n olLayer.setZIndex(this.#nextIndex++);\n model.__setVisible(model.visible);\n }\n\n this.#topLevelLayers.add(model);\n this.#map.olMap.addLayer(olLayer);\n }\n\n /**\n * Removes the given layer from the map and all relevant indices.\n * The layer will be destroyed.\n */\n #removeLayer(model: LayerType | LayerBaseType) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if (!this.#topLevelLayers.has(model as any)) {\n LOG.warn(\n `Cannot remove layer '${model.id}': only top level layers can be removed at this time.`\n );\n return;\n }\n\n if (!(model instanceof AbstractLayer)) {\n throw new Error(\n `Internal error: expected top level layer to be an instance of AbstractLayer.`\n );\n }\n\n this.#map.olMap.removeLayer(model.olLayer);\n this.#topLevelLayers.delete(model);\n this.#unIndexLayer(model);\n if (this.#activeBaseLayer.value === model) {\n const newBaselayer = this.getBaseLayers()[0];\n if (newBaselayer) {\n checkLayerInstance(newBaselayer);\n }\n this.#updateBaseLayer(newBaselayer);\n }\n model.destroy();\n }\n\n #updateBaseLayer(model: LayerType | undefined) {\n if (this.#activeBaseLayer.value === model) {\n return;\n }\n\n if (LOG.isDebug()) {\n const getId = (model: AbstractLayer | undefined) => {\n return model ? `'${model.id}'` : undefined;\n };\n\n LOG.debug(\n `Switching active base layer from ${getId(this.#activeBaseLayer.value)} to ${getId(model)}`\n );\n }\n\n batch(() => {\n this.#activeBaseLayer.value?.__setVisible(false);\n this.#activeBaseLayer.value = model;\n model?.__setVisible(true);\n });\n }\n\n /**\n * Index the layer and all its children.\n */\n #indexLayer(model: LayerType) {\n // layer id -> layer (or sublayer)\n const registrations: [string, OlBaseLayer | undefined][] = [];\n const visit = (model: LayerType | (AbstractLayerBase & Sublayer)) => {\n const id = model.id;\n const olLayer = \"olLayer\" in model ? model.olLayer : undefined;\n if (this.#layersById.has(id)) {\n throw new Error(\n `Layer id '${id}' is not unique. Either assign a unique id yourself ` +\n `or skip configuring 'id' for an automatically generated id.`\n );\n }\n if (olLayer && this.#layersByOlLayer.has(olLayer)) {\n throw new Error(`OlLayer used by layer '${id}' has already been used in map.`);\n }\n\n // Register this layer with the maps.\n this.#layersById.set(id, model);\n if (olLayer) {\n this.#layersByOlLayer.set(olLayer, model as LayerType); // ol is present --> not a sublayer\n }\n registrations.push([id, olLayer]);\n\n // Recurse into nested children.\n for (const layer of model.layers?.__getRawLayers() ?? []) {\n visit(layer);\n }\n for (const sublayer of model.sublayers?.__getRawSublayers() ?? []) {\n visit(sublayer);\n }\n };\n\n try {\n visit(model);\n } catch (e) {\n // If any error happens, undo the indexing.\n // This way we don't leave a partially indexed layer tree behind.\n for (const [id, olLayer] of registrations) {\n this.#layersById.delete(id);\n if (olLayer) {\n this.#layersByOlLayer.delete(olLayer);\n }\n }\n throw e;\n }\n }\n\n /**\n * Removes index entries for the given layer and all its children.\n */\n #unIndexLayer(model: AbstractLayer) {\n const visit = (model: AbstractLayer | AbstractLayerBase) => {\n if (\"olLayer\" in model) {\n this.#layersByOlLayer.delete(model.olLayer);\n }\n this.#layersById.delete(model.id);\n\n for (const layer of model.layers?.__getRawLayers() ?? []) {\n visit(layer);\n }\n\n for (const sublayer of model.sublayers?.__getRawSublayers() ?? []) {\n visit(sublayer);\n }\n };\n visit(model);\n }\n}\n\nfunction sortLayersByDisplayOrder(layers: Layer[]) {\n layers.sort((left, right) => {\n // currently layers are added with increasing z-index (base layers: 0), so\n // ordering by z-index is automatically the correct display order.\n const leftZ = left.olLayer.getZIndex() ?? 1;\n const rightZ = right.olLayer.getZIndex() ?? 1;\n return leftZ - rightZ;\n });\n}\n\nfunction checkLayerInstance(object: Layer): asserts object is Layer & AbstractLayer {\n if (!(object instanceof AbstractLayer)) {\n throw new Error(\n `Layer is not a valid layer instance. Use one of the classes provided by the map package instead.`\n );\n }\n}\n"],"names":["model"],"mappings":";;;;;AAWA,MAAM,GAAA,GAAM,aAAa,qBAAqB,CAAA,CAAA;AAE9C,MAAM,YAAe,GAAA,CAAA,CAAA;AACrB,MAAM,yBAA4B,GAAA,CAAA,CAAA;AAW3B,MAAM,eAAkB,GAAA,QAAA;AAKxB,MAAM,mBAA+C,CAAA;AAAA,EACxD,IAAA,CAAA;AAAA;AAAA,EAGA,kBAAkB,WAAuB,EAAA,CAAA;AAAA;AAAA,EAGzC,WAAA,uBAAkB,GAA2B,EAAA,CAAA;AAAA;AAAA,EAG7C,gBAAA,uBAAwD,OAAQ,EAAA,CAAA;AAAA;AAAA,EAGhE,mBAAmB,QAAoB,EAAA,CAAA;AAAA;AAAA,EAGvC,UAAa,GAAA,yBAAA,CAAA;AAAA,EAEb,YAAY,GAAmB,EAAA;AAC3B,IAAA,IAAA,CAAK,IAAO,GAAA,GAAA,CAAA;AAAA,GAChB;AAAA,EAEA,OAAU,GAAA;AAEN,IAAA,KAAA,MAAW,KAAS,IAAA,IAAA,CAAK,WAAY,CAAA,MAAA,EAAU,EAAA;AAC3C,MAAA,KAAA,CAAM,OAAQ,EAAA,CAAA;AAAA,KAClB;AACA,IAAA,IAAA,CAAK,gBAAgB,KAAM,EAAA,CAAA;AAC3B,IAAA,IAAA,CAAK,YAAY,KAAM,EAAA,CAAA;AACvB,IAAA,IAAA,CAAK,iBAAiB,KAAQ,GAAA,KAAA,CAAA,CAAA;AAAA,GAClC;AAAA,EAEA,SAAS,KAAoB,EAAA;AACzB,IAAA,kBAAA,CAAmB,KAAK,CAAA,CAAA;AAExB,IAAM,KAAA,CAAA,aAAA,CAAc,KAAK,IAAI,CAAA,CAAA;AAC7B,IAAA,IAAA,CAAK,UAAU,KAAK,CAA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aseType, SublayersCollection } from "../api";
2
2
  import { AbstractLayerBase } from "./AbstractLayerBase";
3
3
  /**
4
4
  * Manages the sublayers of a layer.
5
5
  */
6
- export declare class SublayersCollectionImpl<Sublayer extends SublayerBaseType & AbstractLayerBase> implements SublayersCollection<Sublayer> {
6
+ export declare class SublayersCollectionImpl<SublayerType extends SublayerBaseType & AbstractLayerBase> implements SublayersCollection<SublayerType> {
7
7
  #private;
8
- constructor(sublayers: Sublayer[]);
8
+ constructor(sublayers: SublayerType[]);
9
9
  destroy(): void;
10
- getItems(options?: LayerRetrievalOptions): Sublayer[];
11
- getSublayers(_options?: LayerRetrievalOptions | undefined): Sublayer[];
10
+ getItems(options?: LayerRetrievalOptions): SublayerType[];
11
+ getSublayers(_options?: LayerRetrievalOptions | undefined): SublayerType[];
12
+ getRecursiveLayers(_options?: RecursiveRetrievalOptions): Sublayer[];
12
13
  /**
13
14
  * Returns a reference to the internal sublayers array.
14
15
  *
15
16
  * NOTE: Do not modify directly!
16
17
  */
17
- __getRawSublayers(): Sublayer[];
18
+ __getRawSublayers(): SublayerType[];
18
19
  }
@@ -1,3 +1,5 @@
1
+ import { getRecursiveLayers } from './getRecursiveLayers.js';
2
+
1
3
  class SublayersCollectionImpl {
2
4
  /* eslint-enable indent */
3
5
  #sublayers;
@@ -17,6 +19,16 @@ class SublayersCollectionImpl {
17
19
  getSublayers(_options) {
18
20
  return this.#sublayers.slice();
19
21
  }
22
+ getRecursiveLayers(_options) {
23
+ return getRecursiveLayers({
24
+ // NOTE: This is safe (but not elegant) because this class does not know about the entire type hierarchy (unions).
25
+ // _Might_ be possible to refactor this class to use the Sublayer union instead in the generic type parameters,
26
+ // but then we might also introduce a cycle in the type definitions, which could be bad (?).
27
+ from: this,
28
+ sortByDisplayOrder: _options?.sortByDisplayOrder,
29
+ filter: _options?.filter
30
+ });
31
+ }
20
32
  /**
21
33
  * Returns a reference to the internal sublayers array.
22
34
  *
@@ -1 +1 @@
1
- {"version":3,"file":"SublayersCollectionImpl.js","sources":["SublayersCollectionImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { LayerRetrievalOptions, SublayerBaseType, SublayersCollection } from \"../api\";\nimport { AbstractLayerBase } from \"./AbstractLayerBase\";\n\n/**\n * Manages the sublayers of a layer.\n */\n// NOTE: adding / removing sublayers currently not supported\n/* eslint-disable indent */\nexport class SublayersCollectionImpl<Sublayer extends SublayerBaseType & AbstractLayerBase>\n implements SublayersCollection<Sublayer>\n{\n /* eslint-enable indent */\n #sublayers: Sublayer[];\n\n constructor(sublayers: Sublayer[]) {\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): Sublayer[] {\n return this.getSublayers(options);\n }\n\n getSublayers(_options?: LayerRetrievalOptions | undefined): Sublayer[] {\n // NOTE: options are ignored because layers are always ordered at this time.\n return this.#sublayers.slice();\n }\n\n /**\n * Returns a reference to the internal sublayers array.\n *\n * NOTE: Do not modify directly!\n */\n __getRawSublayers(): Sublayer[] {\n return this.#sublayers;\n }\n}\n"],"names":[],"mappings":"AAUO,MAAM,uBAEb,CAAA;AAAA;AAAA,EAEI,UAAA,CAAA;AAAA,EAEA,YAAY,SAAuB,EAAA;AAC/B,IAAA,IAAA,CAAK,UAAa,GAAA,SAAA,CAAA;AAAA,GACtB;AAAA,EAEA,OAAU,GAAA;AACN,IAAW,KAAA,MAAA,KAAA,IAAS,KAAK,UAAY,EAAA;AACjC,MAAA,KAAA,CAAM,OAAQ,EAAA,CAAA;AAAA,KAClB;AACA,IAAA,IAAA,CAAK,aAAa,EAAC,CAAA;AAAA,GACvB;AAAA;AAAA,EAGA,SAAS,OAA6C,EAAA;AAClD,IAAO,OAAA,IAAA,CAAK,aAAa,OAAO,CAAA,CAAA;AAAA,GACpC;AAAA,EAEA,aAAa,QAA0D,EAAA;AAEnE,IAAO,OAAA,IAAA,CAAK,WAAW,KAAM,EAAA,CAAA;AAAA,GACjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,iBAAgC,GAAA;AAC5B,IAAA,OAAO,IAAK,CAAA,UAAA,CAAA;AAAA,GAChB;AACJ;;;;"}
1
+ {"version":3,"file":"SublayersCollectionImpl.js","sources":["SublayersCollectionImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport {\n LayerRetrievalOptions,\n RecursiveRetrievalOptions,\n Sublayer,\n SublayerBaseType,\n SublayersCollection\n} from \"../api\";\nimport { AbstractLayerBase } from \"./AbstractLayerBase\";\nimport { getRecursiveLayers } from \"./getRecursiveLayers\";\n\n/**\n * Manages the sublayers of a layer.\n */\n// NOTE: adding / removing sublayers currently not supported\n/* eslint-disable indent */\nexport class SublayersCollectionImpl<SublayerType extends SublayerBaseType & AbstractLayerBase>\n implements SublayersCollection<SublayerType>\n{\n /* eslint-enable indent */\n #sublayers: SublayerType[];\n\n constructor(sublayers: SublayerType[]) {\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 getSublayers(_options?: LayerRetrievalOptions | undefined): SublayerType[] {\n // NOTE: options are ignored because layers are always ordered at this time.\n return this.#sublayers.slice();\n }\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 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 __getRawSublayers(): SublayerType[] {\n return this.#sublayers;\n }\n}\n"],"names":[],"mappings":";;AAiBO,MAAM,uBAEb,CAAA;AAAA;AAAA,EAEI,UAAA,CAAA;AAAA,EAEA,YAAY,SAA2B,EAAA;AACnC,IAAA,IAAA,CAAK,UAAa,GAAA,SAAA,CAAA;AAAA,GACtB;AAAA,EAEA,OAAU,GAAA;AACN,IAAW,KAAA,MAAA,KAAA,IAAS,KAAK,UAAY,EAAA;AACjC,MAAA,KAAA,CAAM,OAAQ,EAAA,CAAA;AAAA,KAClB;AACA,IAAA,IAAA,CAAK,aAAa,EAAC,CAAA;AAAA,GACvB;AAAA;AAAA,EAGA,SAAS,OAAiD,EAAA;AACtD,IAAO,OAAA,IAAA,CAAK,aAAa,OAAO,CAAA,CAAA;AAAA,GACpC;AAAA,EAEA,aAAa,QAA8D,EAAA;AAEvE,IAAO,OAAA,IAAA,CAAK,WAAW,KAAM,EAAA,CAAA;AAAA,GACjC;AAAA,EAEA,mBAAmB,QAAkD,EAAA;AACjE,IAAA,OAAO,kBAAmB,CAAA;AAAA;AAAA;AAAA;AAAA,MAItB,IAAM,EAAA,IAAA;AAAA,MACN,oBAAoB,QAAU,EAAA,kBAAA;AAAA,MAC9B,QAAQ,QAAU,EAAA,MAAA;AAAA,KACrB,CAAA,CAAA;AAAA,GACL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,iBAAoC,GAAA;AAChC,IAAA,OAAO,IAAK,CAAA,UAAA,CAAA;AAAA,GAChB;AACJ;;;;"}
@@ -0,0 +1,16 @@
1
+ import { AnyLayer, ChildrenCollection, RecursiveRetrievalOptions } from "../api";
2
+ export interface RecursiveLayerOptions<LayerType> extends RecursiveRetrievalOptions {
3
+ /**
4
+ * Starting point(s) of the recursion.
5
+ * The layers in this collections and their all of their children (recursively) will be included in the result.
6
+ */
7
+ from: ChildrenCollection<LayerType>;
8
+ /**
9
+ * If set to `true`, layers will be ordered by their display order:
10
+ * Layers listed first in the returned array are shown _below_ layers listed at a later index.
11
+ *
12
+ * By default, layers are returned in arbitrary order.
13
+ */
14
+ sortByDisplayOrder?: boolean;
15
+ }
16
+ export declare function getRecursiveLayers<LayerType extends AnyLayer>(options: RecursiveLayerOptions<LayerType>): AnyLayer[];
@@ -0,0 +1,23 @@
1
+ function getRecursiveLayers(options) {
2
+ const filter = options.filter ?? (() => true);
3
+ const sortByDisplayOrder = options.sortByDisplayOrder ?? false;
4
+ const result = [];
5
+ gatherRecursiveLayers(options.from, filter, sortByDisplayOrder, result);
6
+ return result;
7
+ }
8
+ function gatherRecursiveLayers(from, filter, sortByDisplayOrder, result) {
9
+ const layers = from.getItems({ sortByDisplayOrder });
10
+ for (const layer of layers) {
11
+ if (!filter(layer)) {
12
+ continue;
13
+ }
14
+ const children = layer.children;
15
+ if (children) {
16
+ gatherRecursiveLayers(children, filter, sortByDisplayOrder, result);
17
+ }
18
+ result.push(layer);
19
+ }
20
+ }
21
+
22
+ export { getRecursiveLayers };
23
+ //# sourceMappingURL=getRecursiveLayers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRecursiveLayers.js","sources":["getRecursiveLayers.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { AnyLayer, ChildrenCollection, RecursiveRetrievalOptions } from \"../api\";\n\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 result: AnyLayer[] = [];\n gatherRecursiveLayers(options.from, filter, sortByDisplayOrder, result);\n return result;\n}\n\n// Walks the layer tree recursively and gathers matching layers into the result array.\nfunction gatherRecursiveLayers<LayerType extends AnyLayer>(\n from: ChildrenCollection<LayerType>,\n filter: (layer: AnyLayer) => boolean,\n sortByDisplayOrder: boolean,\n result: AnyLayer[]\n): void {\n const layers = from.getItems({ sortByDisplayOrder });\n for (const layer of layers) {\n if (!filter(layer)) {\n continue;\n }\n\n const children = layer.children;\n if (children) {\n // Pushes into result as a side effect\n gatherRecursiveLayers(children, filter, sortByDisplayOrder, result);\n }\n result.push(layer);\n }\n}\n"],"names":[],"mappings":"AAoBO,SAAS,mBACZ,OACU,EAAA;AACV,EAAM,MAAA,MAAA,GAAS,OAAQ,CAAA,MAAA,KAAW,MAAM,IAAA,CAAA,CAAA;AACxC,EAAM,MAAA,kBAAA,GAAqB,QAAQ,kBAAsB,IAAA,KAAA,CAAA;AACzD,EAAA,MAAM,SAAqB,EAAC,CAAA;AAC5B,EAAA,qBAAA,CAAsB,OAAQ,CAAA,IAAA,EAAM,MAAQ,EAAA,kBAAA,EAAoB,MAAM,CAAA,CAAA;AACtE,EAAO,OAAA,MAAA,CAAA;AACX,CAAA;AAGA,SAAS,qBACL,CAAA,IAAA,EACA,MACA,EAAA,kBAAA,EACA,MACI,EAAA;AACJ,EAAA,MAAM,MAAS,GAAA,IAAA,CAAK,QAAS,CAAA,EAAE,oBAAoB,CAAA,CAAA;AACnD,EAAA,KAAA,MAAW,SAAS,MAAQ,EAAA;AACxB,IAAI,IAAA,CAAC,MAAO,CAAA,KAAK,CAAG,EAAA;AAChB,MAAA,SAAA;AAAA,KACJ;AAEA,IAAA,MAAM,WAAW,KAAM,CAAA,QAAA,CAAA;AACvB,IAAA,IAAI,QAAU,EAAA;AAEV,MAAsB,qBAAA,CAAA,QAAA,EAAU,MAAQ,EAAA,kBAAA,EAAoB,MAAM,CAAA,CAAA;AAAA,KACtE;AACA,IAAA,MAAA,CAAO,KAAK,KAAK,CAAA,CAAA;AAAA,GACrB;AACJ;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { Group } from "ol/layer";
2
- import { GroupLayerCollection, Layer, LayerRetrievalOptions } from "../../api";
2
+ import { AnyLayer, GroupLayerCollection, Layer, LayerRetrievalOptions, RecursiveRetrievalOptions } from "../../api";
3
3
  import { GroupLayer, GroupLayerConfig } from "../../api/layers/GroupLayer";
4
4
  import { AbstractLayer } from "../AbstractLayer";
5
5
  import { MapModelImpl } from "../MapModelImpl";
@@ -26,6 +26,7 @@ export declare class GroupLayerCollectionImpl implements GroupLayerCollection {
26
26
  destroy(): void;
27
27
  getItems(options?: LayerRetrievalOptions): (AbstractLayer & Layer)[];
28
28
  getLayers(_options?: LayerRetrievalOptions | undefined): (AbstractLayer & Layer)[];
29
+ getRecursiveLayers(_options?: RecursiveRetrievalOptions): AnyLayer[];
29
30
  /**
30
31
  * Returns a reference to the internal group layer array.
31
32
  *
@@ -1,6 +1,7 @@
1
1
  import { Group } from 'ol/layer.js';
2
2
  import { AbstractLayer } from '../AbstractLayer.js';
3
3
  import { AbstractLayerBase } from '../AbstractLayerBase.js';
4
+ import { getRecursiveLayers } from '../getRecursiveLayers.js';
4
5
 
5
6
  class GroupLayerImpl extends AbstractLayer {
6
7
  #children;
@@ -41,6 +42,11 @@ class GroupLayerCollectionImpl {
41
42
  layers = layers.slice();
42
43
  for (const layer of layers) {
43
44
  if (layer instanceof AbstractLayer) {
45
+ if (layer.isBaseLayer) {
46
+ throw new Error(
47
+ `Layer '${layer.id}' of group '${parent.id}' is marked as base layer. Layers that belong to a group layer cannot be a base layer.`
48
+ );
49
+ }
44
50
  layer.__attachToGroup(parent);
45
51
  } else {
46
52
  throw new Error(
@@ -68,6 +74,13 @@ class GroupLayerCollectionImpl {
68
74
  getLayers(_options) {
69
75
  return this.#layers.slice();
70
76
  }
77
+ getRecursiveLayers(_options) {
78
+ return getRecursiveLayers({
79
+ from: this,
80
+ sortByDisplayOrder: _options?.sortByDisplayOrder,
81
+ filter: _options?.filter
82
+ });
83
+ }
71
84
  /**
72
85
  * Returns a reference to the internal group layer array.
73
86
  *
@@ -1 +1 @@
1
- {"version":3,"file":"GroupLayerImpl.js","sources":["GroupLayerImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Group } from \"ol/layer\";\nimport { GroupLayerCollection, Layer, LayerRetrievalOptions } from \"../../api\";\nimport { GroupLayer, GroupLayerConfig } from \"../../api/layers/GroupLayer\";\nimport { AbstractLayer } from \"../AbstractLayer\";\nimport { AbstractLayerBase } from \"../AbstractLayerBase\";\nimport { MapModelImpl } from \"../MapModelImpl\";\n\nexport class GroupLayerImpl extends AbstractLayer implements GroupLayer {\n #children: GroupLayerCollectionImpl;\n\n constructor(config: GroupLayerConfig) {\n const groupLayers = config.layers;\n const olGroup = new Group({ layers: groupLayers.map((sublayer) => sublayer.olLayer) });\n super({ ...config, olLayer: olGroup });\n this.#children = new GroupLayerCollectionImpl(groupLayers, this);\n }\n\n get type() {\n return \"group\" as const;\n }\n\n get legend() {\n return undefined;\n }\n\n get layers(): GroupLayerCollectionImpl {\n return this.#children;\n }\n\n get sublayers(): undefined {\n return undefined;\n }\n\n /**\n * return raw OL LayerGroup\n * Warning: Do not manipulate the collection of layers in this group, changes are not synchronized!\n */\n get olLayer(): Group {\n return super.olLayer as Group;\n }\n\n __attachToMap(map: MapModelImpl): void {\n super.__attachToMap(map);\n this.layers.__getRawLayers().forEach((layer) => layer.__attachToMap(map));\n }\n}\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 GroupLayerCollectionImpl implements GroupLayerCollection {\n #layers: (AbstractLayer & Layer)[];\n #parent: GroupLayer;\n\n constructor(layers: Layer[], parent: GroupLayer) {\n layers = layers.slice(); // Don't modify the input\n for (const layer of layers) {\n if (layer instanceof AbstractLayer) {\n layer.__attachToGroup(parent); //attach every layer to the parent group layer\n } else {\n throw new Error(\n `Layer '${layer.id}' of group '${parent.id}' does not implement abstract class '${AbstractLayerBase.name}`\n );\n }\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.__detachFromGroup();\n layer.destroy();\n }\n this.#layers = [];\n }\n\n // Generic method name for consistent interface\n getItems(options?: LayerRetrievalOptions): (AbstractLayer & Layer)[] {\n return this.getLayers(options);\n }\n\n getLayers(_options?: LayerRetrievalOptions | undefined): (AbstractLayer & Layer)[] {\n // NOTE: options are ignored because layers are always ordered at this time.\n return this.#layers.slice();\n }\n\n /**\n * Returns a reference to the internal group layer array.\n *\n * NOTE: Do not modify directly!\n */\n __getRawLayers(): (AbstractLayer & Layer)[] {\n return this.#layers;\n }\n\n /**\n * Returns the parent group layer that owns this collection.\n */\n __getParent(): GroupLayer {\n return this.#parent;\n }\n}\n"],"names":[],"mappings":";;;;AASO,MAAM,uBAAuB,aAAoC,CAAA;AAAA,EACpE,SAAA,CAAA;AAAA,EAEA,YAAY,MAA0B,EAAA;AAClC,IAAA,MAAM,cAAc,MAAO,CAAA,MAAA,CAAA;AAC3B,IAAA,MAAM,OAAU,GAAA,IAAI,KAAM,CAAA,EAAE,MAAQ,EAAA,WAAA,CAAY,GAAI,CAAA,CAAC,QAAa,KAAA,QAAA,CAAS,OAAO,CAAA,EAAG,CAAA,CAAA;AACrF,IAAA,KAAA,CAAM,EAAE,GAAG,MAAQ,EAAA,OAAA,EAAS,SAAS,CAAA,CAAA;AACrC,IAAA,IAAA,CA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,KACJ;AACA,IAAA,IAAA,CAAK,OAAU,GAAA,MAAA,CAAA;AACf,IAAA,IAAA,CAAK,OAAU,GAAA,MAAA,CAAA;AAAA,GACnB;AAAA;AAAA;AAAA;AAAA,EAKA,OAAU,GAAA;AACN,IAAW,KAAA,MAAA,KAAA,IAAS,KAAK,OAAS,EAAA;AAC9B,MAAA,KAAA,CAAM,iBAAkB,EAAA,CAAA;AACxB,MAAA,KAAA,CAAM,OAAQ,EAAA,CAAA;AAAA,KAClB;AACA,IAAA,IAAA,CAAK,UAAU,EAAC,CAAA;AAAA,GACpB;AAAA;AAAA,EAGA,SAAS,OAA4D,EAAA;AACjE,IAAO,OAAA,IAAA,CAAK,UAAU,OAAO,CAAA,CAAA;AAAA,GACjC;AAAA,EAEA,UAAU,QAAyE,EAAA;AAE/E,IAAO,OAAA,IAAA,CAAK,QAAQ,KAAM,EAAA,CAAA;AAAA,GAC9B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,cAA4C,GAAA;AACxC,IAAA,OAAO,IAAK,CAAA,OAAA,CAAA;AAAA,GAChB;AAAA;AAAA;AAAA;AAAA,EAKA,WAA0B,GAAA;AACtB,IAAA,OAAO,IAAK,CAAA,OAAA,CAAA;AAAA,GAChB;AACJ;;;;"}
1
+ {"version":3,"file":"GroupLayerImpl.js","sources":["GroupLayerImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Group } from \"ol/layer\";\nimport {\n AnyLayer,\n GroupLayerCollection,\n Layer,\n LayerRetrievalOptions,\n RecursiveRetrievalOptions\n} from \"../../api\";\nimport { GroupLayer, GroupLayerConfig } from \"../../api/layers/GroupLayer\";\nimport { AbstractLayer } from \"../AbstractLayer\";\nimport { AbstractLayerBase } from \"../AbstractLayerBase\";\nimport { MapModelImpl } from \"../MapModelImpl\";\nimport { getRecursiveLayers } from \"../getRecursiveLayers\";\n\nexport class GroupLayerImpl extends AbstractLayer implements GroupLayer {\n #children: GroupLayerCollectionImpl;\n\n constructor(config: GroupLayerConfig) {\n const groupLayers = config.layers;\n const olGroup = new Group({ layers: groupLayers.map((sublayer) => sublayer.olLayer) });\n super({ ...config, olLayer: olGroup });\n this.#children = new GroupLayerCollectionImpl(groupLayers, this);\n }\n\n get type() {\n return \"group\" as const;\n }\n\n get legend() {\n return undefined;\n }\n\n get layers(): GroupLayerCollectionImpl {\n return this.#children;\n }\n\n get sublayers(): undefined {\n return undefined;\n }\n\n /**\n * return raw OL LayerGroup\n * Warning: Do not manipulate the collection of layers in this group, changes are not synchronized!\n */\n get olLayer(): Group {\n return super.olLayer as Group;\n }\n\n __attachToMap(map: MapModelImpl): void {\n super.__attachToMap(map);\n this.layers.__getRawLayers().forEach((layer) => layer.__attachToMap(map));\n }\n}\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 GroupLayerCollectionImpl implements GroupLayerCollection {\n #layers: (AbstractLayer & Layer)[];\n #parent: GroupLayer;\n\n constructor(layers: Layer[], parent: GroupLayer) {\n layers = layers.slice(); // Don't modify the input\n for (const layer of layers) {\n if (layer instanceof AbstractLayer) {\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.__attachToGroup(parent); //attach every layer to the parent group layer\n } else {\n throw new Error(\n `Layer '${layer.id}' of group '${parent.id}' does not implement abstract class '${AbstractLayerBase.name}`\n );\n }\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.__detachFromGroup();\n layer.destroy();\n }\n this.#layers = [];\n }\n\n // Generic method name for consistent interface\n getItems(options?: LayerRetrievalOptions): (AbstractLayer & Layer)[] {\n return this.getLayers(options);\n }\n\n getLayers(_options?: LayerRetrievalOptions | undefined): (AbstractLayer & Layer)[] {\n // NOTE: options are ignored because layers are always ordered at this time.\n return this.#layers.slice();\n }\n\n getRecursiveLayers(_options?: RecursiveRetrievalOptions): AnyLayer[] {\n return getRecursiveLayers({\n from: this,\n sortByDisplayOrder: _options?.sortByDisplayOrder,\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 __getRawLayers(): (AbstractLayer & Layer)[] {\n return this.#layers;\n }\n\n /**\n * Returns the parent group layer that owns this collection.\n */\n __getParent(): GroupLayer {\n return this.#parent;\n }\n}\n"],"names":[],"mappings":";;;;;AAgBO,MAAM,uBAAuB,aAAoC,CAAA;AAAA,EACpE,SAAA,CAAA;AAAA,EAEA,YAAY,MAA0B,EAAA;AAClC,IAAA,MAAM,cAAc,MAAO,CAAA,MAAA,CAAA;AAC3B,IAAA,MAAM,OAAU,GAAA,IAAI,KAAM,CAAA,EAAE,MAAQ,EAAA,WAAA,CAAY,GAAI,CAAA,CAAC,QAAa,KAAA,QAAA,CAAS,OAAO,CAAA,EAAG,CAAA,CAAA;AACrF,IAAA,KAAA,CAAM,EAAE,GAAG,MAAQ,EAAA,OAAA,EAAS,SAAS,CAAA,CAAA;AACrC,IAAA,IAAA,CAAK,SAAY,GAAA,IAAI,wBAAyB,CAAA,WAAA,EAAa,IAAI,CAAA,CAAA;AAAA,GACnE;AAAA,EAEA,IAAI,IAAO,GAAA;AACP,IAAO,OAAA,OAAA,CAAA;AAAA,GACX;AAAA,EAEA,IAAI,MAAS,GAAA;AACT,IAAO,OAAA,KAAA,CAAA,CAAA;AAAA,GACX;AAAA,EAEA,IAAI,MAAmC,GAAA;AACnC,IAAA,OAAO,IAAK,CAAA,SAAA,CAAA;AAAA,GAChB;AAAA,EAEA,IAAI,SAAuB,GAAA;AACvB,IAAO,OAAA,KAAA,CAAA,CAAA;AAAA,GACX;AAAA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S,EAAA;AAC9B,MAAA,KAAA,CAAM,iBAAkB,EAAA,CAAA;AACxB,MAAA,KAAA,CAAM,OAAQ,EAAA,CAAA;AAAA,KAClB;AACA,IAAA,IAAA,CAAK,UAAU,EAAC,CAAA;AAAA,GACpB;AAAA;AAAA,EAGA,SAAS,OAA4D,EAAA;AACjE,IAAO,OAAA,IAAA,CAAK,UAAU,OAAO,CAAA,CAAA;AAAA,GACjC;AAAA,EAEA,UAAU,QAAyE,EAAA;AAE/E,IAAO,OAAA,IAAA,CAAK,QAAQ,KAAM,EAAA,CAAA;AAAA,GAC9B;AAAA,EAEA,mBAAmB,QAAkD,EAAA;AACjE,IAAA,OAAO,kBAAmB,CAAA;AAAA,MACtB,IAAM,EAAA,IAAA;AAAA,MACN,oBAAoB,QAAU,EAAA,kBAAA;AAAA,MAC9B,QAAQ,QAAU,EAAA,MAAA;AAAA,KACrB,CAAA,CAAA;AAAA,GACL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,cAA4C,GAAA;AACxC,IAAA,OAAO,IAAK,CAAA,OAAA,CAAA;AAAA,GAChB;AAAA;AAAA;AAAA;AAAA,EAKA,WAA0B,GAAA;AACtB,IAAA,OAAO,IAAK,CAAA,OAAA,CAAA;AAAA,GAChB;AACJ;;;;"}
@@ -14,6 +14,7 @@ class WMSLayerImpl extends AbstractLayer {
14
14
  #sublayers;
15
15
  #layer;
16
16
  #source;
17
+ #fetchCapabilities;
17
18
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
19
  #capabilities;
19
20
  #abortController = new AbortController();
@@ -39,6 +40,7 @@ class WMSLayerImpl extends AbstractLayer {
39
40
  }
40
41
  });
41
42
  this.#url = config.url;
43
+ this.#fetchCapabilities = config.fetchCapabilities ?? true;
42
44
  this.#source = source;
43
45
  this.#layer = layer;
44
46
  this.#sublayers = new SublayersCollectionImpl(constructSublayers(config.sublayers));
@@ -97,6 +99,9 @@ class WMSLayerImpl extends AbstractLayer {
97
99
  }
98
100
  }
99
101
  };
102
+ if (!this.#fetchCapabilities) {
103
+ return;
104
+ }
100
105
  this.#fetchWMSCapabilities().then((result) => {
101
106
  batch(() => {
102
107
  const parser = new WMSCapabilities();
@@ -1 +1 @@
1
- {"version":3,"file":"WMSLayerImpl.js","sources":["WMSLayerImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport {\n batch,\n computed,\n Reactive,\n reactive,\n ReadonlyReactive,\n watch\n} from \"@conterra/reactivity-core\";\nimport { createLogger, destroyResource, isAbortError, Resource } from \"@open-pioneer/core\";\nimport { ImageWrapper } from \"ol\";\nimport WMSCapabilities from \"ol/format/WMSCapabilities\";\nimport ImageLayer from \"ol/layer/Image\";\nimport type ImageSource from \"ol/source/Image\";\nimport ImageWMS from \"ol/source/ImageWMS\";\nimport { WMSLayer, WMSLayerConfig, WMSSublayer, WMSSublayerConfig } from \"../../api\";\nimport { fetchCapabilities } from \"../../util/capabilities-utils\";\nimport { AbstractLayer } from \"../AbstractLayer\";\nimport { AbstractLayerBase } from \"../AbstractLayerBase\";\nimport { MapModelImpl } from \"../MapModelImpl\";\nimport { SublayersCollectionImpl } from \"../SublayersCollectionImpl\";\n\nconst LOG = createLogger(\"map:WMSLayer\");\n\nexport class WMSLayerImpl extends AbstractLayer implements WMSLayer {\n #url: string;\n #sublayers: SublayersCollectionImpl<WMSSublayerImpl>;\n #layer: ImageLayer<ImageSource>;\n #source: ImageWMS;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n #capabilities: Record<string, any> | undefined;\n readonly #abortController = new AbortController();\n\n #visibleSublayers: ReadonlyReactive<string[]>;\n #sublayersWatch: Resource | undefined;\n\n constructor(config: WMSLayerConfig) {\n const layer = new ImageLayer();\n super({\n ...config,\n olLayer: layer\n });\n const source = new ImageWMS({\n ...config.sourceOptions,\n url: config.url,\n params: {\n ...config.sourceOptions?.params\n },\n // Use http service to load tiles; needed for authentication etc.\n imageLoadFunction: (wrapper, url) => {\n return this.#loadImage(wrapper, url).catch((error) => {\n LOG.error(`Failed to load tile at '${url}'`, error);\n });\n }\n });\n this.#url = config.url;\n this.#source = source;\n this.#layer = layer;\n this.#sublayers = new SublayersCollectionImpl(constructSublayers(config.sublayers));\n this.#visibleSublayers = computed(() => this.#getVisibleLayerNames(), {\n equal(a, b) {\n return a.length === b.length && a.every((v, i) => v === b[i]);\n }\n });\n\n this.#sublayersWatch = watch(\n () => [this.#visibleSublayers.value],\n ([layers]) => {\n this.#updateLayersParam(layers);\n },\n {\n immediate: true\n }\n );\n }\n\n destroy() {\n this.#abortController.abort();\n this.#sublayersWatch = destroyResource(this.#sublayersWatch);\n super.destroy();\n }\n\n get type() {\n return \"wms\" as const;\n }\n\n get legend() {\n return undefined;\n }\n\n get url(): string {\n return this.#url;\n }\n\n get layers(): undefined {\n return undefined;\n }\n\n get sublayers(): SublayersCollectionImpl<WMSSublayerImpl> {\n return this.#sublayers;\n }\n\n get capabilities() {\n return this.#capabilities;\n }\n\n __attachToMap(map: MapModelImpl): void {\n super.__attachToMap(map);\n for (const sublayer of this.#sublayers.getSublayers()) {\n sublayer.__attach(map, this, this);\n }\n\n /** Find all leaf nodes representing a layer in the structure */\n const getNestedSublayer = (sublayers: WMSSublayerImpl[], layers: WMSSublayerImpl[]) => {\n for (const sublayer of sublayers) {\n const nested = sublayer.sublayers.getSublayers();\n if (nested.length) {\n getNestedSublayer(nested, layers);\n } else {\n if (sublayer.name) {\n layers.push(sublayer);\n }\n }\n }\n };\n\n this.#fetchWMSCapabilities()\n .then((result: string) => {\n batch(() => {\n const parser = new WMSCapabilities();\n const capabilities = parser.read(result);\n this.#capabilities = capabilities;\n\n const layers: WMSSublayerImpl[] = [];\n getNestedSublayer(this.#sublayers.getSublayers(), layers);\n\n for (const layer of layers) {\n const legendUrl = getWMSLegendUrl(capabilities, layer.name!);\n layer.__setLegend(legendUrl);\n }\n });\n })\n .catch((error) => {\n if (isAbortError(error)) {\n LOG.debug(`Layer ${this.id} has been destroyed before fetching capabilities`);\n return;\n }\n LOG.error(`Failed to fetch WMS capabilities for layer ${this.id}`, error);\n });\n }\n\n /**\n * Gathers the visibility of _all_ sublayers and assembles the 'layers' WMS parameter.\n * The parameters are then applied to the WMS source.\n */\n #updateLayersParam(layers: string[]) {\n this.#source.updateParams({\n \"LAYERS\": layers\n });\n\n // only set source if there are visible sublayers, otherwise\n // we send an invalid http request\n const source = layers.length === 0 ? null : this.#source;\n if (this.#layer.getSource() !== source) {\n this.#layer.setSource(source);\n }\n }\n\n #getVisibleLayerNames() {\n const layers: string[] = [];\n const visitSublayer = (sublayer: WMSSublayerImpl) => {\n if (!sublayer.visible) {\n return;\n }\n\n const nestedSublayers = sublayer.sublayers.__getRawSublayers();\n if (nestedSublayers.length) {\n for (const nestedSublayer of nestedSublayers) {\n visitSublayer(nestedSublayer);\n }\n } else {\n /**\n * Push sublayer only, if layer name is not an empty string | undefined | ...\n */\n if (sublayer.name) {\n layers.push(sublayer.name);\n }\n }\n };\n\n for (const sublayer of this.sublayers.__getRawSublayers()) {\n visitSublayer(sublayer);\n }\n return layers;\n }\n\n async #fetchWMSCapabilities(): Promise<string> {\n const httpService = this.map.__sharedDependencies.httpService;\n const url = `${this.#url}?LANGUAGE=ger&SERVICE=WMS&REQUEST=GetCapabilities`;\n return fetchCapabilities(url, httpService, this.#abortController.signal);\n }\n\n async #loadImage(imageWrapper: ImageWrapper, imageUrl: string): Promise<void> {\n const httpService = this.map.__sharedDependencies.httpService;\n const image = imageWrapper.getImage() as HTMLImageElement;\n\n const response = await httpService.fetch(imageUrl);\n if (!response.ok) {\n throw new Error(`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\n image.addEventListener(\"load\", finish);\n image.addEventListener(\"error\", finish);\n image.src = objectUrl;\n }\n}\n\nclass WMSSublayerImpl extends AbstractLayerBase implements WMSSublayer {\n #parent: WMSSublayerImpl | WMSLayerImpl | undefined;\n #parentLayer: WMSLayerImpl | undefined;\n #name: string | undefined;\n #legend = reactive<string | undefined>();\n #sublayers: SublayersCollectionImpl<WMSSublayerImpl>;\n #visible: Reactive<boolean>;\n\n constructor(config: WMSSublayerConfig) {\n super(config);\n this.#name = config.name;\n this.#visible = reactive(config.visible ?? true);\n this.#sublayers = new SublayersCollectionImpl(constructSublayers(config.sublayers));\n }\n\n get type() {\n return \"wms-sublayer\" as const;\n }\n\n get name(): string | undefined {\n return this.#name;\n }\n\n get layers(): undefined {\n return undefined;\n }\n\n get sublayers(): SublayersCollectionImpl<WMSSublayerImpl> {\n return this.#sublayers;\n }\n\n get parent(): WMSSublayerImpl | WMSLayerImpl {\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(): WMSLayerImpl {\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 get legend(): string | undefined {\n return this.#legend.value;\n }\n\n 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 __attach(\n map: MapModelImpl,\n parentLayer: WMSLayerImpl,\n parent: WMSLayerImpl | WMSSublayerImpl\n ): void {\n super.__attachToMap(map);\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 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.__getRawSublayers()) {\n sublayer.__attach(map, parentLayer, this);\n }\n }\n\n /**\n * Called by the parent layer to update the legend on load.\n */\n __setLegend(legendUrl: string | undefined) {\n this.#legend.value = legendUrl;\n }\n\n setVisible(newVisibility: boolean): void {\n this.#visible.value = newVisibility;\n }\n}\n\nfunction constructSublayers(sublayerConfigs: WMSSublayerConfig[] = []): WMSSublayerImpl[] {\n const sublayers: WMSSublayerImpl[] = [];\n try {\n for (const sublayerConfig of sublayerConfigs) {\n sublayers.push(new WMSSublayerImpl(sublayerConfig));\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\n/** extract the legend url from the service capabilities */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getWMSLegendUrl(capabilities: Record<string, any>, layerName: string) {\n const capabilitiesContent = capabilities?.Capability;\n const rootLayerCapabilities = capabilitiesContent?.Layer;\n let url: string | undefined = undefined;\n\n /** Recurse search for the currrent layer within the parsed capabilities service*/\n //eslint-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 // theorfore, 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":";;;;;;;;;;A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cAAmC,SAAmB,EAAA;AAClF,EAAA,MAAM,sBAAsB,YAAc,EAAA,UAAA,CAAA;AAC1C,EAAA,MAAM,wBAAwB,mBAAqB,EAAA,KAAA,CAAA;AACnD,EAAA,IAAI,GAA0B,GAAA,KAAA,CAAA,CAAA;AAI9B,EAAM,MAAA,iBAAA,GAAoB,CAAC,KAAiC,KAAA;AACxD,IAAA,KAAA,MAAW,gBAAgB,KAAO,EAAA;AAE9B,MAAI,IAAA,YAAA,EAAc,SAAS,SAAW,EAAA;AAClC,QAAA,MAAM,WAAc,GAAA,YAAA,CAAA;AACpB,QAAA,MAAM,SAAS,WAAY,CAAA,KAAA,CAAA;AAC3B,QAAA,IAAI,CAAC,MAAA,IAAU,CAAC,MAAA,CAAO,MAAQ,EAAA;AAC3B,UAAA,GAAA,CAAI,MAAM,iDAAiD,CAAA,CAAA;AAC3D,UAAA,OAAA;AAAA,SACJ;AAGA,QAAM,MAAA,WAAA,GAAc,OAAO,CAAC,CAAA,CAAA;AAC5B,QAAM,GAAA,GAAA,WAAA,CAAY,SAAY,GAAA,CAAC,CAAG,EAAA,cAAA,CAAA;AAAA,OACtC,MAAA,IAAW,aAAa,KAAO,EAAA;AAC3B,QAAA,iBAAA,CAAkB,aAAa,KAAK,CAAA,CAAA;AAAA,OACxC;AAAA,KACJ;AAAA,GACJ,CAAA;AACA,EAAA,IAAI,qBAAuB,EAAA;AACvB,IAAA,iBAAA,CAAkB,sBAAsB,KAAK,CAAA,CAAA;AAAA,GACjD;AACA,EAAO,OAAA,GAAA,CAAA;AACX;;;;"}
1
+ {"version":3,"file":"WMSLayerImpl.js","sources":["WMSLayerImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport {\n batch,\n computed,\n Reactive,\n reactive,\n ReadonlyReactive,\n watch\n} from \"@conterra/reactivity-core\";\nimport { createLogger, destroyResource, isAbortError, Resource } from \"@open-pioneer/core\";\nimport { ImageWrapper } from \"ol\";\nimport WMSCapabilities from \"ol/format/WMSCapabilities\";\nimport ImageLayer from \"ol/layer/Image\";\nimport type ImageSource from \"ol/source/Image\";\nimport ImageWMS from \"ol/source/ImageWMS\";\nimport { WMSLayer, WMSLayerConfig, WMSSublayer, WMSSublayerConfig } from \"../../api\";\nimport { fetchCapabilities } from \"../../util/capabilities-utils\";\nimport { AbstractLayer } from \"../AbstractLayer\";\nimport { AbstractLayerBase } from \"../AbstractLayerBase\";\nimport { MapModelImpl } from \"../MapModelImpl\";\nimport { SublayersCollectionImpl } from \"../SublayersCollectionImpl\";\n\nconst LOG = createLogger(\"map:WMSLayer\");\n\nexport class WMSLayerImpl extends AbstractLayer implements WMSLayer {\n #url: string;\n #sublayers: SublayersCollectionImpl<WMSSublayerImpl>;\n #layer: ImageLayer<ImageSource>;\n #source: ImageWMS;\n #fetchCapabilities: boolean;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n #capabilities: Record<string, any> | undefined;\n readonly #abortController = new AbortController();\n\n #visibleSublayers: ReadonlyReactive<string[]>;\n #sublayersWatch: Resource | undefined;\n\n constructor(config: WMSLayerConfig) {\n const layer = new ImageLayer();\n super({\n ...config,\n olLayer: layer\n });\n const source = new ImageWMS({\n ...config.sourceOptions,\n url: config.url,\n params: {\n ...config.sourceOptions?.params\n },\n // Use http service to load tiles; needed for authentication etc.\n imageLoadFunction: (wrapper, url) => {\n return this.#loadImage(wrapper, url).catch((error) => {\n LOG.error(`Failed to load tile at '${url}'`, error);\n });\n }\n });\n this.#url = config.url;\n this.#fetchCapabilities = config.fetchCapabilities ?? true;\n this.#source = source;\n this.#layer = layer;\n this.#sublayers = new SublayersCollectionImpl(constructSublayers(config.sublayers));\n this.#visibleSublayers = computed(() => this.#getVisibleLayerNames(), {\n equal(a, b) {\n return a.length === b.length && a.every((v, i) => v === b[i]);\n }\n });\n\n this.#sublayersWatch = watch(\n () => [this.#visibleSublayers.value],\n ([layers]) => {\n this.#updateLayersParam(layers);\n },\n {\n immediate: true\n }\n );\n }\n\n destroy() {\n this.#abortController.abort();\n this.#sublayersWatch = destroyResource(this.#sublayersWatch);\n super.destroy();\n }\n\n get type() {\n return \"wms\" as const;\n }\n\n get legend() {\n return undefined;\n }\n\n get url(): string {\n return this.#url;\n }\n\n get layers(): undefined {\n return undefined;\n }\n\n get sublayers(): SublayersCollectionImpl<WMSSublayerImpl> {\n return this.#sublayers;\n }\n\n get capabilities() {\n return this.#capabilities;\n }\n\n __attachToMap(map: MapModelImpl): void {\n super.__attachToMap(map);\n for (const sublayer of this.#sublayers.getSublayers()) {\n sublayer.__attach(map, this, this);\n }\n\n /** Find all leaf nodes representing a layer in the structure */\n const getNestedSublayer = (sublayers: WMSSublayerImpl[], layers: WMSSublayerImpl[]) => {\n for (const sublayer of sublayers) {\n const nested = sublayer.sublayers.getSublayers();\n if (nested.length) {\n getNestedSublayer(nested, layers);\n } else {\n if (sublayer.name) {\n layers.push(sublayer);\n }\n }\n }\n };\n\n if (!this.#fetchCapabilities) {\n return;\n }\n\n this.#fetchWMSCapabilities()\n .then((result: string) => {\n batch(() => {\n const parser = new WMSCapabilities();\n const capabilities = parser.read(result);\n this.#capabilities = capabilities;\n\n const layers: WMSSublayerImpl[] = [];\n getNestedSublayer(this.#sublayers.getSublayers(), layers);\n\n for (const layer of layers) {\n const legendUrl = getWMSLegendUrl(capabilities, layer.name!);\n layer.__setLegend(legendUrl);\n }\n });\n })\n .catch((error) => {\n if (isAbortError(error)) {\n LOG.debug(`Layer ${this.id} has been destroyed before fetching capabilities`);\n return;\n }\n LOG.error(`Failed to fetch WMS capabilities for layer ${this.id}`, error);\n });\n }\n\n /**\n * Gathers the visibility of _all_ sublayers and assembles the 'layers' WMS parameter.\n * The parameters are then applied to the WMS source.\n */\n #updateLayersParam(layers: string[]) {\n this.#source.updateParams({\n \"LAYERS\": layers\n });\n\n // only set source if there are visible sublayers, otherwise\n // we send an invalid http request\n const source = layers.length === 0 ? null : this.#source;\n if (this.#layer.getSource() !== source) {\n this.#layer.setSource(source);\n }\n }\n\n #getVisibleLayerNames() {\n const layers: string[] = [];\n const visitSublayer = (sublayer: WMSSublayerImpl) => {\n if (!sublayer.visible) {\n return;\n }\n\n const nestedSublayers = sublayer.sublayers.__getRawSublayers();\n if (nestedSublayers.length) {\n for (const nestedSublayer of nestedSublayers) {\n visitSublayer(nestedSublayer);\n }\n } else {\n /**\n * Push sublayer only, if layer name is not an empty string | undefined | ...\n */\n if (sublayer.name) {\n layers.push(sublayer.name);\n }\n }\n };\n\n for (const sublayer of this.sublayers.__getRawSublayers()) {\n visitSublayer(sublayer);\n }\n return layers;\n }\n\n async #fetchWMSCapabilities(): Promise<string> {\n const httpService = this.map.__sharedDependencies.httpService;\n const url = `${this.#url}?LANGUAGE=ger&SERVICE=WMS&REQUEST=GetCapabilities`;\n return fetchCapabilities(url, httpService, this.#abortController.signal);\n }\n\n async #loadImage(imageWrapper: ImageWrapper, imageUrl: string): Promise<void> {\n const httpService = this.map.__sharedDependencies.httpService;\n const image = imageWrapper.getImage() as HTMLImageElement;\n\n const response = await httpService.fetch(imageUrl);\n if (!response.ok) {\n throw new Error(`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\n image.addEventListener(\"load\", finish);\n image.addEventListener(\"error\", finish);\n image.src = objectUrl;\n }\n}\n\nclass WMSSublayerImpl extends AbstractLayerBase implements WMSSublayer {\n #parent: WMSSublayerImpl | WMSLayerImpl | undefined;\n #parentLayer: WMSLayerImpl | undefined;\n #name: string | undefined;\n #legend = reactive<string | undefined>();\n #sublayers: SublayersCollectionImpl<WMSSublayerImpl>;\n #visible: Reactive<boolean>;\n\n constructor(config: WMSSublayerConfig) {\n super(config);\n this.#name = config.name;\n this.#visible = reactive(config.visible ?? true);\n this.#sublayers = new SublayersCollectionImpl(constructSublayers(config.sublayers));\n }\n\n get type() {\n return \"wms-sublayer\" as const;\n }\n\n get name(): string | undefined {\n return this.#name;\n }\n\n get layers(): undefined {\n return undefined;\n }\n\n get sublayers(): SublayersCollectionImpl<WMSSublayerImpl> {\n return this.#sublayers;\n }\n\n get parent(): WMSSublayerImpl | WMSLayerImpl {\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(): WMSLayerImpl {\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 get legend(): string | undefined {\n return this.#legend.value;\n }\n\n 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 __attach(\n map: MapModelImpl,\n parentLayer: WMSLayerImpl,\n parent: WMSLayerImpl | WMSSublayerImpl\n ): void {\n super.__attachToMap(map);\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 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.__getRawSublayers()) {\n sublayer.__attach(map, parentLayer, this);\n }\n }\n\n /**\n * Called by the parent layer to update the legend on load.\n */\n __setLegend(legendUrl: string | undefined) {\n this.#legend.value = legendUrl;\n }\n\n setVisible(newVisibility: boolean): void {\n this.#visible.value = newVisibility;\n }\n}\n\nfunction constructSublayers(sublayerConfigs: WMSSublayerConfig[] = []): WMSSublayerImpl[] {\n const sublayers: WMSSublayerImpl[] = [];\n try {\n for (const sublayerConfig of sublayerConfigs) {\n sublayers.push(new WMSSublayerImpl(sublayerConfig));\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\n/** extract the legend url from the service capabilities */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getWMSLegendUrl(capabilities: Record<string, any>, layerName: string) {\n const capabilitiesContent = capabilities?.Capability;\n const rootLayerCapabilities = capabilitiesContent?.Layer;\n let url: string | undefined = undefined;\n\n /** Recurse search for the currrent layer within the parsed capabilities service*/\n //eslint-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 // theorfore, 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":";;;;;;;;;;AAuBA,MAAM,GAAA,GAAM,aAAa,cAAc,CAAA,CAAA;AAEhC,MAAM,qBAAqB,aAAkC,CAAA;AAAA,EAChE,IAAA,CAAA;AAAA,EACA,UAAA,CAAA;AAAA,EACA,MAAA,CAAA;AAAA,EACA,OAAA,CAAA;AAAA,EACA,kBAAA,CAAA;AAAA;AAAA,EAGA,aAAA,CAAA;AAAA,EACS,gBAAA,GAAmB,IAAI,eAAgB,EAAA,CAAA;AAAA,EAEhD,iBAAA,CAAA;AA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AAI,GAA0B,GAAA,KAAA,CAAA,CAAA;AAI9B,EAAM,MAAA,iBAAA,GAAoB,CAAC,KAAiC,KAAA;AACxD,IAAA,KAAA,MAAW,gBAAgB,KAAO,EAAA;AAE9B,MAAI,IAAA,YAAA,EAAc,SAAS,SAAW,EAAA;AAClC,QAAA,MAAM,WAAc,GAAA,YAAA,CAAA;AACpB,QAAA,MAAM,SAAS,WAAY,CAAA,KAAA,CAAA;AAC3B,QAAA,IAAI,CAAC,MAAA,IAAU,CAAC,MAAA,CAAO,MAAQ,EAAA;AAC3B,UAAA,GAAA,CAAI,MAAM,iDAAiD,CAAA,CAAA;AAC3D,UAAA,OAAA;AAAA,SACJ;AAGA,QAAM,MAAA,WAAA,GAAc,OAAO,CAAC,CAAA,CAAA;AAC5B,QAAM,GAAA,GAAA,WAAA,CAAY,SAAY,GAAA,CAAC,CAAG,EAAA,cAAA,CAAA;AAAA,OACtC,MAAA,IAAW,aAAa,KAAO,EAAA;AAC3B,QAAA,iBAAA,CAAkB,aAAa,KAAK,CAAA,CAAA;AAAA,OACxC;AAAA,KACJ;AAAA,GACJ,CAAA;AACA,EAAA,IAAI,qBAAuB,EAAA;AACvB,IAAA,iBAAA,CAAkB,sBAAsB,KAAK,CAAA,CAAA;AAAA,GACjD;AACA,EAAO,OAAA,GAAA,CAAA;AACX;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@open-pioneer/map",
4
- "version": "0.8.0",
4
+ "version": "0.9.0-dev.20250220091855",
5
5
  "description": "This package integrates OpenLayers maps into an open pioneer trails application.",
6
6
  "keywords": [
7
7
  "open-pioneer-trails"
@@ -20,7 +20,7 @@
20
20
  "@open-pioneer/react-utils": "^2.4.0",
21
21
  "@open-pioneer/runtime": "^2.4.0",
22
22
  "@types/proj4": "^2.5.2",
23
- "ol": "^10.2.1",
23
+ "ol": "^10.3.0",
24
24
  "proj4": "^2.12.1",
25
25
  "react": "^18.3.1",
26
26
  "react-dom": "^18.3.1",