@masterportal/masterportalapi 2.36.0 → 2.38.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 CHANGED
@@ -3,6 +3,34 @@
3
3
 
4
4
  The [Semantic Versioning](https://semver.org/spec/v2.0.0.html) is used.
5
5
 
6
+ ## 2.38.0 - 2024-06-04
7
+
8
+ ### Added
9
+ - Added support for Node LTS version ^20.12.2 and npm Version ^10.5.0.
10
+
11
+ ### Changed
12
+ - The following packages have been updated:
13
+ - dependencies:
14
+ - ol: 9.1.0 to 9.2.4
15
+ - olcs: 2.19.3 to 2.20.0
16
+
17
+ ### Fixed
18
+ - The mitigation for issue 666 in ol-cesium since version 2.37.0 is removed
19
+ - Webgl: vectorTiles were not displayed.
20
+ - WMS-Layer: special loadFunction is only used if layer's attribute `isSecured` is true.
21
+
22
+ ---
23
+
24
+ ## 2.37.0 - 2024-04-23
25
+
26
+ ### Fixed
27
+ - Issue Masterportal #1114: `isSecured` parameter is considered for WMS load function
28
+ - Issue Masterportal #1114: custom loading function for WMS is now applied on non-tiled WMS, too.
29
+ However, because of issue 666 in ol-cesium it does not work for 3D and is enabled for `isSecured: true` layers only
30
+ - Image layers that cannot be converted by olcs are now properly handled
31
+
32
+ ---
33
+
6
34
  ## 2.36.0 - 2024-04-11
7
35
 
8
36
  ### Changed
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.36.0",
4
+ "version": "2.38.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.1.0",
24
+ "ol": "9.2.4",
25
25
  "ol-mapbox-style": "12.2.1",
26
- "olcs": "2.19.3",
26
+ "olcs": "2.20.0",
27
27
  "proj4": "^2.10.0",
28
28
  "xml2js": "^0.6.2"
29
29
  },
@@ -59,8 +59,8 @@
59
59
  "@cesium/engine": "^6.2.0"
60
60
  },
61
61
  "engines": {
62
- "node": "^16.13.2 || ^18.12.0 || ^20.9.0",
63
- "npm": "^8.1.2 || ^9.3.1 || ^10.1.0"
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": {
@@ -26,7 +26,7 @@ async function createTerrainProvider (rawLayer) {
26
26
  * @param {OLCesium} map ol cesium map
27
27
  * @returns {void}
28
28
  */
29
- async function setVisible (value, rawLayer, map) {
29
+ export async function setVisible (value, rawLayer, map) {
30
30
  if (map && typeof map.getCesiumScene === "function") {
31
31
  if (value) {
32
32
  map.getCesiumScene().terrainProvider = await createTerrainProvider(rawLayer);
@@ -64,5 +64,3 @@ export function get (key) {
64
64
  }
65
65
  return this.values[key];
66
66
  }
67
-
68
- module.exports.setVisible = setVisible;
package/src/layer/wms.js CHANGED
@@ -76,11 +76,17 @@ export function makeParams (rawLayer) {
76
76
  return params;
77
77
  }
78
78
 
79
- async function defaultTileLoadFunction (imageTile, src) {
80
- const response = await fetch(src),
81
- data = await response.blob();
79
+ /**
80
+ * Return a ol tile or image load function for the rawLayer. Fetches with credentials: 'include'.
81
+ * @returns {function} tile/image load function
82
+ */
83
+ export function loadFunctionWithCredentials () {
84
+ return async (image, src) => {
85
+ const response = await fetch(src, {credentials: "include"}),
86
+ data = await response.blob();
82
87
 
83
- imageTile.getImage().src = URL.createObjectURL(data);
88
+ image.getImage().src = URL.createObjectURL(data);
89
+ };
84
90
  }
85
91
 
86
92
  /**
@@ -93,6 +99,7 @@ async function defaultTileLoadFunction (imageTile, src) {
93
99
  * @param {string|number} [rawLayer.tilesize] - optional needed to create the tileGrid
94
100
  * @param {string|"anonymous"} [rawLayer.crossOrigin] - optional needed for CORS requests of image data, to enable canvas export
95
101
  * @param {string} [rawLayer.cqlFilter] - optional CQL filter to add to the request
102
+ * @param {boolean} [rawLayer.isSecured] - if the layer is secured by BasicAuth, images are loaded with credentials: 'include'.
96
103
  * @param {object} options - optional resolutions and origin to create the TileGrid
97
104
  * @param {Array} [options.resolutions] - optional resolutions to create the TileGrid, must be in descending order
98
105
  * @param {Array} [options.origin] - optional origin to create the TileGrid
@@ -111,7 +118,10 @@ export function createLayerSource (rawLayer, options) {
111
118
  serverType: rawLayer.serverType,
112
119
  projection: projection,
113
120
  attributions: rawLayer.olAttribution,
114
- crossOrigin: rawLayer.crossOrigin
121
+ crossOrigin: rawLayer.crossOrigin,
122
+ ...rawLayer.isSecured ? {
123
+ imageLoadFunction: loadFunctionWithCredentials()
124
+ } : {}
115
125
  });
116
126
  }
117
127
  if (options && options.resolutions) {
@@ -129,7 +139,9 @@ export function createLayerSource (rawLayer, options) {
129
139
  projection: projection,
130
140
  attributions: rawLayer.olAttribution,
131
141
  crossOrigin: rawLayer.crossOrigin,
132
- tileLoadFunction: defaultTileLoadFunction
142
+ ...rawLayer.isSecured ? {
143
+ tileLoadFunction: loadFunctionWithCredentials()
144
+ } : {}
133
145
  });
134
146
  }
135
147
 
@@ -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
- const selectedInteractions = config.mapInteractions?.interactionModes ? config.mapInteractions?.interactionModes : {dragPan: false, altShiftDragRotate: false, pinchRotate: false},
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
  ]),
@@ -112,7 +112,8 @@ class WMSRasterSynchronizer extends AbstractSynchronizer {
112
112
  provider = this.createProviderForTileWMS(source, viewProj, olLayer);
113
113
  }
114
114
  else if (source instanceof ImageWMS) {
115
- return [this.createImageryLayerForImageWMS(olLayer, viewProj)];
115
+ cesiumLayer = this.createImageryLayerForImageWMS(olLayer, viewProj);
116
+ return cesiumLayer ? [cesiumLayer] : null;
116
117
  }
117
118
  else if (source instanceof StaticImageSource) {
118
119
  provider = this.createProviderForStaticImageSource(source);
@@ -107,6 +107,7 @@ export function createVectorTileLayerRenderer () {
107
107
  fragment: result.builder.getSymbolFragmentShader(),
108
108
  vertex: result.builder.getSymbolVertexShader()
109
109
  },
110
+ builder: result.builder,
110
111
  attributes: {
111
112
  fillColor: {
112
113
  size: 2,
@@ -102,6 +102,33 @@ describe("wms.js", function () {
102
102
  });
103
103
  });
104
104
 
105
+ describe("loadFunctionWithCredentials", function () {
106
+ beforeEach(() => {
107
+ const blob = new Blob();
108
+
109
+ global.fetch = jest.fn().mockImplementation(async (url, {credentials}) => {
110
+ if ((url === "SECURE_WMS" && credentials === "include") ||
111
+ (url === "INSECURE_WMS" && (typeof credentials === "undefined" || credentials === "omit"))) {
112
+ return {
113
+ ok: true,
114
+ status: 200,
115
+ blob: () => Promise.resolve(blob)
116
+ };
117
+ }
118
+ throw new Error("Bad request");
119
+ });
120
+ URL.createObjectURL = jest.fn().mockImplementation(value => value === blob ? "blob:BLOB" : null);
121
+ });
122
+
123
+ it("passes credentials if isSecured is set", async function () {
124
+ const result = wms.loadFunctionWithCredentials(),
125
+ input = {src: ""};
126
+
127
+ await result({getImage: () => input}, "SECURE_WMS");
128
+ expect(input.src).toEqual("blob:BLOB");
129
+ });
130
+ });
131
+
105
132
  describe("createLayerSource", function () {
106
133
  it("creates a TileWMS for multi tile requests", function () {
107
134
  const source = wms.createLayerSource({singleTile: false});