@masterportal/masterportalapi 2.58.0 → 2.60.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,30 @@
3
3
 
4
4
  The [Semantic Versioning](https://semver.org/spec/v2.0.0.html) is used.
5
5
 
6
+ ## 2.60.0 - 2026-04-10
7
+
8
+ ### Added
9
+ - Issue #15: At VectorTile layer the `vtStyles` attribute is evaluated, and the style is applied using the `layers` attribute or to the styles attribute `defaultStyle`.
10
+
11
+ ### Changed
12
+ - The following packages have been updated:
13
+ - dependencies:
14
+ - ol-mapbox-style: 12.5.0 to 13.3.0
15
+
16
+ ---
17
+
18
+ ## 2.59.0 - 2026-03-13
19
+
20
+ ### Changed
21
+ - Updated examples to prevent console errors caused by certain layers/services.
22
+ - The following packages have been updated:
23
+ - dependencies:
24
+ - @cesium/engine: 20.0.1 to 23.0.0
25
+ - The following packages have been overwritten:
26
+ - geotiff in ol: to 2.1.3
27
+
28
+ ---
29
+
6
30
  ## 2.58.0 - 2026-02-19
7
31
 
8
32
  ### Changed
@@ -62,16 +62,6 @@
62
62
  "circle-rotate-with-view": true,
63
63
  "circle-opacity": 0.8
64
64
  }
65
- },
66
- {
67
- "id": "4002",
68
- "name": "Gebäude LoD2",
69
- "url": "https://daten-hamburg.de/gdi3d/datasource-data/LoD2",
70
- "typ": "TileSet3D",
71
- "styleId": "3DTileSetStyle",
72
- "cesium3DTilesetOptions": {
73
- "maximumScreenSpaceError": 6
74
- }
75
65
  }
76
66
  ],
77
67
  "cesiumLib":"https://geoportal-hamburg.de/mastercode/cesium/latest/Cesium.js",
@@ -200,6 +200,57 @@
200
200
  }
201
201
  ]
202
202
  },
203
+ {
204
+ "id": "6002",
205
+ "name": "ArcGIS VectorTile with layers attribute",
206
+ "shortname": "VectorTile",
207
+ "typ": "VectorTile",
208
+ "visibility": false,
209
+ "preview": {
210
+ "src": "./resources/vectorTile.png"
211
+ },
212
+ "layers": "M020_N/DS07_TatsaechlicheNutzung/G020_600_GEB_TNutz_F/P05_CI054_Platz,M020_N/DS07_TatsaechlicheNutzung/G020_600_GEB_TNutz_F/P06_CI060_BaulichGepraegteFlaeche",
213
+ "gfiAttributes": "showAll",
214
+ "url": "https://test.geoportal-hamburg.de/vt/esri/tile/{z}/{y}/{x}.pbf",
215
+ "epsg": "EPSG:25832",
216
+ "extent": [
217
+ 441336.2209999999,
218
+ 5915995,
219
+ 594002,
220
+ 5986767.56699999981
221
+ ],
222
+ "origin": [
223
+ -9497963.94293634221,
224
+ 9997963.94293634221
225
+ ],
226
+ "resolutions": [
227
+ 39054.5466520950868,
228
+ 19527.2733260475434,
229
+ 9763.63666302377169,
230
+ 4881.81833151188584,
231
+ 2440.90916575594292,
232
+ 1220.45458287797146,
233
+ 610.227291438985731,
234
+ 305.113645719492865,
235
+ 152.556822859746433,
236
+ 76.2784114298732163,
237
+ 38.1392057149366082,
238
+ 19.0696028574683041,
239
+ 9.534801428734152,
240
+ 4.767400714367076,
241
+ 2.383700357183538,
242
+ 1.191850178591769
243
+ ],
244
+ "tileSize": 512,
245
+ "vtStyles": [
246
+ {
247
+ "id": "VectorTile_STYLE",
248
+ "name": "Test",
249
+ "url": "https://test.geoportal-hamburg.de/vt/esri/resources/styles/root.json",
250
+ "defaultStyle": true
251
+ }
252
+ ]
253
+ },
203
254
  {
204
255
  "id": "7001",
205
256
  "name": "TopPlusOpen",
@@ -215,141 +266,5 @@
215
266
  "typ": "WMTS",
216
267
  "optionsFromCapabilities": true,
217
268
  "layers": "eoc:basemap"
218
- },
219
- {
220
- "id": "7003",
221
- "name": "Geoland Basemap",
222
- "urls": [
223
- "https://maps1.wien.gv.at/basemap/geolandbasemap/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png",
224
- "https://maps2.wien.gv.at/basemap/geolandbasemap/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png",
225
- "https://maps3.wien.gv.at/basemap/geolandbasemap/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png",
226
- "https://maps4.wien.gv.at/basemap/geolandbasemap/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png",
227
- "https://maps.wien.gv.at/basemap/geolandbasemap/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png"
228
- ],
229
- "typ": "WMTS",
230
- "layer": "geolandbasemap",
231
- "version": "1.0.0",
232
- "format": "image/png",
233
- "style": "normal",
234
- "transparent": false,
235
- "tileSize": "256",
236
- "minScale": "0",
237
- "maxScale": "2500000",
238
- "tileMatrixSet": "google3857",
239
- "matrixSizes": [
240
- [
241
- 1,
242
- 1
243
- ],
244
- [
245
- 2,
246
- 2
247
- ],
248
- [
249
- 4,
250
- 4
251
- ],
252
- [
253
- 8,
254
- 8
255
- ],
256
- [
257
- 16,
258
- 16
259
- ],
260
- [
261
- 32,
262
- 32
263
- ],
264
- [
265
- 64,
266
- 64
267
- ],
268
- [
269
- 128,
270
- 128
271
- ],
272
- [
273
- 256,
274
- 256
275
- ],
276
- [
277
- 512,
278
- 512
279
- ],
280
- [
281
- 1024,
282
- 1024
283
- ],
284
- [
285
- 2048,
286
- 2048
287
- ],
288
- [
289
- 4096,
290
- 4096
291
- ],
292
- [
293
- 8192,
294
- 8192
295
- ],
296
- [
297
- 16384,
298
- 16384
299
- ],
300
- [
301
- 32768,
302
- 32768
303
- ],
304
- [
305
- 65536,
306
- 65536
307
- ],
308
- [
309
- 131072,
310
- 131072
311
- ],
312
- [
313
- 262144,
314
- 262144
315
- ],
316
- [
317
- 524288,
318
- 524288
319
- ]
320
- ],
321
- "coordinateSystem": "EPSG:3857",
322
- "layerAttribution": "nicht vorhanden",
323
- "legend": false,
324
- "cache": true,
325
- "wrapX": true,
326
- "origin": [
327
- -20037508.3428,
328
- 20037508.3428
329
- ],
330
- "scales": [
331
- 559082264.029,
332
- 279541132.015,
333
- 139770566.007,
334
- 69885283.0036,
335
- 34942641.5018,
336
- 17471320.7509,
337
- 8735660.37545,
338
- 4367830.18773,
339
- 2183915.09386,
340
- 1091957.54693,
341
- 45978.773466,
342
- 272989.386733,
343
- 136494.693366,
344
- 68247.3466832,
345
- 34123.6733416,
346
- 17061.8366708,
347
- 8530.91833540,
348
- 4265.45916770,
349
- 2132.72958385,
350
- 1066.36479193
351
- ],
352
- "resLength": "20",
353
- "requestEncoding": "REST"
354
269
  }
355
270
  ]
package/example/index.js CHANGED
@@ -195,6 +195,19 @@ fetch(vtStyleUrl)
195
195
  });
196
196
  */
197
197
 
198
+ /* VECTOR TILE EXAMPLE 2, using layers attribute */
199
+ /*
200
+ document.getElementById("enable").style.display = "none";
201
+ window.mpapi.map = mapsAPI.map.createMap(config, "2D", {errorCallback});
202
+
203
+ window.mpapi.map.getLayers().forEach(layer => {
204
+ window.mpapi.map.removeLayer(layer);
205
+ });
206
+
207
+ const vtLayer = window.mpapi.map.addLayer("6002");
208
+
209
+ */
210
+
198
211
  /* WMTS example */
199
212
  /*
200
213
  window.mpapi.map = mapsAPI.map.createMap(config, "2D", {errorCallback});
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.58.0",
4
+ "version": "2.60.0",
5
5
  "license": "MIT",
6
6
  "description": "Basic functions of the Masterportal as api",
7
7
  "repository": {
@@ -35,7 +35,7 @@
35
35
  "core-js": "^3.33.1",
36
36
  "dayjs": "^1.11.10",
37
37
  "ol": "10.8.0",
38
- "ol-mapbox-style": "12.5.0",
38
+ "ol-mapbox-style": "13.3.0",
39
39
  "olcs": "^2.22.1",
40
40
  "proj4": "^2.10.0",
41
41
  "xml2js": "^0.6.2"
@@ -70,7 +70,12 @@
70
70
  "util": "^0.12.5"
71
71
  },
72
72
  "peerDependencies": {
73
- "@cesium/engine": "^20.0.1"
73
+ "@cesium/engine": "^23.0.0"
74
+ },
75
+ "overrides": {
76
+ "ol": {
77
+ "geotiff": "^2.1.3"
78
+ }
74
79
  },
75
80
  "engines": {
76
81
  "node": "^22.19.0 || ^24.11.1",
@@ -78,6 +83,7 @@
78
83
  },
79
84
  "homepage": "https://bitbucket.org/geowerkstatt-hamburg/masterportalapi#readme",
80
85
  "directories": {
86
+ "doc": "docs",
81
87
  "example": "example",
82
88
  "test": "test"
83
89
  },
package/publiccode.yml CHANGED
@@ -81,8 +81,8 @@ maintenance:
81
81
  name: Masterportal
82
82
  platforms:
83
83
  - web
84
- releaseDate: '2026-02-19'
84
+ releaseDate: '2026-04-10'
85
85
  roadmap: 'https://bitbucket.org/geowerkstatt-hamburg/masterportalapi/src/master/'
86
86
  softwareType: api
87
- softwareVersion: 2.58.0
87
+ softwareVersion: 2.60.0
88
88
  url: 'https://bitbucket.org/geowerkstatt-hamburg/masterportalapi.git'
@@ -4,7 +4,7 @@ import VectorTileSource from "ol/source/VectorTile";
4
4
  import OpenLayersTileGrid from "ol/tilegrid/TileGrid";
5
5
  import {extentFromProjection} from "ol/tilegrid";
6
6
  import * as webgl from "../renderer/webgl";
7
- import {apply, stylefunction} from "ol-mapbox-style";
7
+ import {apply, applyStyle, stylefunction} from "ol-mapbox-style";
8
8
 
9
9
  import defaults from "../defaults";
10
10
 
@@ -132,9 +132,54 @@ export function createLayerSource (url, options = {}) {
132
132
  return new VectorTileSource(sourceParams);
133
133
  }
134
134
 
135
+ /**
136
+ * Set a mapbox style
137
+ * @param {ol.layer.VectorTile} layer - layer to style
138
+ * @param {object} glStyle - MapBox style definition
139
+ * @param {options} [styleParams={}] - Additional options for style specification
140
+ * @param {string} url - MapBox style url
141
+ * @returns {void}
142
+ */
143
+ export function setStyle (layer, glStyle, {options = {}} = {}, url) {
144
+ if (url) {
145
+ fetch(url)
146
+ .then(response => response.json())
147
+ .then(style => {
148
+ const styles = options.layers ? style.layers.filter((styleLayer) => options.layers.includes(styleLayer.id)) : style.layers;
149
+
150
+ style.layers = styles;
151
+ applyStyle(layer, style);
152
+ });
153
+ }
154
+ if (glStyle && glStyle.sources) {
155
+
156
+ Object.keys(glStyle.sources).forEach((key) => {
157
+ const glStyleSourceId = key;
158
+
159
+ if (glStyle.sources[key].type !== "vector" && glStyle.sources[key].type !== "geojson") {
160
+ const olMap = layer.get("map");
161
+
162
+ apply(olMap, url);
163
+ }
164
+ else {
165
+ stylefunction(layer, glStyle,
166
+ options.sourceId ? options.sourceId : glStyleSourceId,
167
+ options.resolutions,
168
+ options.spriteData,
169
+ options.spriteImageUrl,
170
+ options.getFonts);
171
+ }
172
+ });
173
+ }
174
+ }
175
+
176
+
135
177
  /**
136
178
  * Creates a Vector Tiles layer.
137
179
  *
180
+ * Note: Within the vtStyles of a layer we introduced a boolean flag called defaultStyle.
181
+ * This option allows to mark a vtStyle as default. When not present, the first entry will be taken
182
+ * as style.
138
183
  * @param {rawLayer} rawLayer - rawLayer as specified in services.json
139
184
  * @param {object} [layerParams={}] - extra params of the layer. Can overwrite or extend all ol layer parameters.
140
185
  * @param {object} [options={}] - parameter object. Not used atm.
@@ -176,34 +221,11 @@ export function createLayer (rawLayer = {}, {layerParams = {}, options = {}} = {
176
221
  if (options.style && rawLayer.renderer !== "webgl") {
177
222
  layer.setStyle(options.style);
178
223
  }
224
+ if (rawLayer.vtStyles) {
225
+ const vtStyle = rawLayer.vtStyles.filter((style) => style.defaultStyle)[0] || rawLayer.vtStyles[0];
179
226
 
180
- return layer;
181
- }
227
+ setStyle(layer, {}, {options: {layers: rawLayer.layers}}, vtStyle.url);
182
228
 
183
- /**
184
- * Set a mapbox style
185
- * @param {ol.layer.VectorTile} layer - layer to style
186
- * @param {object} glStyle - MapBox style definition
187
- * @param {options} [styleParams={}] - Additional options for style specification
188
- * @param {string} url - MapBox style url
189
- * @returns {void}
190
- */
191
- export function setStyle (layer, glStyle, {options = {}} = {}, url) {
192
- Object.keys(glStyle.sources).forEach((key) => {
193
- const glStyleSourceId = key;
194
-
195
- if (glStyle.sources[key].type !== "vector" && glStyle.sources[key].type !== "geojson") {
196
- const olMap = layer.get("map");
197
-
198
- apply(olMap, url);
199
- }
200
- else {
201
- stylefunction(layer, glStyle,
202
- options.sourceId ? options.sourceId : glStyleSourceId,
203
- options.resolutions,
204
- options.spriteData,
205
- options.spriteImageUrl,
206
- options.getFonts);
207
- }
208
- });
229
+ }
230
+ return layer;
209
231
  }
package/src/lib/ping.js CHANGED
@@ -21,7 +21,8 @@ export default function ({url, typ, capabilitiesUrl, ...rest}) {
21
21
  .forEach(entity => entity.url ? statusCheckUrls.push(entity.url) : null);
22
22
  }
23
23
  else if (typ === "TileSet3D" || typ === "Terrain3D") {
24
- statusCheckUrls.push(url);
24
+ // 3D tile layers: skip HEAD ping; Cesium GET requests will load tiles
25
+ return Promise.resolve(200);
25
26
  }
26
27
  else if (typ === "GeoJSON") {
27
28
  if (!url && rest.features) {
@@ -1,4 +1,4 @@
1
- import {Style} from "ol/style.js";
1
+ import {Style, Icon} from "ol/style.js";
2
2
  import PointStyle from "./styles/point/stylePoint";
3
3
  import TextStyle from "./styles/styleText";
4
4
  import PolygonStyle from "./styles/polygon/stylePolygon";
@@ -267,6 +267,35 @@ function createStyle (styleObject, feature, isClustered, wfsImgPathFromConfig) {
267
267
  if (feature?.getGeometry().getType() === "Point" || feature?.getGeometry().getType() === "MultiPoint") {
268
268
  feature.setStyle(styleObjectGeometry);
269
269
  }
270
+ // polygon with icon in the center is optional for given polygonImage in style config file
271
+ if (style?.polygonImage && (feature?.getGeometry().getType() === "Polygon" || feature?.getGeometry().getType() === "MultiPolygon")) {
272
+ if (!Array.isArray(styleObjectGeometry)) {
273
+ styleObjectGeometry = [styleObjectGeometry];
274
+ }
275
+ styleObjectGeometry.push(new Style({
276
+ geometry: function (geometryFeature) {
277
+ const geometry = geometryFeature.getGeometry(),
278
+ geometryType = geometry.getType();
279
+
280
+
281
+ if (geometryType === "Polygon") {
282
+ return geometry.getInteriorPoint();
283
+ }
284
+ if (geometryType === "MultiPolygon") {
285
+ return geometry.getInteriorPoints();
286
+ }
287
+ return geometry;
288
+
289
+ },
290
+ image: new Icon({
291
+ anchor: [0.5, 0.5],
292
+ anchorXUnits: "fraction",
293
+ anchorYUnits: "fraction",
294
+ crossOrigin: "anonymous",
295
+ src: wfsImgPathFromConfig + style?.polygonImage
296
+ })
297
+ }));
298
+ }
270
299
  return styleObjectGeometry;
271
300
  }
272
301
 
@@ -22,13 +22,17 @@ class PolygonStyle extends StyleClass {
22
22
  * @param {ol/feature} feature Feature to be styled.
23
23
  * @param {object} styles styling properties to overwrite defaults
24
24
  * @param {Boolean} isClustered Flag to show if feature is clustered.
25
+ * @param {Boolean} wfsImgPathFromConfig image Path of the wfs.
25
26
  * @returns {void}
26
27
  */
27
- initialize (feature, styles, isClustered) {
28
+ initialize (feature, styles, isClustered, wfsImgPathFromConfig) {
28
29
  this.setFeature(feature);
29
30
  this.setIsClustered(isClustered);
30
31
  this.overwriteStyling(styles);
31
32
  this.setStyle(this.createStyle());
33
+ if (wfsImgPathFromConfig !== undefined) {
34
+ this.setImagePath(wfsImgPathFromConfig);
35
+ }
32
36
  }
33
37
 
34
38
  /**
@@ -124,6 +128,15 @@ class PolygonStyle extends StyleClass {
124
128
 
125
129
  return legendCanvas.toDataURL();
126
130
  }
131
+
132
+ /**
133
+ * Setter for imagePath.
134
+ * @param {String} value Image path.
135
+ * @returns {void}
136
+ */
137
+ setImagePath (value) {
138
+ this.attributes.imagePath = value;
139
+ }
127
140
  }
128
141
 
129
142
  export default PolygonStyle;
@@ -29,7 +29,11 @@ jest.mock("../../src/renderer/webgl.js", () => {
29
29
 
30
30
  describe("vectorTile.js", function () {
31
31
 
32
- beforeAll(() => crs.registerProjections());
32
+ beforeAll(() => {
33
+ crs.registerProjections();
34
+ global.Request = global.Request || jest.fn();
35
+ global.Response = global.Response || jest.fn();
36
+ });
33
37
 
34
38
  const rawLayer = {
35
39
  name: "VT Test",
@@ -3,7 +3,7 @@ import PointStyle from "../../src/vectorStyle/styles/point/stylePoint";
3
3
  import LineStringStyle from "../../src/vectorStyle/styles/styleLine";
4
4
  import CesiumStyle from "../../src/vectorStyle/styles/styleCesium";
5
5
  import PolygonStyle from "../../src/vectorStyle/styles/polygon/stylePolygon";
6
- import {Style, Stroke, Fill} from "ol/style.js";
6
+ import {Style, Stroke, Fill, Icon} from "ol/style.js";
7
7
  import {GeoJSON} from "ol/format.js";
8
8
 
9
9
  let rules,
@@ -280,6 +280,41 @@ describe("createStyle", () => {
280
280
  });
281
281
  });
282
282
 
283
+ it("should return the correct style for a feature with geometry of type Polygon ", () => {
284
+ const stylingRules = [{
285
+ "conditions": {
286
+ "sequence": [0, 0]
287
+ },
288
+ "style": {
289
+ "polygonStrokeColor": [
290
+ 161,
291
+ 113,
292
+ 14,
293
+ 1
294
+ ],
295
+ "polygonStrokeWidth": 0.2,
296
+ "polygonFillColor": [
297
+ 161,
298
+ 113,
299
+ 14,
300
+ 1
301
+ ],
302
+ "polygonImage": "image.svg"
303
+ }
304
+ }],
305
+ styleObject = {styleId: "styleId", rules: stylingRules},
306
+ polygonFeature = jsonObjects[2],
307
+ style = createStyle.createStyle(styleObject, polygonFeature, isClustered, wfsImgPathFromConfig);
308
+
309
+ expect(style === null).toBe(false);
310
+ expect(style).toBeInstanceOf(Array);
311
+ style.forEach(aStyle => {
312
+ expect(aStyle).toBeInstanceOf(Style);
313
+ });
314
+ expect(style[1].getImage()).toBeInstanceOf(Icon);
315
+ expect(style[1].getImage().getSrc()).toEqual(wfsImgPathFromConfig + stylingRules[0].style.polygonImage);
316
+ });
317
+
283
318
  it("should return the correct style for a feature with geometry of type MultiPolygon ", () => {
284
319
  const stylingRules = [{
285
320
  "conditions": {
@@ -13,6 +13,7 @@ describe("stylePolygon", () => {
13
13
  imageName: "krankenhaus.png"
14
14
  },
15
15
  isClustered = false,
16
+ wfsImgPathFromConfig = "/path/to/wfs/images/",
16
17
  stylePolygonClass = new PolygonStyle(feature, style, isClustered);
17
18
 
18
19
  describe("createStyle", function () {
@@ -61,4 +62,11 @@ describe("stylePolygon", () => {
61
62
  });
62
63
  });
63
64
 
65
+ describe("setImagePath", () => {
66
+ it("defines setImagePath() needed for polygon with Icon", () => {
67
+ stylePolygonClass.setImagePath(wfsImgPathFromConfig);
68
+ expect(stylePolygonClass.attributes.imagePath).toEqual(wfsImgPathFromConfig);
69
+ });
70
+ });
71
+
64
72
  });