@masterportal/masterportalapi 2.19.1 → 2.20.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.
@@ -1,9 +1,9 @@
1
1
  import WebGLPointsLayer from "ol/layer/WebGLPoints";
2
2
  import WebGLVectorLayerRenderer from "ol/renderer/webgl/VectorLayer";
3
3
  import VectorLayer from "ol/layer/Layer";
4
- import {packColor} from "ol/renderer/webgl/shaders";
5
4
  import styleList from "../vectorStyle/styleList";
6
5
  import {getRulesForFeature} from "../vectorStyle/lib/getRuleForIndex";
6
+ import {returnColor} from "../vectorStyle/lib/colorConvertions";
7
7
 
8
8
  /**
9
9
  * The default style for OpenLayers WebGLPoints class
@@ -11,82 +11,26 @@ import {getRulesForFeature} from "../vectorStyle/lib/getRuleForIndex";
11
11
  * @private
12
12
  */
13
13
  const defaultStyle = {
14
- symbol: {
15
- symbolType: "circle",
16
- size: 20,
17
- color: "#006688",
18
- rotateWithView: false,
19
- offset: [0, 0],
20
- opacity: 0.6
21
- }
22
- };
23
-
24
- /**
25
- * parses the styling rules for the renderer
26
- * @static
27
- * @private
28
- * @returns {Object} the style options object with conditional functions
29
- */
30
- export function getRenderFunctions () {
31
- return {
32
- /**
33
- * Used for polygon fills
34
- * Reads the relevant properties from the Masterportal style object
35
- * @see https://bitbucket.org/geowerkstatt-hamburg/masterportal/src/dev/doc/style.json.md
36
- */
37
- fill: {
38
- attributes: {
39
- color: (feature) => {
40
- return packColor(feature.styleRule?.style.polygonFillColor || "#006688");
41
- },
42
- opacity: (feature) => {
43
- return typeof feature.styleRule?.style.polygonFillColor?.[3] === "number" ?
44
- feature.styleRule.style.polygonFillColor[3] : 1;
45
- }
46
- }
47
- },
48
- stroke: {
49
- /**
50
- * Used for polygon edges and lineStrings
51
- * Reads the relevant properties from the Masterportal style object
52
- * @see https://bitbucket.org/geowerkstatt-hamburg/masterportal/src/dev/doc/style.json.md
53
- */
54
- attributes: {
55
- color: (feature) => {
56
- return packColor(feature.styleRule?.style.polygonStrokeColor || "#006688");
57
- },
58
- width: (feature) => {
59
- return feature.styleRule?.style.polygonStrokeWidth || 1;
60
- },
61
- opacity: (feature) => {
62
- return typeof feature.styleRule?.style.polygonStrokeColor?.[3] === "number" ?
63
- feature.styleRule.style.polygonStrokeColor[3] : 1;
64
- }
65
- }
66
- },
67
- point: {
68
- /**
69
- * As of now, the generic VectorLayerRenderer only supports points rendered as quads
70
- * available attributes: color, size, opacity
71
- * Due to that, we use WebGLPoints Layer Class for point geom types
72
- * Reads the relevant properties from the Masterportal style object
73
- * @see https://bitbucket.org/geowerkstatt-hamburg/masterportal/src/dev/doc/style.json.md
74
- */
75
- attributes: {
76
- color: (feature) => {
77
- return packColor(feature.styleRule?.style.circleFillColor || "#006688");
78
- },
79
- size: (feature) => {
80
- return feature.styleRule?.style.circleRadius || 20;
81
- },
82
- opacity: (feature) => {
83
- return typeof feature.styleRule?.style.circleFillColor?.[3] === "number" ?
84
- feature.styleRule.style.circleFillColor[3] : 1;
85
- }
86
- }
14
+ symbol: {
15
+ symbolType: "circle",
16
+ size: 20,
17
+ color: "#006688",
18
+ rotateWithView: false,
19
+ offset: [0, 0],
20
+ opacity: 0.6
87
21
  }
22
+ },
23
+
24
+ /** @type {import('../src/ol/style/literal.js').LiteralStyle} */
25
+ style = {
26
+ "stroke-color": ["get", "STROKECOLOR"],
27
+ // NOTICE: does not work with ol 7.4.0, throws errors -> use 1 pixel width
28
+ // "stroke-width": ["get", "STROKEWIDTH"],
29
+ "stroke-width": 1,
30
+ "fill-color": ["get", "FILLCOLOR"],
31
+ "opacity": ["get", "OPACITY"],
32
+ "size": ["get", "CIRCLESIZE"]
88
33
  };
89
- }
90
34
 
91
35
  /**
92
36
  * Creates a layer object to extend from.
@@ -109,7 +53,9 @@ export function createVectorLayerRenderer () {
109
53
  * @experimental
110
54
  */
111
55
  createRenderer () {
112
- return new WebGLVectorLayerRenderer(this, getRenderFunctions());
56
+ return new WebGLVectorLayerRenderer(this, {
57
+ style
58
+ });
113
59
  }
114
60
  }
115
61
 
@@ -132,9 +78,24 @@ export function formatFeatureStyles (feature, styleObject) {
132
78
  // extract first matching rule only
133
79
  const rule = getRulesForFeature(styleObject, feature)[0];
134
80
 
135
- // don't set on properties to avoid GFI issues
136
81
  // undefined if no match
137
82
  feature.styleRule = rule;
83
+
84
+ if (rule && rule.style) {
85
+ // TODO set style on properties will be visible in GFI
86
+ const polygonFillColor = returnColor(rule.style.polygonFillColor, "hex"),
87
+ circleFillColor = returnColor(rule.style.circleFillColor, "hex"),
88
+ fillColor = polygonFillColor ? polygonFillColor : circleFillColor,
89
+ polygonStrokeColor = returnColor(rule.style.polygonStrokeColor, "hex"),
90
+ polygonStrokeWidth = rule.style.polygonStrokeWidth,
91
+ size = rule.style.circleRadius;
92
+
93
+ feature.set("FILLCOLOR", fillColor ? fillColor : "#006688");
94
+ feature.set("STROKECOLOR", polygonStrokeColor ? polygonStrokeColor : "#006688");
95
+ feature.set("STROKEWIDTH", polygonStrokeWidth ? polygonStrokeWidth : 1);
96
+ feature.set("OPACITY", polygonFillColor ? polygonFillColor[3] : 1);
97
+ feature.set("CIRCLESIZE", size ? size : 20);
98
+ }
138
99
  }
139
100
 
140
101
  /**
@@ -6,8 +6,7 @@ import LineStringStyle from "./styles/styleLine";
6
6
  import CesiumStyle from "./styles/styleCesium";
7
7
  import {getRuleForIndex, getRulesForFeature} from "./lib/getRuleForIndex";
8
8
 
9
- const legendsOfAllStyles = [],
10
- uniqueStyles = [];
9
+ const legendsOfAllStyles = [];
11
10
  let legendInformationLength = 0;
12
11
 
13
12
  /**
@@ -30,17 +29,13 @@ function isMultiGeometry (geometryType) {
30
29
  */
31
30
  function getSimpleGeometryStyle (geometryType, feature, rule, isClustered, wfsImgPathFromConfig) {
32
31
  const style = rule?.style,
33
- legendValue = style ? style.legendValue : null,
34
- alreadyExisitingStyle = uniqueStyles.find(element => element.featureStyle === style && element.geometryType === geometryType);
32
+ legendValue = style ? style.legendValue : null;
35
33
  let styleObject,
36
34
  styleObjectForLegend = null;
37
35
 
38
36
  feature.legendValue = legendValue ? legendValue : null;
39
37
 
40
- if (alreadyExisitingStyle) {
41
- styleObject = alreadyExisitingStyle.featureStyleObject;
42
- }
43
- else if (geometryType === "Point") {
38
+ if (geometryType === "Point") {
44
39
  styleObject = new PointStyle(feature, style, isClustered);
45
40
  if (isClustered) {
46
41
  styleObjectForLegend = new PointStyle(feature, style, false);
@@ -78,7 +73,6 @@ function getSimpleGeometryStyle (geometryType, feature, rule, isClustered, wfsIm
78
73
  styleObjectForLegend.initialize(feature, style, false, wfsImgPathFromConfig);
79
74
  styleObjectForLegend.legendValue = legendValue;
80
75
  }
81
- uniqueStyles.push({featureStyle: style, featureStyleObject: styleObject, geometryType});
82
76
  styleObject.initialize(feature, style, isClustered, wfsImgPathFromConfig);
83
77
  styleObject.addLegendInfo(geometryType, styleObjectForLegend === null ? styleObject : styleObjectForLegend, rule);
84
78
  styleObject.legendValue = legendValue;
@@ -122,6 +116,7 @@ function getMultiGeometryStyle (geometryType, feature, rules, isClustered, wfsIm
122
116
  console.warn("Multi encapsulated multiGeometries are not supported.");
123
117
  }
124
118
  else if (!simpleStyle.styleMultiGeomOnlyWithRule || rule) {
119
+ simpleStyle.getStyle()?.setGeometry(geometry);
125
120
  olStyle.push(simpleStyle);
126
121
  }
127
122
  });
@@ -136,7 +131,7 @@ function getMultiGeometryStyle (geometryType, feature, rules, isClustered, wfsIm
136
131
  else {
137
132
  const simpleStyle = getSimpleGeometryStyle(geometryType, feature, rules, isClustered, wfsImgPathFromConfig);
138
133
 
139
- simpleStyle.getStyle().setGeometry(geometryType);
134
+ simpleStyle.getStyle()?.setGeometry(geometryType);
140
135
  olStyle.push(simpleStyle);
141
136
  }
142
137
  return olStyle;
@@ -227,10 +222,22 @@ function createStyle (styleObject, feature, isClustered, wfsImgPathFromConfig) {
227
222
  style = Array.isArray(rules) && rules.length > 0 ? rules[0].style : null,
228
223
  hasLabelField = style?.labelField,
229
224
  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();
225
+ legendInformation = Array.isArray(geometryStyle) ? geometryStyle[0].legendInfos : geometryStyle.legendInfos;
226
+ let styleObjectGeometry = null;
227
+
228
+ if (Array.isArray(geometryStyle)) {
229
+ styleObjectGeometry = [];
230
+ geometryStyle.forEach(styleItem => {
231
+ if (styleItem.getStyle() !== null) {
232
+ styleObjectGeometry.push(styleItem.getStyle());
233
+ }
234
+ });
235
+ }
236
+ else {
237
+ styleObjectGeometry = geometryStyle.getStyle();
238
+ }
232
239
 
233
- if (geometryStyle.length > 1) {
240
+ if (Array.isArray(geometryStyle) && geometryStyle.length > 1) {
234
241
  for (const i in geometryStyle) {
235
242
  captureLegendFromFeature(styleObject.styleId, geometryStyle[i].legendInfos);
236
243
  }
@@ -238,9 +245,8 @@ function createStyle (styleObject, feature, isClustered, wfsImgPathFromConfig) {
238
245
  else {
239
246
  captureLegendFromFeature(styleObject.styleId, legendInformation);
240
247
  }
241
-
242
248
  // label style is optional and depends on some fields
243
- if (isClustered || hasLabelField) {
249
+ if (styleObjectGeometry !== null && (isClustered || hasLabelField)) {
244
250
  if (Array.isArray(styleObjectGeometry)) {
245
251
  styleObjectGeometry[0].setText(getLabelStyle(feature, style, isClustered));
246
252
  }
@@ -38,14 +38,14 @@ class PointStyle extends StyleClass {
38
38
  this.setFeature(feature);
39
39
  this.setIsClustered(isClustered);
40
40
  this.overwriteStyling(styles);
41
- this.setStyle(this.getStyle());
41
+ this.setStyle(this.createStyle());
42
42
  }
43
43
 
44
44
  /**
45
45
  * This function returns a style for each feature.
46
46
  * @returns {ol/style} - The created style.
47
47
  */
48
- getStyle () {
48
+ createStyle () {
49
49
  if (this.nullStyle) {
50
50
  return null;
51
51
  }
@@ -28,14 +28,14 @@ class PolygonStyle extends StyleClass {
28
28
  this.setFeature(feature);
29
29
  this.setIsClustered(isClustered);
30
30
  this.overwriteStyling(styles);
31
- this.setStyle(this.getStyle());
31
+ this.setStyle(this.createStyle());
32
32
  }
33
33
 
34
34
  /**
35
35
  * This function returns a style for each feature.
36
36
  * @returns {ol/style} - The created style.
37
37
  */
38
- getStyle () {
38
+ createStyle () {
39
39
  if (this.nullStyle) {
40
40
  return null;
41
41
  }
@@ -35,6 +35,14 @@ class StyleClass {
35
35
  this.style = value;
36
36
  }
37
37
 
38
+ /**
39
+ * Getter for style.
40
+ * @returns {ol/style} - The style.
41
+ */
42
+ getStyle () {
43
+ return this.style;
44
+ }
45
+
38
46
  /*
39
47
  * setter for styles
40
48
  * @param {object} styles styles
@@ -22,14 +22,14 @@ class CesiumStyle extends StyleClass {
22
22
  initialize (rule) {
23
23
  this.overwriteStyling(rule.style);
24
24
  this.setConditions(rule.conditions);
25
- this.setStyle(this.getStyle());
25
+ this.setStyle(this.createStyle());
26
26
  }
27
27
 
28
28
  /**
29
29
  * This function returns a style for each feature.
30
30
  * @returns {ol/style} - The created style.
31
31
  */
32
- getStyle () {
32
+ createStyle () {
33
33
  return this.createCondition(this.get("conditions"), this.get("style"));
34
34
  }
35
35
 
@@ -26,14 +26,14 @@ class LineStringStyle extends StyleClass {
26
26
  this.setFeature(feature);
27
27
  this.setIsClustered(isClustered);
28
28
  this.overwriteStyling(styles);
29
- this.setStyle(this.getStyle());
29
+ this.setStyle(this.createStyle());
30
30
  }
31
31
 
32
32
  /**
33
33
  * This function returns a style for each feature.
34
34
  * @returns {ol/style/Style} - The created style.
35
35
  */
36
- getStyle () {
36
+ createStyle () {
37
37
  if (this.nullStyle) {
38
38
  return null;
39
39
  }
@@ -28,14 +28,14 @@ class TextStyle extends StyleClass {
28
28
  this.setFeature(feature);
29
29
  this.setIsClustered(isClustered);
30
30
  this.overwriteStyling(styles);
31
- this.setStyle(this.getStyle());
31
+ this.setStyle(this.createStyle());
32
32
  }
33
33
 
34
34
  /**
35
35
  * This function returns a style for each feature.
36
36
  * @returns {ol/style} - The created style.
37
37
  */
38
- getStyle () {
38
+ createStyle () {
39
39
  if (this.nullStyle) {
40
40
  return null;
41
41
  }
@@ -414,5 +414,57 @@ describe("wfs.js", function () {
414
414
  expect(webgl.afterLoading).toHaveBeenCalled();
415
415
  });
416
416
  });
417
+ describe("loadFeaturesManually", function () {
418
+ const consoleError = console.error;
419
+ let tick;
420
+
421
+ beforeEach(() => {
422
+ tick = () => {
423
+ return new Promise(resolve => {
424
+ setTimeout(resolve, 0);
425
+ });
426
+ };
427
+
428
+ if (global.fetch) {
429
+ global.fetch.mockClear();
430
+ }
431
+ });
432
+ // to reset show error on load in console
433
+ afterEach(() => {
434
+ console.error = consoleError;
435
+ });
436
+
437
+ it("load features manually", async function () {
438
+ global.fetch = jest.fn().mockImplementationOnce(() => {
439
+ return new Promise((resolve) => {
440
+ resolve({
441
+ ok: true,
442
+ status: 200,
443
+ text: () => {
444
+ return featureCollection;
445
+ }
446
+ });
447
+ });
448
+ });
449
+
450
+ const format = new WFS(),
451
+ source = new VectorSource({
452
+ format: format,
453
+ url: "https://url.de",
454
+ version: "1.1.0",
455
+ featureType: "krankenhaeuser_hh",
456
+ featureNS: "http://www.deegree.org/app"
457
+ }),
458
+ layerAttributes = {
459
+ crs: "EPSG:25832",
460
+ version: "1.1.0",
461
+ url: "https://url.de"
462
+ };
463
+
464
+ wfs.loadFeaturesManually(layerAttributes, source);
465
+ await tick();
466
+ expect(source.getFeatures()).toHaveLength(1);
467
+ });
468
+ });
417
469
  });
418
470
 
@@ -0,0 +1,50 @@
1
+ import {Draw} from "ol/interaction.js";
2
+ import VectorSource from "ol/source/Vector";
3
+
4
+ import drawInteractions from "../../../src/maps/interactions/drawInteractions";
5
+
6
+ describe("src/maps/interactions/drawInteractions.js", () => {
7
+ describe("createDrawInteraction", () => {
8
+ it("should create a draw interaction", () => {
9
+ const source = new VectorSource(),
10
+ drawType = "pen",
11
+ drawInteraction = drawInteractions.createDrawInteraction(drawType, source);
12
+
13
+ expect(drawInteraction).not.toBeUndefined();
14
+ expect(drawInteraction).not.toBeNull();
15
+ expect(drawInteraction).toBeInstanceOf(Draw);
16
+ });
17
+
18
+ it("should return null, if drawType is not supported", () => {
19
+ const source = new VectorSource(),
20
+ drawType = "abc",
21
+ drawInteraction = drawInteractions.createDrawInteraction(drawType, source);
22
+
23
+ expect(drawInteraction).not.toBeUndefined();
24
+ expect(drawInteraction).toBeNull();
25
+ expect(drawInteraction).not.toBeInstanceOf(Draw);
26
+ });
27
+ });
28
+
29
+ describe("transformMapUnitRadius", () => {
30
+ it("should return the input meter radius in meter ", () => {
31
+ const radius = 100,
32
+ mapProjection = {
33
+ getUnits: () => "m"
34
+ },
35
+ mapUnitRadius = drawInteractions.transformMapUnitRadius(radius, mapProjection);
36
+
37
+ expect(mapUnitRadius).toEqual(100);
38
+ });
39
+
40
+ it("should return the input degree radius in meter ", () => {
41
+ const radius = 100,
42
+ mapProjection = {
43
+ getUnits: () => "degrees"
44
+ },
45
+ mapUnitRadius = drawInteractions.transformMapUnitRadius(radius, mapProjection);
46
+
47
+ expect(mapUnitRadius).toEqual(0.0008983152841195215);
48
+ });
49
+ });
50
+ });
@@ -4,7 +4,6 @@ import Polygon from "ol/geom/Polygon";
4
4
  import * as webgl from "../../src/renderer/webgl";
5
5
  import WebGLPointsLayer from "ol/layer/WebGLPoints";
6
6
  import Layer from "ol/layer/Layer";
7
- import {packColor} from "ol/renderer/webgl/shaders";
8
7
  import styleList from "../../src/vectorStyle/styleList";
9
8
 
10
9
  describe("webgl.js", () => {
@@ -108,54 +107,5 @@ describe("webgl.js", () => {
108
107
  expect($feature.styleRule).toEqual(styleRule);
109
108
  });
110
109
  });
111
- describe("getRenderFunctions", () => {
112
- it("should read the style from styleRule and pack them to single float", () => {
113
- const renderFunctions = webgl.getRenderFunctions();
114
-
115
- $feature = feature.clone();
116
- webgl.formatFeatureStyles($feature, styleObject);
117
- expect(renderFunctions.fill.attributes.color($feature)).toEqual(packColor(styleRule.style.polygonFillColor));
118
- expect(renderFunctions.fill.attributes.opacity($feature)).toEqual(styleRule.style.polygonFillColor[3]);
119
- expect(renderFunctions.stroke.attributes.color($feature)).toEqual(packColor(styleRule.style.polygonStrokeColor));
120
- expect(renderFunctions.stroke.attributes.width($feature)).toEqual(styleRule.style.polygonStrokeWidth);
121
- expect(renderFunctions.stroke.attributes.opacity($feature)).toEqual(styleRule.style.polygonStrokeColor[3]);
122
- expect(renderFunctions.point.attributes.color($feature)).toEqual(packColor(styleRule.style.circleFillColor));
123
- expect(renderFunctions.point.attributes.size($feature)).toEqual(styleRule.style.circleRadius);
124
- expect(renderFunctions.point.attributes.opacity($feature)).toEqual(styleRule.style.circleFillColor[3]);
125
- });
126
- it("should return default values if style is empty, i.e. \"default\" style", () => {
127
- const renderFunctions = webgl.getRenderFunctions();
128
-
129
- styleObject = {
130
- rules: [{
131
- style: {}
132
- }]
133
- };
134
- $feature = feature.clone();
135
- webgl.formatFeatureStyles($feature, styleObject);
136
- expect(typeof renderFunctions.fill.attributes.color($feature)).toEqual("number");
137
- expect(typeof renderFunctions.fill.attributes.opacity($feature)).toEqual("number");
138
- expect(typeof renderFunctions.stroke.attributes.color($feature)).toEqual("number");
139
- expect(typeof renderFunctions.stroke.attributes.width($feature)).toEqual("number");
140
- expect(typeof renderFunctions.stroke.attributes.opacity($feature)).toEqual("number");
141
- expect(typeof renderFunctions.point.attributes.color($feature)).toEqual("number");
142
- expect(typeof renderFunctions.point.attributes.size($feature)).toEqual("number");
143
- expect(typeof renderFunctions.point.attributes.opacity($feature)).toEqual("number");
144
- });
145
- it("should return default values if no style rule is found", () => {
146
- const renderFunctions = webgl.getRenderFunctions();
147
-
148
- $feature = feature.clone();
149
- expect(feature.styleRule).toBeUndefined();
150
- expect(typeof renderFunctions.fill.attributes.color($feature)).toEqual("number");
151
- expect(typeof renderFunctions.fill.attributes.opacity($feature)).toEqual("number");
152
- expect(typeof renderFunctions.stroke.attributes.color($feature)).toEqual("number");
153
- expect(typeof renderFunctions.stroke.attributes.width($feature)).toEqual("number");
154
- expect(typeof renderFunctions.stroke.attributes.opacity($feature)).toEqual("number");
155
- expect(typeof renderFunctions.point.attributes.color($feature)).toEqual("number");
156
- expect(typeof renderFunctions.point.attributes.size($feature)).toEqual("number");
157
- expect(typeof renderFunctions.point.attributes.opacity($feature)).toEqual("number");
158
- });
159
- });
160
110
  });
161
111
  });
@@ -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 () {
@@ -27,8 +27,11 @@ describe("stylePoint", () => {
27
27
  expect(typeof stylePointClass.setSize).toBe("function");
28
28
  });
29
29
  });
30
- describe("getStyle", function () {
30
+ describe("createStyle", function () {
31
31
  it("returns an instance of openlayers style", () => {
32
+ const createdStyle = stylePointClass.createStyle();
33
+
34
+ stylePointClass.setStyle(createdStyle);
32
35
  expect(stylePointClass.getStyle()).toBeInstanceOf(Style);
33
36
  });
34
37
  it("returns an instance of openlayers circleStyle", () => {
@@ -39,6 +42,9 @@ describe("stylePoint", () => {
39
42
  legendValue: "Krankenhaus",
40
43
  imageName: "krankenhaus.png"
41
44
  };
45
+ const createdStyle = stylePointClass.createStyle();
46
+
47
+ stylePointClass.setStyle(createdStyle);
42
48
 
43
49
  expect(stylePointClass.getStyle()).toBeInstanceOf(Style);
44
50
  expect(stylePointClass.getStyle().getImage()).toBeInstanceOf(CircleStyle);