@masterportal/masterportalapi 2.22.0 → 2.24.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 +39 -9
- package/example/config/portal.json +1 -1
- package/example/index.js +1 -1
- package/jest.config.js +3 -0
- package/package.json +66 -65
- package/src/index.js +0 -2
- package/src/layer/terrain.js +8 -6
- package/src/layer/tileset.js +14 -5
- package/src/maps/interactions/{drawInteractions.js → drawInteraction.js} +27 -3
- package/src/maps/interactions/modifyInteraction.js +18 -0
- package/src/maps/interactions/selectInteraction.js +35 -0
- package/src/maps/olcs/3dUtils/wmsRasterSynchronizer.js +2 -2
- package/src/maps/olcs/olcsMap.js +2 -2
- package/src/vectorStyle/lib/createLegendInfo.js +16 -8
- package/src/vectorStyle/lib/getGeometryTypeFromService.js +10 -8
- package/test/layer/geojson/index.test.js +4 -2
- package/test/layer/oaf.test.js +5 -3
- package/test/layer/terrain.test.js +4 -2
- package/test/layer/tileset.test.js +10 -5
- package/test/layer/vectorBase.test.js +4 -2
- package/test/layer/wfs.test.js +4 -2
- package/test/maps/interactions/{drawInteractions.test.js → drawInteraction.test.js} +36 -2
- package/test/maps/interactions/modifyInteraction.test.js +18 -0
- package/test/maps/interactions/selectInteraction.test.js +31 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,32 +3,62 @@
|
|
|
3
3
|
|
|
4
4
|
The [Semantic Versioning](https://semver.org/spec/v2.0.0.html) is used.
|
|
5
5
|
|
|
6
|
-
##
|
|
6
|
+
## 2.24.0 - 2023-08-03
|
|
7
7
|
### Added
|
|
8
|
+
- The following packages have been installed:
|
|
9
|
+
- @swc/jest: 0.2.27
|
|
10
|
+
- Add a function to convertUnits in drawInteractions.
|
|
8
11
|
|
|
9
12
|
### Changed
|
|
13
|
+
- The following packages have been updated:
|
|
14
|
+
- dependencies:
|
|
15
|
+
- core-js: 3.30.2 to 3.32.0
|
|
16
|
+
- dayjs: 1.11.7 to 1.11.9
|
|
17
|
+
- olcs: 2.14.0 to 2.15.0
|
|
18
|
+
- xml2js: 0.5.0 to 0.6.2
|
|
19
|
+
- devDependencies:
|
|
20
|
+
- @babel/core: 7.21.8 to 7.22.9
|
|
21
|
+
- @babel/plugin-transform-modules-commonjs: 7.21.5 to 7.21.5
|
|
22
|
+
- @parcel/transformer-sass: 2.8.3 to 2.9.3
|
|
23
|
+
- buffer: 5.7.1 to 6.0.3
|
|
24
|
+
- eslint: 8.40.0 to 8.46.0
|
|
25
|
+
- jest: 29.5.0 to 29.6.2
|
|
26
|
+
- jest-canvas-mock: 2.5.0 to 2.5.2
|
|
27
|
+
- jest-environment-jsdom: 29.5.0 to 29.6.2
|
|
28
|
+
- parcel: 2.8.3 to 2.9.3
|
|
29
|
+
- sass: 1.62.1 to 1.64.2
|
|
10
30
|
|
|
11
|
-
###
|
|
31
|
+
### Fixed
|
|
32
|
+
- Changed peerDependency from cesium 1.106.0 to @cesium/engine 2.4.1.
|
|
12
33
|
|
|
13
|
-
|
|
34
|
+
---
|
|
14
35
|
|
|
15
|
-
|
|
36
|
+
## 2.23.0 - 2023-08-02
|
|
37
|
+
### Added
|
|
38
|
+
- Add select and modify interactions for editing ol features.
|
|
16
39
|
|
|
40
|
+
### Fixed
|
|
41
|
+
- The legend for wfs is now created again via the Describefeaturetype.
|
|
17
42
|
|
|
18
43
|
---
|
|
44
|
+
|
|
19
45
|
## 2.22.0 - 2023-07-25
|
|
46
|
+
### Changed
|
|
47
|
+
- Replace derprecated cesium tileset and terrain loading functions.
|
|
48
|
+
- WFST Refactoring
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## 2.21.0 - 2023-07-21
|
|
20
53
|
### Added
|
|
21
|
-
- VectorStyle: Add Styling rules for
|
|
54
|
+
- VectorStyle: Add Styling rules for Geometries of type `Circle`.
|
|
22
55
|
- Add Styling and zIndex to draw interactions and improve the draw behavior.
|
|
23
56
|
|
|
24
57
|
### Changed
|
|
25
58
|
- Changed peerDependency from cesium 1.106.0 to @cesium/engine 2.4.1.
|
|
26
|
-
- WFS:
|
|
59
|
+
- WFS:
|
|
27
60
|
- Migrated writeTransaction and sendTransaction from masterportal the masterportalAPI.
|
|
28
61
|
- Exports in src/layer/wfs.js changed to export default {} to provide ES-Syntax.
|
|
29
|
-
### Deprecated
|
|
30
|
-
|
|
31
|
-
### Removed
|
|
32
62
|
|
|
33
63
|
### Fixed
|
|
34
64
|
- WFS: fixed a bug that prevented parsing GeoServer responses.
|
package/example/index.js
CHANGED
|
@@ -249,7 +249,7 @@ document.getElementById("enable").addEventListener("click", function () {
|
|
|
249
249
|
document.getElementById("layer-visibility").style.display = "none";
|
|
250
250
|
}
|
|
251
251
|
else {
|
|
252
|
-
const lib = portalConfig.cesiumLib ? portalConfig.cesiumLib : "https://geoportal-hamburg.de/mastercode/cesium/
|
|
252
|
+
const lib = portalConfig.cesiumLib ? portalConfig.cesiumLib : "https://geoportal-hamburg.de/mastercode/cesium/latest/index.js";
|
|
253
253
|
|
|
254
254
|
document.getElementById("layer-visibility").style.display = "block";
|
|
255
255
|
|
package/jest.config.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/* eslint-env node */
|
|
2
2
|
module.exports = {
|
|
3
|
+
"transform": {
|
|
4
|
+
"^.+\\.(t|j)sx?$": "@swc/jest"
|
|
5
|
+
},
|
|
3
6
|
/** ol prints errors without HTMLCanvasElement being available in test environment */
|
|
4
7
|
"setupFiles": ["jest-canvas-mock"],
|
|
5
8
|
/** node_modules are usually ignored by babel-jest, but ol is published in ES6 */
|
package/package.json
CHANGED
|
@@ -1,65 +1,66 @@
|
|
|
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.
|
|
23
|
-
"dayjs": "^1.11.
|
|
24
|
-
"ol": "7.4.0",
|
|
25
|
-
"olcs": "^2.
|
|
26
|
-
"proj4": "^2.9.0",
|
|
27
|
-
"xml2js": "^0.
|
|
28
|
-
},
|
|
29
|
-
"devDependencies": {
|
|
30
|
-
"@babel/core": "^7.
|
|
31
|
-
"@babel/plugin-transform-modules-commonjs": "^7.
|
|
32
|
-
"@parcel/transformer-sass": "^2.
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"jest
|
|
40
|
-
"jest-
|
|
41
|
-
"jest-
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
"
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@masterportal/masterportalapi",
|
|
3
|
+
"author": "Implementierungspartnerschaft Masterportal <info@masterportal.org> (https://www.masterportal.org)",
|
|
4
|
+
"version": "2.24.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.32.0",
|
|
23
|
+
"dayjs": "^1.11.9",
|
|
24
|
+
"ol": "7.4.0",
|
|
25
|
+
"olcs": "^2.15.0",
|
|
26
|
+
"proj4": "^2.9.0",
|
|
27
|
+
"xml2js": "^0.6.2"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@babel/core": "^7.22.9",
|
|
31
|
+
"@babel/plugin-transform-modules-commonjs": "^7.22.5",
|
|
32
|
+
"@parcel/transformer-sass": "^2.9.3",
|
|
33
|
+
"@swc/jest": "^0.2.27",
|
|
34
|
+
"buffer": "^6.0.3",
|
|
35
|
+
"canvas": "^2.11.2",
|
|
36
|
+
"eslint": "^8.46.0",
|
|
37
|
+
"events": "^3.3.0",
|
|
38
|
+
"husky": "^8.0.3",
|
|
39
|
+
"jest": "^29.6.2",
|
|
40
|
+
"jest-canvas-mock": "^2.5.2",
|
|
41
|
+
"jest-environment-jsdom": "^29.6.2",
|
|
42
|
+
"jest-fetch-mock": "^3.0.3",
|
|
43
|
+
"jsdoc": "^4.0.2",
|
|
44
|
+
"parcel": "^2.9.3",
|
|
45
|
+
"process": "^0.11.10",
|
|
46
|
+
"sass": "^1.64.2",
|
|
47
|
+
"stream-browserify": "^3.0.0",
|
|
48
|
+
"timers-browserify": "^2.0.12",
|
|
49
|
+
"use-resize-observer": "^9.1.0"
|
|
50
|
+
},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"@cesium/engine": "^2.4.1"
|
|
53
|
+
},
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": "^16.13.2 || ^18.12.0",
|
|
56
|
+
"npm": "^8.1.2 || ^9.3.1"
|
|
57
|
+
},
|
|
58
|
+
"homepage": "https://bitbucket.org/geowerkstatt-hamburg/masterportalapi#readme",
|
|
59
|
+
"directories": {
|
|
60
|
+
"example": "example",
|
|
61
|
+
"test": "test"
|
|
62
|
+
},
|
|
63
|
+
"bugs": {
|
|
64
|
+
"url": "https://bitbucket.org/geowerkstatt-hamburg/masterportalapi/issues"
|
|
65
|
+
}
|
|
66
|
+
}
|
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
|
};
|
package/src/layer/terrain.js
CHANGED
|
@@ -5,14 +5,15 @@
|
|
|
5
5
|
* @param {string} [rawLayer.cesiumTerrainProviderOptions] - see https://cesiumjs.org/Cesium/Build/Documentation/CesiumTerrainProvider.html
|
|
6
6
|
* @returns {void}
|
|
7
7
|
*/
|
|
8
|
-
function createTerrainProvider (rawLayer) {
|
|
9
|
-
const options = {}
|
|
8
|
+
async function createTerrainProvider (rawLayer) {
|
|
9
|
+
const options = {},
|
|
10
|
+
terrainProvider = await Cesium.CesiumTerrainProvider.fromUrl(rawLayer.url, options);
|
|
10
11
|
|
|
11
12
|
if (rawLayer.cesiumTerrainProviderOptions) {
|
|
12
13
|
Object.assign(options, rawLayer.cesiumTerrainProviderOptions);
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
-
return
|
|
15
|
+
|
|
16
|
+
return terrainProvider;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
/**
|
|
@@ -24,10 +25,10 @@ function createTerrainProvider (rawLayer) {
|
|
|
24
25
|
* @param {OLCesium} map ol cesium map
|
|
25
26
|
* @returns {void}
|
|
26
27
|
*/
|
|
27
|
-
|
|
28
|
+
async function setVisible (value, rawLayer, map) {
|
|
28
29
|
if (map && typeof map.getCesiumScene === "function") {
|
|
29
30
|
if (value) {
|
|
30
|
-
map.getCesiumScene().terrainProvider = createTerrainProvider(rawLayer);
|
|
31
|
+
map.getCesiumScene().terrainProvider = await createTerrainProvider(rawLayer);
|
|
31
32
|
}
|
|
32
33
|
else {
|
|
33
34
|
map.getCesiumScene().terrainProvider = new Cesium.EllipsoidTerrainProvider({});
|
|
@@ -63,3 +64,4 @@ export function get (key) {
|
|
|
63
64
|
return this.values[key];
|
|
64
65
|
}
|
|
65
66
|
|
|
67
|
+
module.exports.setVisible = setVisible;
|
package/src/layer/tileset.js
CHANGED
|
@@ -9,11 +9,12 @@ function createTileSet (rawLayer) {
|
|
|
9
9
|
const url = rawLayer.url.split("?")[0] + "/tileset.json",
|
|
10
10
|
options = {};
|
|
11
11
|
|
|
12
|
+
|
|
12
13
|
if (rawLayer.cesium3DTilesetOptions) {
|
|
13
14
|
Object.assign(options, rawLayer.cesium3DTilesetOptions);
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
-
return
|
|
16
|
+
|
|
17
|
+
return Promise.resolve(Cesium.Cesium3DTileset.fromUrl(url, options));
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
/**
|
|
@@ -24,6 +25,7 @@ function createTileSet (rawLayer) {
|
|
|
24
25
|
* @param {string} [rawLayer.cesiumTerrainProviderOptions] - see https://cesiumjs.org/Cesium/Build/Documentation/CesiumTerrainProvider.html
|
|
25
26
|
* @returns {void}
|
|
26
27
|
*/
|
|
28
|
+
|
|
27
29
|
export default function Tileset (rawLayer) {
|
|
28
30
|
this.values = {
|
|
29
31
|
name: rawLayer.name,
|
|
@@ -31,8 +33,13 @@ export default function Tileset (rawLayer) {
|
|
|
31
33
|
typ: rawLayer.typ
|
|
32
34
|
};
|
|
33
35
|
if (Cesium) {
|
|
34
|
-
this.tileset = createTileSet(rawLayer);
|
|
35
|
-
this.tileset.
|
|
36
|
+
this.tileset = Promise.resolve(createTileSet(rawLayer));
|
|
37
|
+
this.tileset.then(function (tileset) {
|
|
38
|
+
if (tileset) {
|
|
39
|
+
tileset.layerReferenceId = rawLayer.id;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
36
43
|
}
|
|
37
44
|
}
|
|
38
45
|
|
|
@@ -69,7 +76,9 @@ Tileset.prototype.setVisible = function (value, map) {
|
|
|
69
76
|
if (map && typeof map.getCesiumScene === "function") {
|
|
70
77
|
if (value) {
|
|
71
78
|
if (!map.getCesiumScene().primitives.contains(this.tileset)) {
|
|
72
|
-
|
|
79
|
+
this.tileset.then(function (tileset) {
|
|
80
|
+
map.getCesiumScene().primitives.add(tileset);
|
|
81
|
+
});
|
|
73
82
|
}
|
|
74
83
|
this.tileset.show = true;
|
|
75
84
|
}
|
|
@@ -38,6 +38,26 @@ let styleObject = null,
|
|
|
38
38
|
styleObjectOuterCircle = null,
|
|
39
39
|
zIndex = 0;
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Converts a value from one unit to another.
|
|
43
|
+
* @param {Number} value The value to convert.
|
|
44
|
+
* @param {String} sourceUnit The source unit.
|
|
45
|
+
* @param {String} targetUnit The target unit.
|
|
46
|
+
* @returns {Number} The converted value.
|
|
47
|
+
*/
|
|
48
|
+
function convertUnits (value, sourceUnit, targetUnit) {
|
|
49
|
+
if (sourceUnit === targetUnit) {
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
else if (sourceUnit === "m" && targetUnit === "km") {
|
|
53
|
+
return value / 1000;
|
|
54
|
+
}
|
|
55
|
+
else if (sourceUnit === "km" && targetUnit === "m") {
|
|
56
|
+
return value * 1000;
|
|
57
|
+
}
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
|
|
41
61
|
/**
|
|
42
62
|
* Transform the radius to map projection unit.
|
|
43
63
|
* @param {Number} radius The radius.
|
|
@@ -70,8 +90,10 @@ function transformMapUnitRadius (radius, mapProjection) {
|
|
|
70
90
|
*/
|
|
71
91
|
function drawOuterCircle (feature, mapProjection, source, options = {}) {
|
|
72
92
|
const innerCircleFeature = feature.clone(),
|
|
73
|
-
|
|
74
|
-
|
|
93
|
+
innerRadius = convertUnits(options.innerRadius, options.unit, "m"),
|
|
94
|
+
outerRadius = convertUnits(options.outerRadius, options.unit, "m"),
|
|
95
|
+
mapUnitInnerRadius = transformMapUnitRadius(innerRadius, mapProjection),
|
|
96
|
+
mapUnitOuterRadius = transformMapUnitRadius(outerRadius, mapProjection),
|
|
75
97
|
innerStyle = createStyle.createStyle(styleObject, innerCircleFeature, false),
|
|
76
98
|
outerStyle = createStyle.createStyle(styleObjectOuterCircle, feature, false);
|
|
77
99
|
|
|
@@ -95,7 +117,8 @@ function drawOuterCircle (feature, mapProjection, source, options = {}) {
|
|
|
95
117
|
* @returns {void}
|
|
96
118
|
*/
|
|
97
119
|
function drawInnerCircle (feature, mapProjection, options = {}) {
|
|
98
|
-
const
|
|
120
|
+
const innerRadius = convertUnits(options.innerRadius, options.unit, "m"),
|
|
121
|
+
mapUnitInnerRadius = transformMapUnitRadius(innerRadius, mapProjection);
|
|
99
122
|
|
|
100
123
|
feature.getGeometry().setRadius(mapUnitInnerRadius);
|
|
101
124
|
}
|
|
@@ -205,6 +228,7 @@ function createDrawInteraction (drawType, source) {
|
|
|
205
228
|
export {styleObject};
|
|
206
229
|
|
|
207
230
|
export default {
|
|
231
|
+
convertUnits,
|
|
208
232
|
createDrawInteraction,
|
|
209
233
|
drawCircle,
|
|
210
234
|
drawInnerCircle,
|
|
@@ -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
|
+
};
|
|
@@ -6,8 +6,8 @@ import {getUid} from "olcs/util.js";
|
|
|
6
6
|
import TileWMS from "ol/source/TileWMS.js";
|
|
7
7
|
import ImageWMS from "ol/source/ImageWMS.js";
|
|
8
8
|
import WMTS from "ol/source/WMTS.js";
|
|
9
|
-
import olcsAbstractSynchronizer from "olcs/AbstractSynchronizer.
|
|
10
|
-
import {extentToRectangle, tileLayerToImageryLayer, updateCesiumLayerProperties} from "olcs/core.
|
|
9
|
+
import olcsAbstractSynchronizer from "olcs/AbstractSynchronizer.ts";
|
|
10
|
+
import {extentToRectangle, tileLayerToImageryLayer, updateCesiumLayerProperties} from "olcs/core.ts";
|
|
11
11
|
import {Tile, Image as ImageLayer} from "ol/layer.js";
|
|
12
12
|
import {stableSort} from "ol/array.js";
|
|
13
13
|
import {getBottomLeft, getBottomRight, getTopRight, getTopLeft} from "ol/extent.js";
|
package/src/maps/olcs/olcsMap.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import OLCesium from "olcs/OLCesium.
|
|
1
|
+
import OLCesium from "olcs/OLCesium.ts";
|
|
2
2
|
import {transform, get} from "ol/proj.js";
|
|
3
|
-
import VectorSynchronizer from "olcs/VectorSynchronizer.
|
|
3
|
+
import VectorSynchronizer from "olcs/VectorSynchronizer.ts";
|
|
4
4
|
|
|
5
5
|
import FixedOverlaySynchronizer from "./3dUtils/fixedOverlaySynchronizer.js";
|
|
6
6
|
import WMSRasterSynchronizer from "./3dUtils/wmsRasterSynchronizer.js";
|
|
@@ -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
|
+
};
|
|
@@ -10,8 +10,10 @@ const features = [new Feature(), new Feature()];
|
|
|
10
10
|
jest.mock("../../../src/renderer/webgl.js", () => {
|
|
11
11
|
const original = jest.requireActual("../../../src/renderer/webgl.js");
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
return {
|
|
14
|
+
...original,
|
|
15
|
+
afterLoading: jest.fn()
|
|
16
|
+
};
|
|
15
17
|
});
|
|
16
18
|
|
|
17
19
|
describe("geojson/index", function () {
|
package/test/layer/oaf.test.js
CHANGED
|
@@ -19,8 +19,10 @@ jest.mock("../../src/rawLayerList.js", () => {
|
|
|
19
19
|
jest.mock("../../src/renderer/webgl.js", () => {
|
|
20
20
|
const original = jest.requireActual("../../src/renderer/webgl.js");
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
return {
|
|
23
|
+
...original,
|
|
24
|
+
afterLoading: jest.fn()
|
|
25
|
+
};
|
|
24
26
|
});
|
|
25
27
|
|
|
26
28
|
|
|
@@ -272,4 +274,4 @@ describe("oaf.js", function () {
|
|
|
272
274
|
expect(webgl.afterLoading).toHaveBeenCalled();
|
|
273
275
|
});
|
|
274
276
|
});
|
|
275
|
-
});
|
|
277
|
+
});
|
|
@@ -5,8 +5,10 @@ describe("terrain.js", function () {
|
|
|
5
5
|
|
|
6
6
|
beforeEach(() => {
|
|
7
7
|
global.Cesium = {};
|
|
8
|
-
global.Cesium.CesiumTerrainProvider =
|
|
8
|
+
global.Cesium.CesiumTerrainProvider = {};
|
|
9
|
+
global.Cesium.CesiumTerrainProvider.fromUrl = jest.fn();
|
|
9
10
|
global.Cesium.EllipsoidTerrainProvider = jest.fn();
|
|
11
|
+
|
|
10
12
|
attr = {
|
|
11
13
|
id: "12883",
|
|
12
14
|
name: "Gelaende",
|
|
@@ -21,7 +23,7 @@ describe("terrain.js", function () {
|
|
|
21
23
|
return {};
|
|
22
24
|
}
|
|
23
25
|
};
|
|
24
|
-
cesiumTerrainProviderSpy = jest.spyOn(global.Cesium, "
|
|
26
|
+
cesiumTerrainProviderSpy = jest.spyOn(global.Cesium.CesiumTerrainProvider, "fromUrl");
|
|
25
27
|
});
|
|
26
28
|
|
|
27
29
|
afterEach(() => {
|
|
@@ -6,7 +6,8 @@ describe("tileset.js", function () {
|
|
|
6
6
|
|
|
7
7
|
beforeEach(() => {
|
|
8
8
|
global.Cesium = {};
|
|
9
|
-
global.Cesium.Cesium3DTileset =
|
|
9
|
+
global.Cesium.Cesium3DTileset = {};
|
|
10
|
+
global.Cesium.Cesium3DTileset.fromUrl = jest.fn();
|
|
10
11
|
global.Cesium.Cesium3DTileStyle = jest.fn(color => color);
|
|
11
12
|
attr = {
|
|
12
13
|
id: "4002",
|
|
@@ -28,7 +29,9 @@ describe("tileset.js", function () {
|
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
31
|
};
|
|
31
|
-
cesium3DTilesetSpy = jest.spyOn(global.Cesium, "
|
|
32
|
+
cesium3DTilesetSpy = jest.spyOn(global.Cesium.Cesium3DTileset, "fromUrl").mockImplementation(() => {
|
|
33
|
+
return Promise.resolve({});
|
|
34
|
+
});
|
|
32
35
|
console.warn = jest.fn();
|
|
33
36
|
});
|
|
34
37
|
|
|
@@ -38,21 +41,23 @@ describe("tileset.js", function () {
|
|
|
38
41
|
console.warn = consoleWarn;
|
|
39
42
|
});
|
|
40
43
|
|
|
41
|
-
function checkAttributes (layer, attrs) {
|
|
44
|
+
async function checkAttributes (layer, attrs) {
|
|
45
|
+
const tileset = await layer.tileset;
|
|
46
|
+
|
|
42
47
|
expect(layer.get("name")).toEqual(attrs.name);
|
|
43
48
|
expect(layer.get("typ")).toEqual(attrs.typ);
|
|
44
49
|
expect(layer.get("id")).toEqual(attrs.id);
|
|
45
|
-
expect(
|
|
50
|
+
expect(tileset.layerReferenceId).toEqual(attrs.id);
|
|
46
51
|
}
|
|
47
52
|
|
|
48
53
|
describe("createLayer", function () {
|
|
49
54
|
it("creates tileset layer without map", function () {
|
|
50
55
|
const layer = new Tileset(attr);
|
|
51
56
|
|
|
52
|
-
checkAttributes(layer, attr);
|
|
53
57
|
expect(layer.tileSet).toEqual(undefined);
|
|
54
58
|
expect(layer.tileset.show).toEqual(undefined);
|
|
55
59
|
expect(cesium3DTilesetSpy).toHaveBeenCalledTimes(1);
|
|
60
|
+
checkAttributes(layer, attr);
|
|
56
61
|
});
|
|
57
62
|
it("creates 2 tileset layers with map and checks attributes", function () {
|
|
58
63
|
const attr2 = {
|
|
@@ -9,8 +9,10 @@ import * as webgl from "../../src/renderer/webgl.js";
|
|
|
9
9
|
jest.mock("../../src/renderer/webgl.js", () => {
|
|
10
10
|
const original = jest.requireActual("../../src/renderer/webgl.js");
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
return {
|
|
13
|
+
...original,
|
|
14
|
+
afterLoading: jest.fn()
|
|
15
|
+
};
|
|
14
16
|
});
|
|
15
17
|
|
|
16
18
|
describe("vectorBase.js", function () {
|
package/test/layer/wfs.test.js
CHANGED
|
@@ -24,8 +24,10 @@ jest.mock("../../src/rawLayerList.js", () => {
|
|
|
24
24
|
jest.mock("../../src/renderer/webgl.js", () => {
|
|
25
25
|
const original = jest.requireActual("../../src/renderer/webgl.js");
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
return {
|
|
28
|
+
...original,
|
|
29
|
+
afterLoading: jest.fn()
|
|
30
|
+
};
|
|
29
31
|
});
|
|
30
32
|
|
|
31
33
|
|
|
@@ -3,9 +3,43 @@ 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
|
+
|
|
8
|
+
describe("src/maps/interactions/drawInteraction.js", () => {
|
|
9
|
+
describe("convertUnits", () => {
|
|
10
|
+
it("shold return 1000 for sourceUnit === 'm' and targetUnit === 'm'", () =>{
|
|
11
|
+
const value = 1000,
|
|
12
|
+
sourceUnit = "m",
|
|
13
|
+
targetUnit = "m";
|
|
14
|
+
|
|
15
|
+
expect(drawInteractions.convertUnits(value, sourceUnit, targetUnit)).toEqual(1000);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("shold return 1000 for sourceUnit === 'm' and targetUnit === 'km'", () =>{
|
|
19
|
+
const value = 1000,
|
|
20
|
+
sourceUnit = "m",
|
|
21
|
+
targetUnit = "km";
|
|
22
|
+
|
|
23
|
+
expect(drawInteractions.convertUnits(value, sourceUnit, targetUnit)).toEqual(1);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("shold return 1000 for sourceUnit === 'km' and targetUnit === 'm'", () =>{
|
|
27
|
+
const value = 1000,
|
|
28
|
+
sourceUnit = "km",
|
|
29
|
+
targetUnit = "m";
|
|
30
|
+
|
|
31
|
+
expect(drawInteractions.convertUnits(value, sourceUnit, targetUnit)).toEqual(1000000);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("shold return 1000 for sourceUnit === 'abc' and targetUnit === 'def'", () =>{
|
|
35
|
+
const value = 1000,
|
|
36
|
+
sourceUnit = "abc",
|
|
37
|
+
targetUnit = "def";
|
|
38
|
+
|
|
39
|
+
expect(drawInteractions.convertUnits(value, sourceUnit, targetUnit)).toEqual(1000);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
7
42
|
|
|
8
|
-
describe("src/maps/interactions/drawInteractions.js", () => {
|
|
9
43
|
describe("transformMapUnitRadius", () => {
|
|
10
44
|
it("should return the input meter radius in meter ", () => {
|
|
11
45
|
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
|
+
});
|