@masterportal/masterportalapi 2.15.2 → 2.17.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,25 +3,54 @@
3
3
 
4
4
  The [Semantic Versioning](https://semver.org/spec/v2.0.0.html) is used.
5
5
 
6
- ## Unreleased - in development
7
- ###
8
- Added
9
- ###
10
- Changed
11
- ###
12
- Deprecated
13
- ###
14
- Removed
15
- ###
16
- Fixed
6
+ ## 2.17.0 - 2023-04-27
7
+ ### Added
8
+ - Added functionality for mapbox style raster sources for vector tile layer.
9
+ - Added possibility to use zoomToFeatureId in vectorStyle.
10
+
11
+ ### Changed
12
+ - ol map default interactions and keyboardEventTarget can now be set by config parameters.
13
+ - The following packages have been updated:
14
+ - dependencies:
15
+ - xml2js: 0.4.23 to 0.5.0
16
+
17
+ ### Fix
18
+ - Fix vectorStyle for circlesegments.
19
+
20
+ ---
21
+
22
+ ## 2.16.0 - 2023-03-28
23
+ ### Added
24
+ - Added support for `npm` version ^9.1.3.
25
+
26
+ ### Changed
27
+ - The following packages have been updated:
28
+ - dependencies:
29
+ - core-js: 3.27.1 to 3.29.1
30
+ - ol: 7.2.2 to 7.3.0
31
+ - proj4: 2.8.1 to 2.9.0
32
+ - devDependencies:
33
+ - @babel/core: 7.20.12 to 7.21.3
34
+ - @babel/plugin-transform-modules-commonjs: 7.20.11 to 7.21.2
35
+ - eslint: 8.31.0 to 8.36.0
36
+ - jest: 29.3.1 to 29.5.0
37
+ - jest-environment-jsdom: 29.3.1 to 29.5.0
38
+ - jsdoc: 4.0.0 to 4.0.2
39
+ - sass: 1.57.1 to 1.59.3
40
+
41
+ ### Fixed
42
+ - Issue Masterportal.#870: Features with `null` style were shown with default style. However, the default style is only supposed to be used for fallbacks; `null` style features must explicitly be invisible. This has been resolved.
43
+ - Style of legend is now always not clustered.
44
+
17
45
  ---
18
46
 
19
47
  ## 2.15.2 - 2023-03-14
20
- ###
21
- Changed
48
+ ### Changed
22
49
  - Update parameters for getGeometryTypeFromService.getGeometryTypeFromWFS and getGeometryTypeFromService.getGeometryTypeFromOAF to pass wfsImgPath.
50
+
23
51
  ### Fixed
24
52
  - Fix imports in createLegendInfo.js
53
+
25
54
  ---
26
55
 
27
56
  ## 2.15.1 - 2023-03-09
package/example/index.js CHANGED
@@ -262,7 +262,7 @@ fetch(vtStyleUrl)
262
262
  .then(style => {
263
263
  const vtLayer = window.mpapi.map.addLayer("6001");
264
264
 
265
- mpapi.vectorTile.setStyle(vtLayer, style);
265
+ mpapi.vectorTile.setStyle(vtLayer, style, vtStyleUrl);
266
266
  });
267
267
  //*/
268
268
 
package/package.json CHANGED
@@ -1,63 +1,64 @@
1
- {
2
- "name": "@masterportal/masterportalapi",
3
- "author": "Implementierungspartnerschaft Masterportal <info@masterportal.org> (https://www.masterportal.org)",
4
- "version": "2.15.2",
5
- "license": "MIT",
6
- "description": "Basic functions of the Masterportal as api",
7
- "repository": {
8
- "type": "git",
9
- "url": "git+https://bitbucket.org/geowerkstatt-hamburg/masterportalapi.git"
10
- },
11
- "main": "src/index.js",
12
- "scripts": {
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",
15
- "test:watch": "jest .test.js --config ./jest.config.js --watch",
16
- "example": "parcel example/index.html",
17
- "generate-jsdoc": "jsdoc ./src -r -d ./docs/ -R ./README.md -c jsdoc.json",
18
- "prePushHook": "eslint --max-warnings 0 \"./**/*.js\" && npm run test",
19
- "prepare": "husky install"
20
- },
21
- "dependencies": {
22
- "core-js": "^3.27.1",
23
- "ol": "7.2.2",
24
- "olcs": "^2.13.1",
25
- "proj4": "^2.8.1",
26
- "xml2js": "^0.4.23"
27
- },
28
- "devDependencies": {
29
- "@babel/core": "^7.20.12",
30
- "@babel/plugin-transform-modules-commonjs": "^7.20.11",
31
- "@parcel/transformer-sass": "^2.6.0",
32
- "buffer": "^6.0.3",
33
- "canvas": "^2.11.0",
34
- "eslint": "^8.31.0",
35
- "events": "^3.3.0",
36
- "husky": "^8.0.3",
37
- "jest": "^29.3.1",
38
- "jest-canvas-mock": "^2.4.0",
39
- "jest-environment-jsdom": "^29.3.1",
40
- "jsdoc": "^4.0.0",
41
- "parcel": "^2.6.0",
42
- "process": "^0.11.10",
43
- "sass": "^1.57.1",
44
- "stream-browserify": "^3.0.0",
45
- "timers-browserify": "^2.0.12",
46
- "use-resize-observer": "^9.1.0"
47
- },
48
- "peerDependencies": {
49
- "cesium": "^1.95.0"
50
- },
51
- "engines": {
52
- "node": "^16.13.2 || ^18.12.0",
53
- "npm": "^8.1.2"
54
- },
55
- "homepage": "https://bitbucket.org/geowerkstatt-hamburg/masterportalapi#readme",
56
- "directories": {
57
- "example": "example",
58
- "test": "test"
59
- },
60
- "bugs": {
61
- "url": "https://bitbucket.org/geowerkstatt-hamburg/masterportalapi/issues"
62
- }
63
- }
1
+ {
2
+ "name": "@masterportal/masterportalapi",
3
+ "author": "Implementierungspartnerschaft Masterportal <info@masterportal.org> (https://www.masterportal.org)",
4
+ "version": "2.17.0",
5
+ "license": "MIT",
6
+ "description": "Basic functions of the Masterportal as api",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://bitbucket.org/geowerkstatt-hamburg/masterportalapi.git"
10
+ },
11
+ "main": "src/index.js",
12
+ "scripts": {
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",
15
+ "test:watch": "jest .test.js --config ./jest.config.js --watch",
16
+ "example": "parcel example/index.html",
17
+ "generate-jsdoc": "jsdoc ./src -r -d ./docs/ -R ./README.md -c jsdoc.json",
18
+ "prePushHook": "eslint --max-warnings 0 \"./**/*.js\" && npm run test",
19
+ "prepare": "husky install"
20
+ },
21
+ "dependencies": {
22
+ "core-js": "^3.29.1",
23
+ "ol": "7.3.0",
24
+ "olcs": "^2.13.1",
25
+ "proj4": "^2.9.0",
26
+ "xml2js": "^0.5.0"
27
+ },
28
+ "devDependencies": {
29
+ "@babel/core": "^7.21.3",
30
+ "@babel/plugin-transform-modules-commonjs": "^7.21.2",
31
+ "@parcel/transformer-sass": "^2.6.0",
32
+ "buffer": "^6.0.3",
33
+ "canvas": "^2.11.0",
34
+ "eslint": "^8.36.0",
35
+ "events": "^3.3.0",
36
+ "husky": "^8.0.3",
37
+ "jest": "^29.5.0",
38
+ "jest-canvas-mock": "^2.4.0",
39
+ "jest-environment-jsdom": "^29.5.0",
40
+ "jsdoc": "^4.0.2",
41
+ "parcel": "^2.6.0",
42
+ "process": "^0.11.10",
43
+ "sass": "^1.59.3",
44
+ "stream-browserify": "^3.0.0",
45
+ "timers-browserify": "^2.0.12",
46
+ "use-resize-observer": "^9.1.0"
47
+ },
48
+ "peerDependencies": {
49
+ "cesium": "^1.95.0"
50
+ },
51
+ "engines": {
52
+ "node": "^16.13.2 || ^18.12.0",
53
+ "npm": "^8.1.2 || ^9.3.1"
54
+ },
55
+ "homepage": "https://bitbucket.org/geowerkstatt-hamburg/masterportalapi#readme",
56
+ "directories": {
57
+ "doc": "docs",
58
+ "example": "example",
59
+ "test": "test"
60
+ },
61
+ "bugs": {
62
+ "url": "https://bitbucket.org/geowerkstatt-hamburg/masterportalapi/issues"
63
+ }
64
+ }
@@ -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
 
7
- import {stylefunction} from "ol-mapbox-style";
7
+ import {stylefunction, apply} from "ol-mapbox-style";
8
8
 
9
9
  import defaults from "../defaults";
10
10
 
@@ -161,13 +161,25 @@ export function createLayer (rawLayer = {}, {layerParams = {}, options = {}} = {
161
161
  * @param {ol.layer.VectorTile} layer - layer to style
162
162
  * @param {object} glStyle - MapBox style definition
163
163
  * @param {options} [styleParams={}] - Additional options for style specification
164
+ * @param {string} url - MapBox style url
164
165
  * @returns {void}
165
166
  */
166
- export function setStyle (layer, glStyle, {options = {}} = {}) {
167
- stylefunction(layer, glStyle,
168
- options.sourceId ? options.sourceId : Object.keys(glStyle.sources)[0],
169
- options.resolutions,
170
- options.spriteData,
171
- options.spriteImageUrl,
172
- options.getFonts);
167
+ export function setStyle (layer, glStyle, {options = {}} = {}, url) {
168
+ Object.keys(glStyle.sources).forEach((key) => {
169
+ const glStyleSourceId = key;
170
+
171
+ if (glStyle.sources[key].type !== "vector" && glStyle.sources[key].type !== "geojson") {
172
+ const olMap = layer.get("map");
173
+
174
+ apply(olMap, url);
175
+ }
176
+ else {
177
+ stylefunction(layer, glStyle,
178
+ options.sourceId ? options.sourceId : glStyleSourceId,
179
+ options.resolutions,
180
+ options.spriteData,
181
+ options.spriteImageUrl,
182
+ options.getFonts);
183
+ }
184
+ });
173
185
  }
@@ -150,18 +150,23 @@ export function createMap (config = defaults, {mapParams, callback, errorCallbac
150
150
  crs.registerProjections(config.namedProjections);
151
151
  setBackgroundImage(config);
152
152
  setGazetteerUrl(config.gazetteerUrl);
153
- const map = new Map(Object.assign({
154
- target: config.target || defaults.target,
155
- interactions: olDefaultInteractions({dragPan: false, altShiftDragRotate: false, pinchRotate: false}).extend([
156
- new DragPan({
157
- condition: function (event) {
158
- return (!event.originalEvent.pointerType || event.originalEvent.pointerType === "mouse") || (config.twoFingerPan && this.getPointerCount() === 2) || !config.twoFingerPan;
159
- }
160
- })
161
- ]),
162
- controls: [],
163
- view: createMapView(config)
164
- }, mapParams));
153
+ const selectedInteractions = config.mapInteractions?.interactionModes ? config.mapInteractions?.interactionModes : {dragPan: false, altShiftDragRotate: false, pinchRotate: false},
154
+ map = new Map(Object.assign({
155
+ target: config.target || defaults.target,
156
+ interactions: olDefaultInteractions(selectedInteractions).extend([
157
+ new DragPan({
158
+ condition: function (event) {
159
+ if (event.originalEvent.shiftKey) {
160
+ return false;
161
+ }
162
+ return (!event.originalEvent.pointerType || event.originalEvent.pointerType === "mouse") || (config.twoFingerPan && this.getPointerCount() === 2) || !config.twoFingerPan;
163
+ }
164
+ })
165
+ ]),
166
+ controls: [],
167
+ view: createMapView(config),
168
+ keyboardEventTarget: config.mapInteractions?.keyboardEventTarget ? config.mapInteractions?.keyboardEventTarget : false
169
+ }, mapParams));
165
170
 
166
171
  map.set("mapMode", "2D");
167
172
  map.set("id", `map2D_${mapIdCounter++}`);
@@ -32,7 +32,8 @@ function getSimpleGeometryStyle (geometryType, feature, rule, isClustered, wfsIm
32
32
  const style = rule?.style,
33
33
  legendValue = style ? style.legendValue : null,
34
34
  alreadyExisitingStyle = uniqueStyles.find(element => element.featureStyle === style && element.geometryType === geometryType);
35
- let styleObject;
35
+ let styleObject,
36
+ styleObjectForLegend = null;
36
37
 
37
38
  feature.legendValue = legendValue ? legendValue : null;
38
39
 
@@ -41,12 +42,21 @@ function getSimpleGeometryStyle (geometryType, feature, rule, isClustered, wfsIm
41
42
  }
42
43
  else if (geometryType === "Point") {
43
44
  styleObject = new PointStyle(feature, style, isClustered);
45
+ if (isClustered) {
46
+ styleObjectForLegend = new PointStyle(feature, style, false);
47
+ }
44
48
  }
45
49
  else if (geometryType === "LineString") {
46
50
  styleObject = new LineStringStyle(feature, style, isClustered);
51
+ if (isClustered) {
52
+ styleObjectForLegend = new LineStringStyle(feature, style, false);
53
+ }
47
54
  }
48
55
  else if (geometryType === "Polygon") {
49
56
  styleObject = new PolygonStyle(feature, style, isClustered);
57
+ if (isClustered) {
58
+ styleObjectForLegend = new PolygonStyle(feature, style, false);
59
+ }
50
60
  }
51
61
  else if (geometryType === "Cesium") {
52
62
  styleObject = new CesiumStyle(rule);
@@ -63,9 +73,14 @@ function getSimpleGeometryStyle (geometryType, feature, rule, isClustered, wfsIm
63
73
  console.warn("Geometry type not implemented: " + geometryType + " default style ist used for feature " + feature);
64
74
  return new Style();
65
75
  }
76
+
77
+ if (styleObjectForLegend !== null) {
78
+ styleObjectForLegend.initialize(feature, style, false, wfsImgPathFromConfig);
79
+ styleObjectForLegend.legendValue = legendValue;
80
+ }
66
81
  uniqueStyles.push({featureStyle: style, featureStyleObject: styleObject, geometryType});
67
82
  styleObject.initialize(feature, style, isClustered, wfsImgPathFromConfig);
68
- styleObject.addLegendInfo(geometryType, styleObject, rule);
83
+ styleObject.addLegendInfo(geometryType, styleObjectForLegend === null ? styleObject : styleObjectForLegend, rule);
69
84
  styleObject.legendValue = legendValue;
70
85
  return styleObject;
71
86
  }
@@ -18,7 +18,8 @@ let styleList,
18
18
  highlightFeaturesPolygonStyleId,
19
19
  highlightFeaturesLineStyleId,
20
20
  styleConf,
21
- featureViaUrlLayers;
21
+ featureViaUrlLayers,
22
+ zoomToFeatureId;
22
23
 
23
24
  /**
24
25
  * Gathers the styleIds of the layers.
@@ -196,9 +197,10 @@ function parseStyles (data) {
196
197
  getStyleIdForHighlightFeaturesPolygon(),
197
198
  getStyleIdForHighlightFeaturesLine(),
198
199
  getStyleIdsFromTools(),
199
- getFeatureViaURLStyles());
200
+ getFeatureViaURLStyles(),
201
+ zoomToFeatureId);
200
202
 
201
- styleIds = styleIds.reduce((acc, val) => acc.concat(val), []);
203
+ styleIds = styleIds.reduce((acc, val) => acc.concat(val), []).filter(item => item);
202
204
  filteredData = dataWithDefaultValue.filter(styleObject => styleIds.includes(styleObject.styleId));
203
205
 
204
206
  return filteredData;
@@ -223,6 +225,7 @@ function initializeStyleList (styleGetters, Config, layers, tools, callback) {
223
225
  highlightFeaturesPointStyleId = styleGetters.highlightFeaturesPointStyleId;
224
226
  highlightFeaturesPolygonStyleId = styleGetters.highlightFeaturesPolygonStyleId;
225
227
  highlightFeaturesLineStyleId = styleGetters.highlightFeaturesLineStyleId;
228
+ zoomToFeatureId = styleGetters.zoomToFeatureId;
226
229
 
227
230
  styleConf = Config.styleConf;
228
231
  featureViaUrlLayers = Config.featureViaURL?.layers;
@@ -46,6 +46,10 @@ class PointStyle extends StyleClass {
46
46
  * @returns {ol/style} - The created style.
47
47
  */
48
48
  getStyle () {
49
+ if (this.nullStyle) {
50
+ return null;
51
+ }
52
+
49
53
  const isClustered = this.isClustered;
50
54
  let type = this.attributes.type.toLowerCase();
51
55
 
@@ -220,11 +220,14 @@ export function createNominalPointStyle (attributes, feature, defaultImageName)
220
220
  if (styleScalingShape === "CIRCLESEGMENTS") {
221
221
  svgPath = createNominalCircleSegments(workingFeature, attributes);
222
222
  style = createSVGStyle(svgPath, 5);
223
+ style.type = "CIRCLESEGMENTS";
224
+ style.scalingAttribute = workingFeature.get(attributes.scalingAttribute);
223
225
  }
224
226
 
225
227
  // create style from svg and image
226
228
  if (imageName !== defaultImageName) {
227
229
  imageStyle = createIconStyle(attributes, feature);
230
+ imageStyle.type = "imageStyle";
228
231
  style = [style, imageStyle];
229
232
  }
230
233
 
@@ -36,6 +36,10 @@ class PolygonStyle extends StyleClass {
36
36
  * @returns {ol/style} - The created style.
37
37
  */
38
38
  getStyle () {
39
+ if (this.nullStyle) {
40
+ return null;
41
+ }
42
+
39
43
  const polygonFillColor = this.attributes.polygonFillColor,
40
44
  polygonFillHatch = this.attributes.polygonFillHatch;
41
45
 
@@ -14,6 +14,7 @@ class StyleClass {
14
14
  this.attributes = {};
15
15
  this.legendInfos = [];
16
16
  this.styleMultiGeomOnlyWithRule = false;
17
+ this.nullStyle = false;
17
18
  }
18
19
 
19
20
  /**
@@ -43,12 +44,16 @@ class StyleClass {
43
44
  // check if styles object is defined
44
45
  // if not, use defaults instead
45
46
  if (styles) {
47
+ this.nullStyle = false;
46
48
  Object.keys(styles).forEach(element => {
47
49
  const value = styles[element];
48
50
 
49
51
  this.attributes[element] = value;
50
52
  });
51
53
  }
54
+ else {
55
+ this.nullStyle = true;
56
+ }
52
57
  }
53
58
 
54
59
  /**
@@ -34,6 +34,10 @@ class LineStringStyle extends StyleClass {
34
34
  * @returns {ol/style/Style} - The created style.
35
35
  */
36
36
  getStyle () {
37
+ if (this.nullStyle) {
38
+ return null;
39
+ }
40
+
37
41
  return new Style({
38
42
  stroke: new Stroke({
39
43
  lineCap: this.attributes.lineStrokeCap,
@@ -36,6 +36,10 @@ class TextStyle extends StyleClass {
36
36
  * @returns {ol/style} - The created style.
37
37
  */
38
38
  getStyle () {
39
+ if (this.nullStyle) {
40
+ return null;
41
+ }
42
+
39
43
  const isClustered = this.isClustered,
40
44
  feature = this.feature,
41
45
  labelField = this.attributes.labelField;
@@ -242,23 +242,69 @@ describe("createStyle", () => {
242
242
  });
243
243
 
244
244
  describe("getSimpleGeometryStyle", function () {
245
- it("should return ol point style", function () {
246
- expect(createStyle.getSimpleGeometryStyle("Point", jsonObjects[0], rules[0], wfsImgPathFromConfig)).toBeInstanceOf(PointStyle);
247
- expect(typeof createStyle.getSimpleGeometryStyle("Point", jsonObjects[0], rules[0], wfsImgPathFromConfig).getStyle().getImage().getStroke().getColor()).toBe("object");
248
- expect(createStyle.getSimpleGeometryStyle("Point", jsonObjects[0], rules[0], wfsImgPathFromConfig).getStyle().getImage().getStroke().getColor()).toEqual([0, 0, 0, 1]);
245
+ let isClustered = false;
246
+
247
+ it("should return ol point style - not clustered", function () {
248
+ const styleObject = createStyle.getSimpleGeometryStyle("Point", jsonObjects[0], rules[0], isClustered, wfsImgPathFromConfig);
249
+
250
+ expect(styleObject).toBeInstanceOf(PointStyle);
251
+ expect(typeof styleObject.getStyle().getImage().getStroke().getColor()).toBe("object");
252
+ expect(styleObject.getStyle().getImage().getStroke().getColor()).toEqual([255, 0, 0, 1]);
253
+ expect(styleObject.getLegendInfos()[0].styleObject.circleStrokeColor).toEqual([255, 0, 0, 1]);
254
+ });
255
+ it("should return ol linestring style - not clustered", function () {
256
+ const styleObject = createStyle.getSimpleGeometryStyle("LineString", jsonObjects[1], rules[1], isClustered, wfsImgPathFromConfig);
257
+
258
+ expect(styleObject).toBeInstanceOf(LineStringStyle);
259
+ expect(typeof styleObject.getStyle().getStroke().getColor()).toBe("object");
260
+ expect(styleObject.getStyle().getStroke().getColor()).toEqual([255, 0, 0, 1]);
261
+ expect(styleObject.getLegendInfos()[0].styleObject.lineStrokeColor).toEqual([255, 0, 0, 1]);
262
+ });
263
+ it("should return ol polygon style - not clustered", function () {
264
+ const styleObject = createStyle.getSimpleGeometryStyle("Polygon", jsonObjects[2], rules[2], isClustered, wfsImgPathFromConfig);
265
+
266
+ expect(styleObject).toBeInstanceOf(PolygonStyle);
267
+ expect(typeof styleObject.getStyle().getStroke().getColor()).toBe("object");
268
+ expect(styleObject.getStyle().getStroke().getColor()).toEqual([255, 0, 0, 255]);
269
+ expect(styleObject.getStyle().getFill().getColor()).toEqual([10, 200, 100, 0.5]);
270
+ expect(styleObject.getLegendInfos()[0].styleObject.polygonStrokeColor).toEqual([255, 0, 0, 255]);
271
+ expect(styleObject.getLegendInfos()[0].styleObject.polygonFillColor).toEqual([10, 200, 100, 0.5]);
249
272
  });
250
- it("should return ol linestring style", function () {
251
- expect(createStyle.getSimpleGeometryStyle("LineString", jsonObjects[1], rules[1], wfsImgPathFromConfig)).toBeInstanceOf(LineStringStyle);
252
- expect(typeof createStyle.getSimpleGeometryStyle("LineString", jsonObjects[1], rules[1], wfsImgPathFromConfig).getStyle().getStroke().getColor()).toBe("object");
253
- expect(createStyle.getSimpleGeometryStyle("LineString", jsonObjects[1], rules[1], wfsImgPathFromConfig).getStyle().getStroke().getColor()).toEqual([255, 0, 0, 1]);
273
+ it("should return ol default style - not clustered", function () {
274
+ expect(createStyle.getSimpleGeometryStyle("not exist", jsonObjects[0], null, isClustered, wfsImgPathFromConfig)).toBeInstanceOf(Style);
254
275
  });
255
- it("should return ol polygon style", function () {
256
- expect(createStyle.getSimpleGeometryStyle("Polygon", jsonObjects[2], rules[2], wfsImgPathFromConfig)).toBeInstanceOf(PolygonStyle);
257
- expect(typeof createStyle.getSimpleGeometryStyle("Polygon", jsonObjects[2], rules[2], wfsImgPathFromConfig).getStyle().getStroke().getColor()).toBe("object");
258
- expect(createStyle.getSimpleGeometryStyle("Polygon", jsonObjects[2], rules[2], wfsImgPathFromConfig).getStyle().getStroke().getColor()).toEqual([255, 0, 0, 255]);
276
+
277
+ it("should return ol point style - clustered", function () {
278
+ isClustered = true;
279
+ const styleObject = createStyle.getSimpleGeometryStyle("Point", jsonObjects[0], rules[0], isClustered, wfsImgPathFromConfig);
280
+
281
+ expect(styleObject).toBeInstanceOf(PointStyle);
282
+ expect(typeof styleObject).toBe("object");
283
+ expect(styleObject.getStyle().getImage().getStroke().getColor()).toEqual([0, 0, 0, 1]);
284
+ expect(styleObject.getLegendInfos()[0].styleObject.circleStrokeColor).toEqual([255, 0, 0, 1]);
285
+ });
286
+ it("should return ol linestring style - clustered", function () {
287
+ isClustered = true;
288
+ const styleObject = createStyle.getSimpleGeometryStyle("LineString", jsonObjects[1], rules[1], isClustered, wfsImgPathFromConfig);
289
+
290
+ expect(styleObject).toBeInstanceOf(LineStringStyle);
291
+ expect(typeof styleObject.getStyle().getStroke().getColor()).toBe("object");
292
+ expect(styleObject.getStyle().getStroke().getColor()).toEqual([255, 0, 0, 1]);
293
+ expect(styleObject.getLegendInfos()[0].styleObject.lineStrokeColor).toEqual([255, 0, 0, 1]);
294
+ });
295
+ it("should return ol polygon style - clustered", function () {
296
+ isClustered = true;
297
+ const styleObject = createStyle.getSimpleGeometryStyle("Polygon", jsonObjects[2], rules[2], isClustered, wfsImgPathFromConfig);
298
+
299
+ expect(styleObject).toBeInstanceOf(PolygonStyle);
300
+ expect(typeof styleObject.getStyle().getStroke().getColor()).toBe("object");
301
+ expect(styleObject.getStyle().getStroke().getColor()).toEqual([255, 0, 0, 255]);
302
+ expect(styleObject.getLegendInfos()[0].styleObject.polygonStrokeColor).toEqual([255, 0, 0, 255]);
303
+ expect(styleObject.getLegendInfos()[0].styleObject.polygonFillColor).toEqual([10, 200, 100, 0.5]);
259
304
  });
260
- it("should return ol default style", function () {
261
- expect(createStyle.getSimpleGeometryStyle("not exist", jsonObjects[0], null, wfsImgPathFromConfig)).toBeInstanceOf(Style);
305
+ it("should return ol default style - clustered", function () {
306
+ isClustered = true;
307
+ expect(createStyle.getSimpleGeometryStyle("not exist", jsonObjects[0], null, isClustered, wfsImgPathFromConfig)).toBeInstanceOf(Style);
262
308
  });
263
309
  });
264
310
 
@@ -328,8 +374,7 @@ describe("getGeometryStyle", function () {
328
374
  expect(Array.isArray(createStyle.getGeometryStyle(jsonObjects[0], rules, wfsImgPathFromConfig).getStyle().getImage().getStroke().getColor())).toBe(true);
329
375
  expect(createStyle.getGeometryStyle(jsonObjects[0], rules, wfsImgPathFromConfig).getStyle().getImage().getStroke().getColor()).toEqual([0, 0, 0, 1]);
330
376
  });
331
- it("should return default style if no rule is found", function () {
332
- expect(Array.isArray(createStyle.getGeometryStyle(jsonObjects[0], [], wfsImgPathFromConfig).getStyle().getImage().getStroke().getColor())).toBe(true);
333
- expect(createStyle.getGeometryStyle(jsonObjects[0], [], wfsImgPathFromConfig).getStyle().getImage().getStroke().getColor()).toEqual([0, 0, 0, 1]);
377
+ it("should return null as style if no rule is found", function () {
378
+ expect(createStyle.getGeometryStyle(jsonObjects[0], [], wfsImgPathFromConfig).getStyle()).toBe(null);
334
379
  });
335
380
  });