@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.
Files changed (65) hide show
  1. package/index.d.ts +824 -200
  2. package/index.js +24 -10
  3. package/package.json +2 -2
  4. package/src/category/category.js +1 -1
  5. package/src/featureProvider/abstractFeatureProvider.js +1 -18
  6. package/src/interaction/eventHandler.js +14 -0
  7. package/src/layer/cesium/cesiumTilesetCesiumImpl.js +4 -19
  8. package/src/layer/cesium/clusterContext.js +18 -0
  9. package/src/layer/cesium/vectorCesiumImpl.js +17 -2
  10. package/src/layer/cesium/vectorContext.js +187 -11
  11. package/src/layer/cesium/vectorRasterTileCesiumImpl.js +0 -1
  12. package/src/layer/cesiumTilesetLayer.js +1 -63
  13. package/src/layer/czmlLayer.js +1 -1
  14. package/src/layer/dataSourceLayer.js +1 -53
  15. package/src/layer/featureLayer.js +42 -38
  16. package/src/layer/featureStoreLayer.js +0 -15
  17. package/src/layer/layer.js +6 -11
  18. package/src/layer/layerSymbols.js +2 -1
  19. package/src/layer/oblique/vectorObliqueImpl.js +6 -0
  20. package/src/layer/openStreetMapLayer.js +6 -0
  21. package/src/layer/openlayers/layerOpenlayersImpl.js +69 -4
  22. package/src/layer/openlayers/rasterLayerOpenlayersImpl.js +0 -80
  23. package/src/layer/rasterLayer.js +1 -1
  24. package/src/layer/vectorHelpers.js +0 -85
  25. package/src/layer/vectorLayer.js +1 -9
  26. package/src/layer/vectorProperties.js +150 -8
  27. package/src/layer/vectorTileLayer.js +0 -9
  28. package/src/map/baseOLMap.js +17 -0
  29. package/src/map/cesiumMap.js +46 -8
  30. package/src/map/vcsMap.js +23 -5
  31. package/src/style/arcStyle.js +316 -0
  32. package/src/style/arrowStyle.js +269 -0
  33. package/src/util/editor/createFeatureSession.js +3 -1
  34. package/src/util/editor/editFeaturesSession.js +315 -0
  35. package/src/util/editor/editGeometrySession.js +5 -1
  36. package/src/util/editor/editorHelpers.js +118 -14
  37. package/src/util/editor/editorSessionHelpers.js +12 -0
  38. package/src/util/editor/editorSymbols.js +6 -0
  39. package/src/util/editor/interactions/editFeaturesMouseOverInteraction.js +120 -0
  40. package/src/util/editor/interactions/editGeometryMouseOverInteraction.js +1 -3
  41. package/src/util/editor/interactions/ensureHandlerSelectionInteraction.js +48 -0
  42. package/src/util/editor/interactions/mapInteractionController.js +5 -2
  43. package/src/util/editor/interactions/selectMultiFeatureInteraction.js +146 -0
  44. package/src/util/editor/interactions/translateVertexInteraction.js +2 -2
  45. package/src/util/editor/transformation/create2DHandlers.js +294 -0
  46. package/src/util/editor/transformation/create3DHandlers.js +575 -0
  47. package/src/util/editor/transformation/extrudeInteraction.js +91 -0
  48. package/src/util/editor/transformation/rotateInteraction.js +188 -0
  49. package/src/util/editor/transformation/scaleInteraction.js +185 -0
  50. package/src/util/editor/transformation/transformationHandler.js +168 -0
  51. package/src/util/editor/transformation/transformationTypes.js +83 -0
  52. package/src/util/editor/transformation/translateInteraction.js +209 -0
  53. package/src/util/featureconverter/arcToCesium.js +87 -0
  54. package/src/util/featureconverter/convert.js +7 -1
  55. package/src/util/featureconverter/extent3D.js +64 -1
  56. package/src/util/featureconverter/lineStringToCesium.js +103 -2
  57. package/src/util/featureconverter/pointHelpers.js +341 -0
  58. package/src/util/featureconverter/pointToCesium.js +27 -76
  59. package/src/util/geometryHelpers.js +11 -8
  60. package/src/util/mapCollection.js +30 -24
  61. package/src/util/math.js +99 -2
  62. package/tests/unit/helpers/cesiumHelpers.js +14 -4
  63. package/tests/unit/helpers/helpers.js +13 -0
  64. package/src/featureProvider/featureProviderHelpers.js +0 -50
  65. package/src/util/splitScreen.js +0 -233
@@ -1,7 +1,7 @@
1
1
  import deepEqual from 'fast-deep-equal';
2
- import { HeightReference, ClassificationType, NearFarScalar, Cartesian3 } from '@vcmap/cesium';
2
+ import { Cartesian3, ClassificationType, HeightReference, NearFarScalar } from '@vcmap/cesium';
3
3
  import { check, checkMaybe } from '@vcsuite/check';
4
- import { parseBoolean, parseEnumKey, parseNumber, parseInteger } from '@vcsuite/parsers';
4
+ import { parseBoolean, parseEnumKey, parseInteger, parseNumber } from '@vcsuite/parsers';
5
5
  import { getLogger as getLoggerByName } from '@vcsuite/logger';
6
6
  import VcsEvent from '../vcsEvent.js';
7
7
 
@@ -35,23 +35,63 @@ function getLogger() {
35
35
  * @property {number} [modelHeading=0] - in degrees
36
36
  * @property {number} [modelPitch=0] - in degrees
37
37
  * @property {number} [modelRoll=0] - in degrees
38
+ * @property {boolean} [modelAutoScale]
38
39
  * @property {Object|undefined} modelOptions - Model options are merged with the model definition from model url, scale and orientation and accepts any option passed to a Cesium.Model.
40
+ * @property {VectorPropertiesPrimitiveOptions} [primitiveOptions] - primitive options to render in 3D instead of a billboard
39
41
  * @property {string|undefined} baseUrl - a base URL to resolve relative model URLs against.
40
42
  * @api
41
43
  */
42
44
 
43
45
  /**
44
- * @typedef {Object} VectorPropertiesModelOptions
45
- * @property {string} url
46
+ * @typedef {Object} VectorPropertiesBaseOptions
46
47
  * @property {Array<number>} scale
47
48
  * @property {number} heading
48
49
  * @property {number} pitch
49
50
  * @property {number} roll
51
+ * @property {boolean} autoScale
52
+ */
53
+
54
+ /**
55
+ * @typedef {VectorPropertiesBaseOptions} VectorPropertiesModelOptions
56
+ * @property {string} url
50
57
  * @api
51
58
  */
52
59
 
60
+ /**
61
+ * @typedef {Object} VectorPropertiesPrimitiveOptions
62
+ * @property {PrimitiveOptionsType} type
63
+ * @property {*} geometryOptions - the options for the specified geometry
64
+ * @property {import("ol/color").Color|import("ol/colorlike").ColorLike} [depthFailColor]
65
+ * @property {import("ol/coordinate").Coordinate} [offset] an offset to apply to the geometry
66
+ * @property {Object} [additionalOptions] - additional options passed to the Primitive constructor
67
+ */
68
+
69
+ /**
70
+ * @typedef {VectorPropertiesBaseOptions} VectorPropertiesPrimitive
71
+ * @property {VectorPropertiesPrimitiveOptions} primitiveOptions
72
+ */
73
+
74
+ /**
75
+ * @enum {string}
76
+ * @property {string} CYLINDER
77
+ * @property {string} SPHERE
78
+ * @property {string} ELLIPSE
79
+ * @property {string} ELLIPSOID
80
+ * @property {string} BOC
81
+ * @const
82
+ */
83
+ export const PrimitiveOptionsType = {
84
+ CYLINDER: 'cylinder',
85
+ SPHERE: 'sphere',
86
+ ELLIPSOID: 'ellipsoid',
87
+ BOX: 'box',
88
+ };
89
+
53
90
  /**
54
91
  * @enum {import("@vcmap/cesium").HeightReference}
92
+ * @property {import("@vcmap/cesium").HeightReference} clampToGround
93
+ * @property {import("@vcmap/cesium").HeightReference} absolute
94
+ * @property {import("@vcmap/cesium").HeightReference} relativeToGround
55
95
  * @const
56
96
  */
57
97
  export const AltitudeModeCesium = {
@@ -62,6 +102,9 @@ export const AltitudeModeCesium = {
62
102
 
63
103
  /**
64
104
  * @enum {import("@vcmap/cesium").ClassificationType}
105
+ * @property {import("@vcmap/cesium").ClassificationType} both
106
+ * @property {import("@vcmap/cesium").ClassificationType} cesium3DTile
107
+ * @property {import("@vcmap/cesium").ClassificationType} terrain
65
108
  * @const
66
109
  */
67
110
  export const ClassificationTypeCesium = {
@@ -197,7 +240,9 @@ class VectorProperties {
197
240
  modelPitch: 0,
198
241
  modelRoll: 0,
199
242
  modelOptions: undefined,
243
+ modelAutoScale: false,
200
244
  baseUrl: undefined,
245
+ primitiveOptions: undefined,
201
246
  };
202
247
  }
203
248
 
@@ -345,6 +390,16 @@ class VectorProperties {
345
390
  * @private
346
391
  */
347
392
  this._modelOptions = options.modelOptions || defaultValues.modelOptions;
393
+ /**
394
+ * @type {boolean}
395
+ * @private
396
+ */
397
+ this._modelAutoScale = parseBoolean(options.modelAutoScale, defaultValues.modelAutoScale);
398
+ /**
399
+ * @type {VectorPropertiesPrimitiveOptions}
400
+ * @private
401
+ */
402
+ this._primitiveOptions = options.primitiveOptions || defaultValues.primitiveOptions;
348
403
 
349
404
  /**
350
405
  * Event raised when properties change. is passed an array of keys for the changed properties.
@@ -1010,6 +1065,35 @@ class VectorProperties {
1010
1065
  return {};
1011
1066
  }
1012
1067
 
1068
+ /**
1069
+ * @type {boolean}
1070
+ */
1071
+ get modelAutoScale() {
1072
+ return this._modelAutoScale;
1073
+ }
1074
+
1075
+ /**
1076
+ * @param {boolean} value
1077
+ */
1078
+ set modelAutoScale(value) {
1079
+ checkMaybe(value, Boolean);
1080
+
1081
+ const booleanValue = !!value;
1082
+ if (this._modelAutoScale !== booleanValue) {
1083
+ this._modelAutoScale = booleanValue;
1084
+ this.propertyChanged.raiseEvent(['modelAutoScale']);
1085
+ }
1086
+ }
1087
+
1088
+ /**
1089
+ * @param {import("ol").Feature<import("ol/geom/Geometry").default>} feature
1090
+ * @returns {*|boolean}
1091
+ */
1092
+ getModelAutoScale(feature) {
1093
+ const featureValue = feature.get('olcs_modelAutoScale');
1094
+ return featureValue !== undefined ? featureValue : this.modelAutoScale;
1095
+ }
1096
+
1013
1097
  /**
1014
1098
  * @api
1015
1099
  * @type {string}
@@ -1040,6 +1124,67 @@ class VectorProperties {
1040
1124
  return featureValue !== undefined ? featureValue : this.baseUrl;
1041
1125
  }
1042
1126
 
1127
+ /**
1128
+ * @type {VectorPropertiesPrimitiveOptions}
1129
+ */
1130
+ get primitiveOptions() {
1131
+ return this._primitiveOptions;
1132
+ }
1133
+
1134
+ /**
1135
+ * @param {VectorPropertiesPrimitiveOptions|undefined} value
1136
+ */
1137
+ set primitiveOptions(value) {
1138
+ checkMaybe(value, Object);
1139
+
1140
+ if (this._primitiveOptions !== value) {
1141
+ this._primitiveOptions = value;
1142
+ this.propertyChanged.raiseEvent(['primitiveOptions']);
1143
+ }
1144
+ }
1145
+
1146
+ /**
1147
+ * @param {import("ol").Feature<import("ol/geom/Geometry").default>} feature
1148
+ * @returns {VectorPropertiesPrimitiveOptions|null}
1149
+ * @api
1150
+ */
1151
+ getPrimitiveOptions(feature) {
1152
+ const featureValue = feature.get('olcs_primitiveOptions');
1153
+ return featureValue !== undefined ? featureValue : this.primitiveOptions;
1154
+ }
1155
+
1156
+ /**
1157
+ * @param {import("ol").Feature<import("ol/geom/Geometry").default>} feature
1158
+ * @returns {VectorPropertiesBaseOptions}
1159
+ * @private
1160
+ */
1161
+ _getBaseOptions(feature) {
1162
+ return {
1163
+ scale: [this.getModelScaleX(feature), this.getModelScaleY(feature), this.getModelScaleZ(feature)],
1164
+ heading: this.getModelHeading(feature),
1165
+ pitch: this.getModelPitch(feature),
1166
+ roll: this.getModelRoll(feature),
1167
+ autoScale: this.getModelAutoScale(feature),
1168
+ };
1169
+ }
1170
+
1171
+ /**
1172
+ * Returns the primive definition of this feature
1173
+ * @param {import("ol").Feature<import("ol/geom/Geometry").default>} feature
1174
+ * @returns {VectorPropertiesPrimitive|null}
1175
+ */
1176
+ getPrimitive(feature) {
1177
+ const primitiveOptions = this.getPrimitiveOptions(feature);
1178
+ if (!primitiveOptions?.geometryOptions) {
1179
+ return null;
1180
+ }
1181
+
1182
+ return {
1183
+ ...this._getBaseOptions(feature),
1184
+ primitiveOptions,
1185
+ };
1186
+ }
1187
+
1043
1188
  /**
1044
1189
  * @param {import("ol").Feature<import("ol/geom/Geometry").default>} feature
1045
1190
  * @returns {VectorPropertiesModelOptions|null}
@@ -1057,11 +1202,8 @@ class VectorProperties {
1057
1202
  }
1058
1203
 
1059
1204
  return {
1205
+ ...this._getBaseOptions(feature),
1060
1206
  url,
1061
- scale: [this.getModelScaleX(feature), this.getModelScaleY(feature), this.getModelScaleZ(feature)],
1062
- heading: this.getModelHeading(feature),
1063
- pitch: this.getModelPitch(feature),
1064
- roll: this.getModelRoll(feature),
1065
1207
  };
1066
1208
  }
1067
1209
 
@@ -12,7 +12,6 @@ import { FeatureVisibilityAction, globalHidden, hidden, highlighted } from './fe
12
12
  import { getStylesArray } from '../util/featureconverter/convert.js';
13
13
  import { vcsLayerName } from './layerSymbols.js';
14
14
  import TileProviderFeatureProvider from '../featureProvider/tileProviderFeatureProvider.js';
15
- import { getGenericFeatureFromClickedObject } from './vectorHelpers.js';
16
15
  import { originalFeatureSymbol } from './vectorSymbols.js';
17
16
  import { getObjectFromClassRegistry, layerClassRegistry, tileProviderClassRegistry } from '../classRegistry.js';
18
17
  import TileProvider from './tileProvider/tileProvider.js';
@@ -238,14 +237,6 @@ class VectorTileLayer extends FeatureLayer {
238
237
  return null;
239
238
  }
240
239
 
241
- /**
242
- * @param {VectorClickedObject} object
243
- * @returns {?GenericFeature}
244
- */
245
- getGenericFeatureFromClickedObject(object) {
246
- return getGenericFeatureFromClickedObject(object, this);
247
- }
248
-
249
240
  /**
250
241
  * @returns {number}
251
242
  * @private
@@ -60,6 +60,23 @@ class BaseOLMap extends VcsMap {
60
60
  this._olListeners = [];
61
61
  }
62
62
 
63
+ /**
64
+ * @type {number}
65
+ * @inheritDoc
66
+ */
67
+ get splitPosition() {
68
+ return super.splitPosition;
69
+ }
70
+
71
+ /**
72
+ * @param {number} position
73
+ * @inheritDoc
74
+ */
75
+ set splitPosition(position) {
76
+ super.splitPosition = position;
77
+ this.requestRender();
78
+ }
79
+
63
80
  /**
64
81
  * @returns {import("ol/Map").default}
65
82
  * @readonly
@@ -27,6 +27,7 @@ import {
27
27
  KeyboardEventModifier,
28
28
  ScreenSpaceEventType,
29
29
  Cesium3DTileset,
30
+ Cartographic,
30
31
  } from '@vcmap/cesium';
31
32
 
32
33
  import { check, checkMaybe } from '@vcsuite/check';
@@ -350,6 +351,25 @@ class CesiumMap extends VcsMap {
350
351
  this._lastEventFrameNumber = null;
351
352
  }
352
353
 
354
+ /**
355
+ * @type {number}
356
+ * @inheritDoc
357
+ */
358
+ get splitPosition() {
359
+ return super.splitPosition;
360
+ }
361
+
362
+ /**
363
+ * @param {number} position
364
+ * @inheritDoc
365
+ */
366
+ set splitPosition(position) {
367
+ super.splitPosition = position;
368
+ if (this._cesiumWidget) {
369
+ this._cesiumWidget.scene.splitPosition = position;
370
+ }
371
+ }
372
+
353
373
  /**
354
374
  * @returns {import("@vcmap/cesium").TerrainProvider}
355
375
  * @api
@@ -524,7 +544,7 @@ class CesiumMap extends VcsMap {
524
544
  this._cesiumWidget.scene.globe.depthTestAgainstTerrain = true;
525
545
  this._cesiumWidget.scene.highDynamicRange = false;
526
546
  // this._cesiumWidget.scene.logarithmicDepthBuffer = false; // TODO observe this
527
- this._cesiumWidget.scene.splitPosition = 0.5;
547
+ this._cesiumWidget.scene.splitPosition = this.splitPosition;
528
548
 
529
549
  this._cesiumWidget.scene.globe.enableLighting = this.enableLightning;
530
550
 
@@ -739,15 +759,14 @@ class CesiumMap extends VcsMap {
739
759
  }
740
760
 
741
761
  /**
742
- * @inheritDoc
743
- * @param {import("ol/coordinate").Coordinate} coordinate - in mercator
762
+ * @param {import("@vcmap/cesium").Cartesian3} cartesian
763
+ * @param {number} latitude - in radians
744
764
  * @returns {number}
765
+ * @private
745
766
  */
746
- getCurrentResolution(coordinate) {
767
+ _getCurrentResolutionFromCartesianLatitude(cartesian, latitude) {
747
768
  const cam = this._cesiumWidget.scene.camera;
748
- const wgs84Coordinate = Projection.mercatorToWgs84(coordinate);
749
- const distance = Cartesian3
750
- .distance(Cartesian3.fromDegrees(wgs84Coordinate[0], wgs84Coordinate[1], wgs84Coordinate[2]), cam.position);
769
+ const distance = Cartesian3.distance(cartesian, cam.position);
751
770
 
752
771
  const fov = Math.PI / 3.0;
753
772
  const width = this.mapElement.offsetWidth;
@@ -755,12 +774,31 @@ class CesiumMap extends VcsMap {
755
774
  const aspectRatio = width / height;
756
775
  const fovy = Math.atan(Math.tan(fov * 0.5) / aspectRatio) * 2.0;
757
776
  const visibleMeters = 2 * distance * Math.tan(fovy / 2);
758
- const relativeCircumference = Math.cos(Math.abs(CesiumMath.toRadians(wgs84Coordinate[1])));
777
+ const relativeCircumference = Math.cos(Math.abs(latitude));
759
778
  const visibleMapUnits = visibleMeters / relativeCircumference;
760
779
 
761
780
  return visibleMapUnits / height;
762
781
  }
763
782
 
783
+ /**
784
+ * @inheritDoc
785
+ * @param {import("ol/coordinate").Coordinate} coordinate - in mercator
786
+ * @returns {number}
787
+ */
788
+ getCurrentResolution(coordinate) {
789
+ const wgs84Coordinate = Projection.mercatorToWgs84(coordinate);
790
+ const cartesian = Cartesian3.fromDegrees(wgs84Coordinate[0], wgs84Coordinate[1], wgs84Coordinate[2]);
791
+ return this._getCurrentResolutionFromCartesianLatitude(cartesian, CesiumMath.toRadians(wgs84Coordinate[1]));
792
+ }
793
+
794
+ /**
795
+ * @param {import("@vcmap/cesium").Cartesian3} cartesian
796
+ * @returns {number}
797
+ */
798
+ getCurrentResolutionFromCartesian(cartesian) {
799
+ return this._getCurrentResolutionFromCartesianLatitude(cartesian, Cartographic.fromCartesian(cartesian).latitude);
800
+ }
801
+
764
802
  /**
765
803
  * @param {boolean} bool
766
804
  * @inheritDoc
package/src/map/vcsMap.js CHANGED
@@ -153,12 +153,10 @@ class VcsMap extends VcsObject {
153
153
  */
154
154
  this.pointerInteractionEvent = new VcsEvent();
155
155
  /**
156
- * If present, the split screen to use on this map. Is set by the mapCollection
157
- * @type {import("@vcmap/core").SplitScreen|null}
158
- * @api
156
+ * The split position to use on this map. Is set by the mapCollection
157
+ * @type {number}
159
158
  */
160
- this.splitScreen = null;
161
-
159
+ this._splitPosition = 0.5;
162
160
  /**
163
161
  * @type {VcsEvent<VcsMapRenderEvent>}
164
162
  * @private
@@ -229,6 +227,26 @@ class VcsMap extends VcsObject {
229
227
  this._setLayerCollectionListeners();
230
228
  }
231
229
 
230
+ /**
231
+ * @type {number}
232
+ */
233
+ get splitPosition() {
234
+ return this._splitPosition;
235
+ }
236
+
237
+ /**
238
+ * The splitPosition should always be aligned with the mapCollection's splitPosition.
239
+ * Use mapCollection to change splitPosition.
240
+ * @param {number} position
241
+ */
242
+ set splitPosition(position) {
243
+ check(position, Number);
244
+ if (position < 0 || position > 1) {
245
+ throw new Error('Position must be between 0 and 1');
246
+ }
247
+ this._splitPosition = position;
248
+ }
249
+
232
250
  /**
233
251
  * An event raised on the maps post render
234
252
  * @type {VcsEvent<VcsMapRenderEvent>}