@masterportal/masterportalapi 2.12.0 → 2.14.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 +19 -1
- package/example/config/portal.json +8 -1
- package/example/config/services.json +10 -0
- package/example/index.js +34 -2
- package/jest.config.js +1 -1
- package/jest.setup.js +9 -1
- package/package.json +63 -63
- package/src/layer/geojson/index.js +3 -3
- package/src/lib/attributeMapper.js +231 -0
- package/src/lib/getValueFromObjectByPath.js +73 -0
- package/src/lib/thousandsSeparator.js +23 -0
- package/src/maps/olcs/3dUtils/wmsRasterSynchronizer.js +3 -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/lib/attributeMapper.test.js +290 -0
- package/test/lib/getValueFromObjectByPath.test.js +61 -0
- package/test/lib/thousandsSeparator.test.js +58 -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,172 @@
|
|
|
1
|
+
import {mapAttributes, isObjectPath} from "../../lib/attributeMapper";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* get value without comma and into number format
|
|
5
|
+
* @param {string|number} value the parameter
|
|
6
|
+
* @returns {number} the parsed value
|
|
7
|
+
*/
|
|
8
|
+
export function getValueWithoutComma (value) {
|
|
9
|
+
if (typeof value === "string" && value.indexOf(",") > -1) {
|
|
10
|
+
return parseFloat(value.replace(",", "."));
|
|
11
|
+
}
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Returns the reference value. If necessary it loops through the feature properties object structure.
|
|
17
|
+
* @param {object} featureProperties properties of the feature
|
|
18
|
+
* @param {string} value attribute value or object path to check
|
|
19
|
+
* @returns {void} attribute property can be of any type
|
|
20
|
+
*/
|
|
21
|
+
export function getReferenceValue (featureProperties, value) {
|
|
22
|
+
const valueIsObjectPath = isObjectPath(value);
|
|
23
|
+
let referenceValue = value;
|
|
24
|
+
|
|
25
|
+
// sets the real feature property value in case referenceValue is an object path
|
|
26
|
+
if (valueIsObjectPath) {
|
|
27
|
+
referenceValue = mapAttributes(featureProperties, referenceValue, false);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// sets the real feature property values also for min-max-arrays in case its values are object pathes.
|
|
31
|
+
if (Array.isArray(referenceValue)) {
|
|
32
|
+
referenceValue.forEach((element, index, arr) => {
|
|
33
|
+
if (isObjectPath(element)) {
|
|
34
|
+
arr[index] = mapAttributes(featureProperties, element, false);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return referenceValue;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Compares values according to its type.
|
|
43
|
+
* @param {string|number} featureValue value to compare
|
|
44
|
+
* @param {string|number|array} referenceValue value to compare
|
|
45
|
+
* @returns {Boolean} true if values equal or in range
|
|
46
|
+
*/
|
|
47
|
+
export function compareValues (featureValue, referenceValue) {
|
|
48
|
+
let value = featureValue;
|
|
49
|
+
|
|
50
|
+
// plain value compare for strings
|
|
51
|
+
if (typeof featureValue === "string" && typeof referenceValue === "string") {
|
|
52
|
+
if (featureValue === referenceValue) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// plain value compare for boolean
|
|
58
|
+
if (typeof featureValue === "boolean" && typeof referenceValue === "boolean") {
|
|
59
|
+
if (featureValue === referenceValue) {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// plain value compare trying to parse featureValue to float
|
|
65
|
+
else if (typeof referenceValue === "number") {
|
|
66
|
+
value = parseFloat(value);
|
|
67
|
+
|
|
68
|
+
if (!isNaN(featureValue) && value === parseFloat(referenceValue)) {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// compare value in range
|
|
73
|
+
else if (Array.isArray(referenceValue) && referenceValue.every(element => typeof element === "number" || element === null) && (referenceValue.length === 2 || referenceValue.length === 4)) {
|
|
74
|
+
value = parseFloat(getValueWithoutComma(value));
|
|
75
|
+
if (!isNaN(getValueWithoutComma(featureValue))) {
|
|
76
|
+
// value in absolute range of numbers [minValue, maxValue]
|
|
77
|
+
if (referenceValue.length === 2) {
|
|
78
|
+
// do nothing
|
|
79
|
+
}
|
|
80
|
+
// value in relative range of numbers [minValue, maxValue, relMin, relMax]
|
|
81
|
+
else if (referenceValue.length === 4) {
|
|
82
|
+
value = 1 / (parseFloat(referenceValue[3], 10) - parseFloat(referenceValue[2], 10)) * (value - parseFloat(referenceValue[2], 10));
|
|
83
|
+
}
|
|
84
|
+
if (referenceValue[0] === null && referenceValue[1] === null) {
|
|
85
|
+
// everything is in a range of [null, null]
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
else if (referenceValue[0] === null) {
|
|
89
|
+
// if a range [null, x] is given, x should not be included
|
|
90
|
+
return value < parseFloat(referenceValue[1]);
|
|
91
|
+
}
|
|
92
|
+
else if (referenceValue[1] === null) {
|
|
93
|
+
// if a range [x, null] is given, x should be included
|
|
94
|
+
return value >= parseFloat(referenceValue[0]);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// if a range [x, y] is given, x should be included but y should not be included
|
|
98
|
+
return value >= parseFloat(referenceValue[0]) && value < parseFloat(referenceValue[1]);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Checks one feature against one property returning true if property satisfies condition.
|
|
106
|
+
* if clustering is activated, the parameter featureProperties has an array of feautures. only the first feature
|
|
107
|
+
* from the array is relevant at point, because only individual features are styled here.
|
|
108
|
+
* The styling of clustered features happens in another function.
|
|
109
|
+
* @param {object} featureProperties properties of the feature that has to be checked
|
|
110
|
+
* @param {string} key attribute name or object path to check
|
|
111
|
+
* @param {string|number|array} value attribute value or object path to check
|
|
112
|
+
* @returns {Boolean} true if property is satisfied. Otherwhile returns false.
|
|
113
|
+
*/
|
|
114
|
+
export function checkProperty (featureProperties, key, value) {
|
|
115
|
+
let featureProperty = featureProperties;
|
|
116
|
+
|
|
117
|
+
// if they are clustered features, then the first one is taken from the array
|
|
118
|
+
if (typeof featureProperties === "object" && Object.prototype.hasOwnProperty.call(featureProperties, "features")) {
|
|
119
|
+
if (Array.isArray(featureProperties.features) && featureProperties.features.length > 0) {
|
|
120
|
+
featureProperty = featureProperties.features[0].getProperties();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const featureValue = mapAttributes(featureProperty, key, false),
|
|
125
|
+
referenceValue = getReferenceValue(featureProperty, value);
|
|
126
|
+
|
|
127
|
+
if ((typeof featureValue === "boolean" || typeof featureValue === "string" || typeof featureValue === "number") && (typeof referenceValue === "boolean" || typeof referenceValue === "string" || typeof referenceValue === "number" ||
|
|
128
|
+
(Array.isArray(referenceValue) && referenceValue.every(element => typeof element === "number" || element === null) &&
|
|
129
|
+
(referenceValue.length === 2 || referenceValue.length === 4)))) {
|
|
130
|
+
return compareValues(featureValue, referenceValue);
|
|
131
|
+
}
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Loops one feature through all properties returning true if all properties are satisfied.
|
|
137
|
+
* Returns also true if rule has no "conditions" to check.
|
|
138
|
+
* @param {ol/feature} feature to check
|
|
139
|
+
* @param {object} rule the rule to check
|
|
140
|
+
* @returns {Boolean} true if all properties are satisfied
|
|
141
|
+
*/
|
|
142
|
+
export function checkProperties (feature, rule) {
|
|
143
|
+
if (rule?.conditions?.properties) {
|
|
144
|
+
const featureProperties = feature.getProperties(),
|
|
145
|
+
properties = rule.conditions.properties;
|
|
146
|
+
let key,
|
|
147
|
+
i;
|
|
148
|
+
|
|
149
|
+
if (Array.isArray(properties)) {
|
|
150
|
+
for (i in properties) {
|
|
151
|
+
const value = properties[i].value;
|
|
152
|
+
|
|
153
|
+
key = properties[i].attrName;
|
|
154
|
+
|
|
155
|
+
if (checkProperty(featureProperties, key, value)) {
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
for (key in properties) {
|
|
162
|
+
const value = properties[key];
|
|
163
|
+
|
|
164
|
+
if (!checkProperty(featureProperties, key, value)) {
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import defaultStyle from "./styles/defaultStyles";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* styleList that stores all the vector styles contained in style.json.
|
|
5
|
+
* Only the styles of the configured layers are kept.
|
|
6
|
+
* If a tool has an attribute "styleId", then also this style is kept.
|
|
7
|
+
* The styleId can be a string or an array of strings or an array of objects that need to have the attribute "id".
|
|
8
|
+
* example "myStyleId", ["myStyleId2", "myStyleId3"], [{"id": "myStyleId4", "name": "I am not relevant for the style"}]
|
|
9
|
+
* @type{Array}
|
|
10
|
+
* @ignore
|
|
11
|
+
*/
|
|
12
|
+
let styleList,
|
|
13
|
+
configuredLayers,
|
|
14
|
+
configuredTools,
|
|
15
|
+
mapMarkerPointStyleId,
|
|
16
|
+
mapMarkerPolygonStyleId,
|
|
17
|
+
highlightFeaturesPointStyleId,
|
|
18
|
+
highlightFeaturesPolygonStyleId,
|
|
19
|
+
highlightFeaturesLineStyleId,
|
|
20
|
+
styleConf,
|
|
21
|
+
featureViaUrlLayers;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Gathers the styleIds of the layers.
|
|
25
|
+
* @returns {Sting[]} - StyleIds from layers.
|
|
26
|
+
*/
|
|
27
|
+
function getStyleIdsFromLayers () {
|
|
28
|
+
const styleIds = [];
|
|
29
|
+
|
|
30
|
+
if (configuredLayers) {
|
|
31
|
+
configuredLayers.forEach(layer => {
|
|
32
|
+
if (layer.typ === "WFS" || layer.typ === "GeoJSON" || layer.typ === "SensorThings" || layer.typ === "TileSet3D") {
|
|
33
|
+
if (layer?.styleId) {
|
|
34
|
+
styleIds.push(layer.styleId);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else if (layer.typ === "GROUP") {
|
|
38
|
+
layer.children.forEach(child => {
|
|
39
|
+
if (child?.styleId) {
|
|
40
|
+
styleIds.push(child.styleId);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return styleIds;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Gathers the styleIds of the configured tools.
|
|
51
|
+
* @returns {String[]} - StyleIds of Tools
|
|
52
|
+
*/
|
|
53
|
+
function getStyleIdsFromTools () {
|
|
54
|
+
const styleIds = [];
|
|
55
|
+
|
|
56
|
+
if (configuredTools) {
|
|
57
|
+
configuredTools.forEach(tool => {
|
|
58
|
+
if (tool?.styleId) {
|
|
59
|
+
if (Array.isArray(tool.styleId)) {
|
|
60
|
+
tool.styleId.forEach(styleIdInArray => {
|
|
61
|
+
if (styleIdInArray instanceof Object) {
|
|
62
|
+
styleIds.push(styleIdInArray.id);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
styleIds.push(styleIdInArray);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
styleIds.push(tool.styleId);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return styleIds;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* gets style id from MapMarker
|
|
80
|
+
* @returns {String} - Style id of mapMarker.
|
|
81
|
+
*/
|
|
82
|
+
function getStyleIdForMapMarkerPoint () {
|
|
83
|
+
let styleId;
|
|
84
|
+
|
|
85
|
+
if (mapMarkerPointStyleId) {
|
|
86
|
+
styleId = mapMarkerPointStyleId;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
styleId = "defaultMapMarkerPoint";
|
|
90
|
+
}
|
|
91
|
+
return styleId;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* gets style id from HighlightFeatures
|
|
96
|
+
* @returns {String} - Style id of highlightFeatures.
|
|
97
|
+
*/
|
|
98
|
+
function getStyleIdForHighlightFeaturesPoint () {
|
|
99
|
+
let styleId;
|
|
100
|
+
|
|
101
|
+
if (highlightFeaturesPointStyleId) {
|
|
102
|
+
styleId = highlightFeaturesPointStyleId;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
styleId = "defaultHighlightFeaturesPoint";
|
|
106
|
+
}
|
|
107
|
+
return styleId;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* gets style id from HighlightFeatures
|
|
112
|
+
* @returns {String} - Style id of highlightFeatures.
|
|
113
|
+
*/
|
|
114
|
+
function getStyleIdForHighlightFeaturesLine () {
|
|
115
|
+
let styleId;
|
|
116
|
+
|
|
117
|
+
if (highlightFeaturesLineStyleId) {
|
|
118
|
+
styleId = highlightFeaturesLineStyleId;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
styleId = "defaultHighlightFeaturesLine";
|
|
122
|
+
}
|
|
123
|
+
return styleId;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* gets style id from MapMarker
|
|
128
|
+
* @returns {String} - Style id of mapMarker.
|
|
129
|
+
*/
|
|
130
|
+
function getStyleIdForMapMarkerPolygon () {
|
|
131
|
+
let styleId;
|
|
132
|
+
|
|
133
|
+
if (mapMarkerPolygonStyleId) {
|
|
134
|
+
styleId = mapMarkerPolygonStyleId;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
styleId = "defaultMapMarkerPolygon";
|
|
138
|
+
}
|
|
139
|
+
return styleId;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* gets style id from HighlightFeatures
|
|
144
|
+
* @returns {String} - Style id of highlightFeatures.
|
|
145
|
+
*/
|
|
146
|
+
function getStyleIdForHighlightFeaturesPolygon () {
|
|
147
|
+
let styleId;
|
|
148
|
+
|
|
149
|
+
if (highlightFeaturesPolygonStyleId) {
|
|
150
|
+
styleId = highlightFeaturesPolygonStyleId;
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
styleId = "defaultHighlightFeaturesPolygon";
|
|
154
|
+
}
|
|
155
|
+
return styleId;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Checks whether the module featureViaURL is activated and retrieves the styleIds.
|
|
160
|
+
* @returns {String[]} Array of styleIds for the layers for the features given via the URL.
|
|
161
|
+
*/
|
|
162
|
+
function getFeatureViaURLStyles () {
|
|
163
|
+
const styleIds = [];
|
|
164
|
+
|
|
165
|
+
if (featureViaUrlLayers !== undefined) {
|
|
166
|
+
featureViaUrlLayers.forEach(layer => {
|
|
167
|
+
styleIds.push(layer.styleId);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
return styleIds;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* overwrite parse function so that only the style objects are saved
|
|
175
|
+
* whose layers are configured in the config.json
|
|
176
|
+
* After that these objects are automatically added to the collection
|
|
177
|
+
* @param {object[]} data parsed style.json
|
|
178
|
+
* @return {object[]} filtered style.json objects
|
|
179
|
+
*/
|
|
180
|
+
function parseStyles (data) {
|
|
181
|
+
const dataWithDefaultValue = [...data];
|
|
182
|
+
let styleIds = [],
|
|
183
|
+
filteredData = [];
|
|
184
|
+
|
|
185
|
+
dataWithDefaultValue.push({styleId: "default", rules: [{style: {}}]},
|
|
186
|
+
defaultStyle.defaultMapMarkerPoint,
|
|
187
|
+
defaultStyle.defaultMapMarkerPolygon,
|
|
188
|
+
defaultStyle.defaultHighlightFeaturesPoint,
|
|
189
|
+
defaultStyle.defaultHighlightFeaturesPolygon,
|
|
190
|
+
defaultStyle.defaultHighlightFeaturesLine);
|
|
191
|
+
|
|
192
|
+
styleIds.push(getStyleIdsFromLayers(),
|
|
193
|
+
getStyleIdForMapMarkerPoint(),
|
|
194
|
+
getStyleIdForMapMarkerPolygon(),
|
|
195
|
+
getStyleIdForHighlightFeaturesPoint(),
|
|
196
|
+
getStyleIdForHighlightFeaturesPolygon(),
|
|
197
|
+
getStyleIdForHighlightFeaturesLine(),
|
|
198
|
+
getStyleIdsFromTools(),
|
|
199
|
+
getFeatureViaURLStyles());
|
|
200
|
+
|
|
201
|
+
styleIds = styleIds.reduce((acc, val) => acc.concat(val), []);
|
|
202
|
+
filteredData = dataWithDefaultValue.filter(styleObject => styleIds.includes(styleObject.styleId));
|
|
203
|
+
|
|
204
|
+
return filteredData;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Initializes the style list with fetching the services.json.
|
|
209
|
+
* [styleConf="https://geoportal-hamburg.de/lgv-config/style_v3.json"] - the URL to fetch the services from.
|
|
210
|
+
* @param {object} [styleGetters] - object with the needed getters from vue store
|
|
211
|
+
* @param {object} [Config] - the Config.js object
|
|
212
|
+
* @param {array} [layers] - an array with the configured layers
|
|
213
|
+
* @param {array} [tools] - an array with the configured tools
|
|
214
|
+
* @param {function} [callback] - called with services after loaded; called with false and error on error
|
|
215
|
+
* @returns {undefined} nothing, add callback to receive styleList
|
|
216
|
+
*/
|
|
217
|
+
function initializeStyleList (styleGetters, Config, layers, tools, callback) {
|
|
218
|
+
configuredLayers = layers;
|
|
219
|
+
configuredTools = tools;
|
|
220
|
+
|
|
221
|
+
mapMarkerPointStyleId = styleGetters.mapMarkerPointStyleId;
|
|
222
|
+
mapMarkerPolygonStyleId = styleGetters.mapMarkerPolygonStyleId;
|
|
223
|
+
highlightFeaturesPointStyleId = styleGetters.highlightFeaturesPointStyleId;
|
|
224
|
+
highlightFeaturesPolygonStyleId = styleGetters.highlightFeaturesPolygonStyleId;
|
|
225
|
+
highlightFeaturesLineStyleId = styleGetters.highlightFeaturesLineStyleId;
|
|
226
|
+
|
|
227
|
+
styleConf = Config.styleConf;
|
|
228
|
+
featureViaUrlLayers = Config.featureViaURL?.layers;
|
|
229
|
+
|
|
230
|
+
const xhr = new XMLHttpRequest();
|
|
231
|
+
|
|
232
|
+
xhr.open("GET", styleConf, false);
|
|
233
|
+
xhr.onreadystatechange = function (event) {
|
|
234
|
+
const target = event.target,
|
|
235
|
+
status = target.status;
|
|
236
|
+
let data;
|
|
237
|
+
|
|
238
|
+
if (status === 200) {
|
|
239
|
+
try {
|
|
240
|
+
data = JSON.parse(target.response);
|
|
241
|
+
}
|
|
242
|
+
catch (error) {
|
|
243
|
+
console.error("An error occured when parsing the response after loading '" + styleConf + "':", error);
|
|
244
|
+
return callback(false, error);
|
|
245
|
+
}
|
|
246
|
+
styleList = parseStyles(data);
|
|
247
|
+
}
|
|
248
|
+
else if (status === 404) {
|
|
249
|
+
console.error("An error occured when trying to fetch services from '" + styleConf + "':", 404);
|
|
250
|
+
return callback(false, true);
|
|
251
|
+
}
|
|
252
|
+
return callback(styleList);
|
|
253
|
+
};
|
|
254
|
+
xhr.send();
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* adds a style to the style list
|
|
259
|
+
* @param {Array} jsonStyles Array of styles
|
|
260
|
+
* @returns {void}
|
|
261
|
+
*/
|
|
262
|
+
function addToStyleList (jsonStyles) {
|
|
263
|
+
jsonStyles.forEach(style => {
|
|
264
|
+
styleList.push(style);
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Returns style object by styleId or by layerId
|
|
270
|
+
* @param {string} layerId layerId
|
|
271
|
+
* @returns {object} style object
|
|
272
|
+
*/
|
|
273
|
+
function returnStyleObject (layerId) {
|
|
274
|
+
return styleList?.find(styleObject => styleObject.styleId === layerId);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export default {
|
|
278
|
+
initializeStyleList,
|
|
279
|
+
addToStyleList,
|
|
280
|
+
returnStyleObject
|
|
281
|
+
};
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
const defaultColors = {
|
|
2
|
+
background: [255, 255, 255, 0],
|
|
3
|
+
fill: [10, 200, 100, 0.5],
|
|
4
|
+
stroke: [0, 0, 0, 1],
|
|
5
|
+
textFill: [255, 255, 255, 1],
|
|
6
|
+
textStroke: [0, 0, 0, 0]
|
|
7
|
+
},
|
|
8
|
+
defaultStyle = {
|
|
9
|
+
point: {
|
|
10
|
+
feature: null,
|
|
11
|
+
isClustered: false,
|
|
12
|
+
type: "circle",
|
|
13
|
+
imagePath: "",
|
|
14
|
+
// für type icon
|
|
15
|
+
imageName: "blank.png",
|
|
16
|
+
imageWidth: 1,
|
|
17
|
+
imageHeight: 1,
|
|
18
|
+
imageScale: 1,
|
|
19
|
+
imageOffsetX: 0.5,
|
|
20
|
+
imageOffsetY: 0.5,
|
|
21
|
+
imageOffsetXUnit: "fraction",
|
|
22
|
+
imageOffsetYUnit: "fraction",
|
|
23
|
+
// for type circle
|
|
24
|
+
circleRadius: 10,
|
|
25
|
+
circleFillColor: defaultColors.fill,
|
|
26
|
+
circleStrokeColor: defaultColors.stroke,
|
|
27
|
+
circleStrokeWidth: 2,
|
|
28
|
+
clusterType: "circle",
|
|
29
|
+
// for type circle
|
|
30
|
+
clusterCircleRadius: 15,
|
|
31
|
+
clusterCircleFillColor: defaultColors.fill,
|
|
32
|
+
clusterCircleStrokeColor: defaultColors.stroke,
|
|
33
|
+
clusterCircleStrokeWidth: 2,
|
|
34
|
+
// for type icon
|
|
35
|
+
clusterImageName: "blank.png",
|
|
36
|
+
clusterImageWidth: 1,
|
|
37
|
+
clusterImageHeight: 1,
|
|
38
|
+
clusterImageScale: 1,
|
|
39
|
+
clusterImageOffsetX: 0.5,
|
|
40
|
+
clusterImageOffsetY: 0.5,
|
|
41
|
+
// Für scalingShape CIRCLESEGMENTS
|
|
42
|
+
circleSegmentsRadius: 10,
|
|
43
|
+
circleSegmentsStrokeWidth: 4,
|
|
44
|
+
circleSegmentsBackgroundColor: defaultColors.background,
|
|
45
|
+
scalingValueDefaultColor: defaultColors.stroke,
|
|
46
|
+
circleSegmentsGap: 10,
|
|
47
|
+
// Für scalingShape CIRCLE_BAR
|
|
48
|
+
circleBarScalingFactor: 1,
|
|
49
|
+
circleBarRadius: 6,
|
|
50
|
+
circleBarLineStroke: 5,
|
|
51
|
+
circleBarCircleFillColor: defaultColors.fill,
|
|
52
|
+
circleBarCircleStrokeColor: defaultColors.stroke,
|
|
53
|
+
circleBarCircleStrokeWidth: 1,
|
|
54
|
+
circleBarLineStrokeColor: defaultColors.stroke,
|
|
55
|
+
scalingAttribute: "",
|
|
56
|
+
rotation: 0,
|
|
57
|
+
// for type regularShape
|
|
58
|
+
rsRadius: 10,
|
|
59
|
+
rsRadius2: undefined,
|
|
60
|
+
rsPoints: 3,
|
|
61
|
+
rsFillColor: [0, 153, 255, 1],
|
|
62
|
+
rsStrokeColor: [0, 0, 0, 1],
|
|
63
|
+
rsStrokeWidth: 5,
|
|
64
|
+
rsAngle: 0,
|
|
65
|
+
rsScale: undefined
|
|
66
|
+
},
|
|
67
|
+
line: {
|
|
68
|
+
lineStrokeColor: defaultColors.stroke,
|
|
69
|
+
lineStrokeWidth: 5,
|
|
70
|
+
lineStrokeCap: "round",
|
|
71
|
+
lineStrokeJoin: "round",
|
|
72
|
+
lineStrokeDash: undefined,
|
|
73
|
+
lineStrokeDashOffset: 0,
|
|
74
|
+
lineStrokeMiterLimit: 10
|
|
75
|
+
},
|
|
76
|
+
polygon: {
|
|
77
|
+
// for stroke
|
|
78
|
+
polygonStrokeColor: defaultColors.stroke,
|
|
79
|
+
polygonStrokeWidth: 1,
|
|
80
|
+
polygonStrokeCap: "round",
|
|
81
|
+
polygonStrokeJoin: "round",
|
|
82
|
+
polygonStrokeDash: undefined,
|
|
83
|
+
polygonStrokeDashOffset: 0,
|
|
84
|
+
polygonStrokeMiterLimit: 10,
|
|
85
|
+
// for fill
|
|
86
|
+
polygonFillColor: defaultColors.fill,
|
|
87
|
+
polygonFillHatch: undefined
|
|
88
|
+
},
|
|
89
|
+
text: {
|
|
90
|
+
textAlign: "center",
|
|
91
|
+
textFont: "Comic Sans MS",
|
|
92
|
+
textScale: 2,
|
|
93
|
+
textOffsetX: 10,
|
|
94
|
+
textOffsetY: -8,
|
|
95
|
+
textFillColor: defaultColors.textFill,
|
|
96
|
+
textStrokeColor: defaultColors.textStroke,
|
|
97
|
+
textStrokeWidth: 3,
|
|
98
|
+
labelField: "",
|
|
99
|
+
textSuffix: "",
|
|
100
|
+
rotation: 0,
|
|
101
|
+
clusterTextType: "counter",
|
|
102
|
+
clusterText: "",
|
|
103
|
+
clusterTextAlign: "center",
|
|
104
|
+
clusterTextFont: "Comic Sans MS",
|
|
105
|
+
clusterTextScale: 2,
|
|
106
|
+
clusterTextOffsetX: 0,
|
|
107
|
+
clusterTextOffsetY: 2,
|
|
108
|
+
clusterTextFillColor: defaultColors.textFill,
|
|
109
|
+
clusterTextStrokeColor: defaultColors.textStroke,
|
|
110
|
+
clusterTextStrokeWidth: 0
|
|
111
|
+
},
|
|
112
|
+
defaultMapMarkerPoint: {
|
|
113
|
+
styleId: "defaultMapMarkerPoint",
|
|
114
|
+
rules: [{
|
|
115
|
+
style:
|
|
116
|
+
{
|
|
117
|
+
type: "icon",
|
|
118
|
+
imageName: `<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='#E10019' class='bi bi-geo-alt-fill' viewBox='0 0 16 16'>
|
|
119
|
+
<path d='M8 16s6-5.686 6-10A6 6 0 0 0 2 6c0 4.314 6 10 6 10zm0-7a3 3 0 1 1 0-6 3 3 0 0 1 0 6z'/>
|
|
120
|
+
</svg>`,
|
|
121
|
+
imagePath: "",
|
|
122
|
+
imageScale: 2,
|
|
123
|
+
imageOffsetY: 16,
|
|
124
|
+
imageOffsetYUnit: "pixels"
|
|
125
|
+
}
|
|
126
|
+
}]
|
|
127
|
+
},
|
|
128
|
+
defaultMapMarkerPolygon: {
|
|
129
|
+
styleId: "defaultMapMarkerPolygon",
|
|
130
|
+
rules: [{
|
|
131
|
+
style:
|
|
132
|
+
{
|
|
133
|
+
polygonStrokeColor: [8, 119, 95, 1],
|
|
134
|
+
polygonStrokeWidth: 4,
|
|
135
|
+
polygonFillColor: [8, 119, 95, 0.3],
|
|
136
|
+
polygonStrokeDash: [8]
|
|
137
|
+
}
|
|
138
|
+
}]
|
|
139
|
+
},
|
|
140
|
+
defaultHighlightFeaturesPoint: {
|
|
141
|
+
styleId: "defaultHighlightFeaturesPoint",
|
|
142
|
+
rules: [{
|
|
143
|
+
style:
|
|
144
|
+
{
|
|
145
|
+
type: "circle",
|
|
146
|
+
circleFillColor: [255, 255, 0, 0.9],
|
|
147
|
+
circleRadius: 8
|
|
148
|
+
}
|
|
149
|
+
}]
|
|
150
|
+
},
|
|
151
|
+
defaultHighlightFeaturesPolygon: {
|
|
152
|
+
styleId: "defaultHighlightFeaturesPolygon",
|
|
153
|
+
rules: [{
|
|
154
|
+
style:
|
|
155
|
+
{
|
|
156
|
+
polygonStrokeColor: [8, 119, 95, 1],
|
|
157
|
+
polygonStrokeWidth: 4,
|
|
158
|
+
polygonFillColor: [8, 119, 95, 0.3],
|
|
159
|
+
polygonStrokeDash: [8]
|
|
160
|
+
}
|
|
161
|
+
}]
|
|
162
|
+
},
|
|
163
|
+
defaultHighlightFeaturesLine: {
|
|
164
|
+
styleId: "defaultHighlightFeaturesLine",
|
|
165
|
+
rules: [{
|
|
166
|
+
style:
|
|
167
|
+
{
|
|
168
|
+
polygonStrokeColor: [8, 119, 95, 1],
|
|
169
|
+
polygonStrokeWidth: 4,
|
|
170
|
+
polygonFillColor: [8, 119, 95, 0.3],
|
|
171
|
+
polygonStrokeDash: [8]
|
|
172
|
+
}
|
|
173
|
+
}]
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export default defaultStyle;
|