@masterportal/masterportalapi 2.19.1 → 2.19.2

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,21 +3,14 @@
3
3
 
4
4
  The [Semantic Versioning](https://semver.org/spec/v2.0.0.html) is used.
5
5
 
6
- ## Unreleased - in development
7
- ### Added
8
- ### Changed
9
- ### Deprecated
10
- ### Removed
6
+ ## 2.19.2 - 2023-06-12
11
7
  ### Fixed
8
+ - VectorStyle of multiple geometries with styling rules does not fail on not existing style.
12
9
 
13
10
  ---
14
11
  ## 2.19.1 - 2023-06-02
15
- ### Added
16
12
  ### Changed
17
13
  - Exports in src/layer/wmts.js changed to export default {} to provide ES-Syntax.
18
- ### Deprecated
19
- ### Removed
20
- ### Fixed
21
14
 
22
15
  ---
23
16
 
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.19.1",
4
+ "version": "2.19.2",
5
5
  "license": "MIT",
6
6
  "description": "Basic functions of the Masterportal as api",
7
7
  "repository": {
@@ -11,7 +11,7 @@
11
11
  "main": "src/index.js",
12
12
  "scripts": {
13
13
  "test": "jest .test.js --config ./jest.config.js --collectCoverage",
14
- "test:trace": "node --trace-warnings node_modules/jest/bin/jest.js ./test/layer/wfs.test.js --config ./jest.config.js",
14
+ "test:trace": "node --trace-warnings node_modules/jest/bin/jest.js .test.js --config ./jest.config.js",
15
15
  "test:watch": "jest .test.js --config ./jest.config.js --watch",
16
16
  "example": "parcel example/index.html",
17
17
  "generate-jsdoc": "jsdoc ./src -r -d ./docs/ -R ./README.md -c jsdoc.json",
@@ -227,10 +227,22 @@ function createStyle (styleObject, feature, isClustered, wfsImgPathFromConfig) {
227
227
  style = Array.isArray(rules) && rules.length > 0 ? rules[0].style : null,
228
228
  hasLabelField = style?.labelField,
229
229
  geometryStyle = getGeometryStyle(feature, rules, isClustered, wfsImgPathFromConfig),
230
- legendInformation = Array.isArray(geometryStyle) ? geometryStyle[0].legendInfos : geometryStyle.legendInfos,
231
- styleObjectGeometry = Array.isArray(geometryStyle) ? geometryStyle.map(styleItem => styleItem.getStyle()) : geometryStyle.getStyle();
230
+ legendInformation = Array.isArray(geometryStyle) ? geometryStyle[0].legendInfos : geometryStyle.legendInfos;
231
+ let styleObjectGeometry = null;
232
232
 
233
- if (geometryStyle.length > 1) {
233
+ if (Array.isArray(geometryStyle)) {
234
+ styleObjectGeometry = [];
235
+ geometryStyle.forEach(styleItem => {
236
+ if (styleItem.getStyle() !== null) {
237
+ styleObjectGeometry.push(styleItem.getStyle());
238
+ }
239
+ });
240
+ }
241
+ else {
242
+ styleObjectGeometry = geometryStyle.getStyle();
243
+ }
244
+
245
+ if (Array.isArray(geometryStyle) && geometryStyle.length > 1) {
234
246
  for (const i in geometryStyle) {
235
247
  captureLegendFromFeature(styleObject.styleId, geometryStyle[i].legendInfos);
236
248
  }
@@ -238,7 +250,6 @@ function createStyle (styleObject, feature, isClustered, wfsImgPathFromConfig) {
238
250
  else {
239
251
  captureLegendFromFeature(styleObject.styleId, legendInformation);
240
252
  }
241
-
242
253
  // label style is optional and depends on some fields
243
254
  if (isClustered || hasLabelField) {
244
255
  if (Array.isArray(styleObjectGeometry)) {
@@ -239,6 +239,129 @@ describe("createStyle", () => {
239
239
 
240
240
  expect(style).toBeInstanceOf(Style);
241
241
  });
242
+
243
+ it("should return the correct style for a feature with geometry of type MultiLineString ", () => {
244
+ const stylingRules = [{
245
+ "conditions": {
246
+ "sequence": [0, 0]
247
+ },
248
+ "style": {
249
+ "lineStrokeColor": [0, 41, 255, 1],
250
+ "lineStrokeDash": [10, 2000],
251
+ "lineStrokeDashOffset": 0,
252
+ "lineStrokeWidth": 4
253
+ }
254
+ }],
255
+ styleObject = {styleId: "styleId", styleMultiGeomOnlyWithRule: true, rules: stylingRules},
256
+ isClustered = false,
257
+ multiLineStringFeature = jsonObjects[4],
258
+ style = createStyle.createStyle(styleObject, multiLineStringFeature, isClustered, wfsImgPathFromConfig);
259
+
260
+ expect(style === null).toBe(false);
261
+ expect(style).toBeInstanceOf(Array);
262
+ style.forEach(aStyle => {
263
+ expect(aStyle).toBeInstanceOf(Style);
264
+ });
265
+ });
266
+
267
+ it("should return the correct style for a feature with geometry of type MultiPolygon ", () => {
268
+ const stylingRules = [{
269
+ "conditions": {
270
+ "sequence": [0, 0]
271
+ },
272
+ "style": {
273
+ "polygonStrokeColor": [
274
+ 161,
275
+ 113,
276
+ 14,
277
+ 1
278
+ ],
279
+ "polygonStrokeWidth": 0.2,
280
+ "polygonFillColor": [
281
+ 161,
282
+ 113,
283
+ 14,
284
+ 1
285
+ ]
286
+ }
287
+ }],
288
+ styleObject = {styleId: "styleId", styleMultiGeomOnlyWithRule: true, rules: stylingRules},
289
+ isClustered = false,
290
+ multiPolygonFeature = jsonObjects[5],
291
+ style = createStyle.createStyle(styleObject, multiPolygonFeature, isClustered, wfsImgPathFromConfig);
292
+
293
+ expect(style === null).toBe(false);
294
+ expect(style).toBeInstanceOf(Array);
295
+ style.forEach(aStyle => {
296
+ expect(aStyle).toBeInstanceOf(Style);
297
+ });
298
+ });
299
+
300
+ it("should return the correct style for a feature with geometry of type GeometryCollection ", () => {
301
+ const stylingRules = [{
302
+ "conditions": {
303
+ "sequence": [0, 0]
304
+ },
305
+ "style": {
306
+ "polygonStrokeColor": [
307
+ 161,
308
+ 113,
309
+ 14,
310
+ 1
311
+ ],
312
+ "polygonStrokeWidth": 0.2,
313
+ "polygonFillColor": [
314
+ 161,
315
+ 113,
316
+ 14,
317
+ 1
318
+ ]
319
+ }
320
+ }],
321
+ styleObject = {styleId: "styleId", styleMultiGeomOnlyWithRule: true, rules: stylingRules},
322
+ isClustered = false,
323
+ geometryCollectionFeature = jsonObjects[6],
324
+ style = createStyle.createStyle(styleObject, geometryCollectionFeature, isClustered, wfsImgPathFromConfig);
325
+
326
+ expect(style === null).toBe(false);
327
+ expect(style).toBeInstanceOf(Array);
328
+ style.forEach(aStyle => {
329
+ expect(aStyle).toBeInstanceOf(Style);
330
+ });
331
+ });
332
+
333
+ it("should return the correct style for a feature with geometry of type MultiPoint ", () => {
334
+ const stylingRules = [{
335
+ "conditions": {
336
+ "sequence": [0, 0]
337
+ },
338
+ "style": {
339
+ "circleRadius": 6,
340
+ "circleStrokeColor": [
341
+ 24,
342
+ 116,
343
+ 205,
344
+ 1
345
+ ],
346
+ "circleFillColor": [
347
+ 135,
348
+ 206,
349
+ 250,
350
+ 1
351
+ ]
352
+ }
353
+ }],
354
+ styleObject = {styleId: "styleId", styleMultiGeomOnlyWithRule: true, rules: stylingRules},
355
+ isClustered = false,
356
+ multiPointFeature = jsonObjects[3],
357
+ style = createStyle.createStyle(styleObject, multiPointFeature, isClustered, wfsImgPathFromConfig);
358
+
359
+ expect(style === null).toBe(false);
360
+ expect(style).toBeInstanceOf(Array);
361
+ style.forEach(aStyle => {
362
+ expect(aStyle).toBeInstanceOf(Style);
363
+ });
364
+ });
242
365
  });
243
366
 
244
367
  describe("getSimpleGeometryStyle", function () {