@masterportal/masterportalapi 2.36.0 → 2.37.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 +10 -0
- package/package.json +1 -1
- package/src/layer/terrain.js +1 -3
- package/src/layer/wms.js +17 -6
- package/src/maps/olcs/3dUtils/wmsRasterSynchronizer.js +2 -1
- package/test/layer/wms.test.js +34 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
|
|
4
4
|
The [Semantic Versioning](https://semver.org/spec/v2.0.0.html) is used.
|
|
5
5
|
|
|
6
|
+
## 2.37.0 - 2024-04-23
|
|
7
|
+
|
|
8
|
+
### Fixed
|
|
9
|
+
- Issue Masterportal #1114: `isSecured` parameter is considered for WMS load function
|
|
10
|
+
- Issue Masterportal #1114: custom loading function for WMS is now applied on non-tiled WMS, too.
|
|
11
|
+
However, because of issue 666 in ol-cesium it does not work for 3D and is enabled for `isSecured: true` layers only
|
|
12
|
+
- Image layers that cannot be converted by olcs are now properly handled
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
6
16
|
## 2.36.0 - 2024-04-11
|
|
7
17
|
|
|
8
18
|
### 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.
|
|
4
|
+
"version": "2.37.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Basic functions of the Masterportal as api",
|
|
7
7
|
"repository": {
|
package/src/layer/terrain.js
CHANGED
|
@@ -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,18 @@ export function makeParams (rawLayer) {
|
|
|
76
76
|
return params;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
/**
|
|
80
|
+
* Return a ol tile or image load function for the rawLayer.
|
|
81
|
+
* @param {object} rawLayer - layer specification as in services.json
|
|
82
|
+
* @returns {function} tile/image load function
|
|
83
|
+
*/
|
|
84
|
+
export function defaultLoadFunction ({isSecured}) {
|
|
85
|
+
return async (image, src) => {
|
|
86
|
+
const response = await fetch(src, {credentials: isSecured ? "include" : "omit"}),
|
|
87
|
+
data = await response.blob();
|
|
82
88
|
|
|
83
|
-
|
|
89
|
+
image.getImage().src = URL.createObjectURL(data);
|
|
90
|
+
};
|
|
84
91
|
}
|
|
85
92
|
|
|
86
93
|
/**
|
|
@@ -93,6 +100,7 @@ async function defaultTileLoadFunction (imageTile, src) {
|
|
|
93
100
|
* @param {string|number} [rawLayer.tilesize] - optional needed to create the tileGrid
|
|
94
101
|
* @param {string|"anonymous"} [rawLayer.crossOrigin] - optional needed for CORS requests of image data, to enable canvas export
|
|
95
102
|
* @param {string} [rawLayer.cqlFilter] - optional CQL filter to add to the request
|
|
103
|
+
* @param {boolean} [rawLayer.isSecured] - whether the layer is secured by BasicAuth and should include or omit the credentials prompt
|
|
96
104
|
* @param {object} options - optional resolutions and origin to create the TileGrid
|
|
97
105
|
* @param {Array} [options.resolutions] - optional resolutions to create the TileGrid, must be in descending order
|
|
98
106
|
* @param {Array} [options.origin] - optional origin to create the TileGrid
|
|
@@ -111,7 +119,10 @@ export function createLayerSource (rawLayer, options) {
|
|
|
111
119
|
serverType: rawLayer.serverType,
|
|
112
120
|
projection: projection,
|
|
113
121
|
attributions: rawLayer.olAttribution,
|
|
114
|
-
crossOrigin: rawLayer.crossOrigin
|
|
122
|
+
crossOrigin: rawLayer.crossOrigin,
|
|
123
|
+
...rawLayer.isSecured ? { // TODO: Remove this guard when olcs#666 is resolved
|
|
124
|
+
imageLoadFunction: defaultLoadFunction(rawLayer)
|
|
125
|
+
} : {}
|
|
115
126
|
});
|
|
116
127
|
}
|
|
117
128
|
if (options && options.resolutions) {
|
|
@@ -129,7 +140,7 @@ export function createLayerSource (rawLayer, options) {
|
|
|
129
140
|
projection: projection,
|
|
130
141
|
attributions: rawLayer.olAttribution,
|
|
131
142
|
crossOrigin: rawLayer.crossOrigin,
|
|
132
|
-
tileLoadFunction:
|
|
143
|
+
tileLoadFunction: defaultLoadFunction(rawLayer)
|
|
133
144
|
});
|
|
134
145
|
}
|
|
135
146
|
|
|
@@ -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
|
-
|
|
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);
|
package/test/layer/wms.test.js
CHANGED
|
@@ -102,6 +102,40 @@ describe("wms.js", function () {
|
|
|
102
102
|
});
|
|
103
103
|
});
|
|
104
104
|
|
|
105
|
+
describe("defaultLoadFunction", 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.defaultLoadFunction({isSecured: true}),
|
|
125
|
+
input = {src: ""};
|
|
126
|
+
|
|
127
|
+
await result({getImage: () => input}, "SECURE_WMS");
|
|
128
|
+
expect(input.src).toEqual("blob:BLOB");
|
|
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
|
+
});
|
|
138
|
+
|
|
105
139
|
describe("createLayerSource", function () {
|
|
106
140
|
it("creates a TileWMS for multi tile requests", function () {
|
|
107
141
|
const source = wms.createLayerSource({singleTile: false});
|