@masterportal/masterportalapi 2.22.0 → 2.23.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 +7 -9
- package/package.json +65 -65
- package/src/index.js +0 -2
- package/src/maps/interactions/modifyInteraction.js +18 -0
- package/src/maps/interactions/selectInteraction.js +35 -0
- package/src/vectorStyle/lib/createLegendInfo.js +16 -8
- package/src/vectorStyle/lib/getGeometryTypeFromService.js +10 -8
- package/test/maps/interactions/{drawInteractions.test.js → drawInteraction.test.js} +2 -2
- package/test/maps/interactions/modifyInteraction.test.js +18 -0
- package/test/maps/interactions/selectInteraction.test.js +31 -0
- /package/src/maps/interactions/{drawInteractions.js → drawInteraction.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,19 +3,17 @@
|
|
|
3
3
|
|
|
4
4
|
The [Semantic Versioning](https://semver.org/spec/v2.0.0.html) is used.
|
|
5
5
|
|
|
6
|
-
##
|
|
6
|
+
## 2.23.0 - 2023-08-02
|
|
7
7
|
### Added
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
### Deprecated
|
|
12
|
-
|
|
13
|
-
### Removed
|
|
8
|
+
- VectorStyle: Add Styling rules for Geoemtries of type `Circle`.
|
|
9
|
+
- Add Styling and zIndex to draw interactions and improve the draw behavior.
|
|
10
|
+
- Add select and modify interactions for editing ol features.
|
|
14
11
|
|
|
15
12
|
### Fixed
|
|
16
|
-
|
|
13
|
+
- The legend for wfs is now created again via the Describefeaturetype.
|
|
17
14
|
|
|
18
15
|
---
|
|
16
|
+
|
|
19
17
|
## 2.22.0 - 2023-07-25
|
|
20
18
|
### Added
|
|
21
19
|
- VectorStyle: Add Styling rules for Geoemtries of type `Circle`.
|
|
@@ -23,7 +21,7 @@
|
|
|
23
21
|
|
|
24
22
|
### Changed
|
|
25
23
|
- Changed peerDependency from cesium 1.106.0 to @cesium/engine 2.4.1.
|
|
26
|
-
- WFS:
|
|
24
|
+
- WFS:
|
|
27
25
|
- Migrated writeTransaction and sendTransaction from masterportal the masterportalAPI.
|
|
28
26
|
- Exports in src/layer/wfs.js changed to export default {} to provide ES-Syntax.
|
|
29
27
|
### Deprecated
|
package/package.json
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@masterportal/masterportalapi",
|
|
3
|
-
"author": "Implementierungspartnerschaft Masterportal <info@masterportal.org> (https://www.masterportal.org)",
|
|
4
|
-
"version": "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.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.30.2",
|
|
23
|
-
"dayjs": "^1.11.7",
|
|
24
|
-
"ol": "7.4.0",
|
|
25
|
-
"olcs": "^2.14.0",
|
|
26
|
-
"proj4": "^2.9.0",
|
|
27
|
-
"xml2js": "^0.5.0"
|
|
28
|
-
},
|
|
29
|
-
"devDependencies": {
|
|
30
|
-
"@babel/core": "^7.21.8",
|
|
31
|
-
"@babel/plugin-transform-modules-commonjs": "^7.21.5",
|
|
32
|
-
"@parcel/transformer-sass": "^2.8.3",
|
|
33
|
-
"buffer": "^5.7.1",
|
|
34
|
-
"canvas": "^2.11.2",
|
|
35
|
-
"eslint": "^8.40.0",
|
|
36
|
-
"events": "^3.3.0",
|
|
37
|
-
"husky": "^8.0.3",
|
|
38
|
-
"jest": "^29.5.0",
|
|
39
|
-
"jest-canvas-mock": "^2.5.0",
|
|
40
|
-
"jest-environment-jsdom": "^29.5.0",
|
|
41
|
-
"jest-fetch-mock": "^3.0.3",
|
|
42
|
-
"jsdoc": "^4.0.2",
|
|
43
|
-
"parcel": "^2.8.3",
|
|
44
|
-
"process": "^0.11.10",
|
|
45
|
-
"sass": "^1.62.1",
|
|
46
|
-
"stream-browserify": "^3.0.0",
|
|
47
|
-
"timers-browserify": "^2.0.12",
|
|
48
|
-
"use-resize-observer": "^9.1.0"
|
|
49
|
-
},
|
|
50
|
-
"peerDependencies": {
|
|
51
|
-
"@cesium/engine": "^2.4.1"
|
|
52
|
-
},
|
|
53
|
-
"engines": {
|
|
54
|
-
"node": "^16.13.2 || ^18.12.0",
|
|
55
|
-
"npm": "^8.1.2 || ^9.3.1"
|
|
56
|
-
},
|
|
57
|
-
"homepage": "https://bitbucket.org/geowerkstatt-hamburg/masterportalapi#readme",
|
|
58
|
-
"directories": {
|
|
59
|
-
"example": "example",
|
|
60
|
-
"test": "test"
|
|
61
|
-
},
|
|
62
|
-
"bugs": {
|
|
63
|
-
"url": "https://bitbucket.org/geowerkstatt-hamburg/masterportalapi/issues"
|
|
64
|
-
}
|
|
65
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@masterportal/masterportalapi",
|
|
3
|
+
"author": "Implementierungspartnerschaft Masterportal <info@masterportal.org> (https://www.masterportal.org)",
|
|
4
|
+
"version": "2.23.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.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.30.2",
|
|
23
|
+
"dayjs": "^1.11.7",
|
|
24
|
+
"ol": "7.4.0",
|
|
25
|
+
"olcs": "^2.14.0",
|
|
26
|
+
"proj4": "^2.9.0",
|
|
27
|
+
"xml2js": "^0.5.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@babel/core": "^7.21.8",
|
|
31
|
+
"@babel/plugin-transform-modules-commonjs": "^7.21.5",
|
|
32
|
+
"@parcel/transformer-sass": "^2.8.3",
|
|
33
|
+
"buffer": "^5.7.1",
|
|
34
|
+
"canvas": "^2.11.2",
|
|
35
|
+
"eslint": "^8.40.0",
|
|
36
|
+
"events": "^3.3.0",
|
|
37
|
+
"husky": "^8.0.3",
|
|
38
|
+
"jest": "^29.5.0",
|
|
39
|
+
"jest-canvas-mock": "^2.5.0",
|
|
40
|
+
"jest-environment-jsdom": "^29.5.0",
|
|
41
|
+
"jest-fetch-mock": "^3.0.3",
|
|
42
|
+
"jsdoc": "^4.0.2",
|
|
43
|
+
"parcel": "^2.8.3",
|
|
44
|
+
"process": "^0.11.10",
|
|
45
|
+
"sass": "^1.62.1",
|
|
46
|
+
"stream-browserify": "^3.0.0",
|
|
47
|
+
"timers-browserify": "^2.0.12",
|
|
48
|
+
"use-resize-observer": "^9.1.0"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"@cesium/engine": "^2.4.1"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": "^16.13.2 || ^18.12.0",
|
|
55
|
+
"npm": "^8.1.2 || ^9.3.1"
|
|
56
|
+
},
|
|
57
|
+
"homepage": "https://bitbucket.org/geowerkstatt-hamburg/masterportalapi#readme",
|
|
58
|
+
"directories": {
|
|
59
|
+
"example": "example",
|
|
60
|
+
"test": "test"
|
|
61
|
+
},
|
|
62
|
+
"bugs": {
|
|
63
|
+
"url": "https://bitbucket.org/geowerkstatt-hamburg/masterportalapi/issues"
|
|
64
|
+
}
|
|
65
|
+
}
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {createMapView} from "./maps/mapView";
|
|
2
2
|
import crs from "./crs";
|
|
3
|
-
import drawInteractions from "./maps/interactions/drawInteractions";
|
|
4
3
|
import rawLayerList from "./rawLayerList";
|
|
5
4
|
import * as wms from "./layer/wms";
|
|
6
5
|
import wmts from "./layer/wmts";
|
|
@@ -37,6 +36,5 @@ export {
|
|
|
37
36
|
ping,
|
|
38
37
|
search,
|
|
39
38
|
crs,
|
|
40
|
-
drawInteractions,
|
|
41
39
|
webgl
|
|
42
40
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {Modify} from "ol/interaction.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Create the modify interaction.
|
|
5
|
+
* @param {ol/source} source The vector layer source containing the features to be modified.
|
|
6
|
+
* @returns {ol/interaction/Modify} The modify interaction.
|
|
7
|
+
*/
|
|
8
|
+
function createModifyInteraction (source) {
|
|
9
|
+
const modifyInteraction = new Modify({
|
|
10
|
+
source: source
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
return modifyInteraction;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
createModifyInteraction
|
|
18
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {Select} from "ol/interaction.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Remove the selected feature.
|
|
5
|
+
* @param {ol/interaction/Select} selectInteraction The select interaction.
|
|
6
|
+
* @param {ol/source} source The vector layer source containing the features to be selected.
|
|
7
|
+
* @returns {void}
|
|
8
|
+
*/
|
|
9
|
+
function removeSelectedFeature (selectInteraction, source) {
|
|
10
|
+
selectInteraction.on("select", event => {
|
|
11
|
+
source.removeFeature(event.selected[0]);
|
|
12
|
+
event.target.getFeatures().clear();
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Create the select interaction.
|
|
18
|
+
* @param {ol/layer|ol/layer[]} layers The vector layers for select features.
|
|
19
|
+
* @param {ol/events/condition} [condition] The ol condition. Default from ol is "singleClick".
|
|
20
|
+
* @returns {ol/interaction/Select} The select interaction.
|
|
21
|
+
*/
|
|
22
|
+
function createSelectInteraction (layers, condition) {
|
|
23
|
+
const selectInteraction = new Select({
|
|
24
|
+
condition: condition,
|
|
25
|
+
layers: Array.isArray(layers) ? layers : [layers],
|
|
26
|
+
hitTolerance: 10
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return selectInteraction;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default {
|
|
33
|
+
createSelectInteraction,
|
|
34
|
+
removeSelectedFeature
|
|
35
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import createStyle from "../createStyle";
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* Creates the style objects for the layer
|
|
4
5
|
* @param {object[]} rules styling rules from the styleObject
|
|
@@ -8,22 +9,29 @@ import createStyle from "../createStyle";
|
|
|
8
9
|
*/
|
|
9
10
|
export function createLegendInfo (rules, geometryType, wfsImgPath) {
|
|
10
11
|
let styleObject,
|
|
11
|
-
simpleGeom
|
|
12
|
+
simpleGeom,
|
|
13
|
+
legendInfos = [];
|
|
12
14
|
|
|
13
15
|
geometryType.forEach(geom => rules.forEach(rule => {
|
|
14
16
|
if (geom === "MultiSurface") {
|
|
15
17
|
simpleGeom = "Polygon";
|
|
16
18
|
styleObject = createStyle.getSimpleGeometryStyle(simpleGeom, "", rule, false, wfsImgPath);
|
|
17
|
-
|
|
19
|
+
legendInfos = legendInfos.concat(styleObject.legendInfos);
|
|
18
20
|
}
|
|
19
21
|
else if (geom.includes("Multi")) {
|
|
20
22
|
simpleGeom = geom.replace("Multi", "");
|
|
21
23
|
styleObject = createStyle.getMultiGeometryStyle(simpleGeom, "", rule, false, wfsImgPath);
|
|
22
|
-
return styleObject;
|
|
23
|
-
}
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
styleObject.forEach(singleStyleObject => {
|
|
26
|
+
legendInfos = legendInfos.concat(singleStyleObject.legendInfos);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
simpleGeom = geom;
|
|
31
|
+
styleObject = createStyle.getSimpleGeometryStyle(simpleGeom, "", rule, false, wfsImgPath);
|
|
32
|
+
legendInfos = legendInfos.concat(styleObject.legendInfos);
|
|
33
|
+
}
|
|
28
34
|
}));
|
|
29
|
-
|
|
35
|
+
|
|
36
|
+
return legendInfos;
|
|
37
|
+
}
|
|
@@ -7,15 +7,15 @@ import {createLegendInfo} from "./createLegendInfo";
|
|
|
7
7
|
* @returns {object[]} subElements of the xml element
|
|
8
8
|
*/
|
|
9
9
|
function getSubelementsFromXMLOtherStructure (xml, featureType) {
|
|
10
|
-
const elements = xml ? Array.from(xml.
|
|
10
|
+
const elements = xml ? Array.from(xml.getElementsByTagNameNS("*", "element")) : [];
|
|
11
11
|
let subElements = [];
|
|
12
12
|
|
|
13
13
|
elements.forEach(element => {
|
|
14
14
|
if (element.getAttribute("name") === featureType) {
|
|
15
15
|
const sibling = element.nextElementSibling;
|
|
16
16
|
|
|
17
|
-
if (sibling && sibling.tagName
|
|
18
|
-
subElements = Array.from(sibling.
|
|
17
|
+
if (sibling && sibling.tagName.endsWith("complexType") && sibling.hasAttribute("name")) {
|
|
18
|
+
subElements = Array.from(sibling.getElementsByTagNameNS("*", "element"));
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
});
|
|
@@ -29,7 +29,8 @@ function getSubelementsFromXMLOtherStructure (xml, featureType) {
|
|
|
29
29
|
* @returns {object[]} subElements of the xml element
|
|
30
30
|
*/
|
|
31
31
|
function getSubelementsFromXML (xml, featureType) {
|
|
32
|
-
const elements = xml ? Array.from(xml.
|
|
32
|
+
const elements = xml ? Array.from(xml.getElementsByTagNameNS("*", "element")) : [];
|
|
33
|
+
|
|
33
34
|
let subElements = [],
|
|
34
35
|
featureTypeWithoutNamespace = featureType;
|
|
35
36
|
|
|
@@ -39,9 +40,10 @@ function getSubelementsFromXML (xml, featureType) {
|
|
|
39
40
|
|
|
40
41
|
elements.forEach(element => {
|
|
41
42
|
if (element.getAttribute("name") === featureTypeWithoutNamespace) {
|
|
42
|
-
subElements = Array.from(element.
|
|
43
|
+
subElements = Array.from(element.getElementsByTagNameNS("*", "element"));
|
|
43
44
|
}
|
|
44
45
|
});
|
|
46
|
+
|
|
45
47
|
if (subElements.length === 0) {
|
|
46
48
|
subElements = getSubelementsFromXMLOtherStructure(xml, featureTypeWithoutNamespace);
|
|
47
49
|
}
|
|
@@ -105,7 +107,7 @@ function getGeometryTypeFromWFS (rules, wfsURL, version, featureType, styleGeome
|
|
|
105
107
|
url = url.slice(0, -1);
|
|
106
108
|
|
|
107
109
|
|
|
108
|
-
fetch(url, {
|
|
110
|
+
return fetch(url, {
|
|
109
111
|
method: "get",
|
|
110
112
|
withCredentials: isSecured,
|
|
111
113
|
responseType: "text"
|
|
@@ -115,7 +117,7 @@ function getGeometryTypeFromWFS (rules, wfsURL, version, featureType, styleGeome
|
|
|
115
117
|
const subElements = getSubelementsFromXML(responseXML, featureType),
|
|
116
118
|
geometryTypes = getTypeAttributesFromSubelements(subElements, styleGeometryType);
|
|
117
119
|
|
|
118
|
-
createLegendInfo(rules, geometryTypes, wfsImgPath);
|
|
120
|
+
return createLegendInfo(rules, geometryTypes, wfsImgPath);
|
|
119
121
|
}).catch(error => {
|
|
120
122
|
return callback(error);
|
|
121
123
|
});
|
|
@@ -152,4 +154,4 @@ function getGeometryTypeFromOAF (rules, oafURL, collection, wfsImgPath, callback
|
|
|
152
154
|
export default {
|
|
153
155
|
getGeometryTypeFromWFS,
|
|
154
156
|
getGeometryTypeFromOAF
|
|
155
|
-
};
|
|
157
|
+
};
|
|
@@ -3,9 +3,9 @@ import Feature from "ol/Feature";
|
|
|
3
3
|
import Circle from "ol/geom/Circle";
|
|
4
4
|
import VectorSource from "ol/source/Vector";
|
|
5
5
|
|
|
6
|
-
import drawInteractions, {styleObject} from "../../../src/maps/interactions/
|
|
6
|
+
import drawInteractions, {styleObject} from "../../../src/maps/interactions/drawInteraction";
|
|
7
7
|
|
|
8
|
-
describe("src/maps/interactions/
|
|
8
|
+
describe("src/maps/interactions/drawInteraction.js", () => {
|
|
9
9
|
describe("transformMapUnitRadius", () => {
|
|
10
10
|
it("should return the input meter radius in meter ", () => {
|
|
11
11
|
const radius = 100,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {Modify} from "ol/interaction.js";
|
|
2
|
+
import VectorSource from "ol/source/Vector";
|
|
3
|
+
|
|
4
|
+
import modifyInteractions from "../../../src/maps/interactions/modifyInteraction";
|
|
5
|
+
|
|
6
|
+
describe("src/maps/interactions/modifyInteraction.js", () => {
|
|
7
|
+
describe("createModifyInteraction", () => {
|
|
8
|
+
it("should create a modify interaction", () => {
|
|
9
|
+
const source = new VectorSource(),
|
|
10
|
+
modifyInteraction = modifyInteractions.createModifyInteraction(source);
|
|
11
|
+
|
|
12
|
+
expect(modifyInteraction).not.toBeUndefined();
|
|
13
|
+
expect(modifyInteraction).not.toBeNull();
|
|
14
|
+
expect(modifyInteraction).toBeInstanceOf(Modify);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/* eslint-disable no-underscore-dangle */
|
|
2
|
+
import {pointerMove, singleClick} from "ol/events/condition.js";
|
|
3
|
+
import {Select} from "ol/interaction.js";
|
|
4
|
+
import VectorLayer from "ol/layer/Vector";
|
|
5
|
+
|
|
6
|
+
import selectInteractions from "../../../src/maps/interactions/selectInteraction";
|
|
7
|
+
|
|
8
|
+
describe("src/maps/interactions/selectInteraction.js", () => {
|
|
9
|
+
describe("createSelectInteraction", () => {
|
|
10
|
+
it("should create a select interaction", () => {
|
|
11
|
+
const layers = new VectorLayer(),
|
|
12
|
+
selectInteraction = selectInteractions.createSelectInteraction(layers);
|
|
13
|
+
|
|
14
|
+
expect(selectInteraction).not.toBeUndefined();
|
|
15
|
+
expect(selectInteraction).not.toBeNull();
|
|
16
|
+
expect(selectInteraction).toBeInstanceOf(Select);
|
|
17
|
+
expect(selectInteraction.condition_).toEqual(singleClick);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("should create a select interaction with condition === pointerMove", () => {
|
|
21
|
+
const layers = new VectorLayer(),
|
|
22
|
+
selectInteraction = selectInteractions.createSelectInteraction(layers, pointerMove);
|
|
23
|
+
|
|
24
|
+
expect(selectInteraction).not.toBeUndefined();
|
|
25
|
+
expect(selectInteraction).not.toBeNull();
|
|
26
|
+
expect(selectInteraction).toBeInstanceOf(Select);
|
|
27
|
+
expect(selectInteraction.condition_).toEqual(pointerMove);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
});
|
|
File without changes
|