@open-pioneer/map 0.9.0-dev.20250217152428 → 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,6 +1,51 @@
1
1
  # @open-pioneer/map
2
2
 
3
- ## 0.9.0-dev.20250217152428
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
+ ```
4
49
 
5
50
  ### Patch Changes
6
51
 
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";
@@ -181,7 +181,7 @@ export interface MapModel extends EventSource<MapModelEvents> {
181
181
  /**
182
182
  * Contains the layers known to a {@link MapModel}.
183
183
  */
184
- export interface LayerCollection {
184
+ export interface LayerCollection extends ChildrenCollection<Layer> {
185
185
  /**
186
186
  * Returns all configured base layers.
187
187
  */
@@ -199,6 +199,35 @@ export interface LayerCollection {
199
199
  * Returns true if the given layer has been successfully activated.
200
200
  */
201
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[];
202
231
  /**
203
232
  * Adds a new layer to the map.
204
233
  *
@@ -207,18 +236,10 @@ export interface LayerCollection {
207
236
  * NOTE: by default, the new layer will be shown on _top_ of all existing layers.
208
237
  */
209
238
  addLayer(layer: Layer): void;
210
- /**
211
- * Returns all operational layers.
212
- */
213
- getOperationalLayers(options?: LayerRetrievalOptions): Layer[];
214
239
  /**
215
240
  * Returns the layer identified by the `id` or undefined, if no such layer exists.
216
241
  */
217
242
  getLayerById(id: string): AnyLayer | undefined;
218
- /**
219
- * Returns all layers known to this collection.
220
- */
221
- getAllLayers(options?: LayerRetrievalOptions): Layer[];
222
243
  /**
223
244
  * Removes a layer identified by the `id` from the map.
224
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;;;;"}
@@ -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;
@@ -218,6 +218,15 @@ export interface SublayersCollection<SublayerType = Sublayer> extends ChildrenCo
218
218
  * Returns the child sublayers in this collection.
219
219
  */
220
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[];
221
230
  }
222
231
  /**
223
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 * 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/**\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":"AA2RO,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,CAAA;AAAA,EACxD,IAAA,CAAA;AAAA;AAAA,EAGA,kBAAkB,WAAuB,EAAA,CAAA;AAAA;AAAA,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,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,CAAA,CAAA;AAAA,GACxB;AAAA,EAEA,aAAyB,GAAA;AACrB,IAAA,OAAO,KAAK,YAAa,EAAA,CAAE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AAM,OAAO,CAAA,CAAA;AAAA,OAC9C;AACA,MAAK,IAAA,CAAA,WAAA,CAAY,MAAOA,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,18 +1,19 @@
1
- import { LayerRetrievalOptions, SublayerBaseType, SublayersCollection } from "../api";
1
+ import { LayerRetrievalOptions, RecursiveRetrievalOptions, Sublayer, SublayerBaseType, 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,CAAK,SAAY,GAAA,IAAI,wBAAyB,CAAA,WAAA,EAAa,IAAI,CAAA,CAAA;AAAA,GACnE;AAAA,EA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A,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;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,OAAiB,GAAA;AACjB,IAAA,OAAO,KAAM,CAAA,OAAA,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AAA,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;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@open-pioneer/map",
4
- "version": "0.9.0-dev.20250217152428",
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"