@masterportal/masterportalapi 2.15.0 → 2.15.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,6 +3,34 @@
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
17
+ ---
18
+
19
+ ## 2.15.2 - 2023-03-14
20
+ ###
21
+ Changed
22
+ - Update parameters for getGeometryTypeFromService.getGeometryTypeFromWFS and getGeometryTypeFromService.getGeometryTypeFromOAF to pass wfsImgPath.
23
+ ### Fixed
24
+ - Fix imports in createLegendInfo.js
25
+ ---
26
+
27
+ ## 2.15.1 - 2023-03-09
28
+ ### Fixed
29
+ - The `labelField` attribute is now evaluated correctly for a text style.
30
+ - The styling for clustered features works now.
31
+
32
+ ---
33
+
6
34
  ## 2.15.0 - 2023-02-28
7
35
  ### Added
8
36
  - WebGL Render-Pipeline for all VectorLayer types can be called using {"renderer": "webgl"} in config.json
package/package.json CHANGED
@@ -1,64 +1,63 @@
1
- {
2
- "name": "@masterportal/masterportalapi",
3
- "author": "Implementierungspartnerschaft Masterportal <info@masterportal.org> (https://www.masterportal.org)",
4
- "version": "2.15.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.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
- "doc": "docs",
58
- "example": "example",
59
- "test": "test"
60
- },
61
- "bugs": {
62
- "url": "https://bitbucket.org/geowerkstatt-hamburg/masterportalapi/issues"
63
- }
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,28 +1,29 @@
1
- import {getSimpleGeometryStyle, getMultiGeometryStyle} from "../createStyle";
1
+ import createStyle from "../createStyle";
2
2
  /**
3
3
  * Creates the style objects for the layer
4
4
  * @param {object[]} rules styling rules from the styleObject
5
5
  * @param {string[]} geometryType Array of geometry types
6
+ * @param {String} wfsImgPath path to wfsImg from Config
6
7
  * @returns {void}
7
8
  */
8
- export function createLegendInfo (rules, geometryType) {
9
+ export function createLegendInfo (rules, geometryType, wfsImgPath) {
9
10
  let styleObject,
10
11
  simpleGeom;
11
12
 
12
13
  geometryType.forEach(geom => rules.forEach(rule => {
13
14
  if (geom === "MultiSurface") {
14
15
  simpleGeom = "Polygon";
15
- styleObject = getSimpleGeometryStyle(simpleGeom, "", rule, false);
16
+ styleObject = createStyle.getSimpleGeometryStyle(simpleGeom, "", rule, false, wfsImgPath);
16
17
  return styleObject;
17
18
  }
18
19
  else if (geom.includes("Multi")) {
19
20
  simpleGeom = geom.replace("Multi", "");
20
- styleObject = getMultiGeometryStyle(simpleGeom, "", rule, false);
21
+ styleObject = createStyle.getMultiGeometryStyle(simpleGeom, "", rule, false, wfsImgPath);
21
22
  return styleObject;
22
23
  }
23
24
 
24
25
  simpleGeom = geom;
25
- styleObject = getSimpleGeometryStyle(simpleGeom, "", rule, false);
26
+ styleObject = createStyle.getSimpleGeometryStyle(simpleGeom, "", rule, false, wfsImgPath);
26
27
  return styleObject;
27
28
  }));
28
29
  }
@@ -86,11 +86,12 @@ function getTypeAttributesFromSubelements (subElements = [], styleGeometryType =
86
86
  * @param {string} featureType wfs feature type from layer
87
87
  * @param {string[] | string} styleGeometryType The configured geometry type of the layer
88
88
  * @param {boolean} isSecured true if wfs is secured
89
+ * @param {String} wfsImgPath path to wfsImg from Config
89
90
  * @param {function} [callback] - called with services after loaded; called with false and error on error
90
91
  * @returns {void}
91
92
  */
92
93
  // eslint-disable-next-line max-params
93
- function getGeometryTypeFromWFS (rules, wfsURL, version, featureType, styleGeometryType, isSecured, callback) {
94
+ function getGeometryTypeFromWFS (rules, wfsURL, version, featureType, styleGeometryType, isSecured, wfsImgPath, callback) {
94
95
  const params = {
95
96
  "SERVICE": "WFS",
96
97
  "VERSION": version,
@@ -114,7 +115,7 @@ function getGeometryTypeFromWFS (rules, wfsURL, version, featureType, styleGeome
114
115
  const subElements = getSubelementsFromXML(responseXML, featureType),
115
116
  geometryTypes = getTypeAttributesFromSubelements(subElements, styleGeometryType);
116
117
 
117
- createLegendInfo(rules, geometryTypes);
118
+ createLegendInfo(rules, geometryTypes, wfsImgPath);
118
119
  }).catch(error => {
119
120
  return callback(error);
120
121
  });
@@ -125,10 +126,11 @@ function getGeometryTypeFromWFS (rules, wfsURL, version, featureType, styleGeome
125
126
  * @param {object[]} rules styling rules from the styleObject
126
127
  * @param {string} oafURL url from layer
127
128
  * @param {String} collection the collection name to fetch geometry type for
129
+ * @param {String} wfsImgPath path to wfsImg from Config
128
130
  * @param {function} [callback] - called with services after loaded; called with false and error on error
129
131
  * @returns {void}
130
132
  */
131
- function getGeometryTypeFromOAF (rules, oafURL, collection, callback) {
133
+ function getGeometryTypeFromOAF (rules, oafURL, collection, wfsImgPath, callback) {
132
134
  const url = oafURL + "/collections/" + collection + "/items?limit=1";
133
135
 
134
136
  fetch(url, {
@@ -140,7 +142,7 @@ function getGeometryTypeFromOAF (rules, oafURL, collection, callback) {
140
142
  const geometryType = response.data?.features[0]?.geometry?.type;
141
143
 
142
144
  if (geometryType) {
143
- createLegendInfo(rules, [geometryType]);
145
+ createLegendInfo(rules, [geometryType], wfsImgPath);
144
146
  }
145
147
  }).catch(error => {
146
148
  return callback(error);
@@ -46,8 +46,12 @@ class PointStyle extends StyleClass {
46
46
  * @returns {ol/style} - The created style.
47
47
  */
48
48
  getStyle () {
49
- const type = this.attributes.type.toLowerCase(),
50
- isClustered = this.isClustered;
49
+ const isClustered = this.isClustered;
50
+ let type = this.attributes.type.toLowerCase();
51
+
52
+ if (isClustered && this.feature.get("features")?.length > 1) {
53
+ type = this.attributes.clusterType.toLowerCase();
54
+ }
51
55
 
52
56
  if (type === "icon") {
53
57
  return createIconStyle(this.attributes, this.feature, isClustered);
@@ -52,7 +52,7 @@ export function createIconStyle (attributes, feature, isClustered) {
52
52
  if (!showCluster) {
53
53
  iconOptions.anchorXUnits = attributes.imageOffsetXUnit;
54
54
  iconOptions.anchorYUnits = attributes.imageOffsetYUnit;
55
- iconOptions.rotation = getRotationValue(attributes.rotation, feature.getProperties());
55
+ iconOptions.rotation = feature ? getRotationValue(attributes.rotation, feature.getProperties()) : 0;
56
56
  }
57
57
 
58
58
  return new Style({
@@ -38,7 +38,7 @@ class TextStyle extends StyleClass {
38
38
  getStyle () {
39
39
  const isClustered = this.isClustered,
40
40
  feature = this.feature,
41
- labelField = this.labelField;
41
+ labelField = this.attributes.labelField;
42
42
 
43
43
  if (isClustered && feature.get("features")?.length > 1 && this.attributes.clusterTextType !== "none") {
44
44
  return this.createClusteredTextStyle();
@@ -1,19 +1,26 @@
1
1
  import PointStyle from "../../../../src/vectorStyle/styles/point/stylePoint";
2
- import {Style} from "ol/style.js";
2
+ import {Circle as CircleStyle, Style} from "ol/style.js";
3
3
 
4
4
  describe("stylePoint", () => {
5
- const feature = {
5
+ let feature,
6
+ isClustered,
7
+ style,
8
+ stylePointClass;
9
+
10
+ beforeEach(() => {
11
+ feature = {
6
12
  geometryName: "geom",
7
13
  id: "DE.HH.UP_GESUNDHEIT_KRANKENHAEUSER_2"
8
- },
14
+ };
9
15
  style = {
10
16
  type: "icon",
11
17
  clusterType: "icon",
12
18
  legendValue: "Krankenhaus",
13
19
  imageName: "krankenhaus.png"
14
- },
15
- isClustered = false,
20
+ };
21
+ isClustered = false;
16
22
  stylePointClass = new PointStyle(feature, style, isClustered);
23
+ });
17
24
 
18
25
  describe("setSize", function () {
19
26
  it("defines setSize()", () => {
@@ -24,5 +31,18 @@ describe("stylePoint", () => {
24
31
  it("returns an instance of openlayers style", () => {
25
32
  expect(stylePointClass.getStyle()).toBeInstanceOf(Style);
26
33
  });
34
+ it("returns an instance of openlayers circleStyle", () => {
35
+ isClustered = true;
36
+ style = {
37
+ type: "icon",
38
+ clusterType: "circle",
39
+ legendValue: "Krankenhaus",
40
+ imageName: "krankenhaus.png"
41
+ };
42
+
43
+ expect(stylePointClass.getStyle()).toBeInstanceOf(Style);
44
+ expect(stylePointClass.getStyle().getImage()).toBeInstanceOf(CircleStyle);
45
+ });
27
46
  });
47
+
28
48
  });
@@ -16,7 +16,8 @@ describe("styleText", () => {
16
16
  type: "icon",
17
17
  clusterType: "icon",
18
18
  legendValue: "Krankenhaus",
19
- imageName: "krankenhaus.png"
19
+ imageName: "krankenhaus.png",
20
+ labelField: ""
20
21
  },
21
22
  isClustered = false,
22
23
  styleTextClass = new TextStyle(feature, style, isClustered);