@masterportal/masterportalapi 2.53.0 → 2.55.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 +21 -1
- package/package.json +7 -5
- package/publiccode.yml +2 -2
- package/src/layer/wms.js +21 -12
- package/src/maps/olcs/3dUtils/wmsRasterSynchronizer.js +4 -0
- package/src/vectorStyle/createStyle.js +1 -1
- package/test/layer/wms.test.js +96 -78
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,27 @@
|
|
|
2
2
|
All important changes in this project are stored in this file.
|
|
3
3
|
|
|
4
4
|
The [Semantic Versioning](https://semver.org/spec/v2.0.0.html) is used.
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## 2.55.0 - 2026-01-09
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
- Changed Node.js support: Versions from Node.js **22.19.0** up to Node.js **24.12.0** (LTS) are now supported
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- Legend: Shows all information, even for objects that are not yet visible on the map.
|
|
14
|
+
- WMS-Layer: the default tileLoadFunction or imageLoadfunction from openlayers is used, if layer not has the atrribute `isSecured` or `isSecured=false`. If on call of createLayer `layerParams.useFetchForWMS = true`, the overwritten load-function of wms is used.
|
|
15
|
+
- 3D WMS: Remove invalid `cql_filter` values.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 2.54.0 - 2025-11-26
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
- Restored compatibility for deep imports under @masterportal/masterportalapi/src/* by adding a scoped subpath export in package.json.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
6
26
|
## 2.53.0 - 2025-11-18
|
|
7
27
|
|
|
8
28
|
### 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.55.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Basic functions of the Masterportal as api",
|
|
7
7
|
"repository": {
|
|
@@ -11,14 +11,16 @@
|
|
|
11
11
|
"source": "src/index.js",
|
|
12
12
|
"main": "src/index.js",
|
|
13
13
|
"exports": {
|
|
14
|
-
".": "./src/index.js"
|
|
14
|
+
".": "./src/index.js",
|
|
15
|
+
"./src/*": "./src/*"
|
|
15
16
|
},
|
|
16
17
|
"targets": {
|
|
17
18
|
"library": {
|
|
18
19
|
"source": "src/index.js",
|
|
19
20
|
"distDir": "dist",
|
|
20
21
|
"outputFormat": "commonjs"
|
|
21
|
-
}
|
|
22
|
+
},
|
|
23
|
+
"main": false
|
|
22
24
|
},
|
|
23
25
|
"scripts": {
|
|
24
26
|
"test": "jest .test.js --config ./jest.config.js --collectCoverage",
|
|
@@ -71,8 +73,8 @@
|
|
|
71
73
|
"@cesium/engine": "^20.0.1"
|
|
72
74
|
},
|
|
73
75
|
"engines": {
|
|
74
|
-
"node": "^22.19.0",
|
|
75
|
-
"npm": "^10.5.0"
|
|
76
|
+
"node": "^22.19.0 || ^24.11.1",
|
|
77
|
+
"npm": "^10.5.0 || ^11.6.2"
|
|
76
78
|
},
|
|
77
79
|
"homepage": "https://bitbucket.org/geowerkstatt-hamburg/masterportalapi#readme",
|
|
78
80
|
"directories": {
|
package/publiccode.yml
CHANGED
|
@@ -81,8 +81,8 @@ maintenance:
|
|
|
81
81
|
name: Masterportal
|
|
82
82
|
platforms:
|
|
83
83
|
- web
|
|
84
|
-
releaseDate: '
|
|
84
|
+
releaseDate: '2026-01-09'
|
|
85
85
|
roadmap: 'https://bitbucket.org/geowerkstatt-hamburg/masterportalapi/src/master/'
|
|
86
86
|
softwareType: api
|
|
87
|
-
softwareVersion: 2.
|
|
87
|
+
softwareVersion: 2.55.0
|
|
88
88
|
url: 'https://bitbucket.org/geowerkstatt-hamburg/masterportalapi.git'
|
package/src/layer/wms.js
CHANGED
|
@@ -112,13 +112,15 @@ export function defaultLoadFunction ({isSecured}) {
|
|
|
112
112
|
* @param {Array} [options.resolutions] - optional resolutions to create the TileGrid, must be in descending order
|
|
113
113
|
* @param {Array} [options.origin] - optional origin to create the TileGrid
|
|
114
114
|
* @param {string} [options.crs] - optional projection code, if not available, projection of map is used
|
|
115
|
+
* @param {object} layerParams - optional layer params
|
|
116
|
+
* @param {Array} [layerParams.useFetchForWMS] - if true, fetch is used to load the tiles, else openlayers default load function is used
|
|
115
117
|
* @returns {(ol.source.TileWMS|ol.source.ImageWMS)} TileWMS or ImageWMS, depending on whether singleTile is true.
|
|
116
118
|
*/
|
|
117
|
-
export function createLayerSource (rawLayer, options) {
|
|
119
|
+
export function createLayerSource (rawLayer, options, layerParams = {}) {
|
|
118
120
|
const params = makeParams(rawLayer),
|
|
119
121
|
projection = rawLayer.crs ? getProjection(rawLayer.crs) : undefined;
|
|
120
|
-
let tileGrid = null
|
|
121
|
-
|
|
122
|
+
let tileGrid = null,
|
|
123
|
+
wmsParams = {};
|
|
122
124
|
|
|
123
125
|
// Fix for daily updated WMS-Time Layer, which use 'current' as the default value of the time-Extent in their getCapabilities
|
|
124
126
|
// The promise isn't resolved quickly enough for the continued work with the layer.
|
|
@@ -128,15 +130,19 @@ export function createLayerSource (rawLayer, options) {
|
|
|
128
130
|
}
|
|
129
131
|
|
|
130
132
|
if (rawLayer.singleTile) {
|
|
131
|
-
|
|
133
|
+
wmsParams = {
|
|
132
134
|
url: rawLayer.url,
|
|
133
135
|
params,
|
|
134
136
|
serverType: rawLayer.serverType,
|
|
135
137
|
projection: projection,
|
|
136
138
|
attributions: rawLayer.olAttribution,
|
|
137
|
-
crossOrigin: rawLayer.crossOrigin
|
|
138
|
-
|
|
139
|
-
|
|
139
|
+
crossOrigin: rawLayer.crossOrigin
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
if (rawLayer.isSecured || layerParams.useFetchForWMS) {
|
|
143
|
+
wmsParams = Object.assign(wmsParams, {imageLoadFunction: defaultLoadFunction(rawLayer)});
|
|
144
|
+
}
|
|
145
|
+
return new ImageWMS(wmsParams);
|
|
140
146
|
}
|
|
141
147
|
if (options && options.resolutions) {
|
|
142
148
|
tileGrid = new TileGrid({
|
|
@@ -145,16 +151,19 @@ export function createLayerSource (rawLayer, options) {
|
|
|
145
151
|
tileSize: parseInt(rawLayer.tilesize, 10)
|
|
146
152
|
});
|
|
147
153
|
}
|
|
148
|
-
|
|
154
|
+
wmsParams = {
|
|
149
155
|
url: rawLayer.url,
|
|
150
156
|
params,
|
|
151
157
|
gutter: rawLayer.gutter || 0,
|
|
152
158
|
tileGrid: tileGrid,
|
|
153
159
|
projection: projection,
|
|
154
160
|
attributions: rawLayer.olAttribution,
|
|
155
|
-
crossOrigin: rawLayer.crossOrigin
|
|
156
|
-
|
|
157
|
-
|
|
161
|
+
crossOrigin: rawLayer.crossOrigin
|
|
162
|
+
};
|
|
163
|
+
if (rawLayer.isSecured || layerParams.useFetchForWMS) {
|
|
164
|
+
wmsParams = Object.assign(wmsParams, {tileLoadFunction: defaultLoadFunction(rawLayer)});
|
|
165
|
+
}
|
|
166
|
+
return new TileWMS(wmsParams);
|
|
158
167
|
}
|
|
159
168
|
|
|
160
169
|
/**
|
|
@@ -178,7 +187,7 @@ export function createLayerSource (rawLayer, options) {
|
|
|
178
187
|
* @returns {ol.Layer} Layer that can be added to map.
|
|
179
188
|
*/
|
|
180
189
|
export function createLayer (rawLayer = {}, {layerParams = {}, options = {}} = {}) {
|
|
181
|
-
const source = createLayerSource(rawLayer, options),
|
|
190
|
+
const source = createLayerSource(rawLayer, options, layerParams),
|
|
182
191
|
Layer = rawLayer.singleTile ? ImageLayer : TileLayer;
|
|
183
192
|
|
|
184
193
|
source.set("olcs_projection", getProjection(OLCS_DEFAULT_OLCS_PROJECTION_CRS));
|
|
@@ -159,6 +159,10 @@ class WMSRasterSynchronizer extends AbstractSynchronizer {
|
|
|
159
159
|
},
|
|
160
160
|
tileGrid = source.getTileGrid();
|
|
161
161
|
|
|
162
|
+
if (typeof params.CQL_FILTER === "undefined") {
|
|
163
|
+
delete params.CQL_FILTER;
|
|
164
|
+
}
|
|
165
|
+
|
|
162
166
|
if (tileGrid) {
|
|
163
167
|
const ext = olLayer.getExtent();
|
|
164
168
|
|
|
@@ -201,7 +201,7 @@ function captureLegendFromFeature (styleId, legendInformation) {
|
|
|
201
201
|
legend = {id: styleId, legendInformation: []};
|
|
202
202
|
legendsOfAllStyles.push(legend);
|
|
203
203
|
}
|
|
204
|
-
|
|
204
|
+
if (styleId === "default" && legend.legendInformation !== legendInformation) {
|
|
205
205
|
legend.legendInformation = legendInformation;
|
|
206
206
|
legendInformationLength = legendInformation.length;
|
|
207
207
|
}
|
package/test/layer/wms.test.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable no-underscore-dangle*/
|
|
1
2
|
import {Map, Attribution} from "ol";
|
|
2
3
|
import TileLayer from "ol/layer/Tile";
|
|
3
4
|
import ImageLayer from "ol/layer/Image";
|
|
@@ -135,95 +136,112 @@ describe("wms.js", function () {
|
|
|
135
136
|
expect(input.src).toEqual("blob:BLOB");
|
|
136
137
|
});
|
|
137
138
|
});
|
|
138
|
-
|
|
139
139
|
describe("createLayerSource", function () {
|
|
140
|
-
it("creates a TileWMS for multi tile requests", function () {
|
|
141
|
-
const source = wms.createLayerSource({singleTile: false});
|
|
142
140
|
|
|
143
|
-
|
|
144
|
-
|
|
141
|
+
describe("createLayerSource", function () {
|
|
142
|
+
it("creates a TileWMS for multi tile requests uses defaultTileLoadFunction from", function () {
|
|
143
|
+
const source = wms.createLayerSource({singleTile: false});
|
|
145
144
|
|
|
146
|
-
|
|
147
|
-
|
|
145
|
+
expect(source).toBeInstanceOf(TileWMS);
|
|
146
|
+
expect(source.tileLoadFunction.toString().indexOf("defaultTileLoadFunction") > -1).toEqual(true);
|
|
147
|
+
});
|
|
148
|
+
it("creates a TileWMS for multi tile requests - uses defaultLoadFunction", function () {
|
|
149
|
+
const layerParams = {useFetchForWMS: true},
|
|
150
|
+
source = wms.createLayerSource({singleTile: false}, {}, layerParams);
|
|
148
151
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
+
expect(source).toBeInstanceOf(TileWMS);
|
|
153
|
+
expect(source.tileLoadFunction.toString().indexOf("await fetch") > -1).toEqual(true);
|
|
154
|
+
expect(source.tileLoadFunction.toString().indexOf("defaultTileLoadFunction") === -1).toEqual(true);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it("creates an ImageWMS for single tile requests uses defaultImageLoadFunction from openlayers", function () {
|
|
158
|
+
const source = wms.createLayerSource({singleTile: true});
|
|
159
|
+
|
|
160
|
+
expect(source).toBeInstanceOf(ImageWMS);
|
|
161
|
+
expect(source.imageLoadFunction_.toString().indexOf("defaultImageLoadFunction") > -1).toEqual(true);
|
|
162
|
+
});
|
|
163
|
+
it("creates an ImageWMS for single tile requests - uses defaultLoadFunction", function () {
|
|
164
|
+
const layerParams = {useFetchForWMS: true},
|
|
165
|
+
source = wms.createLayerSource({singleTile: true}, {}, layerParams);
|
|
166
|
+
|
|
167
|
+
expect(source).toBeInstanceOf(ImageWMS);
|
|
168
|
+
expect(source.imageLoadFunction_.toString().indexOf("await fetch") > -1).toEqual(true);
|
|
169
|
+
expect(source.imageLoadFunction_.toString().indexOf("defaultImageLoadFunction") === -1).toEqual(true);
|
|
170
|
+
});
|
|
171
|
+
it("creates a LayerSource with crossOrigin set to 'anonymous'", function () {
|
|
152
172
|
// only relevant for TileWMS and ImageWMS instances
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
173
|
+
const
|
|
174
|
+
tileWMS = wms.createLayerSource({singleTile: false, crossOrigin: "anonymous"}),
|
|
175
|
+
imageWMS = wms.createLayerSource({singleTile: true, crossOrigin: "anonymous"});
|
|
156
176
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
177
|
+
expect(imageWMS.crossOrigin_).toEqual("anonymous");
|
|
178
|
+
expect(tileWMS.crossOrigin).toEqual("anonymous");
|
|
179
|
+
});
|
|
160
180
|
});
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
html: "© " +
|
|
181
|
+
describe("createLayerSource with a tileGrid", function () {
|
|
182
|
+
function attrFunction () {
|
|
183
|
+
return [new Attribution({
|
|
184
|
+
html: "© " +
|
|
166
185
|
"<a href=\"http://www.geo.admin.ch/internet/geoportal/" +
|
|
167
186
|
"en/home.html\">" +
|
|
168
187
|
"Pixelmap 1:1000000 / geo.admin.ch</a>"
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
it("creates an ImageWMS for single tile requests, contains no tileGrid", function () {
|
|
214
|
-
const rawLayer = {
|
|
215
|
-
singleTile: true,
|
|
216
|
-
serverType: "geoserver",
|
|
217
|
-
url: "https://url.de",
|
|
218
|
-
olAttribution: attrFunction
|
|
219
|
-
},
|
|
220
|
-
source = wms.createLayerSource(rawLayer);
|
|
188
|
+
})];
|
|
189
|
+
}
|
|
190
|
+
it("creates a TileWMS without tileGrid, options are undefined", function () {
|
|
191
|
+
const options = undefined,
|
|
192
|
+
source = wms.createLayerSource({singleTile: false, tilesize: "10"}, options);
|
|
193
|
+
|
|
194
|
+
expect(source).toBeInstanceOf(TileWMS);
|
|
195
|
+
expect(source.getTileGrid()).toEqual(null);
|
|
196
|
+
});
|
|
197
|
+
it("creates a TileWMS without tileGrid, options without resolutions", function () {
|
|
198
|
+
const options = {
|
|
199
|
+
origin: [442800, 5809000]
|
|
200
|
+
},
|
|
201
|
+
source = wms.createLayerSource({singleTile: false, tilesize: "10"}, options);
|
|
202
|
+
|
|
203
|
+
expect(source).toBeInstanceOf(TileWMS);
|
|
204
|
+
expect(source.getTileGrid()).toEqual(null);
|
|
205
|
+
});
|
|
206
|
+
it("creates a TileWMS containing a tileGrid", function () {
|
|
207
|
+
const options = {
|
|
208
|
+
resolutions: [2000, 1000],
|
|
209
|
+
origin: [442800, 5809000]
|
|
210
|
+
},
|
|
211
|
+
rawLayer = {
|
|
212
|
+
singleTile: false,
|
|
213
|
+
tilesize: "10",
|
|
214
|
+
gutter: "1",
|
|
215
|
+
serverType: "geoserver",
|
|
216
|
+
url: "https://url.de",
|
|
217
|
+
olAttribution: attrFunction
|
|
218
|
+
},
|
|
219
|
+
source = wms.createLayerSource(rawLayer, options);
|
|
220
|
+
|
|
221
|
+
expect(source).toBeInstanceOf(TileWMS);
|
|
222
|
+
expect(source.getTileGrid()).toBeInstanceOf(TileGrid);
|
|
223
|
+
expect(source.getTileGrid().getOrigin()).toEqual(options.origin);
|
|
224
|
+
expect(source.getTileGrid().getResolutions()).toEqual(options.resolutions);
|
|
225
|
+
expect(source.getTileGrid().getTileSize()).toEqual(parseInt(rawLayer.tilesize, 10));
|
|
226
|
+
expect(source.getAttributions()).toBe(attrFunction);
|
|
227
|
+
expect(source.getUrls()).toEqual([rawLayer.url]);
|
|
228
|
+
expect(source.gutter_).toEqual(rawLayer.gutter);
|
|
229
|
+
});
|
|
221
230
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
231
|
+
it("creates an ImageWMS for single tile requests, contains no tileGrid", function () {
|
|
232
|
+
const rawLayer = {
|
|
233
|
+
singleTile: true,
|
|
234
|
+
serverType: "geoserver",
|
|
235
|
+
url: "https://url.de",
|
|
236
|
+
olAttribution: attrFunction
|
|
237
|
+
},
|
|
238
|
+
source = wms.createLayerSource(rawLayer);
|
|
239
|
+
|
|
240
|
+
expect(source).toBeInstanceOf(ImageWMS);
|
|
241
|
+
expect(source.getAttributions()).toBe(attrFunction);
|
|
242
|
+
expect(source.getUrl()).toEqual(rawLayer.url);
|
|
243
|
+
expect(source.serverType_).toEqual(rawLayer.serverType);
|
|
244
|
+
});
|
|
227
245
|
});
|
|
228
246
|
});
|
|
229
247
|
|