@vcmap/core 5.0.0-rc.8 → 5.0.0-rc.9
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/index.d.ts +110 -102
- package/index.js +4 -5
- package/package.json +2 -2
- package/src/category/appBackedCategory.js +38 -3
- package/src/category/category.js +37 -10
- package/src/category/categoryCollection.js +3 -3
- package/src/classRegistry.js +107 -28
- package/src/featureProvider/abstractFeatureProvider.js +1 -1
- package/src/featureProvider/tileProviderFeatureProvider.js +2 -0
- package/src/featureProvider/wmsFeatureProvider.js +2 -0
- package/src/layer/cesiumTilesetLayer.js +3 -6
- package/src/layer/czmlLayer.js +2 -2
- package/src/layer/dataSourceLayer.js +2 -2
- package/src/layer/featureLayer.js +10 -23
- package/src/layer/featureStoreLayer.js +3 -3
- package/src/layer/geojsonHelpers.js +1 -18
- package/src/layer/geojsonLayer.js +2 -2
- package/src/layer/layer.js +3 -3
- package/src/layer/openStreetMapLayer.js +2 -2
- package/src/layer/pointCloudLayer.js +4 -4
- package/src/layer/rasterLayer.js +2 -2
- package/src/layer/singleImageLayer.js +2 -2
- package/src/layer/terrainLayer.js +2 -2
- package/src/layer/tileProvider/mvtTileProvider.js +18 -0
- package/src/layer/tileProvider/staticGeojsonTileProvider.js +19 -4
- package/src/layer/tileProvider/tileProvider.js +10 -1
- package/src/layer/tileProvider/urlTemplateTileProvider.js +15 -0
- package/src/layer/tmsLayer.js +2 -2
- package/src/layer/vectorLayer.js +9 -18
- package/src/layer/vectorTileLayer.js +12 -21
- package/src/layer/wfsLayer.js +2 -2
- package/src/layer/wmsLayer.js +2 -2
- package/src/layer/wmtsLayer.js +2 -2
- package/src/map/baseOLMap.js +2 -2
- package/src/map/cesiumMap.js +2 -2
- package/src/map/obliqueMap.js +2 -2
- package/src/map/openlayersMap.js +2 -2
- package/src/map/vcsMap.js +2 -2
- package/src/overrideClassRegistry.js +204 -0
- package/src/style/declarativeStyleItem.js +17 -18
- package/src/style/styleFactory.js +14 -33
- package/src/style/styleItem.js +15 -96
- package/src/style/vectorStyleItem.js +68 -78
- package/src/style/writeStyle.js +4 -7
- package/src/util/projection.js +0 -3
- package/src/util/viewpoint.js +0 -3
- package/src/vcsApp.js +103 -5
- package/src/vcsAppContextHelpers.js +51 -38
- package/src/globalCollections.js +0 -7
- package/src/layer/tileProvider/tileProviderFactory.js +0 -28
|
@@ -6,7 +6,7 @@ import Circle from 'ol/style/Circle.js';
|
|
|
6
6
|
import OLText from 'ol/style/Text.js';
|
|
7
7
|
import Fill from 'ol/style/Fill.js';
|
|
8
8
|
|
|
9
|
-
import StyleItem
|
|
9
|
+
import StyleItem from './styleItem.js';
|
|
10
10
|
import {
|
|
11
11
|
cesiumColorToColor,
|
|
12
12
|
emptyStyle,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
whiteColor,
|
|
15
15
|
} from './styleHelpers.js';
|
|
16
16
|
import { originalFeatureSymbol } from '../layer/vectorSymbols.js';
|
|
17
|
-
import {
|
|
17
|
+
import { styleClassRegistry } from '../classRegistry.js';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* @typedef {Object} DeclarativeStyleItemConditions
|
|
@@ -119,7 +119,7 @@ class DeclarativeStyleItem extends StyleItem {
|
|
|
119
119
|
if (declarativeStyle.strokeWidth) {
|
|
120
120
|
addCustomProperty(this.cesiumStyle, 'strokeWidth', declarativeStyle);
|
|
121
121
|
}
|
|
122
|
-
/** @type {DeclarativeStyleOptions} */
|
|
122
|
+
/** @type {DeclarativeStyleOptions} */ // XXX is this even still needed?
|
|
123
123
|
this._styleOptions = declarativeStyle;
|
|
124
124
|
|
|
125
125
|
/** @type {Map<string,import("ol/style/Circle").default>} */
|
|
@@ -127,22 +127,18 @@ class DeclarativeStyleItem extends StyleItem {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
/**
|
|
130
|
-
* @param {DeclarativeStyleItemSections=} sections
|
|
131
130
|
* @returns {DeclarativeStyleItemOptions}
|
|
132
131
|
* @api
|
|
133
132
|
*/
|
|
134
|
-
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
if (usedSections.declarativeStyle) {
|
|
142
|
-
options.declarativeStyle = this.cesiumStyle.style;
|
|
143
|
-
}
|
|
133
|
+
toJSON() {
|
|
134
|
+
const config = /** @type {DeclarativeStyleItemOptions} */ (super.toJSON());
|
|
135
|
+
|
|
136
|
+
config.declarativeStyle = Object.fromEntries(
|
|
137
|
+
Object.entries(this.cesiumStyle.style)
|
|
138
|
+
.filter(([, value]) => value != null),
|
|
139
|
+
);
|
|
144
140
|
|
|
145
|
-
return
|
|
141
|
+
return config;
|
|
146
142
|
}
|
|
147
143
|
|
|
148
144
|
/**
|
|
@@ -154,7 +150,9 @@ class DeclarativeStyleItem extends StyleItem {
|
|
|
154
150
|
if (result) {
|
|
155
151
|
return result.assign(this);
|
|
156
152
|
}
|
|
157
|
-
|
|
153
|
+
const config = this.toJSON();
|
|
154
|
+
delete config.name;
|
|
155
|
+
return new DeclarativeStyleItem(config);
|
|
158
156
|
}
|
|
159
157
|
|
|
160
158
|
/**
|
|
@@ -163,8 +161,9 @@ class DeclarativeStyleItem extends StyleItem {
|
|
|
163
161
|
* @api
|
|
164
162
|
*/
|
|
165
163
|
assign(styleItem) {
|
|
166
|
-
|
|
164
|
+
super.assign(styleItem);
|
|
167
165
|
this._styleOptions = this.cesiumStyle.style;
|
|
166
|
+
this.cesiumStyle = new Cesium3DTileStyle(this._styleOptions);
|
|
168
167
|
return this;
|
|
169
168
|
}
|
|
170
169
|
|
|
@@ -559,7 +558,7 @@ class DeclarativeStyleItem extends StyleItem {
|
|
|
559
558
|
}
|
|
560
559
|
|
|
561
560
|
export default DeclarativeStyleItem;
|
|
562
|
-
|
|
561
|
+
styleClassRegistry.registerClass(DeclarativeStyleItem.className, DeclarativeStyleItem);
|
|
563
562
|
|
|
564
563
|
/**
|
|
565
564
|
* @type {DeclarativeStyleItem}
|
|
@@ -1,48 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import StyleItem
|
|
3
|
-
import
|
|
1
|
+
import { is } from '@vcsuite/check';
|
|
2
|
+
import StyleItem from './styleItem.js';
|
|
3
|
+
import { defaultDeclarativeStyle } from './declarativeStyleItem.js';
|
|
4
|
+
import { styleClassRegistry } from '../classRegistry.js';
|
|
4
5
|
import VectorStyleItem from './vectorStyleItem.js';
|
|
5
|
-
import { styleCollection } from '../globalCollections.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* @
|
|
9
|
-
*/
|
|
10
|
-
function getLogger() {
|
|
11
|
-
return getLoggerByName('styleFactory');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @param {(Reference|DeclarativeStyleItemOptions|VectorStyleItemOptions|StyleItem|string)=} styleOptions
|
|
8
|
+
* @param {(DeclarativeStyleItemOptions|VectorStyleItemOptions|StyleItem)=} styleOptions
|
|
16
9
|
* @param {StyleItem=} defaultStyle
|
|
17
10
|
* @returns {StyleItem}
|
|
18
11
|
*/
|
|
19
12
|
// eslint-disable-next-line import/prefer-default-export
|
|
20
13
|
export function getStyleOrDefaultStyle(styleOptions, defaultStyle) {
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
getLogger().warning(`could not find style with name ${styleOptions}`);
|
|
27
|
-
} else if (styleOptions && (styleOptions instanceof StyleItem)) {
|
|
28
|
-
return styleOptions;
|
|
29
|
-
} else if (styleOptions) { // DeclarativeStyleItemOptions || VectorStyleItemOptions || ClusterStyleItemOptions
|
|
30
|
-
if (
|
|
31
|
-
/** @type {DeclarativeStyleItemOptions} */ (styleOptions).type === StyleType.DECLARATIVE ||
|
|
32
|
-
/** @type {DeclarativeStyleItemOptions} */ (styleOptions).declarativeStyle) {
|
|
33
|
-
return new DeclarativeStyleItem(/** @type {DeclarativeStyleItemOptions} */ (styleOptions));
|
|
34
|
-
} else if (/** @type {Reference} */ (styleOptions).type === StyleType.REFERENCE) {
|
|
35
|
-
const { name } = /** @type {Reference} */ (styleOptions);
|
|
36
|
-
const styleItem = styleCollection.getByKey(name);
|
|
14
|
+
if (is(styleOptions, [StyleItem, { type: String }])) {
|
|
15
|
+
if (styleOptions instanceof StyleItem) {
|
|
16
|
+
return styleOptions;
|
|
17
|
+
} else {
|
|
18
|
+
const styleItem = styleClassRegistry.createFromTypeOptions(styleOptions);
|
|
37
19
|
if (styleItem) {
|
|
20
|
+
if (styleItem instanceof VectorStyleItem && defaultStyle instanceof VectorStyleItem) {
|
|
21
|
+
return defaultStyle.assign(styleItem);
|
|
22
|
+
}
|
|
38
23
|
return styleItem;
|
|
39
24
|
}
|
|
40
|
-
getLogger().warning(`could not find style with name ${name}`);
|
|
41
|
-
} else {
|
|
42
|
-
// @ts-ignore
|
|
43
|
-
const vectorStyle = new VectorStyleItem(/** @type {VectorStyleItemOptions} */ styleOptions);
|
|
44
|
-
return defaultStyle instanceof VectorStyleItem ? defaultStyle.assign(vectorStyle) : vectorStyle;
|
|
45
25
|
}
|
|
46
26
|
}
|
|
27
|
+
|
|
47
28
|
return defaultStyle || defaultDeclarativeStyle.clone();
|
|
48
29
|
}
|
package/src/style/styleItem.js
CHANGED
|
@@ -4,13 +4,7 @@ import deepEqual from 'fast-deep-equal';
|
|
|
4
4
|
import { parseEnumValue } from '@vcsuite/parsers';
|
|
5
5
|
import VcsObject from '../vcsObject.js';
|
|
6
6
|
import VcsEvent from '../vcsEvent.js';
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @namespace style
|
|
11
|
-
* @export
|
|
12
|
-
* @api
|
|
13
|
-
*/
|
|
7
|
+
import { styleClassRegistry } from '../classRegistry.js';
|
|
14
8
|
|
|
15
9
|
/**
|
|
16
10
|
* @typedef {Object} StyleItemLegendEntry
|
|
@@ -21,51 +15,16 @@ import { VcsClassRegistry } from '../classRegistry.js';
|
|
|
21
15
|
|
|
22
16
|
/**
|
|
23
17
|
* @typedef {VcsObjectOptions} StyleItemOptions
|
|
24
|
-
* @property {string|undefined} [type] - used in configuration to differentiate vector from declarative styles
|
|
25
|
-
* @property {string|Object<string, string>|undefined} title - name is used when none is specifies
|
|
26
|
-
* @property {Array<StyleItemLegendEntry>|undefined} [legend]
|
|
27
18
|
* @property {number} [colorBlendMode=import("@vcmap/cesium").Cesium3DTileColorBlendMode.HIGHLIGHT] - colorBlendMode for 3D Tiledataset @see https://cesiumjs.org/import("@vcmap/cesium").Build/Documentation/Cesium3DTileColorBlendMode.html
|
|
28
19
|
* @api
|
|
29
20
|
*/
|
|
30
21
|
|
|
31
|
-
/**
|
|
32
|
-
* @typedef {Object} Reference
|
|
33
|
-
* @property {string} [type=StyleType.REFERENCE]
|
|
34
|
-
* @property {string} name
|
|
35
|
-
* @property {string|undefined} [url] - vcs:undocumented this is not yet implemented
|
|
36
|
-
* @api
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
22
|
/**
|
|
40
23
|
* @typedef {Object} StyleItemSections
|
|
41
24
|
* @property {boolean|undefined} [meta]
|
|
42
25
|
* @api
|
|
43
26
|
*/
|
|
44
27
|
|
|
45
|
-
/**
|
|
46
|
-
* Enumeration of possible style types.
|
|
47
|
-
* @enum {string}
|
|
48
|
-
* @property {string} VECTOR
|
|
49
|
-
* @property {string} DECLARATIVE
|
|
50
|
-
* @property {string} REFERENCE
|
|
51
|
-
* @export
|
|
52
|
-
* @api
|
|
53
|
-
*/
|
|
54
|
-
export const StyleType = {
|
|
55
|
-
VECTOR: 'vector',
|
|
56
|
-
DECLARATIVE: 'declarative',
|
|
57
|
-
REFERENCE: 'reference',
|
|
58
|
-
CLUSTER: 'cluster',
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* indicates, that this style is part of the config and can be referenced by name
|
|
63
|
-
* @type {symbol}
|
|
64
|
-
* @export
|
|
65
|
-
* @api
|
|
66
|
-
*/
|
|
67
|
-
export const referenceableStyleSymbol = Symbol('referencableStyleSymbol');
|
|
68
|
-
|
|
69
28
|
/**
|
|
70
29
|
* An abstract style definition which can be applied to a layer
|
|
71
30
|
* @class
|
|
@@ -83,18 +42,6 @@ class StyleItem extends VcsObject {
|
|
|
83
42
|
constructor(options) {
|
|
84
43
|
super(options);
|
|
85
44
|
|
|
86
|
-
/**
|
|
87
|
-
* @type {string|Object<string, string>}
|
|
88
|
-
*/
|
|
89
|
-
this.title = options.title || this.name.toString();
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Legend entries
|
|
93
|
-
* @type {Array<StyleItemLegendEntry>}
|
|
94
|
-
* @api
|
|
95
|
-
*/
|
|
96
|
-
this.legend = options.legend || [];
|
|
97
|
-
|
|
98
45
|
/** @type {Array<string>} */
|
|
99
46
|
this.supportedLayers = [];
|
|
100
47
|
|
|
@@ -146,42 +93,21 @@ class StyleItem extends VcsObject {
|
|
|
146
93
|
this.supportedLayers.indexOf(className) > -1;
|
|
147
94
|
}
|
|
148
95
|
|
|
149
|
-
/**
|
|
150
|
-
* Gets the options for this style item to be used in a config or vcsMeta
|
|
151
|
-
* @param {(VectorStyleItemSections|DeclarativeStyleItemSections)=} sections
|
|
152
|
-
* @returns {VectorStyleItemOptions|DeclarativeStyleItemOptions}
|
|
153
|
-
* @api
|
|
154
|
-
*/
|
|
155
|
-
getOptions(sections) {
|
|
156
|
-
if (sections && sections.meta) {
|
|
157
|
-
return {
|
|
158
|
-
name: this.name.toString(),
|
|
159
|
-
title: this.title,
|
|
160
|
-
legend: this.legend.length ? this.legend : undefined,
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
return {};
|
|
164
|
-
}
|
|
165
|
-
|
|
166
96
|
/**
|
|
167
97
|
* @inheritDoc
|
|
168
98
|
* @returns {StyleItemOptions}
|
|
169
99
|
*/
|
|
170
100
|
toJSON() {
|
|
171
|
-
const config = {
|
|
172
|
-
if (this.
|
|
173
|
-
config.
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
if (this.legend.length > 0) {
|
|
177
|
-
config.legend = this.legend.slice();
|
|
101
|
+
const config = /** @type {StyleItemOptions} */ (super.toJSON());
|
|
102
|
+
if (this.colorBlendMode !== Cesium3DTileColorBlendMode.HIGHLIGHT) {
|
|
103
|
+
config.colorBlendMode = this.colorBlendMode;
|
|
178
104
|
}
|
|
179
105
|
|
|
180
106
|
return config;
|
|
181
107
|
}
|
|
182
108
|
|
|
183
109
|
/**
|
|
184
|
-
* Clones this style
|
|
110
|
+
* Clones this style. Does not pass the name property.
|
|
185
111
|
* @param {StyleItem=} result
|
|
186
112
|
* @returns {StyleItem}
|
|
187
113
|
* @api
|
|
@@ -194,36 +120,29 @@ class StyleItem extends VcsObject {
|
|
|
194
120
|
* @returns {StyleItem}
|
|
195
121
|
* @api
|
|
196
122
|
*/
|
|
197
|
-
|
|
198
|
-
|
|
123
|
+
assign(styleItem) {
|
|
124
|
+
this.properties = JSON.parse(JSON.stringify(styleItem.properties));
|
|
125
|
+
return this;
|
|
126
|
+
}
|
|
199
127
|
|
|
200
128
|
/**
|
|
129
|
+
* Tests if two styleItems are equivalent. Does not match the name property (e.g. identifier)
|
|
201
130
|
* @param {StyleItem} styleItem
|
|
202
131
|
* @returns {boolean}
|
|
203
132
|
* @api
|
|
204
133
|
*/
|
|
205
134
|
equals(styleItem) {
|
|
206
135
|
if (this !== styleItem) {
|
|
207
|
-
const options = this.
|
|
208
|
-
|
|
136
|
+
const options = this.toJSON();
|
|
137
|
+
delete options.name;
|
|
138
|
+
const candidateOptions = styleItem.toJSON();
|
|
139
|
+
delete candidateOptions.name;
|
|
209
140
|
return deepEqual(options, candidateOptions);
|
|
210
141
|
}
|
|
211
142
|
|
|
212
143
|
return true;
|
|
213
144
|
}
|
|
214
145
|
|
|
215
|
-
/**
|
|
216
|
-
* gets a reference to this style by its name. should only be used for static styles, aka styles already part of the config
|
|
217
|
-
* @returns {Reference}
|
|
218
|
-
* @api
|
|
219
|
-
*/
|
|
220
|
-
getReference() {
|
|
221
|
-
return {
|
|
222
|
-
type: StyleType.REFERENCE,
|
|
223
|
-
name: this.name.toString(),
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
|
|
227
146
|
/**
|
|
228
147
|
* @protected
|
|
229
148
|
*/
|
|
@@ -242,4 +161,4 @@ class StyleItem extends VcsObject {
|
|
|
242
161
|
}
|
|
243
162
|
|
|
244
163
|
export default StyleItem;
|
|
245
|
-
|
|
164
|
+
styleClassRegistry.registerClass(StyleItem.className, StyleItem);
|
|
@@ -10,7 +10,7 @@ import Circle from 'ol/style/Circle.js';
|
|
|
10
10
|
import RegularShape from 'ol/style/RegularShape.js';
|
|
11
11
|
|
|
12
12
|
import { check, checkMaybe } from '@vcsuite/check';
|
|
13
|
-
import StyleItem
|
|
13
|
+
import StyleItem from './styleItem.js';
|
|
14
14
|
import {
|
|
15
15
|
parseColor,
|
|
16
16
|
PatternType,
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
getDefaultVectorStyleItemOptions,
|
|
25
25
|
} from './styleHelpers.js';
|
|
26
26
|
import { getShapeFromOptions } from './shapesCategory.js';
|
|
27
|
-
import {
|
|
27
|
+
import { styleClassRegistry } from '../classRegistry.js';
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* @typedef {Object} VectorStyleItemPattern
|
|
@@ -711,7 +711,9 @@ class VectorStyleItem extends StyleItem {
|
|
|
711
711
|
});
|
|
712
712
|
return result;
|
|
713
713
|
}
|
|
714
|
-
|
|
714
|
+
const config = this.toJSON();
|
|
715
|
+
delete config.name;
|
|
716
|
+
return new VectorStyleItem(config);
|
|
715
717
|
}
|
|
716
718
|
|
|
717
719
|
/**
|
|
@@ -720,6 +722,7 @@ class VectorStyleItem extends StyleItem {
|
|
|
720
722
|
* @api
|
|
721
723
|
*/
|
|
722
724
|
assign(result) {
|
|
725
|
+
super.assign(result);
|
|
723
726
|
if (result.fillColor) {
|
|
724
727
|
this.fillColor = result.fillColor.slice();
|
|
725
728
|
}
|
|
@@ -756,79 +759,61 @@ class VectorStyleItem extends StyleItem {
|
|
|
756
759
|
}
|
|
757
760
|
|
|
758
761
|
/**
|
|
759
|
-
* @param {VectorStyleItemSections=} sections
|
|
760
762
|
* @returns {VectorStyleItemOptions}
|
|
761
763
|
* @api
|
|
762
764
|
*/
|
|
763
|
-
|
|
765
|
+
toJSON() {
|
|
764
766
|
// TODO clean default, only copy relevant keys
|
|
765
|
-
const options = /** @type {VectorStyleItemOptions} */ (super.
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
image: true,
|
|
773
|
-
};
|
|
774
|
-
|
|
775
|
-
if (usedSections.fill) {
|
|
776
|
-
if (this._fillOptions) {
|
|
777
|
-
options.fill = {
|
|
778
|
-
color: /** @type {import("ol/color").Color} */ (parseColor(this._fillOptions.color).slice()),
|
|
779
|
-
};
|
|
780
|
-
if (this._fillOptions.pattern) {
|
|
781
|
-
options.fill.pattern = { ...this._fillOptions.pattern };
|
|
782
|
-
}
|
|
783
|
-
} else if (this.exclude.fill) {
|
|
784
|
-
options.fill = false;
|
|
767
|
+
const options = /** @type {VectorStyleItemOptions} */ (super.toJSON());
|
|
768
|
+
if (this._fillOptions) {
|
|
769
|
+
options.fill = {
|
|
770
|
+
color: /** @type {import("ol/color").Color} */ (parseColor(this._fillOptions.color).slice()),
|
|
771
|
+
};
|
|
772
|
+
if (this._fillOptions.pattern) {
|
|
773
|
+
options.fill.pattern = { ...this._fillOptions.pattern };
|
|
785
774
|
}
|
|
775
|
+
} else if (this.exclude.fill) {
|
|
776
|
+
options.fill = false;
|
|
786
777
|
}
|
|
787
778
|
|
|
788
|
-
if (
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
options.stroke = false;
|
|
793
|
-
}
|
|
779
|
+
if (this._stroke) {
|
|
780
|
+
options.stroke = getStrokeOptions(this._stroke);
|
|
781
|
+
} else if (this.exclude.stroke) {
|
|
782
|
+
options.stroke = false;
|
|
794
783
|
}
|
|
795
784
|
|
|
796
|
-
if (
|
|
797
|
-
|
|
798
|
-
options.text = getTextOptions(this._text);
|
|
799
|
-
}
|
|
785
|
+
if (this._text) {
|
|
786
|
+
options.text = getTextOptions(this._text);
|
|
800
787
|
}
|
|
801
788
|
|
|
802
|
-
if (
|
|
789
|
+
if (this._label) {
|
|
803
790
|
options.label = this._label;
|
|
804
791
|
}
|
|
805
792
|
|
|
806
|
-
if (
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
options.image = false;
|
|
831
|
-
}
|
|
793
|
+
if (this._image instanceof Icon) {
|
|
794
|
+
options.image = {
|
|
795
|
+
src: this._image.getSrc(), // XXX this is an issue... we dont want a data URI in the geoJSON
|
|
796
|
+
scale: this._image.getScale(),
|
|
797
|
+
opacity: this._image.getOpacity(),
|
|
798
|
+
};
|
|
799
|
+
} else if (this._image instanceof Circle) {
|
|
800
|
+
options.image = {
|
|
801
|
+
scale: this._image.getScale(),
|
|
802
|
+
fill: getFillOptions(this._image),
|
|
803
|
+
radius: this._image.getRadius(),
|
|
804
|
+
stroke: this._image.getStroke() ? getStrokeOptions(this._image.getStroke()) : undefined,
|
|
805
|
+
};
|
|
806
|
+
} else if (this._image instanceof RegularShape) {
|
|
807
|
+
options.image = {
|
|
808
|
+
scale: this._image.getScale(),
|
|
809
|
+
fill: getFillOptions(this._image),
|
|
810
|
+
points: this._image.getPoints(),
|
|
811
|
+
angle: this._image.getAngle(),
|
|
812
|
+
radius: this._image.getRadius(),
|
|
813
|
+
stroke: this._image.getStroke() ? getStrokeOptions(this._image.getStroke()) : undefined,
|
|
814
|
+
};
|
|
815
|
+
} else if (this.exclude.image) {
|
|
816
|
+
options.image = false;
|
|
832
817
|
}
|
|
833
818
|
|
|
834
819
|
return options;
|
|
@@ -842,33 +827,38 @@ class VectorStyleItem extends StyleItem {
|
|
|
842
827
|
const type = feature.getGeometry().getType();
|
|
843
828
|
const extrusion = feature.get('olcs_extrudedHeight') ||
|
|
844
829
|
(feature.get('olcs_storeyHeight') && feature.get('olcs_storeyNumber'));
|
|
845
|
-
const sections =
|
|
830
|
+
const sections = new Set();
|
|
846
831
|
|
|
847
832
|
if (type === 'Point' || type === 'MultiPoint') {
|
|
848
833
|
if (feature[vectorStyleSymbol].label != null) {
|
|
849
|
-
sections.text
|
|
850
|
-
sections.label
|
|
834
|
+
sections.add('text');
|
|
835
|
+
sections.add('label');
|
|
851
836
|
}
|
|
852
|
-
sections.image
|
|
837
|
+
sections.add('image');
|
|
853
838
|
|
|
854
839
|
if (extrusion) {
|
|
855
|
-
sections.stroke
|
|
840
|
+
sections.add('stroke');
|
|
856
841
|
}
|
|
857
842
|
} else if (type === 'LineString' || type === 'MultiLineString') {
|
|
858
|
-
sections.stroke
|
|
843
|
+
sections.add('stroke');
|
|
859
844
|
if (extrusion) {
|
|
860
|
-
sections.fill
|
|
845
|
+
sections.add('fill');
|
|
861
846
|
}
|
|
862
847
|
} else if (type === 'Polygon' || type === 'MultiPolygon' || type === 'Circle') {
|
|
863
|
-
sections.stroke
|
|
864
|
-
sections.fill
|
|
848
|
+
sections.add('stroke');
|
|
849
|
+
sections.add('fill');
|
|
865
850
|
} else if (type === 'GeometryCollection') {
|
|
866
|
-
sections.stroke
|
|
867
|
-
sections.fill
|
|
868
|
-
sections.image
|
|
869
|
-
sections.text
|
|
870
|
-
}
|
|
871
|
-
|
|
851
|
+
sections.add('stroke');
|
|
852
|
+
sections.add('fill');
|
|
853
|
+
sections.add('image');
|
|
854
|
+
sections.add('text');
|
|
855
|
+
}
|
|
856
|
+
const config = this.toJSON();
|
|
857
|
+
const options = {};
|
|
858
|
+
sections.forEach((key) => {
|
|
859
|
+
options[key] = config[key];
|
|
860
|
+
});
|
|
861
|
+
return options;
|
|
872
862
|
}
|
|
873
863
|
|
|
874
864
|
/**
|
|
@@ -908,7 +898,7 @@ export default VectorStyleItem;
|
|
|
908
898
|
* @export
|
|
909
899
|
*/
|
|
910
900
|
export const defaultVectorStyle = new VectorStyleItem(getDefaultVectorStyleItemOptions());
|
|
911
|
-
|
|
901
|
+
styleClassRegistry.registerClass(VectorStyleItem.className, VectorStyleItem);
|
|
912
902
|
|
|
913
903
|
/**
|
|
914
904
|
* @param {import("@vcmap/cesium").Color} cesiumColor
|
package/src/style/writeStyle.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import VectorStyleItem from './vectorStyleItem.js';
|
|
2
2
|
import DeclarativeStyleItem from './declarativeStyleItem.js';
|
|
3
|
-
import { referenceableStyleSymbol } from './styleItem.js';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* @param {VectorStyleItemOptions} obj
|
|
@@ -34,13 +33,11 @@ export function embedIconsInStyle(obj, embeddedIcons) {
|
|
|
34
33
|
* @param {VcsMeta=} vcsMeta
|
|
35
34
|
* @returns {VcsMeta}
|
|
36
35
|
*/
|
|
37
|
-
function writeStyle(style, vcsMeta = {}) {
|
|
38
|
-
if (style
|
|
39
|
-
vcsMeta.style = style.
|
|
40
|
-
} else if (style instanceof VectorStyleItem) {
|
|
41
|
-
vcsMeta.style = embedIconsInStyle(style.getOptions(), vcsMeta.embeddedIcons);
|
|
36
|
+
function writeStyle(style, vcsMeta = {}) { // XXX this entire function is not what is to be expected. feature store expects styles as refs to be possible
|
|
37
|
+
if (style instanceof VectorStyleItem) {
|
|
38
|
+
vcsMeta.style = embedIconsInStyle(style.toJSON(), vcsMeta.embeddedIcons);
|
|
42
39
|
} else if (style instanceof DeclarativeStyleItem) {
|
|
43
|
-
vcsMeta.style = style.
|
|
40
|
+
vcsMeta.style = style.toJSON();
|
|
44
41
|
}
|
|
45
42
|
return vcsMeta;
|
|
46
43
|
}
|
package/src/util/projection.js
CHANGED
|
@@ -2,7 +2,6 @@ import { getTransform, get as getProjection, equivalent } from 'ol/proj.js';
|
|
|
2
2
|
import { register } from 'ol/proj/proj4.js';
|
|
3
3
|
import proj4 from 'proj4';
|
|
4
4
|
import { check } from '@vcsuite/check';
|
|
5
|
-
import { VcsClassRegistry } from '../classRegistry.js';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* @typedef {Object} ProjectionOptions
|
|
@@ -362,5 +361,3 @@ export const wgs84Projection = new Projection({ epsg: 4326 });
|
|
|
362
361
|
* @export
|
|
363
362
|
*/
|
|
364
363
|
export const mercatorProjection = new Projection({ epsg: 3857 });
|
|
365
|
-
|
|
366
|
-
VcsClassRegistry.registerClass(Projection.className, Projection);
|
package/src/util/viewpoint.js
CHANGED
|
@@ -3,7 +3,6 @@ import { parseBoolean, parseNumber } from '@vcsuite/parsers';
|
|
|
3
3
|
import Projection, { wgs84Projection } from './projection.js';
|
|
4
4
|
import VcsObject from '../vcsObject.js';
|
|
5
5
|
import Extent from './extent.js';
|
|
6
|
-
import { VcsClassRegistry } from '../classRegistry.js';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* compares two numeric properties
|
|
@@ -332,5 +331,3 @@ class ViewPoint extends VcsObject {
|
|
|
332
331
|
}
|
|
333
332
|
|
|
334
333
|
export default ViewPoint;
|
|
335
|
-
|
|
336
|
-
VcsClassRegistry.registerClass(ViewPoint.className, ViewPoint);
|