@open-pioneer/map 0.1.0
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 +12 -0
- package/LICENSE +202 -0
- package/MapRegistryImpl.d.ts +15 -0
- package/MapRegistryImpl.js +89 -0
- package/MapRegistryImpl.js.map +1 -0
- package/README.md +653 -0
- package/_virtual/_virtual-pioneer-module_react-hooks.js +7 -0
- package/_virtual/_virtual-pioneer-module_react-hooks.js.map +1 -0
- package/api/MapConfig.d.ts +111 -0
- package/api/MapModel.d.ts +112 -0
- package/api/MapRegistry.d.ts +54 -0
- package/api/index.d.ts +12 -0
- package/api/layers/SimpleLayer.d.ts +24 -0
- package/api/layers/SimpleLayer.js +6 -0
- package/api/layers/SimpleLayer.js.map +1 -0
- package/api/layers/WMSLayer.d.ts +42 -0
- package/api/layers/WMSLayer.js +6 -0
- package/api/layers/WMSLayer.js.map +1 -0
- package/api/layers/base.d.ts +170 -0
- package/api/layers/index.d.ts +3 -0
- package/api/shared.d.ts +10 -0
- package/index.d.ts +1 -0
- package/index.js +11 -0
- package/index.js.map +1 -0
- package/layers/BkgTopPlusOpen.d.ts +21 -0
- package/layers/BkgTopPlusOpen.js +61 -0
- package/layers/BkgTopPlusOpen.js.map +1 -0
- package/model/AbstractLayer.d.ts +24 -0
- package/model/AbstractLayer.js +133 -0
- package/model/AbstractLayer.js.map +1 -0
- package/model/AbstractLayerBase.d.ts +37 -0
- package/model/AbstractLayerBase.js +106 -0
- package/model/AbstractLayerBase.js.map +1 -0
- package/model/LayerCollectionImpl.d.ts +27 -0
- package/model/LayerCollectionImpl.js +226 -0
- package/model/LayerCollectionImpl.js.map +1 -0
- package/model/MapModelImpl.d.ts +19 -0
- package/model/MapModelImpl.js +179 -0
- package/model/MapModelImpl.js.map +1 -0
- package/model/SublayersCollectionImpl.d.ts +15 -0
- package/model/SublayersCollectionImpl.js +29 -0
- package/model/SublayersCollectionImpl.js.map +1 -0
- package/model/createMapModel.d.ts +3 -0
- package/model/createMapModel.js +154 -0
- package/model/createMapModel.js.map +1 -0
- package/model/layers/SimpleLayerImpl.d.ts +9 -0
- package/model/layers/SimpleLayerImpl.js +10 -0
- package/model/layers/SimpleLayerImpl.js.map +1 -0
- package/model/layers/WMSLayerImpl.d.ts +29 -0
- package/model/layers/WMSLayerImpl.js +177 -0
- package/model/layers/WMSLayerImpl.js.map +1 -0
- package/package.json +67 -0
- package/projections.d.ts +27 -0
- package/projections.js +15 -0
- package/projections.js.map +1 -0
- package/services.d.ts +1 -0
- package/services.js +2 -0
- package/services.js.map +1 -0
- package/ui/MapAnchor.d.ts +49 -0
- package/ui/MapAnchor.js +91 -0
- package/ui/MapAnchor.js.map +1 -0
- package/ui/MapContainer.d.ts +60 -0
- package/ui/MapContainer.js +192 -0
- package/ui/MapContainer.js.map +1 -0
- package/ui/MapContext.d.ts +11 -0
- package/ui/MapContext.js +17 -0
- package/ui/MapContext.js.map +1 -0
- package/ui/hooks.d.ts +24 -0
- package/ui/hooks.js +73 -0
- package/ui/hooks.js.map +1 -0
- package/ui/styles.css +3 -0
- package/ui/styles.css.map +1 -0
- package/ui/useMapModel.d.ts +31 -0
- package/ui/useMapModel.js +21 -0
- package/ui/useMapModel.js.map +1 -0
- package/util/defer.d.ts +18 -0
- package/util/defer.js +21 -0
- package/util/defer.js.map +1 -0
- package/util/ol-test-support.d.ts +2 -0
- package/util/ol-test-support.js +24 -0
- package/util/ol-test-support.js.map +1 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { MapOptions as OlMapBaseOptions } from "ol/Map";
|
|
2
|
+
import type OlView from "ol/View";
|
|
3
|
+
import type { ViewOptions as OlViewOptions } from "ol/View";
|
|
4
|
+
import { Layer } from "./layers";
|
|
5
|
+
/**
|
|
6
|
+
* Configures an extent.
|
|
7
|
+
*
|
|
8
|
+
* Coordinates must be valid for the map's configured projection.
|
|
9
|
+
*/
|
|
10
|
+
export interface ExtentConfig {
|
|
11
|
+
xMin: number;
|
|
12
|
+
yMin: number;
|
|
13
|
+
xMax: number;
|
|
14
|
+
yMax: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Configures a coordinate.
|
|
18
|
+
*
|
|
19
|
+
* Coordinates must be valid for the map's configured projection.
|
|
20
|
+
*/
|
|
21
|
+
export interface CoordinateConfig {
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
z?: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Configures the map's initial extent.
|
|
28
|
+
*/
|
|
29
|
+
export interface InitialExtentConfig {
|
|
30
|
+
kind: "extent";
|
|
31
|
+
extent: ExtentConfig;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Configures the map's initial position.
|
|
35
|
+
*/
|
|
36
|
+
export interface InitialPositionConfig {
|
|
37
|
+
kind: "position";
|
|
38
|
+
center: CoordinateConfig;
|
|
39
|
+
zoom: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Configures the map's initial view.
|
|
43
|
+
*/
|
|
44
|
+
export type InitialViewConfig = InitialExtentConfig | InitialPositionConfig;
|
|
45
|
+
/**
|
|
46
|
+
* Advanced options during map construction.
|
|
47
|
+
*/
|
|
48
|
+
export interface OlMapOptions extends Omit<OlMapBaseOptions, "target" | "view"> {
|
|
49
|
+
/**
|
|
50
|
+
* Advanced options to control the view.
|
|
51
|
+
*
|
|
52
|
+
* We recommend using the `OlViewOptions` type.
|
|
53
|
+
*
|
|
54
|
+
* > Warning: When a fully constructed `OlView` instance is provided, some options
|
|
55
|
+
* > of {@link MapConfig} (such as `initialView` or `projection`) cannot be applied anymore.
|
|
56
|
+
*/
|
|
57
|
+
view: OlView | OlViewOptions | Promise<OlViewOptions> | undefined;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Options supported during map construction.
|
|
61
|
+
*/
|
|
62
|
+
export interface MapConfig {
|
|
63
|
+
/**
|
|
64
|
+
* Configures the initial view.
|
|
65
|
+
* This can be an extent, or a (center, zoom) value.
|
|
66
|
+
*/
|
|
67
|
+
initialView?: InitialViewConfig;
|
|
68
|
+
/**
|
|
69
|
+
* Configures a specific projection, e.g. `"EPSG:4326"`.
|
|
70
|
+
* Defaults to `EPSG:3857`.
|
|
71
|
+
*
|
|
72
|
+
* To use custom projections, make sure that they are registered first:
|
|
73
|
+
*
|
|
74
|
+
* ```ts
|
|
75
|
+
* import { registerProjections } from "@open-pioneer/map";
|
|
76
|
+
*
|
|
77
|
+
* // Usually done at the top of the module.
|
|
78
|
+
* // This will register the projection(s) in proj4's global registry.
|
|
79
|
+
* registerProjections({
|
|
80
|
+
* "EPSG:31466": "+proj=tmerc +lat_0=0 +lon_0=6 +k=1 +x_0=2500000 +y_0=0 +ellps=bessel +nadgrids=BETA2007.gsb +units=m +no_defs +type=crs",
|
|
81
|
+
* // ... more projections
|
|
82
|
+
* });
|
|
83
|
+
*
|
|
84
|
+
* // later, use projection: "EPSG:31466"
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
projection?: "EPSG:3857" | "EPSG:4326" | "EPSG:25832" | "EPSG:25833" | (string & {});
|
|
88
|
+
/**
|
|
89
|
+
* Configures the layers of the map.
|
|
90
|
+
*
|
|
91
|
+
* **Layer order**
|
|
92
|
+
*
|
|
93
|
+
* Layers defined in this array are (by default) displayed in their listed order:
|
|
94
|
+
* layers defined first are shown at the bottom, and layers defined at a later position
|
|
95
|
+
* are shown _above_ their predecessors.
|
|
96
|
+
*
|
|
97
|
+
* Note: base layers are always shown below all operational layers.
|
|
98
|
+
*/
|
|
99
|
+
layers?: Layer[];
|
|
100
|
+
/**
|
|
101
|
+
* Advanced OpenLayers configuration.
|
|
102
|
+
*
|
|
103
|
+
* Options in this object are passed to the OlMap's constructor.
|
|
104
|
+
* Other properties defined in this configuration (e.g. {@link initialView})
|
|
105
|
+
* will be applied on top of these map options.
|
|
106
|
+
*
|
|
107
|
+
* > Warning: Not all properties here are supported.
|
|
108
|
+
* > For example, you cannot set the `target` because the target is controlled by the `<MapContainer />`.
|
|
109
|
+
*/
|
|
110
|
+
advanced?: Partial<OlMapOptions>;
|
|
111
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { EventSource } from "@open-pioneer/core";
|
|
2
|
+
import type OlMap from "ol/Map";
|
|
3
|
+
import type OlBaseLayer from "ol/layer/Base";
|
|
4
|
+
import type { ExtentConfig } from "./MapConfig";
|
|
5
|
+
import type { Layer, LayerBase } from "./layers";
|
|
6
|
+
import type { LayerRetrievalOptions } from "./shared";
|
|
7
|
+
/** Events emitted by the {@link MapModel}. */
|
|
8
|
+
export interface MapModelEvents {
|
|
9
|
+
"changed": void;
|
|
10
|
+
"changed:container": void;
|
|
11
|
+
"changed:initialExtent": void;
|
|
12
|
+
"destroy": void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Represents a map.
|
|
16
|
+
*/
|
|
17
|
+
export interface MapModel extends EventSource<MapModelEvents> {
|
|
18
|
+
/**
|
|
19
|
+
* The unique id of the map.
|
|
20
|
+
*/
|
|
21
|
+
readonly id: string;
|
|
22
|
+
/**
|
|
23
|
+
* The container in which the map is currently being rendered.
|
|
24
|
+
*
|
|
25
|
+
* May be undefined if the map is not being rendered at the moment.
|
|
26
|
+
* May change at runtime.
|
|
27
|
+
*
|
|
28
|
+
* The `changed:container` event is emitted when this value changes.
|
|
29
|
+
*/
|
|
30
|
+
readonly container: HTMLElement | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* The initial map extent.
|
|
33
|
+
*
|
|
34
|
+
* May be undefined before the map is shown.
|
|
35
|
+
* This is guaranteed to be initialized if the promise returned by {@link whenDisplayed} has resolved.
|
|
36
|
+
*
|
|
37
|
+
* The `changed:initialExtent` event is emitted when this value changes.
|
|
38
|
+
*/
|
|
39
|
+
readonly initialExtent: ExtentConfig | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Contains all known layers of this map.
|
|
42
|
+
*
|
|
43
|
+
* Note that not all layers in this collection may be active in the OpenLayers map.
|
|
44
|
+
* Also note that not all layers in the OpenLayers map may be contained in this collection.
|
|
45
|
+
*/
|
|
46
|
+
readonly layers: LayerCollection;
|
|
47
|
+
/**
|
|
48
|
+
* The raw OpenLayers map.
|
|
49
|
+
*/
|
|
50
|
+
readonly olMap: OlMap;
|
|
51
|
+
/**
|
|
52
|
+
* Returns a promise that resolves when the map has mounted in the DOM.
|
|
53
|
+
*/
|
|
54
|
+
whenDisplayed(): Promise<void>;
|
|
55
|
+
}
|
|
56
|
+
/** Events emitted by the {@link LayerCollection}. */
|
|
57
|
+
export interface LayerCollectionEvents {
|
|
58
|
+
changed: void;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Contains the layers known to a {@link MapModel}.
|
|
62
|
+
*/
|
|
63
|
+
export interface LayerCollection extends EventSource<LayerCollectionEvents> {
|
|
64
|
+
/**
|
|
65
|
+
* Returns all configured base layers.
|
|
66
|
+
*/
|
|
67
|
+
getBaseLayers(): Layer[];
|
|
68
|
+
/**
|
|
69
|
+
* Returns the currently active base layer.
|
|
70
|
+
*/
|
|
71
|
+
getActiveBaseLayer(): Layer | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Activates the base layer with the given id.
|
|
74
|
+
* `undefined` can be used to hide all base layers.
|
|
75
|
+
*
|
|
76
|
+
* The associated layer is made visible and all other base layers are hidden.
|
|
77
|
+
*
|
|
78
|
+
* Returns true if the given layer has been successfully activated.
|
|
79
|
+
*/
|
|
80
|
+
activateBaseLayer(id: string | undefined): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Adds a new layer to the map.
|
|
83
|
+
*
|
|
84
|
+
* The new layer is automatically registered with this collection.
|
|
85
|
+
*
|
|
86
|
+
* NOTE: by default, the new layer will be shown on _top_ of all existing layers.
|
|
87
|
+
*/
|
|
88
|
+
addLayer(layer: Layer): void;
|
|
89
|
+
/**
|
|
90
|
+
* Returns all operational layers.
|
|
91
|
+
*/
|
|
92
|
+
getOperationalLayers(options?: LayerRetrievalOptions): Layer[];
|
|
93
|
+
/**
|
|
94
|
+
* Returns the layer identified by the `id` or undefined, if no such layer exists.
|
|
95
|
+
*/
|
|
96
|
+
getLayerById(id: string): LayerBase | undefined;
|
|
97
|
+
/**
|
|
98
|
+
* Returns all layers known to this collection.
|
|
99
|
+
*/
|
|
100
|
+
getAllLayers(options?: LayerRetrievalOptions): Layer[];
|
|
101
|
+
/**
|
|
102
|
+
* Removes a layer identified by the `id` from the map.
|
|
103
|
+
*
|
|
104
|
+
* NOTE: The current implementation only supports removal of _top level_ layers.
|
|
105
|
+
*/
|
|
106
|
+
removeLayerById(id: string): void;
|
|
107
|
+
/**
|
|
108
|
+
* Given a raw OpenLayers layer instance, returns the associated {@link Layer} - or undefined
|
|
109
|
+
* if the layer is unknown to this collection.
|
|
110
|
+
*/
|
|
111
|
+
getLayerByRawInstance(olLayer: OlBaseLayer): Layer | undefined;
|
|
112
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type OlMap from "ol/Map";
|
|
2
|
+
import type { MapConfig } from "./MapConfig";
|
|
3
|
+
import type { MapModel } from "./MapModel";
|
|
4
|
+
/**
|
|
5
|
+
* Provides access to registered map instances.
|
|
6
|
+
*
|
|
7
|
+
* Maps are identified by a unique id.
|
|
8
|
+
*
|
|
9
|
+
* Inject an instance of this service by referencing the interface name `"map.MapRegistry"`.
|
|
10
|
+
*/
|
|
11
|
+
export interface MapRegistry {
|
|
12
|
+
/**
|
|
13
|
+
* Returns the map model associated with the given id.
|
|
14
|
+
* Returns undefined if there is no such model.
|
|
15
|
+
*/
|
|
16
|
+
getMapModel(mapId: string): Promise<MapModel | undefined>;
|
|
17
|
+
/**
|
|
18
|
+
* Like {@link getMapModel}, but throws if no model exists for the given `mapId`.
|
|
19
|
+
*/
|
|
20
|
+
expectMapModel(mapId: string): Promise<MapModel>;
|
|
21
|
+
/**
|
|
22
|
+
* Given a raw OpenLayers map instance, returns the associated {@link MapModel} - or undefined
|
|
23
|
+
* if the map is unknown to this registry.
|
|
24
|
+
*
|
|
25
|
+
* All OpenLayers maps created by this registry (e.g. via {@link MapConfigProvider}) have an associated map model.
|
|
26
|
+
*/
|
|
27
|
+
getMapModelByRawInstance(olMap: OlMap): MapModel | undefined;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Provides an OpenLayers map configuration with a given map id.
|
|
31
|
+
*
|
|
32
|
+
* The implementor must also provide the interface name `"map.MapConfigProvider"`.
|
|
33
|
+
*/
|
|
34
|
+
export interface MapConfigProvider {
|
|
35
|
+
/**
|
|
36
|
+
* Unique identifier of the map.
|
|
37
|
+
*/
|
|
38
|
+
readonly mapId: string;
|
|
39
|
+
/**
|
|
40
|
+
* Returns the map configuration for this map.
|
|
41
|
+
*
|
|
42
|
+
* Called by the {@link MapRegistry} when the map is requested for the first time.
|
|
43
|
+
*
|
|
44
|
+
* See {@link MapConfig} for supported options.
|
|
45
|
+
*/
|
|
46
|
+
getMapConfig(): Promise<MapConfig>;
|
|
47
|
+
}
|
|
48
|
+
import "@open-pioneer/runtime";
|
|
49
|
+
declare module "@open-pioneer/runtime" {
|
|
50
|
+
interface ServiceRegistry {
|
|
51
|
+
"map.MapRegistry": MapRegistry;
|
|
52
|
+
"map.MapConfigProvider": MapConfigProvider;
|
|
53
|
+
}
|
|
54
|
+
}
|
package/api/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from "./MapConfig";
|
|
2
|
+
export * from "./MapModel";
|
|
3
|
+
export * from "./MapRegistry";
|
|
4
|
+
export * from "./layers";
|
|
5
|
+
export * from "./shared";
|
|
6
|
+
export { getProjection, registerProjections, type ProjectionDefinition } from "../projections";
|
|
7
|
+
export { BkgTopPlusOpen, type BkgTopPlusOpenProps } from "../layers/BkgTopPlusOpen";
|
|
8
|
+
export { useCenter, useProjection, useResolution, useScale } from "../ui/hooks";
|
|
9
|
+
export { MapAnchor, type MapAnchorProps, type MapAnchorPosition } from "../ui/MapAnchor";
|
|
10
|
+
export { MapContainer, type MapContainerProps, type MapPadding } from "../ui/MapContainer";
|
|
11
|
+
export { useMapModel, type UseMapModelResult, type UseMapModelLoading, type UseMapModelResolved, type UseMapModelRejected } from "../ui/useMapModel";
|
|
12
|
+
export { TOPMOST_LAYER_Z } from "../model/LayerCollectionImpl";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type OlBaseLayer from "ol/layer/Base";
|
|
2
|
+
import { LayerConfig, Layer } from "./base";
|
|
3
|
+
/**
|
|
4
|
+
* Options to construct a simple layer.
|
|
5
|
+
*
|
|
6
|
+
* Simple layers are wrappers around a custom OpenLayers layer.
|
|
7
|
+
*/
|
|
8
|
+
export interface SimpleLayerConfig extends LayerConfig {
|
|
9
|
+
/**
|
|
10
|
+
* The raw OpenLayers instance.
|
|
11
|
+
*/
|
|
12
|
+
olLayer: OlBaseLayer;
|
|
13
|
+
}
|
|
14
|
+
/** Constructor for {@link SimpleLayer}. */
|
|
15
|
+
export interface SimpleLayerConstructor {
|
|
16
|
+
prototype: SimpleLayer;
|
|
17
|
+
/** Creates a new {@link SimpleLayer}. */
|
|
18
|
+
new (config: SimpleLayerConfig): SimpleLayer;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A simple layer type wrapping an OpenLayers layer.
|
|
22
|
+
*/
|
|
23
|
+
export type SimpleLayer = Layer;
|
|
24
|
+
export declare const SimpleLayer: SimpleLayerConstructor;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SimpleLayer.js","sources":["SimpleLayer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport type OlBaseLayer from \"ol/layer/Base\";\nimport { LayerConfig, Layer } from \"./base\";\nimport { SimpleLayerImpl } from \"../../model/layers/SimpleLayerImpl\";\n\n/**\n * Options to construct a simple layer.\n *\n * Simple layers are wrappers around a custom OpenLayers layer.\n */\nexport interface SimpleLayerConfig extends LayerConfig {\n /**\n * The raw OpenLayers instance.\n */\n olLayer: OlBaseLayer;\n}\n\n/** Constructor for {@link SimpleLayer}. */\nexport interface SimpleLayerConstructor {\n prototype: SimpleLayer;\n\n /** Creates a new {@link SimpleLayer}. */\n new (config: SimpleLayerConfig): SimpleLayer;\n}\n\n/**\n * A simple layer type wrapping an OpenLayers layer.\n */\nexport type SimpleLayer = Layer;\nexport const SimpleLayer: SimpleLayerConstructor = SimpleLayerImpl;\n"],"names":[],"mappings":";;AA8BO,MAAM,WAAsC,GAAA;;;;"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Options as WMSSourceOptions } from "ol/source/ImageWMS";
|
|
2
|
+
import type { LayerBaseConfig, Layer, SublayersCollection } from "./base";
|
|
3
|
+
/**
|
|
4
|
+
* Configuration options to construct a WMS layer.
|
|
5
|
+
*/
|
|
6
|
+
export interface WMSLayerConfig extends LayerBaseConfig {
|
|
7
|
+
/** URL of the WMS service. */
|
|
8
|
+
url: string;
|
|
9
|
+
/** Configures the layer's sublayers. */
|
|
10
|
+
sublayers?: WMSSublayerConfig[];
|
|
11
|
+
/**
|
|
12
|
+
* Additional source options for the layer's WMS source.
|
|
13
|
+
*
|
|
14
|
+
* NOTE: These options are intended for advanced configuration:
|
|
15
|
+
* the WMS Layer manages some of the open layers source options itself.
|
|
16
|
+
*/
|
|
17
|
+
sourceOptions?: Partial<WMSSourceOptions>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Configuration options to construct the sublayers of a WMS layer.
|
|
21
|
+
*/
|
|
22
|
+
export interface WMSSublayerConfig extends LayerBaseConfig {
|
|
23
|
+
/** The name of the WMS sublayer in the service's capabilities. */
|
|
24
|
+
name: string;
|
|
25
|
+
/** Configuration for nested sublayers. */
|
|
26
|
+
sublayers?: WMSSublayerConfig[];
|
|
27
|
+
}
|
|
28
|
+
/** Represents a WMS layer. */
|
|
29
|
+
export interface WMSLayer extends Layer {
|
|
30
|
+
readonly sublayers: SublayersCollection;
|
|
31
|
+
/** The URL of the WMS service that was used during layer construction. */
|
|
32
|
+
readonly url: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Constructor for {@link WMSLayer}.
|
|
36
|
+
*/
|
|
37
|
+
export interface WMSLayerConstructor {
|
|
38
|
+
prototype: WMSLayer;
|
|
39
|
+
/** Creates a new {@link WMSLayer}. */
|
|
40
|
+
new (config: WMSLayerConfig): WMSLayer;
|
|
41
|
+
}
|
|
42
|
+
export declare const WMSLayer: WMSLayerConstructor;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WMSLayer.js","sources":["WMSLayer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport type { Options as WMSSourceOptions } from \"ol/source/ImageWMS\";\nimport { WMSLayerImpl } from \"../../model/layers/WMSLayerImpl\";\nimport type { LayerBaseConfig, Layer, SublayersCollection } from \"./base\";\n\n/**\n * Configuration options to construct a WMS layer.\n */\nexport interface WMSLayerConfig extends LayerBaseConfig {\n /** URL of the WMS service. */\n url: string;\n\n /** Configures the layer's sublayers. */\n sublayers?: WMSSublayerConfig[];\n\n /**\n * Additional source options for the layer's WMS source.\n *\n * NOTE: These options are intended for advanced configuration:\n * the WMS Layer manages some of the open layers source options itself.\n */\n sourceOptions?: Partial<WMSSourceOptions>;\n}\n\n/**\n * Configuration options to construct the sublayers of a WMS layer.\n */\nexport interface WMSSublayerConfig extends LayerBaseConfig {\n /** The name of the WMS sublayer in the service's capabilities. */\n name: string;\n\n /** Configuration for nested sublayers. */\n sublayers?: WMSSublayerConfig[];\n}\n\n/** Represents a WMS layer. */\nexport interface WMSLayer extends Layer {\n readonly sublayers: SublayersCollection;\n\n /** The URL of the WMS service that was used during layer construction. */\n readonly url: string;\n}\n\n/**\n * Constructor for {@link WMSLayer}.\n */\nexport interface WMSLayerConstructor {\n prototype: WMSLayer;\n\n /** Creates a new {@link WMSLayer}. */\n new (config: WMSLayerConfig): WMSLayer;\n}\n\nexport const WMSLayer: WMSLayerConstructor = WMSLayerImpl;\n"],"names":[],"mappings":";;AAsDO,MAAM,QAAgC,GAAA;;;;"}
|
|
@@ -0,0 +1,170 @@
|
|
|
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
|
+
/** Events emitted by the {@link Layer} and other layer types. */
|
|
6
|
+
export interface LayerBaseEvents {
|
|
7
|
+
"changed": void;
|
|
8
|
+
"changed:title": void;
|
|
9
|
+
"changed:description": void;
|
|
10
|
+
"changed:visible": void;
|
|
11
|
+
"changed:attributes": void;
|
|
12
|
+
"changed:loadState": void;
|
|
13
|
+
"destroy": void;
|
|
14
|
+
}
|
|
15
|
+
/** The load state of a layer. */
|
|
16
|
+
export type LayerLoadState = "not-loaded" | "loading" | "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 LayerBase<AdditionalEvents = {}> extends EventSource<LayerBaseEvents & AdditionalEvents> {
|
|
53
|
+
/** The map this layer belongs to. */
|
|
54
|
+
readonly map: MapModel;
|
|
55
|
+
/**
|
|
56
|
+
* The unique id of this layer within its map model.
|
|
57
|
+
*
|
|
58
|
+
* NOTE: layer ids may not be globally unique: layers that belong
|
|
59
|
+
* to different map models may have the same id.
|
|
60
|
+
*/
|
|
61
|
+
readonly id: string;
|
|
62
|
+
/** The human-readable title of this layer. */
|
|
63
|
+
readonly title: string;
|
|
64
|
+
/** The human-readable description of this layer. May be empty. */
|
|
65
|
+
readonly description: string;
|
|
66
|
+
/**
|
|
67
|
+
* Whether the layer is visible or not.
|
|
68
|
+
*
|
|
69
|
+
* NOTE: The model's visible state may do more than influence the raw OpenLayers's visibility property.
|
|
70
|
+
* Future versions may completely remove invisible layers from the OpenLayer's map under some circumstances.
|
|
71
|
+
*/
|
|
72
|
+
readonly visible: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* The collection of child sublayers for this layer.
|
|
75
|
+
*
|
|
76
|
+
* Layers that can never have any sublayers may not have a `sublayers` collection.
|
|
77
|
+
*/
|
|
78
|
+
readonly sublayers: SublayersCollection | undefined;
|
|
79
|
+
/**
|
|
80
|
+
* Additional attributes associated with this layer.
|
|
81
|
+
*/
|
|
82
|
+
readonly attributes: Readonly<Record<string | symbol, unknown>>;
|
|
83
|
+
/**
|
|
84
|
+
* Updates the title of this layer.
|
|
85
|
+
*/
|
|
86
|
+
setTitle(newTitle: string): void;
|
|
87
|
+
/**
|
|
88
|
+
* Updates the description of this layer.
|
|
89
|
+
*/
|
|
90
|
+
setDescription(newDescription: string): void;
|
|
91
|
+
/**
|
|
92
|
+
* Updates the visibility of this layer to the new value.
|
|
93
|
+
*
|
|
94
|
+
* NOTE: The visibility of base layers cannot be changed through this method.
|
|
95
|
+
* Call {@link LayerCollection.activateBaseLayer} instead.
|
|
96
|
+
*/
|
|
97
|
+
setVisible(newVisibility: boolean): void;
|
|
98
|
+
/**
|
|
99
|
+
* Updates the attributes of this layer.
|
|
100
|
+
* Values in `newAttributes` are merged into the existing ones (i.e. via `Object.assign`).
|
|
101
|
+
*/
|
|
102
|
+
updateAttributes(newAttributes: Record<string | symbol, unknown>): void;
|
|
103
|
+
/**
|
|
104
|
+
* Deletes the attribute of this layer.
|
|
105
|
+
*/
|
|
106
|
+
deleteAttribute(deleteAttribute: string | symbol): void;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Configuration options supported by all operational layer types.
|
|
110
|
+
*/
|
|
111
|
+
export interface LayerConfig extends LayerBaseConfig {
|
|
112
|
+
/**
|
|
113
|
+
* Whether this layer is a base layer or not.
|
|
114
|
+
* Only one base layer can be active at a time.
|
|
115
|
+
*
|
|
116
|
+
* Defaults to `false`.
|
|
117
|
+
*/
|
|
118
|
+
isBaseLayer?: boolean;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Represents an operational layer in the map.
|
|
122
|
+
*
|
|
123
|
+
* Instances of this interface cannot be constructed directly; use a real layer
|
|
124
|
+
* class such as {@link SimpleLayer} instead.
|
|
125
|
+
*/
|
|
126
|
+
export interface Layer<AdditionalEvents = {}> extends LayerBase<AdditionalEvents> {
|
|
127
|
+
/**
|
|
128
|
+
* The load state of a layer.
|
|
129
|
+
*/
|
|
130
|
+
readonly loadState: LayerLoadState;
|
|
131
|
+
/**
|
|
132
|
+
* The raw OpenLayers layer.
|
|
133
|
+
*/
|
|
134
|
+
readonly olLayer: OlBaseLayer;
|
|
135
|
+
/**
|
|
136
|
+
* True if this layer is a base layer.
|
|
137
|
+
*
|
|
138
|
+
* Only one base layer can be visible at a time.
|
|
139
|
+
*/
|
|
140
|
+
readonly isBaseLayer: boolean;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Represents a sublayer of another layer.
|
|
144
|
+
*/
|
|
145
|
+
export interface Sublayer extends LayerBase {
|
|
146
|
+
/**
|
|
147
|
+
* The direct parent of this layer instance.
|
|
148
|
+
* This can either be the parent layer or another sublayer.
|
|
149
|
+
*/
|
|
150
|
+
readonly parent: Layer | Sublayer;
|
|
151
|
+
/**
|
|
152
|
+
* The parent layer that owns this sublayer.
|
|
153
|
+
*/
|
|
154
|
+
readonly parentLayer: Layer;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Events emitted by the {@link SublayersCollection}.
|
|
158
|
+
*/
|
|
159
|
+
export interface SublayersCollectionEvents {
|
|
160
|
+
changed: void;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Contains the sublayers that belong to a {@link Layer} or {@link Sublayer}.
|
|
164
|
+
*/
|
|
165
|
+
export interface SublayersCollection extends EventSource<SublayersCollectionEvents> {
|
|
166
|
+
/**
|
|
167
|
+
* Returns the child sublayers in this collection.
|
|
168
|
+
*/
|
|
169
|
+
getSublayers(options?: LayerRetrievalOptions): Sublayer[];
|
|
170
|
+
}
|
package/api/shared.d.ts
ADDED
|
@@ -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
|
+
}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./api";
|
package/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import '@open-pioneer/runtime';
|
|
2
|
+
export { SimpleLayer } from './api/layers/SimpleLayer.js';
|
|
3
|
+
export { WMSLayer } from './api/layers/WMSLayer.js';
|
|
4
|
+
export { getProjection, registerProjections } from './projections.js';
|
|
5
|
+
export { BkgTopPlusOpen } from './layers/BkgTopPlusOpen.js';
|
|
6
|
+
export { useCenter, useProjection, useResolution, useScale } from './ui/hooks.js';
|
|
7
|
+
export { MapAnchor } from './ui/MapAnchor.js';
|
|
8
|
+
export { MapContainer } from './ui/MapContainer.js';
|
|
9
|
+
export { useMapModel } from './ui/useMapModel.js';
|
|
10
|
+
export { TOPMOST_LAYER_Z } from './model/LayerCollectionImpl.js';
|
|
11
|
+
//# 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,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';
|
|
2
|
+
import WMTSTileGrid from 'ol/tilegrid/WMTS';
|
|
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 ${( 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
|