@masterportal/masterportalapi 2.13.0 → 2.15.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/.eslintrc +2 -1
- package/CHANGELOG.md +16 -7
- package/example/config/localGeoJSONPoints.js +2106 -0
- package/example/config/portal.json +47 -1
- package/example/config/services.json +20 -0
- package/example/index.js +50 -7
- package/jest.config.js +1 -1
- package/jest.setup.js +9 -1
- package/package.json +64 -62
- package/src/index.js +3 -1
- package/src/layer/geojson/index.js +55 -4
- package/src/layer/oaf.js +35 -5
- package/src/layer/vectorBase.js +20 -1
- package/src/layer/wfs.js +38 -7
- package/src/lib/attributeMapper.js +231 -0
- package/src/lib/getValueFromObjectByPath.js +73 -0
- package/src/lib/thousandsSeparator.js +23 -0
- package/src/maps/ol/olMap.js +4 -3
- package/src/renderer/webgl.js +250 -0
- package/src/vectorStyle/createStyle.js +259 -0
- package/src/vectorStyle/lib/colorConvertions.js +97 -0
- package/src/vectorStyle/lib/createLegendInfo.js +28 -0
- package/src/vectorStyle/lib/getGeometryTypeFromService.js +153 -0
- package/src/vectorStyle/lib/getRuleForIndex.js +62 -0
- package/src/vectorStyle/lib/valueOperations.js +172 -0
- package/src/vectorStyle/styleList.js +281 -0
- package/src/vectorStyle/styles/defaultStyles.js +177 -0
- package/src/vectorStyle/styles/point/stylePoint.js +108 -0
- package/src/vectorStyle/styles/point/stylePointCircle.js +29 -0
- package/src/vectorStyle/styles/point/stylePointIcon.js +79 -0
- package/src/vectorStyle/styles/point/stylePointInterval.js +124 -0
- package/src/vectorStyle/styles/point/stylePointNominal.js +232 -0
- package/src/vectorStyle/styles/point/stylePointRegularShape.js +39 -0
- package/src/vectorStyle/styles/polygon/polygonStyleHatch.js +160 -0
- package/src/vectorStyle/styles/polygon/stylePolygon.js +125 -0
- package/src/vectorStyle/styles/style.js +161 -0
- package/src/vectorStyle/styles/styleCesium.js +106 -0
- package/src/vectorStyle/styles/styleLine.js +51 -0
- package/src/vectorStyle/styles/styleText.js +143 -0
- package/test/layer/geojson/index.test.js +23 -0
- package/test/layer/oaf.test.js +30 -0
- package/test/layer/vectorBase.test.js +27 -7
- package/test/layer/wfs.test.js +30 -0
- package/test/lib/attributeMapper.test.js +290 -0
- package/test/lib/getValueFromObjectByPath.test.js +61 -0
- package/test/lib/thousandsSeparator.test.js +58 -0
- package/test/renderer/webgl.test.js +161 -0
- package/test/vectorStyle/createStyle.test.js +335 -0
- package/test/vectorStyle/lib/colorConvertions.test.js +42 -0
- package/test/vectorStyle/lib/getRuleForIndex.test.js +132 -0
- package/test/vectorStyle/lib/valueOperations.test.js +191 -0
- package/test/vectorStyle/styles/point/stylePoint.test.js +28 -0
- package/test/vectorStyle/styles/point/stylePointCircle.test.js +30 -0
- package/test/vectorStyle/styles/point/stylePointIcon.test.js +83 -0
- package/test/vectorStyle/styles/point/stylePointInterval.test.js +57 -0
- package/test/vectorStyle/styles/point/stylePointNominal.test.js +84 -0
- package/test/vectorStyle/styles/point/stylePointRegularShape.test.js +24 -0
- package/test/vectorStyle/styles/polygon/polygonStyleHatch.test.js +95 -0
- package/test/vectorStyle/styles/polygon/stylePolygon.test.js +61 -0
- package/test/vectorStyle/styles/styleLine.test.js +29 -0
- package/test/vectorStyle/styles/styleText.test.js +49 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import {drawHatch} from "../../../../src/vectorStyle/styles/polygon/polygonStyleHatch";
|
|
2
|
+
|
|
3
|
+
describe("polygonStyleHatches", function () {
|
|
4
|
+
describe("drawHatch", function () {
|
|
5
|
+
let context = null;
|
|
6
|
+
|
|
7
|
+
beforeEach(function () {
|
|
8
|
+
context = {
|
|
9
|
+
stroke: jest.fn(),
|
|
10
|
+
translate: jest.fn(),
|
|
11
|
+
rotate: jest.fn(),
|
|
12
|
+
beginPath: jest.fn(),
|
|
13
|
+
rect: jest.fn(),
|
|
14
|
+
moveTo: jest.fn(),
|
|
15
|
+
lineTo: jest.fn(),
|
|
16
|
+
arc: jest.fn(),
|
|
17
|
+
lineWidth: 50
|
|
18
|
+
};
|
|
19
|
+
jest.spyOn(context, "translate");
|
|
20
|
+
jest.spyOn(context, "rotate");
|
|
21
|
+
jest.spyOn(context, "beginPath");
|
|
22
|
+
jest.spyOn(context, "rect");
|
|
23
|
+
jest.spyOn(context, "moveTo");
|
|
24
|
+
jest.spyOn(context, "lineTo");
|
|
25
|
+
jest.spyOn(context, "arc");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("should draw patterns from known names to the context object", function () {
|
|
29
|
+
drawHatch(context, 100, "zig-line-horizontal");
|
|
30
|
+
|
|
31
|
+
expect(context.stroke).toHaveBeenCalledTimes(1);
|
|
32
|
+
expect(context.translate).toHaveBeenCalledTimes(2);
|
|
33
|
+
context.translate(50, 50);
|
|
34
|
+
expect(context.translate).toHaveBeenCalledWith(50, 50);
|
|
35
|
+
context.translate(-50, -50);
|
|
36
|
+
expect(context.translate).toHaveBeenCalledWith(-50, -50);
|
|
37
|
+
expect(context.rotate).toHaveBeenCalledTimes(1);
|
|
38
|
+
expect(context.rotate).toHaveBeenCalledWith(1.5707963267948966);
|
|
39
|
+
expect(context.beginPath).toHaveBeenCalledTimes(1);
|
|
40
|
+
expect(context.rect).toHaveBeenCalledTimes(0);
|
|
41
|
+
expect(context.moveTo).toHaveBeenCalledTimes(1);
|
|
42
|
+
expect(context.moveTo).toHaveBeenCalledWith(0, -25);
|
|
43
|
+
expect(context.lineTo).toHaveBeenCalledTimes(2);
|
|
44
|
+
expect(context.lineTo).toHaveBeenCalledWith(75, 50);
|
|
45
|
+
expect(context.lineTo).toHaveBeenCalledWith(0, 125);
|
|
46
|
+
expect(context.arc).toHaveBeenCalledTimes(0);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("should draw patterns from custom definitions to the context object", function () {
|
|
50
|
+
drawHatch(context, 100, {
|
|
51
|
+
"draw": [
|
|
52
|
+
{
|
|
53
|
+
"type": "arc",
|
|
54
|
+
"parameters": [
|
|
55
|
+
0.5, 0.5, 7.5, -4.14, 1.14
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"type": "arc",
|
|
60
|
+
"parameters": [
|
|
61
|
+
0.55, 0.5, 7.5, -2, 1.14
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"type": "line",
|
|
66
|
+
"parameters": [
|
|
67
|
+
[0.66, 0.75],
|
|
68
|
+
[1, 0.75]
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"type": "rect",
|
|
73
|
+
"parameters": [
|
|
74
|
+
[0, 0, 1, 1]
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
expect(context.stroke).toHaveBeenCalledTimes(4);
|
|
81
|
+
expect(context.translate).toHaveBeenCalledTimes(0);
|
|
82
|
+
expect(context.rotate).toHaveBeenCalledTimes(0);
|
|
83
|
+
expect(context.beginPath).toHaveBeenCalledTimes(4);
|
|
84
|
+
expect(context.rect).toHaveBeenCalledTimes(1);
|
|
85
|
+
expect(context.rect).toHaveBeenCalledWith(0, 0, 100, 100);
|
|
86
|
+
expect(context.moveTo).toHaveBeenCalledTimes(1);
|
|
87
|
+
expect(context.moveTo).toHaveBeenCalledWith(66, 75);
|
|
88
|
+
expect(context.lineTo).toHaveBeenCalledTimes(1);
|
|
89
|
+
expect(context.lineTo).toHaveBeenCalledWith(100, 75);
|
|
90
|
+
expect(context.arc).toHaveBeenCalledTimes(2);
|
|
91
|
+
expect(context.arc).toHaveBeenCalledWith(50, 50, 7.5, -4.14, 1.14, false);
|
|
92
|
+
expect(context.arc).toHaveBeenCalledWith(55.00000000000001, 50, 7.5, -2, 1.14, false);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import PolygonStyle from "../../../../src/vectorStyle/styles/polygon/stylePolygon";
|
|
2
|
+
import {Style} from "ol/style.js";
|
|
3
|
+
|
|
4
|
+
describe("stylePolygon", () => {
|
|
5
|
+
const feature = {
|
|
6
|
+
geometryName: "geom",
|
|
7
|
+
id: "DE.HH.UP_GESUNDHEIT_KRANKENHAEUSER_2"
|
|
8
|
+
},
|
|
9
|
+
style = {
|
|
10
|
+
type: "icon",
|
|
11
|
+
clusterType: "icon",
|
|
12
|
+
legendValue: "Krankenhaus",
|
|
13
|
+
imageName: "krankenhaus.png"
|
|
14
|
+
},
|
|
15
|
+
isClustered = false,
|
|
16
|
+
stylePolygonClass = new PolygonStyle(feature, style, isClustered);
|
|
17
|
+
|
|
18
|
+
describe("getStyle", function () {
|
|
19
|
+
it("returns an instance of openlayers style", () => {
|
|
20
|
+
expect(stylePolygonClass.getStyle()).toBeInstanceOf(Style);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe("getPolygonFillHatch", () => {
|
|
25
|
+
it("should generate a polygon fill pattern with the given parameters", () => {
|
|
26
|
+
const params = {
|
|
27
|
+
pattern: "diagonal",
|
|
28
|
+
size: 30,
|
|
29
|
+
lineWidth: 10,
|
|
30
|
+
backgroundColor: [0, 0, 0, 1],
|
|
31
|
+
patternColor: [255, 255, 255, 1]
|
|
32
|
+
},
|
|
33
|
+
canvas = stylePolygonClass.getPolygonFillHatch(params);
|
|
34
|
+
|
|
35
|
+
expect(canvas).toBeInstanceOf(HTMLCanvasElement);
|
|
36
|
+
expect(canvas.width).toEqual(30);
|
|
37
|
+
expect(canvas.height).toEqual(30);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
describe("getPolygonFillHatchLegendDataUrl", () => {
|
|
43
|
+
it("should generate a legend data URL for the given style", () => {
|
|
44
|
+
const HatchStyle = {
|
|
45
|
+
polygonFillHatch: {
|
|
46
|
+
pattern: "diagonal",
|
|
47
|
+
size: 30,
|
|
48
|
+
lineWidth: 10,
|
|
49
|
+
backgroundColor: [0, 0, 0, 1],
|
|
50
|
+
patternColor: [255, 255, 255, 1]
|
|
51
|
+
},
|
|
52
|
+
polygonStrokeColor: [0, 0, 0, 1],
|
|
53
|
+
polygonStrokeWidth: "2"
|
|
54
|
+
},
|
|
55
|
+
dataUrl = stylePolygonClass.getPolygonFillHatchLegendDataUrl(HatchStyle);
|
|
56
|
+
|
|
57
|
+
expect(dataUrl).toMatch(/^data:image\/png;base64,/);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import LineStyle from "../../../src/vectorStyle/styles/styleLine";
|
|
2
|
+
import {Style} from "ol/style.js";
|
|
3
|
+
|
|
4
|
+
describe("styleLine", () => {
|
|
5
|
+
const feature = {
|
|
6
|
+
geometryName: "geom",
|
|
7
|
+
id: "DE.HH.UP_GESUNDHEIT_KRANKENHAEUSER_2"
|
|
8
|
+
},
|
|
9
|
+
style = {
|
|
10
|
+
type: "icon",
|
|
11
|
+
clusterType: "icon",
|
|
12
|
+
legendValue: "Krankenhaus",
|
|
13
|
+
imageName: "krankenhaus.png"
|
|
14
|
+
},
|
|
15
|
+
isClustered = false,
|
|
16
|
+
styleLineClass = new LineStyle(feature, style, isClustered);
|
|
17
|
+
|
|
18
|
+
describe("initialize", function () {
|
|
19
|
+
it("returns an instance of openlayers style", () => {
|
|
20
|
+
expect(typeof styleLineClass.initialize).toBe("function");
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe("getStyle", function () {
|
|
25
|
+
it("returns an instance of openlayers style", () => {
|
|
26
|
+
expect(styleLineClass.getStyle()).toBeInstanceOf(Style);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import TextStyle from "../../../src/vectorStyle/styles/styleText";
|
|
2
|
+
import {Text} from "ol/style.js";
|
|
3
|
+
|
|
4
|
+
describe("styleText", () => {
|
|
5
|
+
const feature = {
|
|
6
|
+
geometryName: "geom",
|
|
7
|
+
id: "DE.HH.UP_GESUNDHEIT_KRANKENHAEUSER_2",
|
|
8
|
+
get: () => {
|
|
9
|
+
return [1, 2, 3];
|
|
10
|
+
},
|
|
11
|
+
getProperties: () => {
|
|
12
|
+
return feature;
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
style = {
|
|
16
|
+
type: "icon",
|
|
17
|
+
clusterType: "icon",
|
|
18
|
+
legendValue: "Krankenhaus",
|
|
19
|
+
imageName: "krankenhaus.png"
|
|
20
|
+
},
|
|
21
|
+
isClustered = false,
|
|
22
|
+
styleTextClass = new TextStyle(feature, style, isClustered);
|
|
23
|
+
|
|
24
|
+
styleTextClass.initialize(feature, style, isClustered);
|
|
25
|
+
|
|
26
|
+
describe("initialize", function () {
|
|
27
|
+
it("returns an instance of openlayers style", () => {
|
|
28
|
+
expect(typeof styleTextClass.initialize).toBe("function");
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
describe("getStyle", function () {
|
|
33
|
+
it("returns an instance of openlayers style", () => {
|
|
34
|
+
expect(styleTextClass.getStyle()).toBeInstanceOf(Text);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe("createClusteredTextStyle", function () {
|
|
39
|
+
it("returns an instance of openlayers style", () => {
|
|
40
|
+
expect(styleTextClass.createClusteredTextStyle()).toBeInstanceOf(Text);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe("createLabeledTextStyle", function () {
|
|
45
|
+
it("returns an instance of openlayers style", () => {
|
|
46
|
+
expect(styleTextClass.createLabeledTextStyle()).toBeInstanceOf(Text);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
});
|