@masterportal/masterportalapi 2.43.0 → 2.45.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
@@ -18,7 +18,34 @@
18
18
 
19
19
  ---
20
20
 
21
- ## 2.43.0 - 2024-01-17
21
+ ## 2.45.0 - 2025-01-28
22
+
23
+ ### Added
24
+ - vectorStyle:
25
+ - extended 3d example by tileset styling
26
+
27
+ ### Changed
28
+ - vectorStyle:
29
+ - renamed configured style type="Cesium" to type="cesium"
30
+
31
+ ### Fixed
32
+ - vectorStyle:
33
+ - fixed styling for type "cesium"
34
+
35
+ ---
36
+
37
+ ## 2.44.0 - 2025-01-22
38
+
39
+ ### Added
40
+ - Tileset.js: The tileset layer knows now the rawLayer transparency.
41
+
42
+ ### Fixed
43
+ - Transparency and visibility information in `addLayer` is now interpreted correctly again
44
+ - WMS-Layer: special loadFunction is used for every value attribute `isSecured` (behaviour equals <2.38.0)
45
+
46
+ ---
47
+
48
+ ## 2.43.0 - 2025-01-17
22
49
 
23
50
  ### Changed
24
51
  - The following packages have been updated:
@@ -32,6 +59,19 @@
32
59
 
33
60
  ---
34
61
 
62
+ ## 2.42.2 - 2024-12-05
63
+ ### Changed
64
+ - Revert Change, because of problems with Routing:
65
+ - The following packages have been updated:
66
+ - dependencies:
67
+ - ol: 9.2.4 to 10.2.1
68
+ - ol-mapbox-style: 12.2.1 to 12.3.5
69
+ - olcs: 2.20.0 to 2.22.1
70
+ - peerDependencies:
71
+ - cesium/engine: 9.2.0 to 12.0.1
72
+
73
+ ---
74
+
35
75
  ## 2.42.1 - 2024-11-28
36
76
 
37
77
  ### Fixed
@@ -62,6 +62,16 @@
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
+ }
65
75
  }
66
76
  ],
67
77
  "cesiumLib":"https://geoportal-hamburg.de/mastercode/cesium/latest/Cesium.js",
@@ -58,6 +58,7 @@
58
58
  "name": "Gebäude LoD2",
59
59
  "url": "https://daten-hamburg.de/gdi3d/datasource-data/LoD2",
60
60
  "typ": "TileSet3D",
61
+ "styleId": "3DTileSetStyle",
61
62
  "cesium3DTilesetOptions": {
62
63
  "maximumScreenSpaceError": 6
63
64
  }
package/example/index.js CHANGED
@@ -235,6 +235,23 @@ window.mpapi.search("Mümmelmannsberg 72", {
235
235
 
236
236
 
237
237
  // Add 3D functionality to the example:
238
+ // ---------------------------------------
239
+ // example style tileset by vectorstyling using style_v3.json
240
+ function getTilesetStyle (styleId) {
241
+ const styleObject = styleList.returnStyleObject(styleId);
242
+
243
+ if (styleObject !== undefined) {
244
+ const createdStyle = createStyle.createStyle(styleObject, undefined, false, config.wfsImgPath),
245
+ options = {
246
+ color: {
247
+ conditions: createdStyle
248
+ }
249
+ };
250
+
251
+ return new Cesium.Cesium3DTileStyle(options);
252
+ }
253
+ return undefined;
254
+ }
238
255
 
239
256
  // add a click-listener to button, that creates a 3D-map on click
240
257
  document.getElementById("enable").addEventListener("click", function () {
@@ -275,11 +292,14 @@ document.getElementById("enable").addEventListener("click", function () {
275
292
 
276
293
  window.mpapi.map = map3D;
277
294
  tilesetLayer = new mpapi.Tileset(rawLayerTileset, window.mpapi.map);
295
+ tilesetLayer.tileset?.then(tileset => {
296
+ tileset.style = getTilesetStyle(rawLayerTileset.styleId);
297
+ });
278
298
  tilesetLayer.setVisible(true, window.mpapi.map);
279
299
 
280
300
  // entities are 2 simple buildings in the park 'planten und blomen' near Tiergartenstraße
281
301
  mpapi.entities.createLayer(rawLayerEntities, window.mpapi.map);
282
- // mpapi.entities.setVisible(true, rawLayerEntities, window.mpapi.map);
302
+ mpapi.entities.setVisible(true, rawLayerEntities, window.mpapi.map);
283
303
 
284
304
  mpapi.terrain.createLayer(rawLayerTerrain, window.mpapi.map);
285
305
  mpapi.terrain.setVisible(true, rawLayerTerrain, window.mpapi.map);
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.43.0",
4
+ "version": "2.45.0",
5
5
  "license": "MIT",
6
6
  "description": "Basic functions of the Masterportal as api",
7
7
  "repository": {
@@ -33,7 +33,8 @@ export default function Tileset (rawLayer) {
33
33
  this.values = {
34
34
  name: rawLayer.name,
35
35
  id: rawLayer.id,
36
- typ: rawLayer.typ
36
+ typ: rawLayer.typ,
37
+ transparency: rawLayer.transparency
37
38
  };
38
39
  if (Cesium) {
39
40
  this.tileset = Promise.resolve(createTileSet(this, rawLayer));
package/src/layer/wms.js CHANGED
@@ -77,12 +77,13 @@ export function makeParams (rawLayer) {
77
77
  }
78
78
 
79
79
  /**
80
- * Return a ol tile or image load function for the rawLayer. Fetches with credentials: 'include'.
80
+ * Return a ol tile or image load function for the rawLayer.
81
+ * @param {object} rawLayer - layer specification as in services.json
81
82
  * @returns {function} tile/image load function
82
83
  */
83
- export function loadFunctionWithCredentials () {
84
+ export function defaultLoadFunction ({isSecured}) {
84
85
  return async (image, src) => {
85
- const response = await fetch(src, {credentials: "include"}),
86
+ const response = await fetch(src, {credentials: isSecured ? "include" : "omit"}),
86
87
  data = await response.blob();
87
88
 
88
89
  image.getImage().src = URL.createObjectURL(data);
@@ -99,7 +100,7 @@ export function loadFunctionWithCredentials () {
99
100
  * @param {string|number} [rawLayer.tilesize] - optional needed to create the tileGrid
100
101
  * @param {string|"anonymous"} [rawLayer.crossOrigin] - optional needed for CORS requests of image data, to enable canvas export
101
102
  * @param {string} [rawLayer.cqlFilter] - optional CQL filter to add to the request
102
- * @param {boolean} [rawLayer.isSecured] - if the layer is secured by BasicAuth, images are loaded with credentials: 'include'.
103
+ * @param {boolean} [rawLayer.isSecured] - whether the layer is secured by BasicAuth and should include or omit the credentials prompt
103
104
  * @param {object} options - optional resolutions and origin to create the TileGrid
104
105
  * @param {Array} [options.resolutions] - optional resolutions to create the TileGrid, must be in descending order
105
106
  * @param {Array} [options.origin] - optional origin to create the TileGrid
@@ -119,9 +120,7 @@ export function createLayerSource (rawLayer, options) {
119
120
  projection: projection,
120
121
  attributions: rawLayer.olAttribution,
121
122
  crossOrigin: rawLayer.crossOrigin,
122
- ...rawLayer.isSecured ? {
123
- imageLoadFunction: loadFunctionWithCredentials()
124
- } : {}
123
+ imageLoadFunction: defaultLoadFunction(rawLayer)
125
124
  });
126
125
  }
127
126
  if (options && options.resolutions) {
@@ -139,9 +138,7 @@ export function createLayerSource (rawLayer, options) {
139
138
  projection: projection,
140
139
  attributions: rawLayer.olAttribution,
141
140
  crossOrigin: rawLayer.crossOrigin,
142
- ...rawLayer.isSecured ? {
143
- tileLoadFunction: loadFunctionWithCredentials()
144
- } : {}
141
+ tileLoadFunction: defaultLoadFunction(rawLayer)
145
142
  });
146
143
  }
147
144
 
@@ -83,15 +83,20 @@ function injectErrorCallback (layer, errorCallback) {
83
83
  * @param {(string|ol/layer/Base)} layerOrId - if of layer to add to map
84
84
  * @param {object} [params] - optional parameter object
85
85
  * @param {boolean} [params.layerParams={}] - additional layerParams specified in portalConfig
86
- * @param {boolean} [params.visibility=true] - whether added layer is initially visible
87
- * @param {Number} [params.transparency=0] - how visible the layer is initially
86
+ * @param {boolean} [params.layerParams.visibility=true] - if params.visibility not given, this is used
87
+ * @param {Number} [params.layerParams.transparency=0] - if params.transparency not given, this is used
88
+ * @param {boolean} [params.visibility=params.layerParams.visibility] - whether added layer is initially visible
89
+ * @param {Number} [params.transparency=params.layerParams.transparency] - how visible the layer is initially
88
90
  * @param {Function} [params.errorCallback=console.error] - callback for layer source error events
89
91
  * @returns {?ol.Layer} added layer
90
92
  */
91
- function addLayer (layerOrId, params = {layerParams: {}, visibility: true, transparency: 0, errorCallback: console.error}) {
92
- const errorCallback = typeof params.errorCallback === "function"
93
- ? params.errorCallback
94
- : console.error;
93
+ function addLayer (layerOrId, params) {
94
+ const visibility = params?.visibility ?? params?.layerParams?.visibility ?? true,
95
+ transparency = params?.transparency ?? params?.layerParams?.transparency ?? 0,
96
+ layerParams = {...params?.layerParams || {}, visibility, transparency},
97
+ errorCallback = typeof params?.errorCallback === "function"
98
+ ? params?.errorCallback
99
+ : console.error;
95
100
  let layer, layerBuilder;
96
101
 
97
102
  // if parameter is id, create and add layer with masterportalAPI mechanisms
@@ -107,9 +112,9 @@ function addLayer (layerOrId, params = {layerParams: {}, visibility: true, trans
107
112
  console.error("Layer with id '" + layerOrId + "' has unknown type '" + rawLayer.typ + "'. No layer added to map.");
108
113
  return null;
109
114
  }
110
- layer = layerBuilder.createLayer(rawLayer, {layerParams: params.layerParams}, {map: this});
111
- layer.setVisible(typeof params.visibility === "boolean" ? params.visibility : true);
112
- layer.setOpacity(typeof params.transparency === "number" ? (100 - params.transparency) / 100 : 1);
115
+ layer = layerBuilder.createLayer(rawLayer, {layerParams}, {map: this});
116
+ layer.setVisible(typeof visibility === "boolean" ? visibility : true);
117
+ layer.setOpacity(typeof transparency === "number" ? (100 - transparency) / 100 : 1);
113
118
  injectErrorCallback(layer, errorCallback);
114
119
  originalAddLayer.call(this, layer);
115
120
  return layer;
@@ -16,7 +16,7 @@ let legendInformationLength = 0;
16
16
  * @returns {Boolean} is geometrytype a multiGeometry
17
17
  */
18
18
  function isMultiGeometry (geometryType) {
19
- return geometryType === "MultiPoint" || geometryType === "MultiLineString" || geometryType === "MultiPolygon" || geometryType === "GeometryCollection" || geometryType === "Cesium";
19
+ return geometryType === "MultiPoint" || geometryType === "MultiLineString" || geometryType === "MultiPolygon" || geometryType === "GeometryCollection" || geometryType === "cesium";
20
20
  }
21
21
 
22
22
  /**
@@ -34,7 +34,9 @@ function getSimpleGeometryStyle (geometryType, feature, rule, isClustered, wfsIm
34
34
  let styleObject,
35
35
  styleObjectForLegend = null;
36
36
 
37
- feature.legendValue = legendValue ? legendValue : null;
37
+ if (feature) {
38
+ feature.legendValue = legendValue ? legendValue : null;
39
+ }
38
40
 
39
41
  if (geometryType === "Point") {
40
42
  styleObject = new PointStyle(feature, style, isClustered);
@@ -54,10 +56,10 @@ function getSimpleGeometryStyle (geometryType, feature, rule, isClustered, wfsIm
54
56
  styleObjectForLegend = new PolygonStyle(feature, style, false);
55
57
  }
56
58
  }
57
- else if (geometryType === "Cesium") {
59
+ else if (geometryType === "cesium") {
58
60
  styleObject = new CesiumStyle(rule);
59
61
  styleObject.initialize(rule);
60
- styleObject.addLegendInfo("Cesium", styleObject, rule);
62
+ styleObject.addLegendInfo("cesium", styleObject, rule);
61
63
  styleObject.legendValue = legendValue;
62
64
  return styleObject;
63
65
  }
@@ -128,7 +130,7 @@ function getMultiGeometryStyle (geometryType, feature, rules, isClustered, wfsIm
128
130
  }
129
131
  });
130
132
  }
131
- else if (geometryType === "Cesium") {
133
+ else if (geometryType === "cesium") {
132
134
  rules.forEach(rule => {
133
135
  const simpleStyle = getSimpleGeometryStyle(geometryType, feature, rule, isClustered, wfsImgPathFromConfig);
134
136
 
@@ -153,7 +155,7 @@ function getMultiGeometryStyle (geometryType, feature, rules, isClustered, wfsIm
153
155
  * @returns {ol/style/Style} style is always returned
154
156
  */
155
157
  function getGeometryStyle (feature, rules, isClustered, wfsImgPathFromConfig) {
156
- const geometryType = feature ? feature.getGeometry().getType() : "Cesium";
158
+ const geometryType = feature ? feature.getGeometry().getType() : "cesium";
157
159
 
158
160
  // For simple geometries the first styling rule is used.
159
161
  // That algorithm implements an OR statement between multiple valid conditions giving precedence to its order in the style.json.
@@ -7,7 +7,7 @@ import {checkProperties} from "../lib/valueOperations";
7
7
  */
8
8
  export function getRulesForFeature (styleObject, feature) {
9
9
  styleObject.rules.forEach(rule => {
10
- if (typeof feature.get("rotation") !== "undefined") {
10
+ if (typeof feature?.get("rotation") !== "undefined") {
11
11
  rule.style.rotation = feature.get("rotation");
12
12
  }
13
13
  });
@@ -140,7 +140,7 @@ export function checkProperty (featureProperties, key, value) {
140
140
  * @returns {Boolean} true if all properties are satisfied
141
141
  */
142
142
  export function checkProperties (feature, rule) {
143
- if (rule?.conditions?.properties) {
143
+ if (rule?.conditions?.properties && feature) {
144
144
  const featureProperties = feature.getProperties(),
145
145
  properties = rule.conditions.properties;
146
146
  let key,
@@ -30,7 +30,7 @@ class CesiumStyle extends StyleClass {
30
30
  * @returns {ol/style} - The created style.
31
31
  */
32
32
  createStyle () {
33
- return this.createCondition(this.get("conditions"), this.get("style"));
33
+ return this.createCondition(this.attributes.conditions, this.style);
34
34
  }
35
35
 
36
36
  /**
@@ -40,7 +40,7 @@ class CesiumStyle extends StyleClass {
40
40
  * @returns {*} - Condition for cesium 3d tile style.
41
41
  */
42
42
  createCondition (conditions, style) {
43
- const {color} = style,
43
+ const color = style?.color || this.attributes.color,
44
44
  condition = [];
45
45
  let ruleCondition;
46
46
 
@@ -102,7 +102,7 @@ describe("wms.js", function () {
102
102
  });
103
103
  });
104
104
 
105
- describe("loadFunctionWithCredentials", function () {
105
+ describe("defaultLoadFunction", function () {
106
106
  beforeEach(() => {
107
107
  const blob = new Blob();
108
108
 
@@ -121,12 +121,19 @@ describe("wms.js", function () {
121
121
  });
122
122
 
123
123
  it("passes credentials if isSecured is set", async function () {
124
- const result = wms.loadFunctionWithCredentials(),
124
+ const result = wms.defaultLoadFunction({isSecured: true}),
125
125
  input = {src: ""};
126
126
 
127
127
  await result({getImage: () => input}, "SECURE_WMS");
128
128
  expect(input.src).toEqual("blob:BLOB");
129
129
  });
130
+ it("does not pass credentials if isSecured is not set", async function () {
131
+ const result = wms.defaultLoadFunction({isSecured: false}),
132
+ input = {src: ""};
133
+
134
+ await result({getImage: () => input}, "INSECURE_WMS");
135
+ expect(input.src).toEqual("blob:BLOB");
136
+ });
130
137
  });
131
138
 
132
139
  describe("createLayerSource", function () {
package/test/map.test.js CHANGED
@@ -122,9 +122,9 @@ describe("map.js", function () {
122
122
  it("sets visibility and transparency", function () {
123
123
  const result1 = Map.prototype.addLayer("works"),
124
124
  result2 = Map.prototype.addLayer("works", {}),
125
- result3 = Map.prototype.addLayer("works", {visibility: false}),
126
- result4 = Map.prototype.addLayer("works", {transparency: 50}),
127
- result5 = Map.prototype.addLayer("works", {visibility: false, transparency: 20});
125
+ result3 = Map.prototype.addLayer("works", {layerParams: {visibility: false}}),
126
+ result4 = Map.prototype.addLayer("works", {layerParams: {transparency: 50}}),
127
+ result5 = Map.prototype.addLayer("works", {layerParams: {visibility: false, transparency: 20}});
128
128
 
129
129
  expect(result1.getOpacity()).toBe(1);
130
130
  expect(result1.getVisible()).toBe(true);
@@ -1,6 +1,7 @@
1
1
  import createStyle from "../../src/vectorStyle/createStyle";
2
2
  import PointStyle from "../../src/vectorStyle/styles/point/stylePoint";
3
3
  import LineStringStyle from "../../src/vectorStyle/styles/styleLine";
4
+ import CesiumStyle from "../../src/vectorStyle/styles/styleCesium";
4
5
  import PolygonStyle from "../../src/vectorStyle/styles/polygon/stylePolygon";
5
6
  import {Style, Stroke, Fill} from "ol/style.js";
6
7
  import {GeoJSON} from "ol/format.js";
@@ -9,6 +10,7 @@ let rules,
9
10
  jsonObjects,
10
11
  multiLineStringRules,
11
12
  multiPolygonRules,
13
+ cesiumRules,
12
14
  isClustered;
13
15
 
14
16
  const wfsImgPathFromConfig = "/path/to/wfs/images",
@@ -238,6 +240,12 @@ beforeEach(() => {
238
240
  polygonStrokeColor: [255, 0, 0, 1]
239
241
  }
240
242
  }];
243
+ cesiumRules = [{
244
+ style: {
245
+ type: "cesium",
246
+ color: "rgba(50, 154, 26, 0.8)"
247
+ }
248
+ }];
241
249
  });
242
250
 
243
251
  describe("createStyle", () => {
@@ -442,6 +450,13 @@ describe("getSimpleGeometryStyle", function () {
442
450
  isClustered = true;
443
451
  expect(createStyle.getSimpleGeometryStyle("not exist", jsonObjects[0], null, isClustered, wfsImgPathFromConfig)).toBeInstanceOf(Style);
444
452
  });
453
+ it("should create Cesium style", function () {
454
+ isClustered = true;
455
+ const tilesetStyle = createStyle.getSimpleGeometryStyle("cesium", undefined, cesiumRules[0], false, wfsImgPathFromConfig);
456
+
457
+ expect(tilesetStyle).toBeInstanceOf(CesiumStyle);
458
+ expect(tilesetStyle.attributes.color).toEqual(cesiumRules[0].style.color);
459
+ });
445
460
  });
446
461
 
447
462
  describe("getMultiGeometryStyle", function () {
@@ -128,5 +128,9 @@ describe("getRuleForIndex", function () {
128
128
  expect(Array.isArray(getRulesForFeature(styleObject, jsonObjects[1]))).toBe(true);
129
129
  expect(getRulesForFeature(styleObject, jsonObjects[1]).length).toEqual(1);
130
130
  });
131
+ it("should not fail if feature is undefined - is the case for type=Cesium", function () {
132
+ expect(Array.isArray(getRulesForFeature(styleObject, undefined))).toBe(true);
133
+ expect(getRulesForFeature(styleObject, jsonObjects[1]).length).toEqual(1);
134
+ });
131
135
  });
132
136
  });
@@ -185,7 +185,7 @@ describe("checkProperties", function () {
185
185
  it("should return true for rule that has no properties", function () {
186
186
  expect(checkProperties(jsonObjects[0], rules[2])).toBe(true);
187
187
  });
188
- it("should return false for rule that has not fitting properties", function () {
189
- expect(checkProperties(jsonObjects[1], rules[1])).toBe(false);
188
+ it("should do nothing if feature is undefined", function () {
189
+ expect(checkProperties(undefined, rules[1])).toBe(true);
190
190
  });
191
191
  });
@@ -0,0 +1,120 @@
1
+ import CesiumStyle from "../../../src/vectorStyle/styles/styleCesium";
2
+ import StyleClass from "../../../src/vectorStyle/styles/style";
3
+
4
+ describe("styleCesium", () => {
5
+ const expectedStyle = ["((${attributes.Dachform} === 'Flachdach'))", "rgba(50, 154, 26, 0.8)"];
6
+ let rule,
7
+ styleCesiumClass;
8
+
9
+ beforeEach(() => {
10
+ rule = {
11
+ conditions: {
12
+ "attributes.Dachform": "Flachdach"
13
+ },
14
+ style: {
15
+ type: "cesium",
16
+ color: "rgba(50, 154, 26, 0.8)"
17
+ }
18
+ };
19
+
20
+ });
21
+
22
+ describe("initialize", function () {
23
+ it("shall call 3 functions for initialization", () => {
24
+ const setConditionsSpy = jest.spyOn(CesiumStyle.prototype, "setConditions"),
25
+ overwriteStylingSpy = jest.spyOn(StyleClass.prototype, "overwriteStyling"),
26
+ setStyleSpy = jest.spyOn(StyleClass.prototype, "setStyle");
27
+
28
+ styleCesiumClass = new CesiumStyle();
29
+ styleCesiumClass.initialize(rule);
30
+ expect(setConditionsSpy).toHaveBeenCalledTimes(1);
31
+ expect(overwriteStylingSpy).toHaveBeenCalledTimes(1);
32
+ expect(setStyleSpy).toHaveBeenCalledTimes(1);
33
+ });
34
+ });
35
+
36
+
37
+ describe("createStyle", function () {
38
+ it("shall call createCondition and create expected style", () => {
39
+ const createConditionSpy = jest.spyOn(CesiumStyle.prototype, "createCondition"),
40
+ createdStyle = styleCesiumClass.createStyle();
41
+
42
+ styleCesiumClass = new CesiumStyle();
43
+ expect(createConditionSpy).toHaveBeenCalledTimes(1);
44
+ expect(createConditionSpy).toHaveBeenCalledWith(rule.conditions, expectedStyle);
45
+ expect(createdStyle).toEqual(expectedStyle);
46
+ });
47
+ });
48
+
49
+ describe("createCondition", function () {
50
+ it("createCondition with conditions and no style", () => {
51
+ let condition = null;
52
+
53
+ styleCesiumClass = new CesiumStyle();
54
+ styleCesiumClass.initialize(rule);
55
+ condition = styleCesiumClass.createCondition(rule.conditions);
56
+
57
+ expect(condition).toEqual(expectedStyle);
58
+ });
59
+
60
+ it("createCondition with no conditions and no style", () => {
61
+ let condition = null;
62
+
63
+ styleCesiumClass = new CesiumStyle();
64
+ delete rule.conditions;
65
+ styleCesiumClass.initialize(rule);
66
+ condition = styleCesiumClass.createCondition(undefined);
67
+
68
+ expect(condition).toEqual(["true", "rgba(50, 154, 26, 0.8)"]);
69
+ });
70
+
71
+
72
+ it("createCondition no conditions but with style", () => {
73
+ let condition = null;
74
+ const style = {
75
+ color: "rgba(150, 154, 26, 0.8)"
76
+ };
77
+
78
+ styleCesiumClass = new CesiumStyle();
79
+ delete rule.conditions;
80
+ styleCesiumClass.initialize(rule);
81
+ condition = styleCesiumClass.createCondition(undefined, style);
82
+
83
+ expect(condition).toEqual(["true", "rgba(150, 154, 26, 0.8)"]);
84
+ });
85
+ });
86
+
87
+ describe("createCesiumConditionForRule", function () {
88
+ it("createCesiumConditionForRule with an equals condition", () => {
89
+ let condition = null;
90
+
91
+ styleCesiumClass = new CesiumStyle();
92
+ styleCesiumClass.initialize(rule);
93
+ condition = styleCesiumClass.createCesiumConditionForRule([["attributes.Dachform", "Flachdach"]]);
94
+
95
+ expect(condition).toEqual("((${attributes.Dachform} === 'Flachdach'))");
96
+ });
97
+
98
+ it("createCesiumConditionForRule with 2 equals conditions", () => {
99
+ let condition = null;
100
+
101
+ styleCesiumClass = new CesiumStyle();
102
+ styleCesiumClass.initialize(rule);
103
+ condition = styleCesiumClass.createCesiumConditionForRule([["attributes.Dachform", "Flachdach"], ["foo", "bar"]]);
104
+
105
+ expect(condition).toEqual("((${attributes.Dachform} === 'Flachdach') && (${foo} === 'bar'))");
106
+ });
107
+
108
+ it("createCesiumConditionForRule with a >, <= condition", () => {
109
+ let condition = null;
110
+
111
+ styleCesiumClass = new CesiumStyle();
112
+ styleCesiumClass.initialize(rule);
113
+ condition = styleCesiumClass.createCesiumConditionForRule([["attributes.height", [10, 20]]]);
114
+
115
+ expect(condition).toEqual("((${attributes.height} > 10 && ${attributes.height} <= 20))");
116
+ });
117
+
118
+
119
+ });
120
+ });