@open-pioneer/map 0.0.0-dev-20241120114910

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.
Files changed (115) hide show
  1. package/CHANGELOG.md +354 -0
  2. package/LICENSE +202 -0
  3. package/MapRegistryImpl.d.ts +17 -0
  4. package/MapRegistryImpl.js +91 -0
  5. package/MapRegistryImpl.js.map +1 -0
  6. package/README.md +871 -0
  7. package/_virtual/_virtual-pioneer-module_react-hooks.js +7 -0
  8. package/_virtual/_virtual-pioneer-module_react-hooks.js.map +1 -0
  9. package/api/BaseFeature.d.ts +31 -0
  10. package/api/MapConfig.d.ts +111 -0
  11. package/api/MapModel.d.ts +229 -0
  12. package/api/MapRegistry.d.ts +48 -0
  13. package/api/index.d.ts +15 -0
  14. package/api/layers/GroupLayer.d.ts +50 -0
  15. package/api/layers/GroupLayer.js +6 -0
  16. package/api/layers/GroupLayer.js.map +1 -0
  17. package/api/layers/SimpleLayer.d.ts +27 -0
  18. package/api/layers/SimpleLayer.js +6 -0
  19. package/api/layers/SimpleLayer.js.map +1 -0
  20. package/api/layers/WMSLayer.d.ts +57 -0
  21. package/api/layers/WMSLayer.js +6 -0
  22. package/api/layers/WMSLayer.js.map +1 -0
  23. package/api/layers/WMTSLayer.d.ts +33 -0
  24. package/api/layers/WMTSLayer.js +6 -0
  25. package/api/layers/WMTSLayer.js.map +1 -0
  26. package/api/layers/base.d.ts +242 -0
  27. package/api/layers/base.js +9 -0
  28. package/api/layers/base.js.map +1 -0
  29. package/api/layers/index.d.ts +5 -0
  30. package/api/shared.d.ts +10 -0
  31. package/assets/images/mapMarker.png +0 -0
  32. package/index.d.ts +1 -0
  33. package/index.js +15 -0
  34. package/index.js.map +1 -0
  35. package/internalTestSupport.d.ts +8 -0
  36. package/internalTestSupport.js +2 -0
  37. package/internalTestSupport.js.map +1 -0
  38. package/layers/BkgTopPlusOpen.d.ts +21 -0
  39. package/layers/BkgTopPlusOpen.js +61 -0
  40. package/layers/BkgTopPlusOpen.js.map +1 -0
  41. package/model/AbstractLayer.d.ts +25 -0
  42. package/model/AbstractLayer.js +186 -0
  43. package/model/AbstractLayer.js.map +1 -0
  44. package/model/AbstractLayerBase.d.ts +54 -0
  45. package/model/AbstractLayerBase.js +119 -0
  46. package/model/AbstractLayerBase.js.map +1 -0
  47. package/model/Highlights.d.ts +42 -0
  48. package/model/Highlights.js +272 -0
  49. package/model/Highlights.js.map +1 -0
  50. package/model/LayerCollectionImpl.d.ts +27 -0
  51. package/model/LayerCollectionImpl.js +228 -0
  52. package/model/LayerCollectionImpl.js.map +1 -0
  53. package/model/MapModelImpl.d.ts +46 -0
  54. package/model/MapModelImpl.js +271 -0
  55. package/model/MapModelImpl.js.map +1 -0
  56. package/model/SublayersCollectionImpl.d.ts +18 -0
  57. package/model/SublayersCollectionImpl.js +31 -0
  58. package/model/SublayersCollectionImpl.js.map +1 -0
  59. package/model/createMapModel.d.ts +4 -0
  60. package/model/createMapModel.js +157 -0
  61. package/model/createMapModel.js.map +1 -0
  62. package/model/layers/GroupLayerImpl.d.ts +39 -0
  63. package/model/layers/GroupLayerImpl.js +88 -0
  64. package/model/layers/GroupLayerImpl.js.map +1 -0
  65. package/model/layers/SimpleLayerImpl.d.ts +13 -0
  66. package/model/layers/SimpleLayerImpl.js +19 -0
  67. package/model/layers/SimpleLayerImpl.js.map +1 -0
  68. package/model/layers/WMSLayerImpl.d.ts +41 -0
  69. package/model/layers/WMSLayerImpl.js +297 -0
  70. package/model/layers/WMSLayerImpl.js.map +1 -0
  71. package/model/layers/WMTSLayerImpl.d.ts +17 -0
  72. package/model/layers/WMTSLayerImpl.js +156 -0
  73. package/model/layers/WMTSLayerImpl.js.map +1 -0
  74. package/package.json +86 -0
  75. package/projections.d.ts +27 -0
  76. package/projections.js +15 -0
  77. package/projections.js.map +1 -0
  78. package/services.d.ts +1 -0
  79. package/services.js +2 -0
  80. package/services.js.map +1 -0
  81. package/ui/CssProps.d.ts +9 -0
  82. package/ui/CssProps.js +13 -0
  83. package/ui/CssProps.js.map +1 -0
  84. package/ui/DefaultMapProvider.d.ts +39 -0
  85. package/ui/DefaultMapProvider.js +24 -0
  86. package/ui/DefaultMapProvider.js.map +1 -0
  87. package/ui/MapAnchor.d.ts +36 -0
  88. package/ui/MapAnchor.js +28 -0
  89. package/ui/MapAnchor.js.map +1 -0
  90. package/ui/MapContainer.d.ts +50 -0
  91. package/ui/MapContainer.js +191 -0
  92. package/ui/MapContainer.js.map +1 -0
  93. package/ui/MapContainerContext.d.ts +7 -0
  94. package/ui/MapContainerContext.js +17 -0
  95. package/ui/MapContainerContext.js.map +1 -0
  96. package/ui/computeMapAnchorStyles.d.ts +3 -0
  97. package/ui/computeMapAnchorStyles.js +51 -0
  98. package/ui/computeMapAnchorStyles.js.map +1 -0
  99. package/ui/hooks.d.ts +34 -0
  100. package/ui/hooks.js +73 -0
  101. package/ui/hooks.js.map +1 -0
  102. package/ui/styles.css +10 -0
  103. package/ui/styles.css.map +1 -0
  104. package/ui/useMapModel.d.ts +58 -0
  105. package/ui/useMapModel.js +59 -0
  106. package/ui/useMapModel.js.map +1 -0
  107. package/util/capabilities-utils.d.ts +2 -0
  108. package/util/capabilities-utils.js +11 -0
  109. package/util/capabilities-utils.js.map +1 -0
  110. package/util/geometry-utils.d.ts +7 -0
  111. package/util/geometry-utils.js +25 -0
  112. package/util/geometry-utils.js.map +1 -0
  113. package/util/ol-test-support.d.ts +2 -0
  114. package/util/ol-test-support.js +24 -0
  115. package/util/ol-test-support.js.map +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WMTSLayer.js","sources":["WMTSLayer.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 { LayerBaseType, LayerConfig } from \"./base\";\nimport { WMTSLayerImpl } from \"../../model/layers/WMTSLayerImpl\";\n\nexport interface WMTSLayerConfig extends LayerConfig {\n /** URL of the WMTS service. */\n url: string;\n\n /** The name of the WMTS layer in the service's capabilities. */\n name: string;\n\n /** The name of the tile matrix set in the service's capabilities. */\n matrixSet: string;\n\n /**\n * Additional source options for the layer's WMTS source.\n *\n * NOTE: These options are intended for advanced configuration:\n * the WMTS Layer manages some of the OpenLayers source options itself.\n */\n sourceOptions?: Partial<WMSSourceOptions>;\n}\n\nexport interface WMTSLayer extends LayerBaseType {\n readonly type: \"wmts\";\n\n /** URL of the WMTS service. */\n readonly url: string;\n\n /** The name of the WMTS layer in the service's capabilities. */\n readonly name: string;\n\n /** The name of the tile matrix set in the service's capabilities. */\n readonly matrixSet: string;\n\n readonly layers: undefined;\n}\n\nexport interface WMTSLayerConstructor {\n prototype: WMTSLayer;\n\n /** Creates a new {@link WMTSLayer}. */\n new (config: WMTSLayerConfig): WMTSLayer;\n}\n\nexport const WMTSLayer: WMTSLayerConstructor = WMTSLayerImpl;\n"],"names":[],"mappings":";;AA+CO,MAAM,SAAkC,GAAA;;;;"}
@@ -0,0 +1,242 @@
1
+ import type { EventSource } from "@open-pioneer/core";
2
+ import type OlBaseLayer from "ol/layer/Base";
3
+ import type { MapModel } from "../MapModel";
4
+ import type { LayerRetrievalOptions } from "../shared";
5
+ import type { SimpleLayer } from "./SimpleLayer";
6
+ import type { WMSLayer, WMSSublayer } from "./WMSLayer";
7
+ import type { WMTSLayer } from "./WMTSLayer";
8
+ import type { GroupLayer, GroupLayerCollection } from "./GroupLayer";
9
+ /** Events emitted by the {@link Layer} and other layer types. */
10
+ export interface LayerBaseEvents {
11
+ "destroy": void;
12
+ }
13
+ /** The load state of a layer. */
14
+ export type LayerLoadState = "not-loaded" | "loading" | "loaded" | "error";
15
+ /** Custom function to check the state of a layer and returning a "loaded" or "error". */
16
+ export type HealthCheckFunction = (layer: Layer) => Promise<"loaded" | "error">;
17
+ /**
18
+ * Configuration options supported by all layer types (layers and sublayers).
19
+ */
20
+ export interface LayerBaseConfig {
21
+ /**
22
+ * The unique id of this layer.
23
+ * Defaults to a generated id.
24
+ */
25
+ id?: string;
26
+ /**
27
+ * The human-readable title of this layer.
28
+ */
29
+ title: string;
30
+ /**
31
+ * The human-readable description of this layer.
32
+ * Defaults to an empty string.
33
+ */
34
+ description?: string;
35
+ /**
36
+ * Whether this layer should initially be visible.
37
+ * Defaults to `true`.
38
+ */
39
+ visible?: boolean;
40
+ /**
41
+ * Additional attributes for this layer.
42
+ * These can be arbitrary values.
43
+ */
44
+ attributes?: Record<string | symbol, unknown>;
45
+ }
46
+ /**
47
+ * Interface shared by all layer types (operational layers and sublayers).
48
+ *
49
+ * Instances of this interface cannot be constructed directly; use a real layer
50
+ * class such as {@link SimpleLayer} instead.
51
+ */
52
+ export interface AnyLayerBaseType<AdditionalEvents = {}> extends EventSource<LayerBaseEvents & AdditionalEvents> {
53
+ /**
54
+ * Identifies the type of this layer.
55
+ */
56
+ readonly type: AnyLayerTypes;
57
+ /** The map this layer belongs to. */
58
+ readonly map: MapModel;
59
+ /**
60
+ * The direct parent of this layer instance, used for sublayers or for layers in a group layer.
61
+ *
62
+ * The property shall be undefined if the layer is not a sublayer or member of a group layer.
63
+ */
64
+ readonly parent: AnyLayer | undefined;
65
+ /**
66
+ * The unique id of this layer within its map model.
67
+ *
68
+ * NOTE: layer ids may not be globally unique: layers that belong
69
+ * to different map models may have the same id.
70
+ */
71
+ readonly id: string;
72
+ /** The human-readable title of this layer. */
73
+ readonly title: string;
74
+ /** The human-readable description of this layer. May be empty. */
75
+ readonly description: string;
76
+ /**
77
+ * Whether the layer is visible or not.
78
+ *
79
+ * NOTE: The model's visible state may do more than influence the raw OpenLayers's visibility property.
80
+ * Future versions may completely remove invisible layers from the OpenLayer's map under some circumstances.
81
+ */
82
+ readonly visible: boolean;
83
+ /**
84
+ * LegendURL from the service capabilities, if available.
85
+ */
86
+ readonly legend: string | undefined;
87
+ /**
88
+ * The direct children of this layer.
89
+ *
90
+ * The children may either be a set of operational layers (e.g. for a group layer) or a set of sublayers, or `undefined`.
91
+ *
92
+ * See also {@link layers} and {@link sublayers}.
93
+ */
94
+ readonly children: ChildrenCollection<AnyLayer> | undefined;
95
+ /**
96
+ * If this layer is a group layer this property contains a collection of all layers that a members to the group.
97
+ *
98
+ * The property shall be `undefined` if it is not a group layer.
99
+ *
100
+ * The properties `layers` and `sublayers` are mutually exclusive.
101
+ */
102
+ readonly layers: GroupLayerCollection | undefined;
103
+ /**
104
+ * The collection of child sublayers for this layer. Sublayers are layers that cannot exist without an appropriate parent layer.
105
+ *
106
+ * Layers that can never have any sublayers may not have a `sublayers` collection.
107
+ *
108
+ * The properties `layers` and `sublayers` are mutually exclusive.
109
+ */
110
+ readonly sublayers: SublayersCollection | undefined;
111
+ /**
112
+ * Additional attributes associated with this layer.
113
+ */
114
+ readonly attributes: Readonly<Record<string | symbol, unknown>>;
115
+ /**
116
+ * Updates the title of this layer.
117
+ */
118
+ setTitle(newTitle: string): void;
119
+ /**
120
+ * Updates the description of this layer.
121
+ */
122
+ setDescription(newDescription: string): void;
123
+ /**
124
+ * Updates the visibility of this layer to the new value.
125
+ *
126
+ * NOTE: The visibility of base layers cannot be changed through this method.
127
+ * Call {@link LayerCollection.activateBaseLayer} instead.
128
+ */
129
+ setVisible(newVisibility: boolean): void;
130
+ /**
131
+ * Updates the attributes of this layer.
132
+ * Values in `newAttributes` are merged into the existing ones (i.e. via `Object.assign`).
133
+ */
134
+ updateAttributes(newAttributes: Record<string | symbol, unknown>): void;
135
+ /**
136
+ * Deletes the attribute of this layer.
137
+ */
138
+ deleteAttribute(deleteAttribute: string | symbol): void;
139
+ }
140
+ /**
141
+ * Configuration options supported by all operational layer types.
142
+ */
143
+ export interface LayerConfig extends LayerBaseConfig {
144
+ /**
145
+ * Whether this layer is a base layer or not.
146
+ * Only one base layer can be active at a time.
147
+ *
148
+ * Defaults to `false`.
149
+ */
150
+ isBaseLayer?: boolean;
151
+ /**
152
+ * Optional property to check the availability of the layer.
153
+ * It is possible to provide either a URL which indicates the state of the service (2xx response meaning "ok")
154
+ * or a {@link HealthCheckFunction} performing a custom check and returning the state.
155
+ */
156
+ healthCheck?: string | HealthCheckFunction;
157
+ }
158
+ /**
159
+ * Represents an operational layer in the map.
160
+ *
161
+ * Instances of this interface cannot be constructed directly; use a real layer
162
+ * class such as {@link SimpleLayer} instead.
163
+ */
164
+ export interface LayerBaseType<AdditionalEvents = {}> extends AnyLayerBaseType<AdditionalEvents> {
165
+ /**
166
+ * Identifies the type of this layer.
167
+ */
168
+ readonly type: LayerTypes;
169
+ /**
170
+ * The load state of a layer.
171
+ */
172
+ readonly loadState: LayerLoadState;
173
+ /**
174
+ * The raw OpenLayers layer.
175
+ */
176
+ readonly olLayer: OlBaseLayer;
177
+ /**
178
+ * True if this layer is a base layer.
179
+ *
180
+ * Only one base layer can be visible at a time.
181
+ */
182
+ readonly isBaseLayer: boolean;
183
+ }
184
+ /**
185
+ * Represents a sublayer of another layer.
186
+ */
187
+ export interface SublayerBaseType extends AnyLayerBaseType {
188
+ /**
189
+ * Identifies the type of this sublayer.
190
+ */
191
+ readonly type: SublayerTypes;
192
+ /**
193
+ * The direct parent of this layer instance.
194
+ * This can either be the parent layer or another sublayer.
195
+ */
196
+ readonly parent: AnyLayer;
197
+ /**
198
+ * The parent layer that owns this sublayer.
199
+ */
200
+ readonly parentLayer: Layer;
201
+ }
202
+ /**
203
+ * Contains the children of a layer.
204
+ */
205
+ export interface ChildrenCollection<LayerType> {
206
+ /**
207
+ * Returns the items in this collection.
208
+ */
209
+ getItems(options?: LayerRetrievalOptions): LayerType[];
210
+ }
211
+ /**
212
+ * Contains the sublayers that belong to a {@link Layer} or {@link Sublayer}.
213
+ */
214
+ export interface SublayersCollection<SublayerType = Sublayer> extends ChildrenCollection<SublayerType> {
215
+ /**
216
+ * Returns the child sublayers in this collection.
217
+ */
218
+ getSublayers(options?: LayerRetrievalOptions): SublayerType[];
219
+ }
220
+ /**
221
+ * Union type for all layers (extending {@link LayerBaseType})
222
+ */
223
+ export type Layer = SimpleLayer | WMSLayer | WMTSLayer | GroupLayer;
224
+ export type LayerTypes = Layer["type"];
225
+ /**
226
+ * Union type for all sublayers (extending {@link SublayerBaseType}
227
+ */
228
+ export type Sublayer = WMSSublayer;
229
+ export type SublayerTypes = Sublayer["type"];
230
+ /**
231
+ * Union for all types of layers
232
+ */
233
+ export type AnyLayer = Layer | Sublayer;
234
+ export type AnyLayerTypes = AnyLayer["type"];
235
+ /**
236
+ * Type guard for checking if the layer is a {@link Sublayer}.
237
+ */
238
+ export declare function isSublayer(layer: AnyLayer): layer is Sublayer;
239
+ /**
240
+ * Type guard for checking if the layer is a {@link Layer} (and not a {@link Sublayer}).
241
+ */
242
+ export declare function isLayer(layer: AnyLayer): layer is Layer;
@@ -0,0 +1,9 @@
1
+ function isSublayer(layer) {
2
+ return "parentLayer" in layer;
3
+ }
4
+ function isLayer(layer) {
5
+ return "olLayer" in layer;
6
+ }
7
+
8
+ export { isLayer, isSublayer };
9
+ //# sourceMappingURL=base.js.map
@@ -0,0 +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;;;;"}
@@ -0,0 +1,5 @@
1
+ export * from "./base";
2
+ export * from "./SimpleLayer";
3
+ export * from "./WMSLayer";
4
+ export * from "./WMTSLayer";
5
+ export * from "./GroupLayer";
@@ -0,0 +1,10 @@
1
+ /** These options can be used by some APIs returning an array of layers (or sublayers). */
2
+ export interface LayerRetrievalOptions {
3
+ /**
4
+ * If set to `true`, layers will be ordered by their display order:
5
+ * Layers listed first in the returned array are shown _below_ layers listed at a later index.
6
+ *
7
+ * By default, layers are returned in arbitrary order.
8
+ */
9
+ sortByDisplayOrder?: boolean;
10
+ }
Binary file
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./api";
package/index.js ADDED
@@ -0,0 +1,15 @@
1
+ export { isLayer, isSublayer } from './api/layers/base.js';
2
+ export { SimpleLayer } from './api/layers/SimpleLayer.js';
3
+ export { WMSLayer } from './api/layers/WMSLayer.js';
4
+ export { WMTSLayer } from './api/layers/WMTSLayer.js';
5
+ export { GroupLayer } from './api/layers/GroupLayer.js';
6
+ export { getProjection, registerProjections } from './projections.js';
7
+ export { BkgTopPlusOpen } from './layers/BkgTopPlusOpen.js';
8
+ export { useCenter, useProjection, useResolution, useScale, useView } from './ui/hooks.js';
9
+ export { MapAnchor } from './ui/MapAnchor.js';
10
+ export { MapContainer } from './ui/MapContainer.js';
11
+ export { useMapModel } from './ui/useMapModel.js';
12
+ export { DefaultMapProvider } from './ui/DefaultMapProvider.js';
13
+ export { calculateBufferedExtent } from './util/geometry-utils.js';
14
+ export { TOPMOST_LAYER_Z } from './model/LayerCollectionImpl.js';
15
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Exported for the `@open-pioneer/map-test-utils` package.
3
+ *
4
+ * This API is unstable.
5
+ *
6
+ * @internal
7
+ */
8
+ export { MapRegistryImpl } from "./MapRegistryImpl";
@@ -0,0 +1,2 @@
1
+ export { MapRegistryImpl } from './MapRegistryImpl.js';
2
+ //# sourceMappingURL=internalTestSupport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internalTestSupport.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,21 @@
1
+ import WMTS from "ol/source/WMTS";
2
+ /** @internal */
3
+ export interface BkgTopPlusOpenProps {
4
+ /**
5
+ * The name of the requesting layer.
6
+ * @default "web"
7
+ */
8
+ layer?: "web" | "web_grau" | "web_light";
9
+ }
10
+ /**
11
+ * Layer source for BKG TopPlus Open.
12
+ *
13
+ * Used for @open-pioneer unit tests: not part of the public interface.
14
+ *
15
+ * @see https://gdz.bkg.bund.de/index.php/default/wmts-topplusopen-wmts-topplus-open.html
16
+ *
17
+ * @internal
18
+ */
19
+ export declare class BkgTopPlusOpen extends WMTS {
20
+ constructor(options?: BkgTopPlusOpenProps);
21
+ }
@@ -0,0 +1,61 @@
1
+ import WMTS from 'ol/source/WMTS.js';
2
+ import WMTSTileGrid from 'ol/tilegrid/WMTS.js';
3
+
4
+ class BkgTopPlusOpen extends WMTS {
5
+ constructor(options) {
6
+ const topLeftCorner = [-380316598427299e-8, 880590808284866e-8];
7
+ const resolutions = [
8
+ 4891.96981025128,
9
+ // AdV-Level 0 (1:17471320.7508974)
10
+ 2445.98490512564,
11
+ // AdV-Level 1 (1:8735660.37544872)
12
+ 1222.99245256282,
13
+ // AdV-Level 2 (1:4367830.18772436)
14
+ 611.49622628141,
15
+ // AdV-Level 3 (1:2183915.09386218)
16
+ 305.748113140705,
17
+ // AdV-Level 4 (1:1091957.54693109)
18
+ 152.874056570353,
19
+ // AdV-Level 5 (1:545978.773465545)
20
+ 76.4370282851763,
21
+ // AdV-Level 6 (1:272989,386732772)
22
+ 38.2185141425881,
23
+ // AdV-Level 7 (1:136494,693366386)
24
+ 19.1092570712941,
25
+ // AdV-Level 8 (1:68247,3466831931)
26
+ 9.55462853564703,
27
+ // AdV-Level 9 (1:34123,6733415966)
28
+ 4.77731426782352,
29
+ // AdV-Level 10 (1:17061,8366707983)
30
+ 2.38865713391176,
31
+ // AdV-Level 11 (1:8530,91833539914)
32
+ 1.19432856695588,
33
+ // AdV-Level 12 (1:4265,45916769957)
34
+ 0.59716428347794
35
+ // AdV-Level 13 (1:2132,72958384978)
36
+ ];
37
+ const matrixIds = new Array(resolutions.length);
38
+ for (let i = 0; i < resolutions.length; i++) {
39
+ matrixIds[i] = i;
40
+ }
41
+ const layer = options?.layer ?? "web";
42
+ super({
43
+ url: `https://sgx.geodatenzentrum.de/wmts_topplus_open/tile/1.0.0/${layer}/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png`,
44
+ layer,
45
+ matrixSet: "EU_EPSG_25832_TOPPLUS",
46
+ format: "image/png",
47
+ projection: "EPSG:25832",
48
+ requestEncoding: "REST",
49
+ tileGrid: new WMTSTileGrid({
50
+ origin: topLeftCorner,
51
+ resolutions,
52
+ matrixIds
53
+ }),
54
+ style: "default",
55
+ attributions: `Kartendarstellung und Pr\xE4sentationsgraphiken: \xA9 Bundesamt f\xFCr Kartographie und Geod\xE4sie ${(/* @__PURE__ */ new Date()).getFullYear()}, <a href="https://sg.geodatenzentrum.de/web_public/gdz/datenquellen/Datenquellen_TopPlusOpen.html" target="_blank">Datenquellen</a>`
56
+ });
57
+ }
58
+ }
59
+
60
+ export { BkgTopPlusOpen };
61
+ //# sourceMappingURL=BkgTopPlusOpen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BkgTopPlusOpen.js","sources":["BkgTopPlusOpen.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport WMTS from \"ol/source/WMTS\";\nimport WMTSTileGrid from \"ol/tilegrid/WMTS\";\n\n/** @internal */\nexport interface BkgTopPlusOpenProps {\n /**\n * The name of the requesting layer.\n * @default \"web\"\n */\n layer?: \"web\" | \"web_grau\" | \"web_light\";\n}\n\n/**\n * Layer source for BKG TopPlus Open.\n *\n * Used for @open-pioneer unit tests: not part of the public interface.\n *\n * @see https://gdz.bkg.bund.de/index.php/default/wmts-topplusopen-wmts-topplus-open.html\n *\n * @internal\n */\nexport class BkgTopPlusOpen extends WMTS {\n constructor(options?: BkgTopPlusOpenProps) {\n const topLeftCorner = [-3803165.98427299, 8805908.08284866];\n\n /**\n * Resolutions taken from AdV WMTS-Profil\n * @see https://www.adv-online.de/AdV-Produkte/Standards-und-Produktblaetter/AdV-Profile/\n */\n const resolutions = [\n 4891.96981025128, // AdV-Level 0 (1:17471320.7508974)\n 2445.98490512564, // AdV-Level 1 (1:8735660.37544872)\n 1222.99245256282, // AdV-Level 2 (1:4367830.18772436)\n 611.49622628141, // AdV-Level 3 (1:2183915.09386218)\n 305.748113140705, // AdV-Level 4 (1:1091957.54693109)\n 152.874056570353, // AdV-Level 5 (1:545978.773465545)\n 76.4370282851763, // AdV-Level 6 (1:272989,386732772)\n 38.2185141425881, // AdV-Level 7 (1:136494,693366386)\n 19.1092570712941, // AdV-Level 8 (1:68247,3466831931)\n 9.55462853564703, // AdV-Level 9 (1:34123,6733415966)\n 4.77731426782352, // AdV-Level 10 (1:17061,8366707983)\n 2.38865713391176, // AdV-Level 11 (1:8530,91833539914)\n 1.19432856695588, // AdV-Level 12 (1:4265,45916769957)\n 0.59716428347794 // AdV-Level 13 (1:2132,72958384978)\n ];\n\n /**\n * The length of matrixIds needs to match the length of the resolutions array\n * @see https://openlayers.org/en/latest/apidoc/module-ol_tilegrid_WMTS-WMTSTileGrid.html\n */\n const matrixIds = new Array(resolutions.length);\n for (let i = 0; i < resolutions.length; i++) {\n matrixIds[i] = i;\n }\n\n const layer = options?.layer ?? \"web\";\n\n super({\n url: `https://sgx.geodatenzentrum.de/wmts_topplus_open/tile/1.0.0/${layer}/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png`,\n layer: layer,\n matrixSet: \"EU_EPSG_25832_TOPPLUS\",\n format: \"image/png\",\n projection: \"EPSG:25832\",\n requestEncoding: \"REST\",\n tileGrid: new WMTSTileGrid({\n origin: topLeftCorner,\n resolutions: resolutions,\n matrixIds: matrixIds\n }),\n style: \"default\",\n attributions: `Kartendarstellung und Präsentationsgraphiken: © Bundesamt für Kartographie und Geodäsie ${new Date().getFullYear()}, <a href=\"https://sg.geodatenzentrum.de/web_public/gdz/datenquellen/Datenquellen_TopPlusOpen.html\" target=\"_blank\">Datenquellen</a>`\n });\n }\n}\n"],"names":[],"mappings":";;;AAuBO,MAAM,uBAAuB,IAAK,CAAA;AAAA,EACrC,YAAY,OAA+B,EAAA;AACvC,IAAM,MAAA,aAAA,GAAgB,CAAC,CAAA,kBAAA,EAAmB,kBAAgB,CAAA,CAAA;AAM1D,IAAA,MAAM,WAAc,GAAA;AAAA,MAChB,gBAAA;AAAA;AAAA,MACA,gBAAA;AAAA;AAAA,MACA,gBAAA;AAAA;AAAA,MACA,eAAA;AAAA;AAAA,MACA,gBAAA;AAAA;AAAA,MACA,gBAAA;AAAA;AAAA,MACA,gBAAA;AAAA;AAAA,MACA,gBAAA;AAAA;AAAA,MACA,gBAAA;AAAA;AAAA,MACA,gBAAA;AAAA;AAAA,MACA,gBAAA;AAAA;AAAA,MACA,gBAAA;AAAA;AAAA,MACA,gBAAA;AAAA;AAAA,MACA,gBAAA;AAAA;AAAA,KACJ,CAAA;AAMA,IAAA,MAAM,SAAY,GAAA,IAAI,KAAM,CAAA,WAAA,CAAY,MAAM,CAAA,CAAA;AAC9C,IAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,WAAA,CAAY,QAAQ,CAAK,EAAA,EAAA;AACzC,MAAA,SAAA,CAAU,CAAC,CAAI,GAAA,CAAA,CAAA;AAAA,KACnB;AAEA,IAAM,MAAA,KAAA,GAAQ,SAAS,KAAS,IAAA,KAAA,CAAA;AAEhC,IAAM,KAAA,CAAA;AAAA,MACF,GAAA,EAAK,+DAA+D,KAAK,CAAA,6DAAA,CAAA;AAAA,MACzE,KAAA;AAAA,MACA,SAAW,EAAA,uBAAA;AAAA,MACX,MAAQ,EAAA,WAAA;AAAA,MACR,UAAY,EAAA,YAAA;AAAA,MACZ,eAAiB,EAAA,MAAA;AAAA,MACjB,QAAA,EAAU,IAAI,YAAa,CAAA;AAAA,QACvB,MAAQ,EAAA,aAAA;AAAA,QACR,WAAA;AAAA,QACA,SAAA;AAAA,OACH,CAAA;AAAA,MACD,KAAO,EAAA,SAAA;AAAA,MACP,cAAc,CAA2F,oGAAA,EAAA,iBAAA,IAAI,IAAK,EAAA,EAAE,aAAa,CAAA,oIAAA,CAAA;AAAA,KACpI,CAAA,CAAA;AAAA,GACL;AACJ;;;;"}
@@ -0,0 +1,25 @@
1
+ import OlBaseLayer from "ol/layer/Base";
2
+ import { LayerBaseType, LayerLoadState, SimpleLayerConfig } from "../api";
3
+ import { AbstractLayerBase } from "./AbstractLayerBase";
4
+ import { MapModelImpl } from "./MapModelImpl";
5
+ /**
6
+ * Base class for normal layer types.
7
+ *
8
+ * These layers always have an associated OpenLayers layer.
9
+ */
10
+ export declare abstract class AbstractLayer<AdditionalEvents = {}> extends AbstractLayerBase<AdditionalEvents> implements LayerBaseType {
11
+ #private;
12
+ constructor(config: SimpleLayerConfig);
13
+ get visible(): boolean;
14
+ get olLayer(): OlBaseLayer;
15
+ get isBaseLayer(): boolean;
16
+ get loadState(): LayerLoadState;
17
+ destroy(): void;
18
+ /**
19
+ * Called by the map model when the layer is added to the map.
20
+ */
21
+ __attachToMap(map: MapModelImpl): void;
22
+ setVisible(newVisibility: boolean): void;
23
+ __setVisible(newVisibility: boolean): void;
24
+ abstract readonly type: "simple" | "wms" | "wmts" | "group";
25
+ }
@@ -0,0 +1,186 @@
1
+ import { external, reactive } from '@conterra/reactivity-core';
2
+ import { createLogger, destroyResource } from '@open-pioneer/core';
3
+ import { unByKey } from 'ol/Observable.js';
4
+ import OlLayer from 'ol/layer/Layer.js';
5
+ import { AbstractLayerBase } from './AbstractLayerBase.js';
6
+
7
+ const LOG = createLogger("map:AbstractLayer");
8
+ class AbstractLayer extends AbstractLayerBase {
9
+ #olLayer;
10
+ #isBaseLayer;
11
+ #healthCheck;
12
+ #visible;
13
+ #loadState;
14
+ #visibilityWatchKey;
15
+ #stateWatchResource;
16
+ constructor(config) {
17
+ super(config);
18
+ this.#olLayer = config.olLayer;
19
+ this.#isBaseLayer = config.isBaseLayer ?? false;
20
+ this.#healthCheck = config.healthCheck;
21
+ this.#visible = external(() => this.#olLayer.getVisible());
22
+ this.#visibilityWatchKey = this.#olLayer.on("change:visible", this.#visible.trigger);
23
+ this.#loadState = reactive(getSourceState(getSource(this.#olLayer)));
24
+ this.__setVisible(config.visible ?? true);
25
+ }
26
+ get visible() {
27
+ return this.#visible.value;
28
+ }
29
+ get olLayer() {
30
+ return this.#olLayer;
31
+ }
32
+ get isBaseLayer() {
33
+ return this.#isBaseLayer;
34
+ }
35
+ get loadState() {
36
+ return this.#loadState.value;
37
+ }
38
+ destroy() {
39
+ if (this.__destroyed) {
40
+ return;
41
+ }
42
+ this.#stateWatchResource = destroyResource(this.#stateWatchResource);
43
+ this.#visibilityWatchKey && unByKey(this.#visibilityWatchKey);
44
+ this.#visibilityWatchKey = void 0;
45
+ this.olLayer.dispose();
46
+ super.destroy();
47
+ }
48
+ /**
49
+ * Called by the map model when the layer is added to the map.
50
+ */
51
+ __attachToMap(map) {
52
+ super.__attachToMap(map);
53
+ const { initial: initialState, resource: stateWatchResource } = watchLoadState(
54
+ this,
55
+ this.#healthCheck,
56
+ (state) => {
57
+ this.#loadState.value = state;
58
+ }
59
+ );
60
+ this.#stateWatchResource = stateWatchResource;
61
+ this.#loadState.value = initialState;
62
+ }
63
+ setVisible(newVisibility) {
64
+ if (this.isBaseLayer) {
65
+ LOG.warn(
66
+ `Cannot change visibility of base layer '${this.id}': use activateBaseLayer() on the map's LayerCollection instead.`
67
+ );
68
+ return;
69
+ }
70
+ this.__setVisible(newVisibility);
71
+ }
72
+ __setVisible(newVisibility) {
73
+ if (this.#olLayer.getVisible() !== newVisibility) {
74
+ this.#olLayer.setVisible(newVisibility);
75
+ }
76
+ }
77
+ }
78
+ function watchLoadState(layer, healthCheck, onChange) {
79
+ const olLayer = layer.olLayer;
80
+ if (!(olLayer instanceof OlLayer)) {
81
+ return {
82
+ initial: "loaded",
83
+ resource: {
84
+ destroy() {
85
+ }
86
+ }
87
+ };
88
+ }
89
+ let currentSource = getSource(olLayer);
90
+ const currentOlLayerState = getSourceState(currentSource);
91
+ let currentLoadState = currentOlLayerState;
92
+ let currentHealthState = "loading";
93
+ if (currentOlLayerState !== "error") {
94
+ doHealthCheck(layer, healthCheck).then((state) => {
95
+ currentHealthState = state;
96
+ updateState();
97
+ });
98
+ }
99
+ const updateState = () => {
100
+ const olLayerState = getSourceState(currentSource);
101
+ const nextLoadState = currentHealthState === "error" ? "error" : olLayerState;
102
+ if (currentLoadState !== nextLoadState) {
103
+ currentLoadState = nextLoadState;
104
+ onChange(currentLoadState);
105
+ }
106
+ };
107
+ let stateHandle;
108
+ stateHandle = currentSource?.on("change", () => {
109
+ updateState();
110
+ });
111
+ const sourceHandle = olLayer.on("change:source", () => {
112
+ stateHandle && unByKey(stateHandle);
113
+ stateHandle = void 0;
114
+ currentSource = getSource(olLayer);
115
+ stateHandle = currentSource?.on("change", () => {
116
+ updateState();
117
+ });
118
+ updateState();
119
+ });
120
+ return {
121
+ initial: currentLoadState,
122
+ resource: {
123
+ destroy() {
124
+ stateHandle && unByKey(stateHandle);
125
+ unByKey(sourceHandle);
126
+ }
127
+ }
128
+ };
129
+ }
130
+ async function doHealthCheck(layer, healthCheck) {
131
+ if (healthCheck == null) {
132
+ return "loaded";
133
+ }
134
+ let healthCheckFn;
135
+ if (typeof healthCheck === "function") {
136
+ healthCheckFn = healthCheck;
137
+ } else if (typeof healthCheck === "string") {
138
+ healthCheckFn = async () => {
139
+ const httpService = layer.map.__sharedDependencies.httpService;
140
+ const response = await httpService.fetch(healthCheck);
141
+ if (response.ok) {
142
+ return "loaded";
143
+ }
144
+ LOG.warn(
145
+ `Health check failed for layer '${layer.id}' (http status ${response.status})`
146
+ );
147
+ return "error";
148
+ };
149
+ } else {
150
+ LOG.error(
151
+ `Unexpected object for 'healthCheck' parameter of layer '${layer.id}'`,
152
+ healthCheck
153
+ );
154
+ return "error";
155
+ }
156
+ try {
157
+ return await healthCheckFn(layer);
158
+ } catch (e) {
159
+ LOG.warn(`Health check failed for layer '${layer.id}'`, e);
160
+ return "error";
161
+ }
162
+ }
163
+ function getSource(olLayer) {
164
+ if (!(olLayer instanceof OlLayer)) {
165
+ return void 0;
166
+ }
167
+ return olLayer?.getSource() ?? void 0;
168
+ }
169
+ function getSourceState(olSource) {
170
+ const state = olSource?.getState();
171
+ switch (state) {
172
+ case void 0:
173
+ return "loaded";
174
+ case "undefined":
175
+ return "not-loaded";
176
+ case "loading":
177
+ return "loading";
178
+ case "ready":
179
+ return "loaded";
180
+ case "error":
181
+ return "error";
182
+ }
183
+ }
184
+
185
+ export { AbstractLayer };
186
+ //# sourceMappingURL=AbstractLayer.js.map