@vcmap/core 5.0.0-rc.23 → 5.0.0-rc.25
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 +824 -200
- package/index.js +24 -10
- package/package.json +2 -2
- package/src/category/category.js +1 -1
- package/src/featureProvider/abstractFeatureProvider.js +1 -18
- package/src/interaction/eventHandler.js +14 -0
- package/src/layer/cesium/cesiumTilesetCesiumImpl.js +4 -19
- package/src/layer/cesium/clusterContext.js +18 -0
- package/src/layer/cesium/vectorCesiumImpl.js +17 -2
- package/src/layer/cesium/vectorContext.js +187 -11
- package/src/layer/cesium/vectorRasterTileCesiumImpl.js +0 -1
- package/src/layer/cesiumTilesetLayer.js +1 -63
- package/src/layer/czmlLayer.js +1 -1
- package/src/layer/dataSourceLayer.js +1 -53
- package/src/layer/featureLayer.js +42 -38
- package/src/layer/featureStoreLayer.js +0 -15
- package/src/layer/layer.js +6 -11
- package/src/layer/layerSymbols.js +2 -1
- package/src/layer/oblique/vectorObliqueImpl.js +6 -0
- package/src/layer/openStreetMapLayer.js +6 -0
- package/src/layer/openlayers/layerOpenlayersImpl.js +69 -4
- package/src/layer/openlayers/rasterLayerOpenlayersImpl.js +0 -80
- package/src/layer/rasterLayer.js +1 -1
- package/src/layer/vectorHelpers.js +0 -85
- package/src/layer/vectorLayer.js +1 -9
- package/src/layer/vectorProperties.js +150 -8
- package/src/layer/vectorTileLayer.js +0 -9
- package/src/map/baseOLMap.js +17 -0
- package/src/map/cesiumMap.js +46 -8
- package/src/map/vcsMap.js +23 -5
- package/src/style/arcStyle.js +316 -0
- package/src/style/arrowStyle.js +269 -0
- package/src/util/editor/createFeatureSession.js +3 -1
- package/src/util/editor/editFeaturesSession.js +315 -0
- package/src/util/editor/editGeometrySession.js +5 -1
- package/src/util/editor/editorHelpers.js +118 -14
- package/src/util/editor/editorSessionHelpers.js +12 -0
- package/src/util/editor/editorSymbols.js +6 -0
- package/src/util/editor/interactions/editFeaturesMouseOverInteraction.js +120 -0
- package/src/util/editor/interactions/editGeometryMouseOverInteraction.js +1 -3
- package/src/util/editor/interactions/ensureHandlerSelectionInteraction.js +48 -0
- package/src/util/editor/interactions/mapInteractionController.js +5 -2
- package/src/util/editor/interactions/selectMultiFeatureInteraction.js +146 -0
- package/src/util/editor/interactions/translateVertexInteraction.js +2 -2
- package/src/util/editor/transformation/create2DHandlers.js +294 -0
- package/src/util/editor/transformation/create3DHandlers.js +575 -0
- package/src/util/editor/transformation/extrudeInteraction.js +91 -0
- package/src/util/editor/transformation/rotateInteraction.js +188 -0
- package/src/util/editor/transformation/scaleInteraction.js +185 -0
- package/src/util/editor/transformation/transformationHandler.js +168 -0
- package/src/util/editor/transformation/transformationTypes.js +83 -0
- package/src/util/editor/transformation/translateInteraction.js +209 -0
- package/src/util/featureconverter/arcToCesium.js +87 -0
- package/src/util/featureconverter/convert.js +7 -1
- package/src/util/featureconverter/extent3D.js +64 -1
- package/src/util/featureconverter/lineStringToCesium.js +103 -2
- package/src/util/featureconverter/pointHelpers.js +341 -0
- package/src/util/featureconverter/pointToCesium.js +27 -76
- package/src/util/geometryHelpers.js +11 -8
- package/src/util/mapCollection.js +30 -24
- package/src/util/math.js +99 -2
- package/tests/unit/helpers/cesiumHelpers.js +14 -4
- package/tests/unit/helpers/helpers.js +13 -0
- package/src/featureProvider/featureProviderHelpers.js +0 -50
- package/src/util/splitScreen.js +0 -233
|
@@ -2,6 +2,7 @@ import Style from 'ol/style/Style.js';
|
|
|
2
2
|
|
|
3
3
|
import { check } from '@vcsuite/check';
|
|
4
4
|
import { parseInteger } from '@vcsuite/parsers';
|
|
5
|
+
import { SplitDirection } from '@vcmap/cesium';
|
|
5
6
|
import Layer from './layer.js';
|
|
6
7
|
import StyleItem from '../style/styleItem.js';
|
|
7
8
|
import VectorStyleItem from '../style/vectorStyleItem.js';
|
|
@@ -13,8 +14,8 @@ import { layerClassRegistry } from '../classRegistry.js';
|
|
|
13
14
|
/**
|
|
14
15
|
* @typedef {LayerOptions} FeatureLayerOptions
|
|
15
16
|
* @property {DeclarativeStyleItemOptions|VectorStyleItemOptions|import("@vcmap/core").StyleItem|undefined} style
|
|
16
|
-
* @property {Object|undefined} genericFeatureProperties - properties to add to generic features, eg for display in the balloon
|
|
17
17
|
* @property {number} [balloonHeightOffset=10]
|
|
18
|
+
* @property {string|undefined} splitDirection - either 'left' or 'right', if omitted none is applied (for 3D Vector currently only Models are split-able)
|
|
18
19
|
* @property {FeatureVisibility|undefined} featureVisibility - vcs:undocumented
|
|
19
20
|
* @api
|
|
20
21
|
*/
|
|
@@ -22,6 +23,7 @@ import { layerClassRegistry } from '../classRegistry.js';
|
|
|
22
23
|
/**
|
|
23
24
|
* @typedef {LayerImplementationOptions} FeatureLayerImplementationOptions
|
|
24
25
|
* @property {GlobalHider} globalHider
|
|
26
|
+
* @property {import("@vcmap/cesium").SplitDirection} splitDirection
|
|
25
27
|
* @property {FeatureVisibility} featureVisibility
|
|
26
28
|
* @property {import("@vcmap/core").StyleItem} style
|
|
27
29
|
* @api
|
|
@@ -38,6 +40,7 @@ import { layerClassRegistry } from '../classRegistry.js';
|
|
|
38
40
|
/**
|
|
39
41
|
* @typedef {import("@vcmap/core").LayerImplementation<import("@vcmap/core").VcsMap>} FeatureLayerImplementation
|
|
40
42
|
* @property {function(import("@vcmap/core").StyleItem, boolean=):void} updateStyle
|
|
43
|
+
* @property {function(import("@vcmap/cesium").SplitDirection):void} updateSplitDirection
|
|
41
44
|
*/
|
|
42
45
|
|
|
43
46
|
/**
|
|
@@ -45,6 +48,7 @@ import { layerClassRegistry } from '../classRegistry.js';
|
|
|
45
48
|
* @class
|
|
46
49
|
* @abstract
|
|
47
50
|
* @extends {Layer}
|
|
51
|
+
* @implements {SplitLayer}
|
|
48
52
|
* @api
|
|
49
53
|
*/
|
|
50
54
|
class FeatureLayer extends Layer {
|
|
@@ -59,7 +63,7 @@ class FeatureLayer extends Layer {
|
|
|
59
63
|
...Layer.getDefaultOptions(),
|
|
60
64
|
style: undefined,
|
|
61
65
|
balloonHeightOffset: 10,
|
|
62
|
-
|
|
66
|
+
splitDirection: undefined,
|
|
63
67
|
};
|
|
64
68
|
}
|
|
65
69
|
|
|
@@ -86,19 +90,27 @@ class FeatureLayer extends Layer {
|
|
|
86
90
|
* @api
|
|
87
91
|
*/
|
|
88
92
|
this.styleChanged = new VcsEvent();
|
|
89
|
-
/**
|
|
90
|
-
* @type {Object}
|
|
91
|
-
* @private
|
|
92
|
-
*/
|
|
93
|
-
this._genericFeatureProperties = options.genericFeatureProperties || defaultOptions.genericFeatureProperties;
|
|
94
|
-
|
|
95
93
|
/**
|
|
96
94
|
* a height offset for rendering of a balloon for a feature of this layer.
|
|
97
95
|
* @type {number}
|
|
98
96
|
* @api
|
|
99
97
|
*/
|
|
100
98
|
this.balloonHeightOffset = parseInteger(options.balloonHeightOffset, defaultOptions.balloonHeightOffset);
|
|
99
|
+
/** @type {import("@vcmap/cesium").SplitDirection} */
|
|
100
|
+
this._splitDirection = SplitDirection.NONE;
|
|
101
101
|
|
|
102
|
+
if (options.splitDirection) {
|
|
103
|
+
this._splitDirection = options.splitDirection === 'left' ?
|
|
104
|
+
SplitDirection.LEFT :
|
|
105
|
+
SplitDirection.RIGHT;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* raised if the split direction changes, is passed the split direction as its only argument
|
|
110
|
+
* @type {VcsEvent<import("@vcmap/cesium").SplitDirection>}
|
|
111
|
+
* @api
|
|
112
|
+
*/
|
|
113
|
+
this.splitDirectionChanged = new VcsEvent();
|
|
102
114
|
/**
|
|
103
115
|
* FeatureVisibility tracks the highlighting and hiding of features on this layer
|
|
104
116
|
* @type {FeatureVisibility}
|
|
@@ -127,12 +139,23 @@ class FeatureLayer extends Layer {
|
|
|
127
139
|
}
|
|
128
140
|
|
|
129
141
|
/**
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* @
|
|
142
|
+
* @api
|
|
143
|
+
* The splitDirection to be applied - for 3D vector features currently only working on points with a Model
|
|
144
|
+
* @type {import("@vcmap/cesium").SplitDirection}
|
|
145
|
+
*/
|
|
146
|
+
get splitDirection() { return this._splitDirection; }
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* @param {import("@vcmap/cesium").SplitDirection} direction
|
|
133
150
|
*/
|
|
134
|
-
|
|
135
|
-
|
|
151
|
+
set splitDirection(direction) {
|
|
152
|
+
if (direction !== this._splitDirection) {
|
|
153
|
+
this.getImplementations().forEach((impl) => {
|
|
154
|
+
/** @type {FeatureLayerImplementation} */ (impl).updateSplitDirection(direction);
|
|
155
|
+
});
|
|
156
|
+
this._splitDirection = direction;
|
|
157
|
+
this.splitDirectionChanged.raiseEvent(this._splitDirection);
|
|
158
|
+
}
|
|
136
159
|
}
|
|
137
160
|
|
|
138
161
|
/**
|
|
@@ -144,6 +167,7 @@ class FeatureLayer extends Layer {
|
|
|
144
167
|
globalHider: this.globalHider,
|
|
145
168
|
featureVisibility: this.featureVisibility,
|
|
146
169
|
style: this.style,
|
|
170
|
+
splitDirection: this.splitDirection,
|
|
147
171
|
};
|
|
148
172
|
}
|
|
149
173
|
|
|
@@ -164,28 +188,6 @@ class FeatureLayer extends Layer {
|
|
|
164
188
|
return null;
|
|
165
189
|
}
|
|
166
190
|
|
|
167
|
-
/**
|
|
168
|
-
* This is called by the selectBehavior to create generic features from clicked objects
|
|
169
|
-
* needs to be implemented by each layer which has clickable objects
|
|
170
|
-
* @param {Object|VectorClickedObject|import("ol").Feature<import("ol/geom/Geometry").default>} object
|
|
171
|
-
* @returns {GenericFeature}
|
|
172
|
-
*/
|
|
173
|
-
// eslint-disable-next-line no-unused-vars
|
|
174
|
-
getGenericFeatureFromClickedObject(object) { // XXX remove after event implementation
|
|
175
|
-
this.getLogger().warning('This method should be implemented by any specific layers');
|
|
176
|
-
return null;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Set properties, which are always added to the generic object, eg. for use in balloons
|
|
181
|
-
* @param {Object} properties
|
|
182
|
-
* @api
|
|
183
|
-
*/
|
|
184
|
-
assignGenericFeatureProperties(properties) {
|
|
185
|
-
check(properties, Object);
|
|
186
|
-
Object.assign(this._genericFeatureProperties, properties);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
191
|
/**
|
|
190
192
|
* @param {(DeclarativeStyleItemOptions|VectorStyleItemOptions|import("@vcmap/core").StyleItem)=} styleOptions
|
|
191
193
|
* @param {(import("@vcmap/core").VectorStyleItem|import("@vcmap/core").DeclarativeStyleItem)=} defaultStyle
|
|
@@ -234,9 +236,10 @@ class FeatureLayer extends Layer {
|
|
|
234
236
|
if (!this.getStyleOrDefaultStyle().equals(this._style)) {
|
|
235
237
|
config.style = this.style.toJSON();
|
|
236
238
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
239
|
+
if (this._splitDirection !== SplitDirection.NONE) {
|
|
240
|
+
config.splitDirection = this._splitDirection === SplitDirection.RIGHT ?
|
|
241
|
+
'right' :
|
|
242
|
+
'left';
|
|
240
243
|
}
|
|
241
244
|
return config;
|
|
242
245
|
}
|
|
@@ -249,6 +252,7 @@ class FeatureLayer extends Layer {
|
|
|
249
252
|
this.featureVisibility.destroy();
|
|
250
253
|
}
|
|
251
254
|
this.styleChanged.destroy();
|
|
255
|
+
this.splitDirectionChanged.destroy();
|
|
252
256
|
super.destroy();
|
|
253
257
|
}
|
|
254
258
|
}
|
|
@@ -454,21 +454,6 @@ class FeatureStoreLayer extends VectorLayer {
|
|
|
454
454
|
return null;
|
|
455
455
|
}
|
|
456
456
|
|
|
457
|
-
/**
|
|
458
|
-
* @param {Object|VectorClickedObject} object
|
|
459
|
-
* @returns {GenericFeature}
|
|
460
|
-
*/
|
|
461
|
-
getGenericFeatureFromClickedObject(object) {
|
|
462
|
-
if (object instanceof Feature) {
|
|
463
|
-
// @ts-ignore
|
|
464
|
-
return super.getGenericFeatureFromClickedObject(/** @type {VectorClickedObject} */ (object));
|
|
465
|
-
}
|
|
466
|
-
const generic = CesiumTilesetLayer.prototype.getGenericFeatureFromClickedObject.call(this, object);
|
|
467
|
-
generic.layerName = this.name;
|
|
468
|
-
generic.layerClass = this.className;
|
|
469
|
-
return generic;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
457
|
/**
|
|
473
458
|
* @inheritDoc
|
|
474
459
|
* @returns {Extent|null}
|
package/src/layer/layer.js
CHANGED
|
@@ -8,17 +8,6 @@ import VcsEvent from '../vcsEvent.js';
|
|
|
8
8
|
import { layerClassRegistry } from '../classRegistry.js';
|
|
9
9
|
import GlobalHider from './globalHider.js';
|
|
10
10
|
|
|
11
|
-
/**
|
|
12
|
-
* @typedef {Object} GenericFeature
|
|
13
|
-
* @property {number} longitude
|
|
14
|
-
* @property {number} latitude
|
|
15
|
-
* @property {number} height
|
|
16
|
-
* @property {string} layerName
|
|
17
|
-
* @property {string} layerClass
|
|
18
|
-
* @property {any} attributes
|
|
19
|
-
* @property {boolean} relativeToGround
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
11
|
/**
|
|
23
12
|
* @typedef {import("@vcmap/core").Layer} SplitLayer
|
|
24
13
|
* @property {import("@vcmap/cesium").SplitDirection} splitDirection
|
|
@@ -68,6 +57,12 @@ import GlobalHider from './globalHider.js';
|
|
|
68
57
|
* @api
|
|
69
58
|
*/
|
|
70
59
|
|
|
60
|
+
/**
|
|
61
|
+
* @typedef {LayerImplementationOptions} SplitLayerImplementationOptions
|
|
62
|
+
* @property {import("@vcmap/cesium").SplitDirection} splitDirection
|
|
63
|
+
* @api
|
|
64
|
+
*/
|
|
65
|
+
|
|
71
66
|
/**
|
|
72
67
|
* Layer implementations for the {@link CesiumMap} map
|
|
73
68
|
* @namespace cesium
|
|
@@ -116,6 +116,12 @@ class VectorObliqueImpl extends LayerObliqueImpl {
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
/**
|
|
120
|
+
* @param {import("@vcmap/cesium").SplitDirection} splitDirection
|
|
121
|
+
*/
|
|
122
|
+
// eslint-disable-next-line class-methods-use-this,no-unused-vars
|
|
123
|
+
updateSplitDirection(splitDirection) {}
|
|
124
|
+
|
|
119
125
|
/**
|
|
120
126
|
* clears the current image and fetches features for the next
|
|
121
127
|
* @private
|
|
@@ -177,6 +177,12 @@ class OpenStreetMapLayer extends Layer {
|
|
|
177
177
|
config.maxLevel = this.maxLevel;
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
+
if (this._splitDirection !== SplitDirection.NONE) {
|
|
181
|
+
config.splitDirection = this._splitDirection === SplitDirection.RIGHT ?
|
|
182
|
+
'right' :
|
|
183
|
+
'left';
|
|
184
|
+
}
|
|
185
|
+
|
|
180
186
|
return config;
|
|
181
187
|
}
|
|
182
188
|
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
import { SplitDirection } from '@vcmap/cesium';
|
|
2
|
+
import { unByKey } from 'ol/Observable.js';
|
|
1
3
|
import { vcsLayerName } from '../layerSymbols.js';
|
|
2
4
|
import LayerImplementation from '../layerImplementation.js';
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
|
-
*
|
|
7
|
+
* @typedef {LayerImplementationOptions} LayerOpenlayersImplementationOptions
|
|
8
|
+
* @property {import("@vcmap/cesium").SplitDirection} splitDirection
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Layer implementation for {@link OpenlayersMap}.
|
|
6
13
|
* @class
|
|
7
14
|
* @extends {LayerImplementation<import("@vcmap/core").OpenlayersMap>}}
|
|
8
15
|
*/
|
|
@@ -11,7 +18,7 @@ class LayerOpenlayersImpl extends LayerImplementation {
|
|
|
11
18
|
|
|
12
19
|
/**
|
|
13
20
|
* @param {import("@vcmap/core").OpenlayersMap} map
|
|
14
|
-
* @param {
|
|
21
|
+
* @param {LayerOpenlayersImplementationOptions} options
|
|
15
22
|
*/
|
|
16
23
|
constructor(map, options) {
|
|
17
24
|
super(map, options);
|
|
@@ -19,19 +26,27 @@ class LayerOpenlayersImpl extends LayerImplementation {
|
|
|
19
26
|
* @type {import("ol/layer").Layer<import("ol/source/Source").default>|null}
|
|
20
27
|
*/
|
|
21
28
|
this.olLayer = null;
|
|
29
|
+
/** @type {import("@vcmap/cesium").SplitDirection} */
|
|
30
|
+
this.splitDirection = options.splitDirection;
|
|
31
|
+
/**
|
|
32
|
+
* @type {Array<import("ol/events").EventsKey>|null}
|
|
33
|
+
* @private
|
|
34
|
+
*/
|
|
35
|
+
this._splitDirectionRenderListeners = null;
|
|
22
36
|
}
|
|
23
37
|
|
|
24
38
|
/**
|
|
25
39
|
* @inheritDoc
|
|
26
40
|
* @returns {Promise<void>}
|
|
27
41
|
*/
|
|
28
|
-
initialize() {
|
|
42
|
+
async initialize() {
|
|
29
43
|
if (!this.initialized) {
|
|
30
44
|
this.olLayer = this.getOLLayer();
|
|
31
45
|
this.olLayer[vcsLayerName] = this.name;
|
|
32
46
|
this.map.addOLLayer(this.olLayer);
|
|
33
47
|
}
|
|
34
|
-
|
|
48
|
+
await super.initialize();
|
|
49
|
+
this.updateSplitDirection(this.splitDirection);
|
|
35
50
|
}
|
|
36
51
|
|
|
37
52
|
/**
|
|
@@ -63,6 +78,52 @@ class LayerOpenlayersImpl extends LayerImplementation {
|
|
|
63
78
|
// eslint-disable-next-line class-methods-use-this
|
|
64
79
|
getOLLayer() { throw new Error(); }
|
|
65
80
|
|
|
81
|
+
/**
|
|
82
|
+
* @param {import("@vcmap/cesium").SplitDirection} splitDirection
|
|
83
|
+
*/
|
|
84
|
+
updateSplitDirection(splitDirection) {
|
|
85
|
+
this.splitDirection = splitDirection;
|
|
86
|
+
if (this.initialized) {
|
|
87
|
+
if (this.splitDirection === SplitDirection.NONE && this._splitDirectionRenderListeners) {
|
|
88
|
+
unByKey(this._splitDirectionRenderListeners);
|
|
89
|
+
this._splitDirectionRenderListeners = null;
|
|
90
|
+
this.olLayer.changed();
|
|
91
|
+
} else if (splitDirection !== SplitDirection.NONE && !this._splitDirectionRenderListeners) {
|
|
92
|
+
this._splitDirectionRenderListeners = [];
|
|
93
|
+
this._splitDirectionRenderListeners
|
|
94
|
+
.push(/** @type {import("ol/events").EventsKey} */
|
|
95
|
+
(this.olLayer.on('prerender', this._splitPreRender.bind(this))),
|
|
96
|
+
);
|
|
97
|
+
this._splitDirectionRenderListeners
|
|
98
|
+
.push(/** @type {import("ol/events").EventsKey} */
|
|
99
|
+
(this.olLayer.on('postrender', (/** @type {import("ol/render/Event").default} */ event) => {
|
|
100
|
+
/** @type {CanvasRenderingContext2D} */ (event.context).restore();
|
|
101
|
+
})),
|
|
102
|
+
);
|
|
103
|
+
this.olLayer.changed();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @param {import("ol/render/Event").default} event
|
|
110
|
+
* @private
|
|
111
|
+
*/
|
|
112
|
+
_splitPreRender(event) {
|
|
113
|
+
// eslint-disable-next-line prefer-destructuring
|
|
114
|
+
const context = /** @type {CanvasRenderingContext2D} */ (event.context);
|
|
115
|
+
const width = context.canvas.width * this.map.splitPosition;
|
|
116
|
+
context.save();
|
|
117
|
+
context.beginPath();
|
|
118
|
+
|
|
119
|
+
if (this.splitDirection === SplitDirection.LEFT) {
|
|
120
|
+
context.rect(0, 0, width, context.canvas.height);
|
|
121
|
+
} else {
|
|
122
|
+
context.rect(width, 0, context.canvas.width - width, context.canvas.height);
|
|
123
|
+
}
|
|
124
|
+
context.clip();
|
|
125
|
+
}
|
|
126
|
+
|
|
66
127
|
/**
|
|
67
128
|
* @inheritDoc
|
|
68
129
|
*/
|
|
@@ -71,6 +132,10 @@ class LayerOpenlayersImpl extends LayerImplementation {
|
|
|
71
132
|
this.map.removeOLLayer(this.olLayer);
|
|
72
133
|
}
|
|
73
134
|
this.olLayer = null;
|
|
135
|
+
if (this._splitDirectionRenderListeners) {
|
|
136
|
+
unByKey(this._splitDirectionRenderListeners);
|
|
137
|
+
this._splitDirectionRenderListeners = null;
|
|
138
|
+
}
|
|
74
139
|
super.destroy();
|
|
75
140
|
}
|
|
76
141
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { SplitDirection } from '@vcmap/cesium';
|
|
2
|
-
import { unByKey } from 'ol/Observable.js';
|
|
3
1
|
import LayerOpenlayersImpl from './layerOpenlayersImpl.js';
|
|
4
2
|
|
|
5
3
|
/**
|
|
@@ -18,8 +16,6 @@ class RasterLayerOpenlayersImpl extends LayerOpenlayersImpl {
|
|
|
18
16
|
*/
|
|
19
17
|
constructor(map, options) {
|
|
20
18
|
super(map, options);
|
|
21
|
-
/** @type {import("@vcmap/cesium").SplitDirection} */
|
|
22
|
-
this.splitDirection = options.splitDirection;
|
|
23
19
|
/** @type {number} */
|
|
24
20
|
this.minLevel = options.minLevel;
|
|
25
21
|
/** @type {number} */
|
|
@@ -30,22 +26,6 @@ class RasterLayerOpenlayersImpl extends LayerOpenlayersImpl {
|
|
|
30
26
|
this.extent = options.extent;
|
|
31
27
|
/** @type {number} */
|
|
32
28
|
this.opacity = options.opacity;
|
|
33
|
-
/**
|
|
34
|
-
* @type {Array<import("ol/events").EventsKey>|null}
|
|
35
|
-
* @private
|
|
36
|
-
*/
|
|
37
|
-
this._splitDirectionRenderListeners = null;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* @inheritDoc
|
|
42
|
-
* @returns {Promise<void>}
|
|
43
|
-
*/
|
|
44
|
-
initialize() {
|
|
45
|
-
return super.initialize()
|
|
46
|
-
.then(() => {
|
|
47
|
-
this.updateSplitDirection(this.splitDirection);
|
|
48
|
-
});
|
|
49
29
|
}
|
|
50
30
|
|
|
51
31
|
/**
|
|
@@ -57,66 +37,6 @@ class RasterLayerOpenlayersImpl extends LayerOpenlayersImpl {
|
|
|
57
37
|
this.olLayer.setOpacity(this.opacity);
|
|
58
38
|
}
|
|
59
39
|
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* @param {import("@vcmap/cesium").SplitDirection} splitDirection
|
|
63
|
-
*/
|
|
64
|
-
updateSplitDirection(splitDirection) {
|
|
65
|
-
this.splitDirection = splitDirection;
|
|
66
|
-
if (this.initialized) {
|
|
67
|
-
if (this.splitDirection === SplitDirection.NONE && this._splitDirectionRenderListeners) {
|
|
68
|
-
unByKey(this._splitDirectionRenderListeners);
|
|
69
|
-
this._splitDirectionRenderListeners = null;
|
|
70
|
-
this.olLayer.changed();
|
|
71
|
-
} else if (splitDirection !== SplitDirection.NONE && !this._splitDirectionRenderListeners) {
|
|
72
|
-
this._splitDirectionRenderListeners = [];
|
|
73
|
-
this._splitDirectionRenderListeners
|
|
74
|
-
.push(/** @type {import("ol/events").EventsKey} */
|
|
75
|
-
(this.olLayer.on('prerender', this._splitPreCompose.bind(this))),
|
|
76
|
-
);
|
|
77
|
-
this._splitDirectionRenderListeners
|
|
78
|
-
.push(/** @type {import("ol/events").EventsKey} */
|
|
79
|
-
(this.olLayer.on('postrender', (/** @type {import("ol/render/Event").default} */ event) => {
|
|
80
|
-
/** @type {CanvasRenderingContext2D} */ (event.context).restore();
|
|
81
|
-
})),
|
|
82
|
-
);
|
|
83
|
-
this.olLayer.changed();
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* @param {import("ol/render/Event").default} event
|
|
90
|
-
* @private
|
|
91
|
-
*/
|
|
92
|
-
_splitPreCompose(event) {
|
|
93
|
-
if (!this.map.splitScreen) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
// eslint-disable-next-line prefer-destructuring
|
|
97
|
-
const context = /** @type {CanvasRenderingContext2D} */ (event.context);
|
|
98
|
-
const width = context.canvas.width * this.map.splitScreen.position;
|
|
99
|
-
context.save();
|
|
100
|
-
context.beginPath();
|
|
101
|
-
|
|
102
|
-
if (this.splitDirection === SplitDirection.LEFT) {
|
|
103
|
-
context.rect(0, 0, width, context.canvas.height);
|
|
104
|
-
} else {
|
|
105
|
-
context.rect(width, 0, context.canvas.width - width, context.canvas.height);
|
|
106
|
-
}
|
|
107
|
-
context.clip();
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* @inheritDoc
|
|
112
|
-
*/
|
|
113
|
-
destroy() {
|
|
114
|
-
if (this._splitDirectionRenderListeners) {
|
|
115
|
-
unByKey(this._splitDirectionRenderListeners);
|
|
116
|
-
this._splitDirectionRenderListeners = null;
|
|
117
|
-
}
|
|
118
|
-
super.destroy();
|
|
119
|
-
}
|
|
120
40
|
}
|
|
121
41
|
|
|
122
42
|
export default RasterLayerOpenlayersImpl;
|
package/src/layer/rasterLayer.js
CHANGED
|
@@ -24,8 +24,8 @@ import { layerClassRegistry } from '../classRegistry.js';
|
|
|
24
24
|
* @property {number} maxLevel
|
|
25
25
|
* @property {string} tilingSchema
|
|
26
26
|
* @property {number} opacity
|
|
27
|
-
* @property {import("@vcmap/cesium").SplitDirection} splitDirection
|
|
28
27
|
* @property {Extent|undefined} extent
|
|
28
|
+
* @property {import("@vcmap/cesium").SplitDirection} splitDirection
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
31
|
/**
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { unByKey } from 'ol/Observable.js';
|
|
2
|
-
import Feature from 'ol/Feature.js';
|
|
3
|
-
import { HeightReference } from '@vcmap/cesium';
|
|
4
2
|
import { FeatureVisibilityAction } from './featureVisibility.js';
|
|
5
|
-
import Projection from '../util/projection.js';
|
|
6
|
-
import { getHeightInfo } from '../util/featureconverter/featureconverterHelper.js';
|
|
7
|
-
import { getFlatCoordinatesFromGeometry } from '../util/geometryHelpers.js';
|
|
8
|
-
import Extent3D from '../util/featureconverter/extent3D.js';
|
|
9
3
|
|
|
10
4
|
/**
|
|
11
5
|
* Added to ol.source.Vector to determine, when the source has last had an update to its features visibility.
|
|
@@ -124,82 +118,3 @@ export function synchronizeFeatureVisibilityWithSource(featureVisibility, source
|
|
|
124
118
|
() => { unByKey(sourceListener); },
|
|
125
119
|
];
|
|
126
120
|
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* @param {VectorClickedObject} object
|
|
130
|
-
* @param {import("@vcmap/core").VectorLayer|import("@vcmap/core").VectorTileLayer} layer
|
|
131
|
-
* @returns {?GenericFeature}
|
|
132
|
-
*/
|
|
133
|
-
export function getGenericFeatureFromClickedObject(object, layer) {
|
|
134
|
-
if (!(object instanceof Feature)) {
|
|
135
|
-
return null;
|
|
136
|
-
}
|
|
137
|
-
const attributes = object.getProperties();
|
|
138
|
-
delete attributes[object.getGeometryName()];
|
|
139
|
-
|
|
140
|
-
const { clickedPosition } = object;
|
|
141
|
-
if (!clickedPosition) {
|
|
142
|
-
return null;
|
|
143
|
-
}
|
|
144
|
-
let { latitude, longitude } = clickedPosition;
|
|
145
|
-
const geometry = object.getGeometry();
|
|
146
|
-
let heightOffset = clickedPosition.height;
|
|
147
|
-
let calculateHeight = !heightOffset;
|
|
148
|
-
if (!geometry) {
|
|
149
|
-
calculateHeight = false; // we cannot calculate the height without geometry;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
let relativeToGround = !heightOffset;
|
|
153
|
-
// Edge Case ClickedPosition is next to the feature and Feature got detected in clickToleranz.
|
|
154
|
-
// if the clicked Position does not intersect the feature the closestPoint will be used.
|
|
155
|
-
// also if the clickedPosition is not on the Feature we do not trust the Height Value;
|
|
156
|
-
const mercatorPoint =
|
|
157
|
-
Projection.wgs84ToMercator([clickedPosition.longitude, clickedPosition.latitude, clickedPosition.height]);
|
|
158
|
-
if (geometry && !geometry.intersectsCoordinate(mercatorPoint)) {
|
|
159
|
-
const closestPoint = geometry.getClosestPoint(mercatorPoint);
|
|
160
|
-
[longitude, latitude] = Projection.mercatorToWgs84(closestPoint);
|
|
161
|
-
calculateHeight = true;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// edge case oblique in this case we do get a height value but not of the feature but the underlying terrain.
|
|
165
|
-
// this is necessary to calculate the correct position of the balloon
|
|
166
|
-
|
|
167
|
-
// if we do not have a height value from the clickedPosition we calculate the height based in the feature;
|
|
168
|
-
if (calculateHeight) {
|
|
169
|
-
const coordinates = getFlatCoordinatesFromGeometry(geometry);
|
|
170
|
-
const heightInfo = getHeightInfo(object, layer.vectorProperties, coordinates);
|
|
171
|
-
if (heightInfo.perPositionHeight || heightInfo.extruded) {
|
|
172
|
-
const extent = Extent3D.fromGeometry(geometry);
|
|
173
|
-
extent.extendWithHeightInfo(heightInfo);
|
|
174
|
-
heightOffset = extent.maxZ;
|
|
175
|
-
}
|
|
176
|
-
// edge case points are rendered depending on the terrain, so we set relativeToGround to true.
|
|
177
|
-
// In this case the heightAboveGroundAdjustment is also just an Offset.
|
|
178
|
-
if (
|
|
179
|
-
!heightInfo.extruded &&
|
|
180
|
-
(geometry.getType() === 'Point' || geometry.getType() === 'MultiPoint') &&
|
|
181
|
-
(
|
|
182
|
-
heightInfo.heightReference === HeightReference.RELATIVE_TO_GROUND ||
|
|
183
|
-
heightInfo.heightReference === HeightReference.CLAMP_TO_GROUND)
|
|
184
|
-
) {
|
|
185
|
-
heightOffset = heightInfo.heightAboveGroundAdjustment;
|
|
186
|
-
relativeToGround = true;
|
|
187
|
-
} else {
|
|
188
|
-
heightOffset += heightInfo.heightAboveGroundAdjustment;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// if we have to calculate the height we have to take heightAboveGround into account
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
delete attributes.clickedPosition;
|
|
195
|
-
heightOffset = Number.isFinite(heightOffset) ? heightOffset : 0;
|
|
196
|
-
return {
|
|
197
|
-
layerName: layer.name,
|
|
198
|
-
layerClass: layer.className,
|
|
199
|
-
attributes: { ...layer.genericFeatureProperties, ...attributes },
|
|
200
|
-
longitude,
|
|
201
|
-
latitude,
|
|
202
|
-
height: heightOffset + layer.balloonHeightOffset,
|
|
203
|
-
relativeToGround,
|
|
204
|
-
};
|
|
205
|
-
}
|
package/src/layer/vectorLayer.js
CHANGED
|
@@ -27,7 +27,6 @@ import ObliqueMap from '../map/obliqueMap.js';
|
|
|
27
27
|
import CesiumMap from '../map/cesiumMap.js';
|
|
28
28
|
import { originalStyle, updateOriginalStyle } from './featureVisibility.js';
|
|
29
29
|
import StyleItem from '../style/styleItem.js';
|
|
30
|
-
import { getGenericFeatureFromClickedObject } from './vectorHelpers.js';
|
|
31
30
|
import { layerClassRegistry } from '../classRegistry.js';
|
|
32
31
|
|
|
33
32
|
/**
|
|
@@ -85,6 +84,7 @@ import { layerClassRegistry } from '../classRegistry.js';
|
|
|
85
84
|
* VectorLayer Layer for OpenlayersMap, Cesium and ObliqueMap
|
|
86
85
|
* @class
|
|
87
86
|
* @extends {FeatureLayer}
|
|
87
|
+
* @implements {SplitLayer}
|
|
88
88
|
* @api stable
|
|
89
89
|
*/
|
|
90
90
|
class VectorLayer extends FeatureLayer {
|
|
@@ -556,14 +556,6 @@ class VectorLayer extends FeatureLayer {
|
|
|
556
556
|
return null;
|
|
557
557
|
}
|
|
558
558
|
|
|
559
|
-
/**
|
|
560
|
-
* @param {VectorClickedObject} object
|
|
561
|
-
* @returns {?GenericFeature}
|
|
562
|
-
*/
|
|
563
|
-
getGenericFeatureFromClickedObject(object) {
|
|
564
|
-
return getGenericFeatureFromClickedObject(object, this);
|
|
565
|
-
}
|
|
566
|
-
|
|
567
559
|
/**
|
|
568
560
|
* @returns {VectorOptions}
|
|
569
561
|
*/
|