@masterportal/masterportalapi 2.19.1 → 2.20.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 +18 -7
- package/example/config/services.json +42 -21
- package/example/index.js +111 -97
- package/jest.setup.js +15 -0
- package/package.json +4 -4
- package/src/index.js +2 -0
- package/src/layer/wfs.js +19 -0
- package/src/maps/interactions/drawInteractions.js +130 -0
- package/src/maps/ol/olMap.js +2 -2
- package/src/renderer/webgl.js +38 -77
- package/src/vectorStyle/createStyle.js +21 -15
- package/src/vectorStyle/styles/point/stylePoint.js +2 -2
- package/src/vectorStyle/styles/polygon/stylePolygon.js +2 -2
- package/src/vectorStyle/styles/style.js +8 -0
- package/src/vectorStyle/styles/styleCesium.js +2 -2
- package/src/vectorStyle/styles/styleLine.js +2 -2
- package/src/vectorStyle/styles/styleText.js +2 -2
- package/test/layer/wfs.test.js +52 -0
- package/test/maps/interactions/drawInteractions.test.js +50 -0
- package/test/renderer/webgl.test.js +0 -50
- package/test/vectorStyle/createStyle.test.js +123 -0
- package/test/vectorStyle/styles/point/stylePoint.test.js +7 -1
- package/test/vectorStyle/styles/polygon/stylePolygon.test.js +4 -1
- package/test/vectorStyle/styles/styleLine.test.js +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,21 +3,32 @@
|
|
|
3
3
|
|
|
4
4
|
The [Semantic Versioning](https://semver.org/spec/v2.0.0.html) is used.
|
|
5
5
|
|
|
6
|
-
##
|
|
6
|
+
## ## 2.20.0 - 2023-06-30
|
|
7
7
|
### Added
|
|
8
|
+
- Add draw interaction for interactive and static geometry types.
|
|
9
|
+
- WFS: Added function to load wfs features manually.
|
|
10
|
+
|
|
8
11
|
### Changed
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
- The following packages have been updated:
|
|
13
|
+
- dependencies:
|
|
14
|
+
- ol: 7.3.0 to 7.4.0
|
|
15
|
+
- cesium: 1.95.0 to 1.106.0
|
|
16
|
+
- The examples in example/index.js are updated.
|
|
17
|
+
|
|
11
18
|
### Fixed
|
|
19
|
+
- VectorStyle: fixed several bugs of multiple geometries with styling rules.
|
|
12
20
|
|
|
13
21
|
---
|
|
22
|
+
|
|
23
|
+
## 2.19.2 - 2023-06-12
|
|
24
|
+
### Fixed
|
|
25
|
+
- VectorStyle of multiple geometries with styling rules does not fail on not existing style.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
14
29
|
## 2.19.1 - 2023-06-02
|
|
15
|
-
### Added
|
|
16
30
|
### Changed
|
|
17
31
|
- Exports in src/layer/wmts.js changed to export default {} to provide ES-Syntax.
|
|
18
|
-
### Deprecated
|
|
19
|
-
### Removed
|
|
20
|
-
### Fixed
|
|
21
32
|
|
|
22
33
|
---
|
|
23
34
|
|
|
@@ -135,32 +135,53 @@
|
|
|
135
135
|
},
|
|
136
136
|
{
|
|
137
137
|
"id": "6001",
|
|
138
|
-
"name": "
|
|
139
|
-
"
|
|
140
|
-
"epsg": "EPSG:25832",
|
|
138
|
+
"name": "ArcGIS VectorTile",
|
|
139
|
+
"shortname": "VectorTile",
|
|
141
140
|
"typ": "VectorTile",
|
|
141
|
+
"visibility": false,
|
|
142
|
+
"preview": {
|
|
143
|
+
"src": "./resources/vectorTile.png"
|
|
144
|
+
},
|
|
145
|
+
"gfiAttributes": "showAll",
|
|
146
|
+
"url": "https://test.geoportal-hamburg.de/vt/esri/tile/{z}/{y}/{x}.pbf",
|
|
147
|
+
"epsg": "EPSG:25832",
|
|
142
148
|
"extent": [
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
149
|
+
441336.2209999999,
|
|
150
|
+
5915995,
|
|
151
|
+
594002,
|
|
152
|
+
5986767.56699999981
|
|
153
|
+
],
|
|
154
|
+
"origin": [
|
|
155
|
+
-9497963.94293634221,
|
|
156
|
+
9997963.94293634221
|
|
147
157
|
],
|
|
148
158
|
"resolutions": [
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
159
|
+
39054.5466520950868,
|
|
160
|
+
19527.2733260475434,
|
|
161
|
+
9763.63666302377169,
|
|
162
|
+
4881.81833151188584,
|
|
163
|
+
2440.90916575594292,
|
|
164
|
+
1220.45458287797146,
|
|
165
|
+
610.227291438985731,
|
|
166
|
+
305.113645719492865,
|
|
167
|
+
152.556822859746433,
|
|
168
|
+
76.2784114298732163,
|
|
169
|
+
38.1392057149366082,
|
|
170
|
+
19.0696028574683041,
|
|
171
|
+
9.534801428734152,
|
|
172
|
+
4.767400714367076,
|
|
173
|
+
2.383700357183538,
|
|
174
|
+
1.191850178591769
|
|
161
175
|
],
|
|
162
|
-
"tileSize":
|
|
163
|
-
"
|
|
176
|
+
"tileSize": 512,
|
|
177
|
+
"vtStyles": [
|
|
178
|
+
{
|
|
179
|
+
"id": "VectorTile_STYLE",
|
|
180
|
+
"name": "Test",
|
|
181
|
+
"url": "https://test.geoportal-hamburg.de/vt/esri/resources/styles/root.json",
|
|
182
|
+
"defaultStyle": true
|
|
183
|
+
}
|
|
184
|
+
]
|
|
164
185
|
},
|
|
165
186
|
{
|
|
166
187
|
"id": "7001",
|
package/example/index.js
CHANGED
|
@@ -18,6 +18,7 @@ function errorCallback (errorEvent) {
|
|
|
18
18
|
console.error("This is an error event:", errorEvent);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
// Definitions:
|
|
21
22
|
//* Add elements to window to play with API in console
|
|
22
23
|
window.mpapi = {
|
|
23
24
|
...mpapi,
|
|
@@ -45,12 +46,12 @@ const hamburgServicesUrl = "https://geodienste.hamburg.de/services-internet.json
|
|
|
45
46
|
// eslint-disable-next-line func-style
|
|
46
47
|
getWfsStyleFunction = function () {
|
|
47
48
|
const styleId = "8712",
|
|
48
|
-
olLayer = window.mpapi.map
|
|
49
|
-
source = olLayer
|
|
49
|
+
olLayer = window.mpapi.map?.getLayers().getArray().find((element) => element.get("id") === "8712"),
|
|
50
|
+
source = olLayer?.getSource(),
|
|
50
51
|
styleObject = styleList.returnStyleObject(styleId);
|
|
51
52
|
let isClusterFeature = false;
|
|
52
53
|
|
|
53
|
-
if (styleObject !== undefined) {
|
|
54
|
+
if (styleObject !== undefined && source !== undefined) {
|
|
54
55
|
source.on("featuresloadend", event => {
|
|
55
56
|
event.features.forEach(element => {
|
|
56
57
|
isClusterFeature = false;
|
|
@@ -61,6 +62,9 @@ const hamburgServicesUrl = "https://geodienste.hamburg.de/services-internet.json
|
|
|
61
62
|
};
|
|
62
63
|
let map2D = null;
|
|
63
64
|
|
|
65
|
+
|
|
66
|
+
// Examples:
|
|
67
|
+
|
|
64
68
|
/* VectorStyle example */
|
|
65
69
|
// Example for using the vectorStyle that is now implemented in the masterportalAPI.
|
|
66
70
|
// Hardcoded to show the school layer "8712" as a wfs and "1534" as wfs with webgl renderer.
|
|
@@ -74,70 +78,8 @@ styleList.initializeStyleList({}, config, config.layers, undefined, (currentStyl
|
|
|
74
78
|
return currentStyleList;
|
|
75
79
|
});
|
|
76
80
|
|
|
77
|
-
// */
|
|
78
81
|
//* Cleans up map before it is re-rendered (happens on every save during dev mode)
|
|
79
82
|
document.getElementById(portalConfig.target).innerHTML = "";
|
|
80
|
-
// add a click-listener to button, that creates a 3D-map on click
|
|
81
|
-
document.getElementById("enable").addEventListener("click", function () {
|
|
82
|
-
if (window.mpapi.map2D === null) {
|
|
83
|
-
window.mpapi.map2D = window.mpapi.map;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (window.mpapi.map.mapMode === "3D") {
|
|
87
|
-
window.mpapi.map.setEnabled(false);
|
|
88
|
-
window.mpapi.map = window.mpapi.map2D;
|
|
89
|
-
window.mpapi.map.getView().setRotation(0);
|
|
90
|
-
document.getElementById("layer-visibility").style.display = "none";
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
const lib = portalConfig.cesiumLib ? portalConfig.cesiumLib : "https://geoportal-hamburg.de/mastercode/cesium/1_99/index.js";
|
|
94
|
-
|
|
95
|
-
document.getElementById("layer-visibility").style.display = "block";
|
|
96
|
-
|
|
97
|
-
load3DScriptModule.load3DScript(lib, function Loaded3DCallback () {
|
|
98
|
-
let tilesetLayer = null;
|
|
99
|
-
|
|
100
|
-
const settings3D = {
|
|
101
|
-
map2D: window.mpapi.map2D,
|
|
102
|
-
// set some options to Cesium scene
|
|
103
|
-
cesiumParameter: {
|
|
104
|
-
fxaa: true,
|
|
105
|
-
globe: {
|
|
106
|
-
enableLighting: true,
|
|
107
|
-
maximumScreenSpaceError: 2,
|
|
108
|
-
tileCacheSize: 20
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
map3D = mapsAPI.map.createMap(settings3D, "3D"),
|
|
113
|
-
rawLayerTerrain = rawLayerList.getLayerWhere({id: "4001"}),
|
|
114
|
-
rawLayerTileset = rawLayerList.getLayerWhere({id: "4002"}),
|
|
115
|
-
rawLayerEntities = rawLayerList.getLayerWhere({id: "4003"});
|
|
116
|
-
|
|
117
|
-
window.mpapi.map = map3D;
|
|
118
|
-
tilesetLayer = new mpapi.Tileset(rawLayerTileset, window.mpapi.map);
|
|
119
|
-
tilesetLayer.setVisible(true, window.mpapi.map);
|
|
120
|
-
|
|
121
|
-
// entities are 2 simple buildings in the park 'planten und blomen' near Tiergartenstraße
|
|
122
|
-
mpapi.entities.createLayer(rawLayerEntities, window.mpapi.map);
|
|
123
|
-
// mpapi.entities.setVisible(true, rawLayerEntities, window.mpapi.map);
|
|
124
|
-
|
|
125
|
-
mpapi.terrain.createLayer(rawLayerTerrain, window.mpapi.map);
|
|
126
|
-
mpapi.terrain.setVisible(true, rawLayerTerrain, window.mpapi.map);
|
|
127
|
-
|
|
128
|
-
window.mpapi.map.setEnabled(true);
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
// add a click-listener to button, that hides background layer in 3d
|
|
134
|
-
document.getElementById("layer-visibility").addEventListener("click", function () {
|
|
135
|
-
map2D.getLayers().forEach(layer => {
|
|
136
|
-
map2D.removeLayer(layer);
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
map2D = mapsAPI.map.createMap(config, "2D", {errorCallback});
|
|
141
83
|
|
|
142
84
|
//* geojson styling function call to override default styling and special wfs styling
|
|
143
85
|
mpapi.geojson.setCustomStyles({
|
|
@@ -167,7 +109,6 @@ const styleWfs = function (feature, resolution) {
|
|
|
167
109
|
};
|
|
168
110
|
|
|
169
111
|
services.find(({id}) => id === "3001").style = styleWfs;
|
|
170
|
-
// */
|
|
171
112
|
|
|
172
113
|
|
|
173
114
|
// eslint-disable-next-line
|
|
@@ -187,6 +128,8 @@ const styleOaf = function (feature, resolution) {
|
|
|
187
128
|
services.find(({id}) => id === "5001").style = styleOaf;
|
|
188
129
|
|
|
189
130
|
//* SYNCHRONOUS EXAMPLE: layerConf is known
|
|
131
|
+
// /*
|
|
132
|
+
map2D = mapsAPI.map.createMap(config, "2D", {errorCallback});
|
|
190
133
|
window.mpapi.map = map2D;
|
|
191
134
|
|
|
192
135
|
["2001", "2002", "1002", "3001", "5001"].forEach(id => window.mpapi.map.addLayer(id, {errorCallback}));
|
|
@@ -204,7 +147,8 @@ services
|
|
|
204
147
|
|
|
205
148
|
// */
|
|
206
149
|
|
|
207
|
-
|
|
150
|
+
//* ASYNCHRONOUS EXAMPLE 1: work with layerConf callback (for testing comment out SYNCHRONOUS EXAMPLE)
|
|
151
|
+
/*
|
|
208
152
|
document.getElementById("enable").style.display = "none";
|
|
209
153
|
mpapi.rawLayerList.initializeLayerList(hamburgServicesUrl,
|
|
210
154
|
conf => {
|
|
@@ -213,49 +157,34 @@ mpapi.rawLayerList.initializeLayerList(hamburgServicesUrl,
|
|
|
213
157
|
layerConf: conf,
|
|
214
158
|
layers: null
|
|
215
159
|
}, "2D");
|
|
216
|
-
["
|
|
160
|
+
["23420", "6074"].forEach(id => window.mpapi.map.addLayer(id));
|
|
217
161
|
});
|
|
218
|
-
|
|
162
|
+
*/
|
|
219
163
|
|
|
220
|
-
|
|
164
|
+
//* ASYNCHRONOUS EXAMPLE 2: work with createMap callback (for testing comment out SYNCHRONOUS EXAMPLE)
|
|
165
|
+
/*
|
|
221
166
|
document.getElementById("enable").style.display = "none";
|
|
222
167
|
window.mpapi.map = mapsAPI.map.createMap({
|
|
223
168
|
...portalConfig, layerConf: hamburgServicesUrl, layers: [
|
|
224
|
-
{id: "
|
|
169
|
+
{id: "23420"},
|
|
225
170
|
{id: "453", transparency: 50}
|
|
226
171
|
]}, "2D",
|
|
227
172
|
{
|
|
228
173
|
callback: () => ["6074"].forEach(id => window.mpapi.map.addLayer(id))
|
|
229
174
|
});
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
/* SEARCH FUNCTION EXAMPLE
|
|
233
|
-
// You may e.g. copy this code to the browser's console to run a search.
|
|
234
|
-
|
|
235
|
-
window.mpapi.search("Eiffe", {
|
|
236
|
-
map: window.mpapi.map,
|
|
237
|
-
zoom: true,
|
|
238
|
-
zoomToParams: {duration: 1000, maxZoom: 8},
|
|
239
|
-
searchStreets: true
|
|
240
|
-
}).then(x => console.log(x)).catch(e => console.error(e));
|
|
241
|
-
|
|
242
|
-
window.mpapi.search("Mümmelmannsberg 72", {
|
|
243
|
-
map: window.mpapi.map,
|
|
244
|
-
zoom: true,
|
|
245
|
-
zoomToParams: {duration: 1000, maxZoom: 8},
|
|
246
|
-
searchAddress: true
|
|
247
|
-
}).then(x => console.log(x)).catch(e => console.error(e));
|
|
175
|
+
*/
|
|
248
176
|
|
|
249
|
-
//*/
|
|
250
177
|
|
|
251
178
|
/* VECTOR TILE EXAMPLE */
|
|
252
179
|
/*
|
|
253
180
|
document.getElementById("enable").style.display = "none";
|
|
254
|
-
|
|
255
|
-
|
|
181
|
+
window.mpapi.map = mapsAPI.map.createMap(config, "2D", {errorCallback});
|
|
182
|
+
|
|
183
|
+
window.mpapi.map.getLayers().forEach(layer => {
|
|
184
|
+
window.mpapi.map.removeLayer(layer);
|
|
256
185
|
});
|
|
257
186
|
|
|
258
|
-
const vtStyleUrl = "https://
|
|
187
|
+
const vtStyleUrl = "https://test.geoportal-hamburg.de/vt/esri/resources/styles/root.json";
|
|
259
188
|
|
|
260
189
|
fetch(vtStyleUrl)
|
|
261
190
|
.then(response => response.json())
|
|
@@ -264,20 +193,105 @@ fetch(vtStyleUrl)
|
|
|
264
193
|
|
|
265
194
|
mpapi.vectorTile.setStyle(vtLayer, style, vtStyleUrl);
|
|
266
195
|
});
|
|
267
|
-
|
|
196
|
+
*/
|
|
268
197
|
|
|
269
198
|
/* WMTS example */
|
|
270
199
|
/*
|
|
271
|
-
|
|
272
|
-
|
|
200
|
+
window.mpapi.map = mapsAPI.map.createMap(config, "2D", {errorCallback});
|
|
201
|
+
|
|
202
|
+
window.mpapi.map.getLayers().forEach(layer => {
|
|
203
|
+
window.mpapi.map.removeLayer(layer);
|
|
273
204
|
});
|
|
274
205
|
window.mpapi.map.addLayer("7001");
|
|
275
206
|
window.mpapi.map.addLayer("7002");
|
|
276
207
|
window.mpapi.map.addLayer("7003");
|
|
277
|
-
|
|
208
|
+
//*/
|
|
278
209
|
|
|
279
210
|
/* VectorStyle example */
|
|
280
211
|
// Example for using the vectorStyle that is now implemented in the masterportalAPI.
|
|
281
212
|
// Apply style to layer "8172"
|
|
282
213
|
// mirrors behavior of Masterportal styling
|
|
283
214
|
getWfsStyleFunction();
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
/* SEARCH FUNCTION EXAMPLE
|
|
218
|
+
// You may e.g. copy this code to the browser's console to run a search.
|
|
219
|
+
|
|
220
|
+
window.mpapi.search("Eiffe", {
|
|
221
|
+
map: window.mpapi.map,
|
|
222
|
+
zoom: true,
|
|
223
|
+
zoomToParams: {duration: 1000, maxZoom: 8},
|
|
224
|
+
searchStreets: true
|
|
225
|
+
}).then(x => console.log(x)).catch(e => console.error(e));
|
|
226
|
+
|
|
227
|
+
window.mpapi.search("Mümmelmannsberg 72", {
|
|
228
|
+
map: window.mpapi.map,
|
|
229
|
+
zoom: true,
|
|
230
|
+
zoomToParams: {duration: 1000, maxZoom: 8},
|
|
231
|
+
searchAddress: true
|
|
232
|
+
}).then(x => console.log(x)).catch(e => console.error(e));
|
|
233
|
+
|
|
234
|
+
//*/
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
// Add 3D functionality to the example:
|
|
238
|
+
|
|
239
|
+
// add a click-listener to button, that creates a 3D-map on click
|
|
240
|
+
document.getElementById("enable").addEventListener("click", function () {
|
|
241
|
+
if (window.mpapi.map2D === null) {
|
|
242
|
+
window.mpapi.map2D = window.mpapi.map;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (window.mpapi.map.mapMode === "3D") {
|
|
246
|
+
window.mpapi.map.setEnabled(false);
|
|
247
|
+
window.mpapi.map = window.mpapi.map2D;
|
|
248
|
+
window.mpapi.map.getView().setRotation(0);
|
|
249
|
+
document.getElementById("layer-visibility").style.display = "none";
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
const lib = portalConfig.cesiumLib ? portalConfig.cesiumLib : "https://geoportal-hamburg.de/mastercode/cesium/1_99/index.js";
|
|
253
|
+
|
|
254
|
+
document.getElementById("layer-visibility").style.display = "block";
|
|
255
|
+
|
|
256
|
+
load3DScriptModule.load3DScript(lib, function Loaded3DCallback () {
|
|
257
|
+
let tilesetLayer = null;
|
|
258
|
+
|
|
259
|
+
const settings3D = {
|
|
260
|
+
map2D: window.mpapi.map2D,
|
|
261
|
+
// set some options to Cesium scene
|
|
262
|
+
cesiumParameter: {
|
|
263
|
+
fxaa: true,
|
|
264
|
+
globe: {
|
|
265
|
+
enableLighting: true,
|
|
266
|
+
maximumScreenSpaceError: 2,
|
|
267
|
+
tileCacheSize: 20
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
map3D = mapsAPI.map.createMap(settings3D, "3D"),
|
|
272
|
+
rawLayerTerrain = rawLayerList.getLayerWhere({id: "4001"}),
|
|
273
|
+
rawLayerTileset = rawLayerList.getLayerWhere({id: "4002"}),
|
|
274
|
+
rawLayerEntities = rawLayerList.getLayerWhere({id: "4003"});
|
|
275
|
+
|
|
276
|
+
window.mpapi.map = map3D;
|
|
277
|
+
tilesetLayer = new mpapi.Tileset(rawLayerTileset, window.mpapi.map);
|
|
278
|
+
tilesetLayer.setVisible(true, window.mpapi.map);
|
|
279
|
+
|
|
280
|
+
// entities are 2 simple buildings in the park 'planten und blomen' near Tiergartenstraße
|
|
281
|
+
mpapi.entities.createLayer(rawLayerEntities, window.mpapi.map);
|
|
282
|
+
// mpapi.entities.setVisible(true, rawLayerEntities, window.mpapi.map);
|
|
283
|
+
|
|
284
|
+
mpapi.terrain.createLayer(rawLayerTerrain, window.mpapi.map);
|
|
285
|
+
mpapi.terrain.setVisible(true, rawLayerTerrain, window.mpapi.map);
|
|
286
|
+
|
|
287
|
+
window.mpapi.map.setEnabled(true);
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
// add a click-listener to button, that hides background layer in 3d
|
|
293
|
+
document.getElementById("layer-visibility").addEventListener("click", function () {
|
|
294
|
+
map2D.getLayers().forEach(layer => {
|
|
295
|
+
map2D.removeLayer(layer);
|
|
296
|
+
});
|
|
297
|
+
});
|
package/jest.setup.js
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import "regenerator-runtime/runtime";
|
|
2
2
|
|
|
3
|
+
class Worker {
|
|
4
|
+
constructor (stringUrl) {
|
|
5
|
+
this.url = stringUrl;
|
|
6
|
+
this.onmessage = () => {
|
|
7
|
+
// empty
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
postMessage (msg) {
|
|
12
|
+
this.onmessage(msg);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
// a mock for web worker
|
|
16
|
+
window.Worker = Worker;
|
|
17
|
+
|
|
3
18
|
window.URL.createObjectURL = function () {
|
|
4
19
|
// empty
|
|
5
20
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@masterportal/masterportalapi",
|
|
3
3
|
"author": "Implementierungspartnerschaft Masterportal <info@masterportal.org> (https://www.masterportal.org)",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.20.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Basic functions of the Masterportal as api",
|
|
7
7
|
"repository": {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"main": "src/index.js",
|
|
12
12
|
"scripts": {
|
|
13
13
|
"test": "jest .test.js --config ./jest.config.js --collectCoverage",
|
|
14
|
-
"test:trace": "node --trace-warnings node_modules/jest/bin/jest.js
|
|
14
|
+
"test:trace": "node --trace-warnings node_modules/jest/bin/jest.js .test.js --config ./jest.config.js",
|
|
15
15
|
"test:watch": "jest .test.js --config ./jest.config.js --watch",
|
|
16
16
|
"example": "parcel example/index.html",
|
|
17
17
|
"generate-jsdoc": "jsdoc ./src -r -d ./docs/ -R ./README.md -c jsdoc.json",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"core-js": "^3.30.2",
|
|
23
23
|
"dayjs": "^1.11.7",
|
|
24
|
-
"ol": "7.
|
|
24
|
+
"ol": "7.4.0",
|
|
25
25
|
"olcs": "^2.14.0",
|
|
26
26
|
"proj4": "^2.9.0",
|
|
27
27
|
"xml2js": "^0.5.0"
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"use-resize-observer": "^9.1.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"cesium": "^1.
|
|
50
|
+
"cesium": "^1.106.0"
|
|
51
51
|
},
|
|
52
52
|
"engines": {
|
|
53
53
|
"node": "^16.13.2 || ^18.12.0",
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {createMapView} from "./maps/mapView";
|
|
2
2
|
import crs from "./crs";
|
|
3
|
+
import drawInteractions from "./maps/interactions/drawInteractions";
|
|
3
4
|
import rawLayerList from "./rawLayerList";
|
|
4
5
|
import * as wms from "./layer/wms";
|
|
5
6
|
import wmts from "./layer/wmts";
|
|
@@ -36,5 +37,6 @@ export {
|
|
|
36
37
|
ping,
|
|
37
38
|
search,
|
|
38
39
|
crs,
|
|
40
|
+
drawInteractions,
|
|
39
41
|
webgl
|
|
40
42
|
};
|
package/src/layer/wfs.js
CHANGED
|
@@ -252,3 +252,22 @@ export function createLayer (rawLayer = {}, {layerParams = {}, options = {}} = {
|
|
|
252
252
|
}
|
|
253
253
|
return layer;
|
|
254
254
|
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Load the features manually.
|
|
258
|
+
* @param {Object} layerAttributes raw layer attributes.
|
|
259
|
+
* @param {module:ol/vector/Source} layerSource - the source of the layer
|
|
260
|
+
* @returns {void}
|
|
261
|
+
*/
|
|
262
|
+
export function loadFeaturesManually (layerAttributes, layerSource) {
|
|
263
|
+
const getUrl = createUrl(layerAttributes, layerAttributes.version, {getCode: () => layerAttributes.crs}, "");
|
|
264
|
+
|
|
265
|
+
fetch(getUrl, layerSource)
|
|
266
|
+
.then(response => response.text())
|
|
267
|
+
.then(responseString => {
|
|
268
|
+
layerSource.addFeatures(layerSource.getFormat().readFeatures(responseString));
|
|
269
|
+
})
|
|
270
|
+
.catch(error => {
|
|
271
|
+
console.error(error);
|
|
272
|
+
});
|
|
273
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import {createBox} from "ol/interaction/Draw.js";
|
|
2
|
+
import {Draw} from "ol/interaction.js";
|
|
3
|
+
|
|
4
|
+
const earthRadius = 6378137,
|
|
5
|
+
roh = 180 / Math.PI,
|
|
6
|
+
mappingDrawTypes = {
|
|
7
|
+
box: {
|
|
8
|
+
type: "Circle",
|
|
9
|
+
options: {
|
|
10
|
+
geometryFunction: createBox()
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
circle: {
|
|
14
|
+
type: "Circle"
|
|
15
|
+
},
|
|
16
|
+
doubleCircle: {
|
|
17
|
+
type: "Circle"
|
|
18
|
+
},
|
|
19
|
+
line: {
|
|
20
|
+
type: "LineString"
|
|
21
|
+
},
|
|
22
|
+
pen: {
|
|
23
|
+
type: "LineString",
|
|
24
|
+
options: {
|
|
25
|
+
freehand: true
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
point: {
|
|
29
|
+
type: "Point"
|
|
30
|
+
},
|
|
31
|
+
polygon: {
|
|
32
|
+
type: "Polygon"
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Transform the radius to map projection unit.
|
|
38
|
+
* @param {Number} radius The radius.
|
|
39
|
+
* @param {Object} mapProjection The map projection.
|
|
40
|
+
* @returns {Number} The transformed radius.
|
|
41
|
+
*/
|
|
42
|
+
function transformMapUnitRadius (radius, mapProjection) {
|
|
43
|
+
const unit = mapProjection.getUnits();
|
|
44
|
+
let mapUnitRadius;
|
|
45
|
+
|
|
46
|
+
if (unit === "m") {
|
|
47
|
+
mapUnitRadius = radius;
|
|
48
|
+
}
|
|
49
|
+
else if (unit === "degrees") {
|
|
50
|
+
mapUnitRadius = radius * roh / earthRadius;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return mapUnitRadius;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Create a feature for the outer circle of draw type: double circle.
|
|
58
|
+
* @param {ol/interaction/Draw} drawInteraction The draw interaction.
|
|
59
|
+
* @param {Object} mapProjection The map projection.
|
|
60
|
+
* @param {ol/source} source The vector layer source for draw features.
|
|
61
|
+
* @param {Object} [options={}] The options for drawing features.
|
|
62
|
+
* @param {Number} [options.circleOuterRadius] The radius for the outer circle.
|
|
63
|
+
* @returns {void}
|
|
64
|
+
*/
|
|
65
|
+
function drawOuterCircle (drawInteraction, mapProjection, source, options = {}) {
|
|
66
|
+
drawInteraction.on("drawend", event => {
|
|
67
|
+
const outerCircleFeature = event.feature.clone(),
|
|
68
|
+
mapUnitOuterRadius = transformMapUnitRadius(options.circleOuterRadius, mapProjection);
|
|
69
|
+
|
|
70
|
+
outerCircleFeature.getGeometry().setRadius(mapUnitOuterRadius);
|
|
71
|
+
source.addFeature(outerCircleFeature);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Create features for non-interactive circle or double circle.
|
|
77
|
+
* @param {ol/interaction/Draw} drawInteraction The draw interaction.
|
|
78
|
+
* @param {String} drawType The current draw type.
|
|
79
|
+
* @param {Object} mapProjection The map projection.
|
|
80
|
+
* @param {ol/source} source The vector layer source for draw features.
|
|
81
|
+
* @param {Object} [options={}] The options for drawing features.
|
|
82
|
+
* @param {Number} [options.circleInnerRadius] The radius for the inner circle.
|
|
83
|
+
* @param {Number} [options.circleOuterRadius] The radius for the outer circle.
|
|
84
|
+
* @param {Boolean} [options.interactiveCircle] Circle is drawn interactively or not.
|
|
85
|
+
* @returns {void}
|
|
86
|
+
*/
|
|
87
|
+
function drawCircle (drawInteraction, drawType, mapProjection, source, options = {}) {
|
|
88
|
+
if (options.interactiveCircle === false && options.circleInnerRadius > 0) {
|
|
89
|
+
drawInteraction.on("drawstart", event => {
|
|
90
|
+
const mapUnitInnerRadius = transformMapUnitRadius(options.circleInnerRadius, mapProjection);
|
|
91
|
+
|
|
92
|
+
event.feature.getGeometry().setRadius(mapUnitInnerRadius);
|
|
93
|
+
drawInteraction.finishDrawing();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
if (drawType === "doubleCircle" && options.circleOuterRadius > 0) {
|
|
97
|
+
drawOuterCircle(drawInteraction, mapProjection, source, options);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Create the draw interaction.
|
|
104
|
+
* @param {String} drawType The current draw type.
|
|
105
|
+
* @param {ol/source} source The vector layer source for draw features.
|
|
106
|
+
* @returns {ol/interaction/Draw|null} The draw interaction.
|
|
107
|
+
*/
|
|
108
|
+
function createDrawInteraction (drawType, source) {
|
|
109
|
+
let drawInteraction = null;
|
|
110
|
+
|
|
111
|
+
if (typeof mappingDrawTypes[drawType] === "object") {
|
|
112
|
+
const options = mappingDrawTypes[drawType].options || {};
|
|
113
|
+
|
|
114
|
+
drawInteraction = new Draw({
|
|
115
|
+
source: source,
|
|
116
|
+
type: mappingDrawTypes[drawType].type,
|
|
117
|
+
freehand: options.freehand,
|
|
118
|
+
geometryFunction: options.geometryFunction
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return drawInteraction;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export default {
|
|
126
|
+
createDrawInteraction,
|
|
127
|
+
drawCircle,
|
|
128
|
+
drawOuterCircle,
|
|
129
|
+
transformMapUnitRadius
|
|
130
|
+
};
|
package/src/maps/ol/olMap.js
CHANGED
|
@@ -4,7 +4,7 @@ import setBackgroundImage from "../../lib/setBackgroundImage";
|
|
|
4
4
|
import getInitialLayers from "../../lib/getInitialLayers";
|
|
5
5
|
import defaults from "../../defaults";
|
|
6
6
|
import * as wms from "../../layer/wms";
|
|
7
|
-
import
|
|
7
|
+
import wmts from "../../layer/wmts";
|
|
8
8
|
import * as geojson from "../../layer/geojson";
|
|
9
9
|
import * as wfs from "../../layer/wfs";
|
|
10
10
|
import * as vectorBase from "../../layer/vectorBase";
|
|
@@ -23,7 +23,7 @@ let mapIdCounter = 0;
|
|
|
23
23
|
*/
|
|
24
24
|
const layerBuilderMap = {
|
|
25
25
|
wms,
|
|
26
|
-
wmts,
|
|
26
|
+
"wmts": wmts,
|
|
27
27
|
wfs,
|
|
28
28
|
geojson,
|
|
29
29
|
vectorBase,
|