@masterportal/masterportalapi 2.37.0 → 2.39.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 +42 -0
- package/package.json +6 -6
- package/src/index.js +1 -1
- package/src/layer/geojson/index.js +25 -0
- package/src/layer/oaf.js +25 -2
- package/src/layer/wms.js +9 -8
- package/src/maps/ol/olMap.js +4 -3
- package/src/renderer/webgl.js +1 -0
- package/src/vectorStyle/lib/valueOperations.js +1 -1
- package/tall +59 -0
- package/test/layer/geojson/index.test.js +30 -0
- package/test/layer/oaf.test.js +31 -1
- package/test/layer/wms.test.js +2 -9
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,48 @@
|
|
|
3
3
|
|
|
4
4
|
The [Semantic Versioning](https://semver.org/spec/v2.0.0.html) is used.
|
|
5
5
|
|
|
6
|
+
## Unreleased - in development
|
|
7
|
+
### __Breaking Changes__
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
### Deprecated
|
|
14
|
+
|
|
15
|
+
### Removed
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
## 2.39.0 - 2024-06-18
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
- peerDependencies:
|
|
24
|
+
- @cesium/engine: 6.2.0 to 9.2.0
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
## 2.38.0 - 2024-06-04
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
- Added support for Node LTS version ^20.12.2 and npm Version ^10.5.0.
|
|
31
|
+
- OAF, GeoJSON: added function loadFeaturesManually.
|
|
32
|
+
|
|
33
|
+
### Changed
|
|
34
|
+
- The following packages have been updated:
|
|
35
|
+
- dependencies:
|
|
36
|
+
- ol: 9.1.0 to 9.2.4
|
|
37
|
+
- olcs: 2.19.3 to 2.20.0
|
|
38
|
+
- Exports in src/layer/oaf.js changed to export default {} to provide ES-Syntax.
|
|
39
|
+
|
|
40
|
+
### Fixed
|
|
41
|
+
- The mitigation for issue 666 in ol-cesium since version 2.37.0 is removed
|
|
42
|
+
- Webgl: vectorTiles were not displayed.
|
|
43
|
+
- WMS-Layer: special loadFunction is only used if layer's attribute `isSecured` is true.
|
|
44
|
+
- Issue#1170: checkProperty was not negated, although it should be, so that styling-rules can be properly excluded.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
6
48
|
## 2.37.0 - 2024-04-23
|
|
7
49
|
|
|
8
50
|
### Fixed
|
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.39.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Basic functions of the Masterportal as api",
|
|
7
7
|
"repository": {
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"core-js": "^3.33.1",
|
|
23
23
|
"dayjs": "^1.11.10",
|
|
24
|
-
"ol": "9.
|
|
24
|
+
"ol": "9.2.4",
|
|
25
25
|
"ol-mapbox-style": "12.2.1",
|
|
26
|
-
"olcs": "2.
|
|
26
|
+
"olcs": "2.20.0",
|
|
27
27
|
"proj4": "^2.10.0",
|
|
28
28
|
"xml2js": "^0.6.2"
|
|
29
29
|
},
|
|
@@ -56,11 +56,11 @@
|
|
|
56
56
|
"util": "^0.12.5"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@cesium/engine": "^
|
|
59
|
+
"@cesium/engine": "^9.2.0"
|
|
60
60
|
},
|
|
61
61
|
"engines": {
|
|
62
|
-
"node": "^16.13.2 || ^18.12.0 || ^20.
|
|
63
|
-
"npm": "^8.1.2 || ^9.3.1 || ^10.
|
|
62
|
+
"node": "^16.13.2 || ^18.12.0 || ^20.12.2",
|
|
63
|
+
"npm": "^8.1.2 || ^9.3.1 || ^10.5.0"
|
|
64
64
|
},
|
|
65
65
|
"homepage": "https://bitbucket.org/geowerkstatt-hamburg/masterportalapi#readme",
|
|
66
66
|
"directories": {
|
package/src/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import wmts from "./layer/wmts";
|
|
|
6
6
|
import wfs from "./layer/wfs";
|
|
7
7
|
import * as geojson from "./layer/geojson";
|
|
8
8
|
import * as vectorTile from "./layer/vectorTile";
|
|
9
|
-
import
|
|
9
|
+
import oaf from "./layer/oaf";
|
|
10
10
|
import * as terrain from "./layer/terrain";
|
|
11
11
|
import * as entities from "./layer/entities";
|
|
12
12
|
import * as webgl from "./renderer/webgl";
|
|
@@ -167,3 +167,28 @@ export function showFeaturesById (layer, featureIdList) {
|
|
|
167
167
|
hideAllFeatures(layer);
|
|
168
168
|
setFeatureStyle(features, undefined);
|
|
169
169
|
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Load the features manually.
|
|
173
|
+
* @param {Object} layerAttributes raw layer attributes.
|
|
174
|
+
* @param {module:ol/vector/Source} layerSource - the source of the layer
|
|
175
|
+
* @returns {void}
|
|
176
|
+
*/
|
|
177
|
+
export function loadFeaturesManually (layerAttributes, layerSource) {
|
|
178
|
+
const getUrl = layerAttributes.url;
|
|
179
|
+
|
|
180
|
+
fetch(getUrl, layerSource)
|
|
181
|
+
.then(response => response.text())
|
|
182
|
+
.then(responseString => {
|
|
183
|
+
const features = layerSource.getFormat().readFeatures(responseString);
|
|
184
|
+
|
|
185
|
+
layerSource.addFeatures(features);
|
|
186
|
+
layerSource.dispatchEvent({
|
|
187
|
+
type: "featuresloadend",
|
|
188
|
+
features: layerSource.getFeatures()
|
|
189
|
+
});
|
|
190
|
+
})
|
|
191
|
+
.catch(error => {
|
|
192
|
+
console.error(error);
|
|
193
|
+
});
|
|
194
|
+
}
|
package/src/layer/oaf.js
CHANGED
|
@@ -178,7 +178,7 @@ function createUrl (rawLayer) {
|
|
|
178
178
|
* {@link https://openlayers.org/en/latest/apidoc/module-ol_source_Vector-VectorSource.html failure/success see}
|
|
179
179
|
* @returns {(ol.source.VectorSource|ol.source.Cluster)} VectorSource or Cluster, depending on whether clusterDistance is set.
|
|
180
180
|
*/
|
|
181
|
-
|
|
181
|
+
function createLayerSource (rawLayer, options = {}) {
|
|
182
182
|
if (!options.loadingStrategy) {
|
|
183
183
|
options.loadingStrategy = bbox;
|
|
184
184
|
}
|
|
@@ -203,7 +203,7 @@ export function createLayerSource (rawLayer, options = {}) {
|
|
|
203
203
|
* @param {options} [optionalParams.options] - additional options
|
|
204
204
|
* @returns {ol.Layer} Layer that can be added to map.
|
|
205
205
|
*/
|
|
206
|
-
|
|
206
|
+
function createLayer (rawLayer = {}, {layerParams = {}, options = {}} = {}) {
|
|
207
207
|
let layer, source;
|
|
208
208
|
|
|
209
209
|
// use WebGL render pipeline, if specified
|
|
@@ -239,3 +239,26 @@ export function createLayer (rawLayer = {}, {layerParams = {}, options = {}} = {
|
|
|
239
239
|
}
|
|
240
240
|
return layer;
|
|
241
241
|
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Load the features manually.
|
|
245
|
+
* @param {Object} layerAttributes raw layer attributes.
|
|
246
|
+
* @param {module:ol/vector/Source} layerSource - the source of the layer
|
|
247
|
+
* @returns {void}
|
|
248
|
+
*/
|
|
249
|
+
function loadFeaturesManually (layerAttributes, layerSource) {
|
|
250
|
+
const getUrl = createUrl(layerAttributes, layerAttributes.version, {getCode: () => layerAttributes.crs}, "");
|
|
251
|
+
|
|
252
|
+
fetch(getUrl, layerSource)
|
|
253
|
+
.then(response => {
|
|
254
|
+
return response.text();
|
|
255
|
+
})
|
|
256
|
+
.then(responseString => {
|
|
257
|
+
layerSource.addFeatures(layerSource.getFormat().readFeatures(responseString));
|
|
258
|
+
})
|
|
259
|
+
.catch(error => {
|
|
260
|
+
console.error(error);
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export default {createLayer, createLayerSource, loadFeaturesManually};
|
package/src/layer/wms.js
CHANGED
|
@@ -77,13 +77,12 @@ export function makeParams (rawLayer) {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
/**
|
|
80
|
-
* Return a ol tile or image load function for the rawLayer.
|
|
81
|
-
* @param {object} rawLayer - layer specification as in services.json
|
|
80
|
+
* Return a ol tile or image load function for the rawLayer. Fetches with credentials: 'include'.
|
|
82
81
|
* @returns {function} tile/image load function
|
|
83
82
|
*/
|
|
84
|
-
export function
|
|
83
|
+
export function loadFunctionWithCredentials () {
|
|
85
84
|
return async (image, src) => {
|
|
86
|
-
const response = await fetch(src, {credentials:
|
|
85
|
+
const response = await fetch(src, {credentials: "include"}),
|
|
87
86
|
data = await response.blob();
|
|
88
87
|
|
|
89
88
|
image.getImage().src = URL.createObjectURL(data);
|
|
@@ -100,7 +99,7 @@ export function defaultLoadFunction ({isSecured}) {
|
|
|
100
99
|
* @param {string|number} [rawLayer.tilesize] - optional needed to create the tileGrid
|
|
101
100
|
* @param {string|"anonymous"} [rawLayer.crossOrigin] - optional needed for CORS requests of image data, to enable canvas export
|
|
102
101
|
* @param {string} [rawLayer.cqlFilter] - optional CQL filter to add to the request
|
|
103
|
-
* @param {boolean} [rawLayer.isSecured] -
|
|
102
|
+
* @param {boolean} [rawLayer.isSecured] - if the layer is secured by BasicAuth, images are loaded with credentials: 'include'.
|
|
104
103
|
* @param {object} options - optional resolutions and origin to create the TileGrid
|
|
105
104
|
* @param {Array} [options.resolutions] - optional resolutions to create the TileGrid, must be in descending order
|
|
106
105
|
* @param {Array} [options.origin] - optional origin to create the TileGrid
|
|
@@ -120,8 +119,8 @@ export function createLayerSource (rawLayer, options) {
|
|
|
120
119
|
projection: projection,
|
|
121
120
|
attributions: rawLayer.olAttribution,
|
|
122
121
|
crossOrigin: rawLayer.crossOrigin,
|
|
123
|
-
...rawLayer.isSecured ? {
|
|
124
|
-
imageLoadFunction:
|
|
122
|
+
...rawLayer.isSecured ? {
|
|
123
|
+
imageLoadFunction: loadFunctionWithCredentials()
|
|
125
124
|
} : {}
|
|
126
125
|
});
|
|
127
126
|
}
|
|
@@ -140,7 +139,9 @@ export function createLayerSource (rawLayer, options) {
|
|
|
140
139
|
projection: projection,
|
|
141
140
|
attributions: rawLayer.olAttribution,
|
|
142
141
|
crossOrigin: rawLayer.crossOrigin,
|
|
143
|
-
|
|
142
|
+
...rawLayer.isSecured ? {
|
|
143
|
+
tileLoadFunction: loadFunctionWithCredentials()
|
|
144
|
+
} : {}
|
|
144
145
|
});
|
|
145
146
|
}
|
|
146
147
|
|
package/src/maps/ol/olMap.js
CHANGED
|
@@ -8,7 +8,7 @@ import wmts from "../../layer/wmts";
|
|
|
8
8
|
import * as geojson from "../../layer/geojson";
|
|
9
9
|
import wfs from "../../layer/wfs";
|
|
10
10
|
import * as vectortile from "../../layer/vectorTile";
|
|
11
|
-
import
|
|
11
|
+
import oaf from "../../layer/oaf";
|
|
12
12
|
import {createMapView} from "../../maps/mapView";
|
|
13
13
|
import rawLayerList from "../../rawLayerList";
|
|
14
14
|
import crs from "../../crs";
|
|
@@ -148,7 +148,8 @@ export function createMap (config = defaults, {mapParams, callback, errorCallbac
|
|
|
148
148
|
crs.registerProjections(config.namedProjections);
|
|
149
149
|
setBackgroundImage(config);
|
|
150
150
|
setGazetteerUrl(config.gazetteerUrl);
|
|
151
|
-
|
|
151
|
+
|
|
152
|
+
const selectedInteractions = Object.assign({}, {dragPan: false, altShiftDragRotate: false, pinchRotate: false}, config.mapInteractions?.interactionModes),
|
|
152
153
|
map = new Map(Object.assign({
|
|
153
154
|
target: config.target || defaults.target,
|
|
154
155
|
interactions: olDefaultInteractions(selectedInteractions).extend([
|
|
@@ -157,7 +158,7 @@ export function createMap (config = defaults, {mapParams, callback, errorCallbac
|
|
|
157
158
|
if (event.originalEvent.shiftKey) {
|
|
158
159
|
return false;
|
|
159
160
|
}
|
|
160
|
-
return (!event.originalEvent.pointerType || event.originalEvent.pointerType === "mouse") || (config.twoFingerPan && this.getPointerCount() === 2) || !config.twoFingerPan;
|
|
161
|
+
return (!event.originalEvent.pointerType || event.originalEvent.pointerType === "mouse") || (config.mapInteractions?.interactionModes?.twoFingerPan && this.getPointerCount() === 2) || !config.mapInteractions?.interactionModes?.twoFingerPan;
|
|
161
162
|
}
|
|
162
163
|
})
|
|
163
164
|
]),
|
package/src/renderer/webgl.js
CHANGED
package/tall
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
v1.0.0
|
|
2
|
+
v1.1.0
|
|
3
|
+
v1.10.0
|
|
4
|
+
v1.2.0
|
|
5
|
+
v1.3.0
|
|
6
|
+
v1.4.0
|
|
7
|
+
v1.5.0
|
|
8
|
+
v1.6.0
|
|
9
|
+
v1.6.1
|
|
10
|
+
v1.7.0
|
|
11
|
+
v1.7.1
|
|
12
|
+
v1.8.0
|
|
13
|
+
v1.9.0
|
|
14
|
+
v2.0.0
|
|
15
|
+
v2.1.0
|
|
16
|
+
v2.1.1
|
|
17
|
+
v2.10.0
|
|
18
|
+
v2.11.0
|
|
19
|
+
v2.12.0
|
|
20
|
+
v2.13.0
|
|
21
|
+
v2.14.0
|
|
22
|
+
v2.15.0
|
|
23
|
+
v2.15.1
|
|
24
|
+
v2.15.2
|
|
25
|
+
v2.16.0
|
|
26
|
+
v2.17.0
|
|
27
|
+
v2.18.0
|
|
28
|
+
v2.19.0
|
|
29
|
+
v2.19.1
|
|
30
|
+
v2.19.2
|
|
31
|
+
v2.2.0
|
|
32
|
+
v2.20.0
|
|
33
|
+
v2.21.0
|
|
34
|
+
v2.22.0
|
|
35
|
+
v2.23.0
|
|
36
|
+
v2.24.0
|
|
37
|
+
v2.25.0
|
|
38
|
+
v2.26.0
|
|
39
|
+
v2.27.0
|
|
40
|
+
v2.28.0
|
|
41
|
+
v2.29.0
|
|
42
|
+
v2.3.0
|
|
43
|
+
v2.30.0
|
|
44
|
+
v2.31.0
|
|
45
|
+
v2.32.0
|
|
46
|
+
v2.33.0
|
|
47
|
+
v2.34.0
|
|
48
|
+
v2.35.0
|
|
49
|
+
v2.36.0
|
|
50
|
+
v2.37.0
|
|
51
|
+
v2.38.0
|
|
52
|
+
v2.39.0
|
|
53
|
+
v2.4.0
|
|
54
|
+
v2.5.0
|
|
55
|
+
v2.5.1
|
|
56
|
+
v2.6.0
|
|
57
|
+
v2.7.0
|
|
58
|
+
v2.8.0
|
|
59
|
+
v2.9.0
|
|
@@ -167,4 +167,34 @@ describe("geojson/index", function () {
|
|
|
167
167
|
expect(features[1].getStyle()()).toBeNull();
|
|
168
168
|
});
|
|
169
169
|
});
|
|
170
|
+
describe("loadFeaturesManually", function () {
|
|
171
|
+
it("loadFeaturesManually shall call fetch", function () {
|
|
172
|
+
console.error = jest.fn();
|
|
173
|
+
global.fetch = jest.fn().mockImplementationOnce(() => {
|
|
174
|
+
return new Promise((resolve) => {
|
|
175
|
+
resolve({
|
|
176
|
+
ok: true,
|
|
177
|
+
status: 200,
|
|
178
|
+
json: () => {
|
|
179
|
+
return [];
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
const layerParams = {
|
|
186
|
+
id: "id",
|
|
187
|
+
url: "url",
|
|
188
|
+
featureNS: "http://www.deegree.org/app",
|
|
189
|
+
featureType: "krankenhaeuser_hh",
|
|
190
|
+
version: "1.0.0"
|
|
191
|
+
},
|
|
192
|
+
options = {},
|
|
193
|
+
layer = geojson.createLayer(layerParams, {options});
|
|
194
|
+
|
|
195
|
+
geojson.loadFeaturesManually(layerParams, layer.getSource());
|
|
196
|
+
|
|
197
|
+
expect(global.fetch.mock.calls.length).toBe(1);
|
|
198
|
+
});
|
|
199
|
+
});
|
|
170
200
|
});
|
package/test/layer/oaf.test.js
CHANGED
|
@@ -5,7 +5,7 @@ import {Style, Icon} from "ol/style.js";
|
|
|
5
5
|
import map from "../../src/maps/map.js";
|
|
6
6
|
import defaults from "../../src/defaults";
|
|
7
7
|
import GeoJSON from "ol/format/GeoJSON.js";
|
|
8
|
-
import
|
|
8
|
+
import oaf from "../../src/layer/oaf";
|
|
9
9
|
import {featureCollection} from "./resources/oafFeatures";
|
|
10
10
|
import * as webgl from "../../src/renderer/webgl.js";
|
|
11
11
|
|
|
@@ -287,4 +287,34 @@ describe("oaf.js", function () {
|
|
|
287
287
|
expect(webgl.afterLoading).toHaveBeenCalledWith(features, layerParams.styleId, layerParams.excludeTypesFromParsing, layerParams.isPointLayer);
|
|
288
288
|
});
|
|
289
289
|
});
|
|
290
|
+
describe("loadFeaturesManually", function () {
|
|
291
|
+
it("loadFeaturesManually shall call fetch", function () {
|
|
292
|
+
console.error = jest.fn();
|
|
293
|
+
global.fetch = jest.fn().mockImplementationOnce(() => {
|
|
294
|
+
return new Promise((resolve) => {
|
|
295
|
+
resolve({
|
|
296
|
+
ok: true,
|
|
297
|
+
status: 200,
|
|
298
|
+
json: () => {
|
|
299
|
+
return featureCollection;
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
const rawLayer = {
|
|
306
|
+
id: "id",
|
|
307
|
+
url: "url",
|
|
308
|
+
featureNS: "http://www.deegree.org/app",
|
|
309
|
+
featureType: "krankenhaeuser_hh",
|
|
310
|
+
version: "1.0.0"
|
|
311
|
+
},
|
|
312
|
+
options = {},
|
|
313
|
+
layer = oaf.createLayer(rawLayer, {options});
|
|
314
|
+
|
|
315
|
+
oaf.loadFeaturesManually(rawLayer, layer.getSource());
|
|
316
|
+
|
|
317
|
+
expect(global.fetch.mock.calls.length).toBe(1);
|
|
318
|
+
});
|
|
319
|
+
});
|
|
290
320
|
});
|
package/test/layer/wms.test.js
CHANGED
|
@@ -102,7 +102,7 @@ describe("wms.js", function () {
|
|
|
102
102
|
});
|
|
103
103
|
});
|
|
104
104
|
|
|
105
|
-
describe("
|
|
105
|
+
describe("loadFunctionWithCredentials", function () {
|
|
106
106
|
beforeEach(() => {
|
|
107
107
|
const blob = new Blob();
|
|
108
108
|
|
|
@@ -121,19 +121,12 @@ describe("wms.js", function () {
|
|
|
121
121
|
});
|
|
122
122
|
|
|
123
123
|
it("passes credentials if isSecured is set", async function () {
|
|
124
|
-
const result = wms.
|
|
124
|
+
const result = wms.loadFunctionWithCredentials(),
|
|
125
125
|
input = {src: ""};
|
|
126
126
|
|
|
127
127
|
await result({getImage: () => input}, "SECURE_WMS");
|
|
128
128
|
expect(input.src).toEqual("blob:BLOB");
|
|
129
129
|
});
|
|
130
|
-
it("does not pass credentials if isSecured is not set", async function () {
|
|
131
|
-
const result = wms.defaultLoadFunction({isSecured: false}),
|
|
132
|
-
input = {src: ""};
|
|
133
|
-
|
|
134
|
-
await result({getImage: () => input}, "INSECURE_WMS");
|
|
135
|
-
expect(input.src).toEqual("blob:BLOB");
|
|
136
|
-
});
|
|
137
130
|
});
|
|
138
131
|
|
|
139
132
|
describe("createLayerSource", function () {
|