@masterportal/masterportalapi 2.54.0 → 2.56.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/.eslintrc CHANGED
@@ -4,6 +4,7 @@
4
4
  "browser": true,
5
5
  "node": true,
6
6
  "es6": true,
7
+ "es2020": true,
7
8
  "jest": true
8
9
  },
9
10
  "globals": {
package/CHANGELOG.md CHANGED
@@ -2,11 +2,36 @@
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
+ ## 2.56.0 - 2026-01-22
7
+
8
+ ### Changed
9
+ - Terrain-Layer: Removed `this`, uses closures instead.
10
+
11
+ ### Fixed
12
+ - VectorStyle:
13
+ - Fixed styling of polygons: `"zig-line-horizontal"` and `"diagonal-right"` are rotated by 90°.
14
+ - Creating legend and capture event ensures working on EventTarget.
15
+
16
+ ---
17
+
18
+ ## 2.55.0 - 2026-01-09
19
+
20
+ ### Changed
21
+ - Changed Node.js support: Versions from Node.js **22.19.0** up to Node.js **24.12.0** (LTS) are now supported
22
+
23
+ ### Fixed
24
+ - Legend: Shows all information, even for objects that are not yet visible on the map.
25
+ - 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.
26
+ - 3D WMS: Remove invalid `cql_filter` values.
27
+
28
+ ---
29
+
6
30
  ## 2.54.0 - 2025-11-26
7
31
 
8
32
  ### Fixed
9
33
  - Restored compatibility for deep imports under @masterportal/masterportalapi/src/* by adding a scoped subpath export in package.json.
34
+
10
35
  ---
11
36
 
12
37
  ## 2.53.0 - 2025-11-18
package/License.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2018-2023 Freie und Hansestadt Hamburg, Landesbetrieb Geoinformation und Vermessung
3
+ Copyright (c) 2018-2026 Freie und Hansestadt Hamburg, Landesbetrieb Geoinformation und Vermessung
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/example/index.js CHANGED
@@ -305,7 +305,8 @@ document.getElementById("enable").addEventListener("click", function () {
305
305
  document.getElementById("layer-visibility").style.display = "block";
306
306
 
307
307
  load3DScriptModule.load3DScript(lib, function Loaded3DCallback () {
308
- let tilesetLayer = null;
308
+ let tilesetLayer = null,
309
+ terrainLayer = null;
309
310
 
310
311
  const settings3D = {
311
312
  map2D: window.mpapi.map2D,
@@ -335,8 +336,8 @@ document.getElementById("enable").addEventListener("click", function () {
335
336
  mpapi.entities.createLayer(rawLayerEntities, window.mpapi.map);
336
337
  mpapi.entities.setVisible(true, rawLayerEntities, window.mpapi.map);
337
338
 
338
- mpapi.terrain.createLayer(rawLayerTerrain, window.mpapi.map);
339
- mpapi.terrain.setVisible(true, rawLayerTerrain, window.mpapi.map);
339
+ terrainLayer = mpapi.terrain.createLayer(rawLayerTerrain, window.mpapi.map);
340
+ terrainLayer.setVisible(true, rawLayerTerrain, window.mpapi.map);
340
341
 
341
342
  window.mpapi.map.setEnabled(true);
342
343
  });
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.54.0",
4
+ "version": "2.56.0",
5
5
  "license": "MIT",
6
6
  "description": "Basic functions of the Masterportal as api",
7
7
  "repository": {
@@ -19,7 +19,8 @@
19
19
  "source": "src/index.js",
20
20
  "distDir": "dist",
21
21
  "outputFormat": "commonjs"
22
- }
22
+ },
23
+ "main": false
23
24
  },
24
25
  "scripts": {
25
26
  "test": "jest .test.js --config ./jest.config.js --collectCoverage",
@@ -72,11 +73,12 @@
72
73
  "@cesium/engine": "^20.0.1"
73
74
  },
74
75
  "engines": {
75
- "node": "^22.19.0",
76
- "npm": "^10.5.0"
76
+ "node": "^22.19.0 || ^24.11.1",
77
+ "npm": "^10.5.0 || ^11.6.2"
77
78
  },
78
79
  "homepage": "https://bitbucket.org/geowerkstatt-hamburg/masterportalapi#readme",
79
80
  "directories": {
81
+ "doc": "docs",
80
82
  "example": "example",
81
83
  "test": "test"
82
84
  },
package/publiccode.yml CHANGED
@@ -75,14 +75,14 @@ maintenance:
75
75
  affiliation: Freie und Hansestadt Hamburg, Landesbetrieb Geoinformation und Vermessung
76
76
  contractors:
77
77
  - name: Landesbetrieb Geoinformation und Vermessung
78
- until: '2025-12-01'
78
+ until: '2026-12-01'
79
79
  website: 'https://www.hamburg.de/bsw/landesbetrieb-geoinformation-und-vermessung/'
80
80
  type: community
81
81
  name: Masterportal
82
82
  platforms:
83
83
  - web
84
- releaseDate: '2025-11-26'
84
+ releaseDate: '2026-01-22'
85
85
  roadmap: 'https://bitbucket.org/geowerkstatt-hamburg/masterportalapi/src/master/'
86
86
  softwareType: api
87
- softwareVersion: 2.54.0
87
+ softwareVersion: 2.56.0
88
88
  url: 'https://bitbucket.org/geowerkstatt-hamburg/masterportalapi.git'
@@ -3,7 +3,7 @@
3
3
  * @param {Object} rawLayer attributes of the layer
4
4
  * @param {string} [rawLayer.url] - the URL of the Cesium terrain server
5
5
  * @param {string} [rawLayer.cesiumTerrainProviderOptions] - see https://cesiumjs.org/Cesium/Build/Documentation/CesiumTerrainProvider.html
6
- * @returns {void}
6
+ * @returns {Promise<Cesium.CesiumTerrainProvider>} the terrain provider
7
7
  */
8
8
  async function createTerrainProvider (rawLayer) {
9
9
  const options = {};
@@ -17,25 +17,6 @@ async function createTerrainProvider (rawLayer) {
17
17
  return terrainProvider;
18
18
  }
19
19
 
20
- /**
21
- * Sets the layers visibility by setting the terrain provider at Cesium scene.
22
- * @param {boolean} value if true, terrainProvider is set to map and terrain will be visible
23
- * @param {Object} rawLayer attributes of the layer
24
- * @param {string} [rawLayer.url] - the URL of the Cesium terrain server
25
- * @param {string} [rawLayer.cesiumTerrainProviderOptions] - see https://cesiumjs.org/Cesium/Build/Documentation/CesiumTerrainProvider.html
26
- * @param {OLCesium} map ol cesium map
27
- * @returns {void}
28
- */
29
- export async function setVisible (value, rawLayer, map) {
30
- if (map && typeof map.getCesiumScene === "function") {
31
- if (value) {
32
- map.getCesiumScene().terrainProvider = await createTerrainProvider(rawLayer);
33
- }
34
- else {
35
- map.getCesiumScene().terrainProvider = new Cesium.EllipsoidTerrainProvider({});
36
- }
37
- }
38
- }
39
20
 
40
21
  /**
41
22
  * Creates an terrain layer to use in ol-Cesium map.
@@ -46,21 +27,41 @@ export async function setVisible (value, rawLayer, map) {
46
27
  * @returns {Object} layer
47
28
  */
48
29
  export function createLayer (rawLayer) {
49
- this.values = {
50
- name: rawLayer.name,
51
- id: rawLayer.id,
52
- typ: rawLayer.typ
30
+ const layer = {
31
+ values: {
32
+ name: rawLayer.name,
33
+ id: rawLayer.id,
34
+ typ: rawLayer.typ
35
+ },
36
+ /**
37
+ * Returns the value for the given key of the rawlayer.
38
+ * @param {String} key to get the value for
39
+ * @returns {*} the value to the key
40
+ */
41
+ get (key) {
42
+ return this.values?.[key];
43
+ },
44
+ /**
45
+ * Sets the layers visibility by setting the terrain provider at Cesium scene.
46
+ * @param {boolean} value if true, terrainProvider is set to map and terrain will be visible
47
+ * @param {Object} layerAttributes attributes of the layer - the raw layer
48
+ * @param {string} [layerAttributes.url] - the URL of the Cesium terrain server
49
+ * @param {Object} [layerAttributes.cesiumTerrainProviderOptions] - see https://cesiumjs.org/Cesium/Build/Documentation/CesiumTerrainProvider.html
50
+ * @param {OLCesium} map ol cesium map
51
+ * @returns {void}
52
+ */
53
+ async setVisible (value, layerAttributes, map) {
54
+ if (map && typeof map.getCesiumScene === "function") {
55
+ if (value) {
56
+ map.getCesiumScene().terrainProvider = await createTerrainProvider(layerAttributes);
57
+ }
58
+ else {
59
+ map.getCesiumScene().terrainProvider = new Cesium.EllipsoidTerrainProvider({});
60
+ }
61
+ }
62
+ }
53
63
  };
54
- return this;
55
- }
56
- /**
57
- * Returns the value for the given key of the rawlayer.
58
- * @param {String} key to get the value for
59
- * @returns {*} the value to the key
60
- */
61
- export function get (key) {
62
- if (!this.values) {
63
- return undefined;
64
- }
65
- return this.values[key];
64
+
65
+ return layer;
66
66
  }
67
+
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
- return new ImageWMS({
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
- imageLoadFunction: defaultLoadFunction(rawLayer)
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
- return new TileWMS({
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
- tileLoadFunction: defaultLoadFunction(rawLayer)
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
 
@@ -26,7 +26,7 @@ export function setCesiumSceneParams (scene, params) {
26
26
  }
27
27
 
28
28
  Object.entries(params).forEach(([key, value]) => {
29
- if (["0", "1", "2", "heading", "tilt", "altitude"].includes(key)) {
29
+ if (["0", "1", "2", "heading", "tilt", "altitude", "pitch"].includes(key)) {
30
30
  return;
31
31
  }
32
32
 
@@ -201,7 +201,7 @@ function captureLegendFromFeature (styleId, legendInformation) {
201
201
  legend = {id: styleId, legendInformation: []};
202
202
  legendsOfAllStyles.push(legend);
203
203
  }
204
- else if (styleId === "default" && legend.legendInformation !== legendInformation) {
204
+ if (styleId === "default" && legend.legendInformation !== legendInformation) {
205
205
  legend.legendInformation = legendInformation;
206
206
  legendInformationLength = legendInformation.length;
207
207
  }
@@ -211,7 +211,7 @@ function captureLegendFromFeature (styleId, legendInformation) {
211
211
  const event = new CustomEvent("legendCaptured");
212
212
 
213
213
  event.id = legend.id;
214
- if (this) {
214
+ if (this instanceof EventTarget && typeof this.dispatchEvent === "function") {
215
215
  this.dispatchEvent(event);
216
216
  }
217
217
  }
@@ -277,14 +277,16 @@ async function returnLegendByStyleId (styleId) {
277
277
  resolve(legend);
278
278
  }
279
279
 
280
- this.addEventListener("legendCaptured", event => {
281
- if (event.id === styleId && event.id !== "default") {
282
- resolve(legendsOfAllStyles.find(element => element.id === event.id));
283
- }
284
- else if (legend && legend.legendInformation.length === legendInformationLength) {
285
- resolve(legendsOfAllStyles.find(element => element.id === event.id));
286
- }
287
- }, false);
280
+ if (this) {
281
+ this.addEventListener("legendCaptured", event => {
282
+ if (event.id === styleId && event.id !== "default") {
283
+ resolve(legendsOfAllStyles.find(element => element.id === event.id));
284
+ }
285
+ else if (legend && legend.legendInformation.length === legendInformationLength) {
286
+ resolve(legendsOfAllStyles.find(element => element.id === event.id));
287
+ }
288
+ }, false);
289
+ }
288
290
  });
289
291
  }
290
292
 
@@ -127,7 +127,7 @@ function rotateContextCenter (context, size, degrees = 90) {
127
127
  const halfSize = 0.5 * size;
128
128
 
129
129
  context.translate(halfSize, halfSize);
130
- context.rotate(degrees * (Math.PI / 180));
130
+ context.rotate(degrees * Math.PI / 180);
131
131
  context.translate(-halfSize, -halfSize);
132
132
  }
133
133
 
@@ -146,13 +146,12 @@ export function drawHatch (context, size, pattern) {
146
146
  if (hatchDefinition) {
147
147
  const {draw, rotate} = hatchDefinition;
148
148
 
149
- if (draw) {
150
- draw.forEach(segment => drawSegment(context, size, segment));
151
- }
152
-
153
149
  if (rotate) {
154
150
  rotateContextCenter(context, size, rotate);
155
151
  }
152
+ if (draw) {
153
+ draw.forEach(segment => drawSegment(context, size, segment));
154
+ }
156
155
  }
157
156
  else {
158
157
  console.error(`polygonStyleHatches: Unknown polygon style "${pattern}". Skipping hatching.`);
@@ -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
- expect(source).toBeInstanceOf(TileWMS);
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
- it("creates an ImageWMS for single tile requests", function () {
147
- const source = wms.createLayerSource({singleTile: true});
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
- expect(source).toBeInstanceOf(ImageWMS);
150
- });
151
- it("creates a LayerSource with crossOrigin set to 'anonymous'", function () {
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
- const
154
- tileWMS = wms.createLayerSource({singleTile: false, crossOrigin: "anonymous"}),
155
- imageWMS = wms.createLayerSource({singleTile: true, crossOrigin: "anonymous"});
173
+ const
174
+ tileWMS = wms.createLayerSource({singleTile: false, crossOrigin: "anonymous"}),
175
+ imageWMS = wms.createLayerSource({singleTile: true, crossOrigin: "anonymous"});
156
176
 
157
- // eslint-disable-next-line no-underscore-dangle
158
- expect(imageWMS.crossOrigin_).toEqual("anonymous");
159
- expect(tileWMS.crossOrigin).toEqual("anonymous");
177
+ expect(imageWMS.crossOrigin_).toEqual("anonymous");
178
+ expect(tileWMS.crossOrigin).toEqual("anonymous");
179
+ });
160
180
  });
161
- });
162
- describe("createLayerSource with a tileGrid", function () {
163
- function attrFunction () {
164
- return [new Attribution({
165
- html: "&copy; " +
181
+ describe("createLayerSource with a tileGrid", function () {
182
+ function attrFunction () {
183
+ return [new Attribution({
184
+ html: "&copy; " +
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
- it("creates a TileWMS without tileGrid, options are undefined", function () {
172
- const options = undefined,
173
- source = wms.createLayerSource({singleTile: false, tilesize: "10"}, options);
174
-
175
- expect(source).toBeInstanceOf(TileWMS);
176
- expect(source.getTileGrid()).toEqual(null);
177
- });
178
- it("creates a TileWMS without tileGrid, options without resolutions", function () {
179
- const options = {
180
- origin: [442800, 5809000]
181
- },
182
- source = wms.createLayerSource({singleTile: false, tilesize: "10"}, options);
183
-
184
- expect(source).toBeInstanceOf(TileWMS);
185
- expect(source.getTileGrid()).toEqual(null);
186
- });
187
- it("creates a TileWMS containing a tileGrid", function () {
188
- const options = {
189
- resolutions: [2000, 1000],
190
- origin: [442800, 5809000]
191
- },
192
- rawLayer = {
193
- singleTile: false,
194
- tilesize: "10",
195
- gutter: "1",
196
- serverType: "geoserver",
197
- url: "https://url.de",
198
- olAttribution: attrFunction
199
- },
200
- source = wms.createLayerSource(rawLayer, options);
201
-
202
- expect(source).toBeInstanceOf(TileWMS);
203
- expect(source.getTileGrid()).toBeInstanceOf(TileGrid);
204
- expect(source.getTileGrid().getOrigin()).toEqual(options.origin);
205
- expect(source.getTileGrid().getResolutions()).toEqual(options.resolutions);
206
- expect(source.getTileGrid().getTileSize()).toEqual(parseInt(rawLayer.tilesize, 10));
207
- expect(source.getAttributions()).toBe(attrFunction);
208
- expect(source.getUrls()).toEqual([rawLayer.url]);
209
- /* eslint-disable no-underscore-dangle */
210
- expect(source.gutter_).toEqual(rawLayer.gutter);
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
- expect(source).toBeInstanceOf(ImageWMS);
223
- expect(source.getAttributions()).toBe(attrFunction);
224
- expect(source.getUrl()).toEqual(rawLayer.url);
225
- /* eslint-disable no-underscore-dangle */
226
- expect(source.serverType_).toEqual(rawLayer.serverType);
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