@vcmap/core 5.0.0-rc.28 → 5.0.0-rc.29
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/README.md +9 -3
- package/build/postinstall.js +13 -2
- package/index.d.ts +155 -106
- package/package.json +9 -4
- package/src/category/category.js +71 -32
- package/src/category/categoryCollection.js +27 -18
- package/src/cesium/cesiumVcsCameraPrimitive.js +13 -5
- package/src/cesium/entity.js +3 -1
- package/src/cesium/wallpaperMaterial.js +4 -2
- package/src/classRegistry.js +11 -4
- package/src/featureProvider/abstractFeatureProvider.js +43 -22
- package/src/featureProvider/tileProviderFeatureProvider.js +11 -5
- package/src/featureProvider/wmsFeatureProvider.js +37 -15
- package/src/interaction/abstractInteraction.js +5 -1
- package/src/interaction/coordinateAtPixel.js +34 -12
- package/src/interaction/eventHandler.js +63 -23
- package/src/interaction/featureAtPixelInteraction.js +96 -32
- package/src/interaction/featureProviderInteraction.js +23 -8
- package/src/interaction/interactionChain.js +19 -9
- package/src/interaction/interactionType.js +23 -26
- package/src/layer/cesium/cesiumTilesetCesiumImpl.js +45 -15
- package/src/layer/cesium/clusterContext.js +10 -3
- package/src/layer/cesium/dataSourceCesiumImpl.js +13 -4
- package/src/layer/cesium/openStreetMapCesiumImpl.js +7 -3
- package/src/layer/cesium/rasterLayerCesiumImpl.js +6 -2
- package/src/layer/cesium/singleImageCesiumImpl.js +14 -3
- package/src/layer/cesium/terrainCesiumImpl.js +3 -2
- package/src/layer/cesium/tmsCesiumImpl.js +15 -3
- package/src/layer/cesium/vectorCesiumImpl.js +69 -25
- package/src/layer/cesium/vectorContext.js +25 -5
- package/src/layer/cesium/vectorRasterTileCesiumImpl.js +15 -5
- package/src/layer/cesium/vectorTileImageryProvider.js +51 -13
- package/src/layer/cesium/wmsCesiumImpl.js +15 -3
- package/src/layer/cesium/wmtsCesiumImpl.js +18 -6
- package/src/layer/cesium/x3dmHelper.js +4 -1
- package/src/layer/cesiumTilesetLayer.js +55 -26
- package/src/layer/czmlLayer.js +11 -5
- package/src/layer/dataSourceLayer.js +25 -17
- package/src/layer/featureLayer.js +33 -18
- package/src/layer/featureStoreLayer.js +161 -99
- package/src/layer/featureStoreLayerChanges.js +57 -17
- package/src/layer/featureVisibility.js +89 -59
- package/src/layer/geojsonHelpers.js +70 -29
- package/src/layer/geojsonLayer.js +17 -11
- package/src/layer/globalHider.js +14 -4
- package/src/layer/layer.js +77 -44
- package/src/layer/layerImplementation.js +12 -4
- package/src/layer/oblique/layerObliqueImpl.js +3 -1
- package/src/layer/oblique/obliqueHelpers.js +75 -30
- package/src/layer/oblique/vectorObliqueImpl.js +175 -69
- package/src/layer/openStreetMapLayer.js +34 -20
- package/src/layer/openlayers/layerOpenlayersImpl.js +37 -15
- package/src/layer/openlayers/openStreetMapOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/rasterLayerOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/singleImageOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/tileDebugOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/tmsOpenlayersImpl.js +6 -3
- package/src/layer/openlayers/vectorOpenlayersImpl.js +14 -4
- package/src/layer/openlayers/vectorTileOpenlayersImpl.js +12 -5
- package/src/layer/openlayers/wmsOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/wmtsOpenlayersImpl.js +12 -5
- package/src/layer/pointCloudLayer.js +21 -10
- package/src/layer/rasterLayer.js +73 -22
- package/src/layer/singleImageLayer.js +10 -7
- package/src/layer/terrainHelpers.js +30 -19
- package/src/layer/terrainLayer.js +16 -7
- package/src/layer/tileLoadedHelper.js +9 -4
- package/src/layer/tileProvider/mvtTileProvider.js +10 -4
- package/src/layer/tileProvider/staticGeojsonTileProvider.js +10 -4
- package/src/layer/tileProvider/tileProvider.js +163 -87
- package/src/layer/tileProvider/urlTemplateTileProvider.js +10 -4
- package/src/layer/tmsLayer.js +7 -6
- package/src/layer/vectorHelpers.js +34 -25
- package/src/layer/vectorLayer.js +77 -36
- package/src/layer/vectorProperties.js +245 -74
- package/src/layer/vectorSymbols.js +3 -1
- package/src/layer/vectorTileLayer.js +121 -70
- package/src/layer/wfsLayer.js +19 -8
- package/src/layer/wmsHelpers.js +11 -6
- package/src/layer/wmsLayer.js +36 -14
- package/src/layer/wmtsLayer.js +35 -20
- package/src/map/baseOLMap.js +57 -31
- package/src/map/cameraLimiter.js +67 -18
- package/src/map/cesiumMap.js +307 -95
- package/src/map/obliqueMap.js +84 -34
- package/src/map/openlayersMap.js +40 -19
- package/src/map/vcsMap.js +21 -8
- package/src/oblique/helpers.js +212 -64
- package/src/oblique/obliqueCollection.js +111 -48
- package/src/oblique/obliqueDataSet.js +53 -21
- package/src/oblique/obliqueImage.js +50 -17
- package/src/oblique/obliqueImageMeta.js +7 -6
- package/src/oblique/obliqueProvider.js +75 -27
- package/src/oblique/obliqueView.js +18 -7
- package/src/oblique/obliqueViewDirection.js +3 -2
- package/src/oblique/parseImageJson.js +57 -23
- package/src/ol/feature.js +8 -3
- package/src/ol/geom/circle.js +12 -3
- package/src/ol/geom/geometryCollection.js +11 -4
- package/src/ol/render/canvas/canvasTileRenderer.js +11 -9
- package/src/overrideClassRegistry.js +13 -3
- package/src/style/arcStyle.js +129 -36
- package/src/style/arrowStyle.js +57 -22
- package/src/style/declarativeStyleItem.js +107 -62
- package/src/style/shapesCategory.js +8 -6
- package/src/style/styleFactory.js +4 -1
- package/src/style/styleHelpers.js +17 -8
- package/src/style/styleItem.js +28 -10
- package/src/style/vectorStyleItem.js +160 -74
- package/src/style/writeStyle.js +5 -7
- package/src/util/clipping/clippingObject.js +72 -38
- package/src/util/clipping/clippingObjectManager.js +53 -19
- package/src/util/clipping/clippingPlaneHelper.js +120 -53
- package/src/util/collection.js +12 -6
- package/src/util/editor/createFeatureSession.js +21 -6
- package/src/util/editor/editFeaturesSession.js +41 -15
- package/src/util/editor/editGeometrySession.js +55 -30
- package/src/util/editor/editorHelpers.js +114 -29
- package/src/util/editor/editorSessionHelpers.js +8 -3
- package/src/util/editor/interactions/createBBoxInteraction.js +11 -3
- package/src/util/editor/interactions/createCircleInteraction.js +7 -2
- package/src/util/editor/interactions/createLineStringInteraction.js +7 -2
- package/src/util/editor/interactions/createPolygonInteraction.js +7 -2
- package/src/util/editor/interactions/editFeaturesMouseOverInteraction.js +7 -5
- package/src/util/editor/interactions/editGeometryMouseOverInteraction.js +8 -3
- package/src/util/editor/interactions/ensureHandlerSelectionInteraction.js +4 -2
- package/src/util/editor/interactions/insertVertexInteraction.js +17 -6
- package/src/util/editor/interactions/mapInteractionController.js +31 -14
- package/src/util/editor/interactions/removeVertexInteraction.js +4 -1
- package/src/util/editor/interactions/selectFeatureMouseOverInteraction.js +19 -10
- package/src/util/editor/interactions/selectMultiFeatureInteraction.js +33 -20
- package/src/util/editor/interactions/selectSingleFeatureInteraction.js +14 -8
- package/src/util/editor/selectFeaturesSession.js +37 -21
- package/src/util/editor/transformation/create2DHandlers.js +82 -37
- package/src/util/editor/transformation/create3DHandlers.js +187 -84
- package/src/util/editor/transformation/extrudeInteraction.js +20 -5
- package/src/util/editor/transformation/rotateInteraction.js +29 -16
- package/src/util/editor/transformation/scaleInteraction.js +31 -15
- package/src/util/editor/transformation/transformationHandler.js +23 -8
- package/src/util/editor/transformation/transformationTypes.js +8 -4
- package/src/util/editor/transformation/translateInteraction.js +86 -32
- package/src/util/editor/validateGeoemetry.js +3 -1
- package/src/util/exclusiveManager.js +6 -3
- package/src/util/extent.js +20 -10
- package/src/util/featureconverter/arcToCesium.js +46 -12
- package/src/util/featureconverter/circleToCesium.js +61 -27
- package/src/util/featureconverter/convert.js +85 -13
- package/src/util/featureconverter/extent3D.js +69 -28
- package/src/util/featureconverter/featureconverterHelper.js +232 -79
- package/src/util/featureconverter/lineStringToCesium.js +107 -35
- package/src/util/featureconverter/pointHelpers.js +117 -45
- package/src/util/featureconverter/pointToCesium.js +128 -31
- package/src/util/featureconverter/polygonToCesium.js +50 -16
- package/src/util/fetch.js +3 -1
- package/src/util/geometryHelpers.js +15 -10
- package/src/util/indexedCollection.js +7 -3
- package/src/util/isMobile.js +8 -2
- package/src/util/layerCollection.js +28 -12
- package/src/util/mapCollection.js +37 -18
- package/src/util/math.js +35 -19
- package/src/util/overrideCollection.js +57 -32
- package/src/util/projection.js +21 -5
- package/src/util/urlHelpers.js +5 -3
- package/src/util/viewpoint.js +66 -33
- package/src/vcsApp.js +133 -69
- package/src/vcsModule.js +3 -2
- package/src/vcsModuleHelpers.js +24 -9
- package/src/vcsObject.js +3 -2
- package/tests/data/dynamicPointCzml.json +24 -35
- package/tests/data/oblique/imageData/imagev34.json +56 -272
- package/tests/data/oblique/imageData/imagev35.json +272 -19
- package/tests/data/oblique/imageData/imagev35PerImageSize.json +299 -19
- package/tests/data/oblique/tiledImageData/12/2199/1342.json +11056 -1
- package/tests/data/oblique/tiledImageData/12/2199/1343.json +11236 -1
- package/tests/data/oblique/tiledImageData/12/2199/1344.json +11077 -1
- package/tests/data/oblique/tiledImageData/12/2200/1342.json +11036 -1
- package/tests/data/oblique/tiledImageData/12/2200/1343.json +11277 -1
- package/tests/data/oblique/tiledImageData/12/2200/1344.json +11131 -1
- package/tests/data/oblique/tiledImageData/12/2201/1342.json +10870 -1
- package/tests/data/oblique/tiledImageData/12/2201/1343.json +11492 -1
- package/tests/data/oblique/tiledImageData/12/2201/1344.json +10909 -1
- package/tests/data/oblique/tiledImageData/image.json +70 -1
- package/tests/data/terrain/layer.json +121 -130
- package/tests/data/testGeoJSON.json +4 -16
- package/tests/unit/helpers/cesiumHelpers.js +58 -33
- package/tests/unit/helpers/helpers.js +10 -2
- package/tests/unit/helpers/imageHelpers.js +8 -4
- package/tests/unit/helpers/obliqueData.js +39 -13
- package/tests/unit/helpers/obliqueHelpers.js +12 -9
- package/tests/unit/helpers/openlayersHelpers.js +4 -1
- package/tests/unit/helpers/terrain/terrainData.js +8 -7
|
@@ -37,7 +37,12 @@ export function getCoordinates(geometries) {
|
|
|
37
37
|
* @param {import("@vcmap/core").VectorProperties} vectorProperties
|
|
38
38
|
* @returns {Object|null}
|
|
39
39
|
*/
|
|
40
|
-
export function getBillboardOptions(
|
|
40
|
+
export function getBillboardOptions(
|
|
41
|
+
feature,
|
|
42
|
+
style,
|
|
43
|
+
heightReference,
|
|
44
|
+
vectorProperties,
|
|
45
|
+
) {
|
|
41
46
|
const imageStyle = style.getImage();
|
|
42
47
|
if (imageStyle) {
|
|
43
48
|
// ImageStyles should always have an opacity value between 0 and 1, default white Color
|
|
@@ -49,7 +54,10 @@ export function getBillboardOptions(feature, style, heightReference, vectorPrope
|
|
|
49
54
|
if (imageStyle.getImageState() === ImageState.LOADING) {
|
|
50
55
|
image = new Promise((resolve, reject) => {
|
|
51
56
|
const imageChangeListener = () => {
|
|
52
|
-
if (
|
|
57
|
+
if (
|
|
58
|
+
imageStyle.getImageState() === ImageState.LOADED ||
|
|
59
|
+
imageStyle.getImageState() === ImageState.EMPTY
|
|
60
|
+
) {
|
|
53
61
|
resolve(imageStyle.getImage(1));
|
|
54
62
|
imageStyle.unlistenImageChange(imageChangeListener);
|
|
55
63
|
} else if (imageStyle.getImageState() === ImageState.ERROR) {
|
|
@@ -67,7 +75,7 @@ export function getBillboardOptions(feature, style, heightReference, vectorPrope
|
|
|
67
75
|
const options = {
|
|
68
76
|
image,
|
|
69
77
|
color,
|
|
70
|
-
scale: imageStyle.
|
|
78
|
+
scale: imageStyle.getScaleArray()[0],
|
|
71
79
|
heightReference,
|
|
72
80
|
verticalOrigin: VerticalOrigin.BOTTOM,
|
|
73
81
|
id: feature.getId(),
|
|
@@ -90,7 +98,12 @@ export function getBillboardOptions(feature, style, heightReference, vectorPrope
|
|
|
90
98
|
* @param {import("@vcmap/core").VectorProperties} vectorProperties
|
|
91
99
|
* @returns {Object|null}
|
|
92
100
|
*/
|
|
93
|
-
export function getLabelOptions(
|
|
101
|
+
export function getLabelOptions(
|
|
102
|
+
feature,
|
|
103
|
+
style,
|
|
104
|
+
heightReference,
|
|
105
|
+
vectorProperties,
|
|
106
|
+
) {
|
|
94
107
|
const textStyle = style.getText();
|
|
95
108
|
const text = textStyle ? textStyle.getText() : null;
|
|
96
109
|
if (text) {
|
|
@@ -103,10 +116,7 @@ export function getLabelOptions(feature, style, heightReference, vectorPropertie
|
|
|
103
116
|
const offsetX = textStyle.getOffsetX() ?? 0;
|
|
104
117
|
const offsetY = textStyle.getOffsetY() ?? 0;
|
|
105
118
|
options.pixelOffset = new Cartesian2(offsetX, offsetY);
|
|
106
|
-
|
|
107
|
-
if (scale) {
|
|
108
|
-
options.scale = Array.isArray(scale) ? scale[0] : scale;
|
|
109
|
-
}
|
|
119
|
+
options.scale = textStyle.getScaleArray()[0];
|
|
110
120
|
|
|
111
121
|
const font = textStyle.getFont();
|
|
112
122
|
if (font) {
|
|
@@ -184,7 +194,7 @@ export function validatePoint(point) {
|
|
|
184
194
|
}
|
|
185
195
|
const flatCoordinates = point.getFlatCoordinates();
|
|
186
196
|
if (flatCoordinates && flatCoordinates.length >= 2) {
|
|
187
|
-
return flatCoordinates.every(value => Number.isFinite(value));
|
|
197
|
+
return flatCoordinates.every((value) => Number.isFinite(value));
|
|
188
198
|
}
|
|
189
199
|
return false;
|
|
190
200
|
}
|
|
@@ -198,8 +208,12 @@ export function validatePoint(point) {
|
|
|
198
208
|
export function getCartesian3AndWGS84FromCoordinates(coordinates, heightInfo) {
|
|
199
209
|
const wgs84Positions = new Array(coordinates.length);
|
|
200
210
|
const positions = new Array(coordinates.length);
|
|
201
|
-
const heightValue =
|
|
202
|
-
heightInfo.
|
|
211
|
+
const heightValue =
|
|
212
|
+
heightInfo.groundLevel +
|
|
213
|
+
heightInfo.storeyHeightsAboveGround.reduce(
|
|
214
|
+
(sum, currentValue) => sum + currentValue,
|
|
215
|
+
0,
|
|
216
|
+
);
|
|
203
217
|
coordinates.forEach((coord, index) => {
|
|
204
218
|
wgs84Positions[index] = Projection.mercatorToWgs84(coord, true);
|
|
205
219
|
let height = null;
|
|
@@ -224,17 +238,33 @@ export function getCartesian3AndWGS84FromCoordinates(coordinates, heightInfo) {
|
|
|
224
238
|
* @returns {Array<import("@vcmap-cesium/engine").PolylineGeometry>}
|
|
225
239
|
* @private
|
|
226
240
|
*/
|
|
227
|
-
export function getLineGeometries(
|
|
241
|
+
export function getLineGeometries(
|
|
242
|
+
wgs84Positions,
|
|
243
|
+
heightInfo,
|
|
244
|
+
positions,
|
|
245
|
+
style,
|
|
246
|
+
) {
|
|
228
247
|
const lineGeometries = [];
|
|
229
|
-
const heightValueCorrection =
|
|
230
|
-
heightInfo.
|
|
248
|
+
const heightValueCorrection =
|
|
249
|
+
heightInfo.skirt +
|
|
250
|
+
heightInfo.storeyHeightsBelowGround.reduce(
|
|
251
|
+
(sum, currentValue) => sum + currentValue,
|
|
252
|
+
0,
|
|
253
|
+
);
|
|
231
254
|
for (let i = 0; i < wgs84Positions.length; i++) {
|
|
232
255
|
const pointPosition = wgs84Positions[i];
|
|
233
|
-
let heightValue =
|
|
256
|
+
let heightValue =
|
|
257
|
+
pointPosition[2] != null ? pointPosition[2] : heightInfo.groundLevel;
|
|
234
258
|
heightValue -= heightValueCorrection;
|
|
235
|
-
const secondPoint = Cartesian3.fromDegrees(
|
|
259
|
+
const secondPoint = Cartesian3.fromDegrees(
|
|
260
|
+
pointPosition[0],
|
|
261
|
+
pointPosition[1],
|
|
262
|
+
heightValue,
|
|
263
|
+
);
|
|
236
264
|
const linePositions = [positions[i], secondPoint];
|
|
237
|
-
lineGeometries.push(
|
|
265
|
+
lineGeometries.push(
|
|
266
|
+
...createLineGeometries({ positions: linePositions }, style),
|
|
267
|
+
);
|
|
238
268
|
}
|
|
239
269
|
return lineGeometries;
|
|
240
270
|
}
|
|
@@ -247,11 +277,18 @@ export function getLineGeometries(wgs84Positions, heightInfo, positions, style)
|
|
|
247
277
|
* @param {import("@vcmap-cesium/engine").Scene} scene
|
|
248
278
|
* @param {import("@vcmap/core").VectorContext|import("@vcmap/core").ClusterContext} context
|
|
249
279
|
*/
|
|
250
|
-
export default function pointToCesium(
|
|
280
|
+
export default function pointToCesium(
|
|
281
|
+
feature,
|
|
282
|
+
style,
|
|
283
|
+
geometries,
|
|
284
|
+
vectorProperties,
|
|
285
|
+
scene,
|
|
286
|
+
context,
|
|
287
|
+
) {
|
|
251
288
|
if (!style.getImage() && !(style.getText() && style.getText().getText())) {
|
|
252
289
|
return;
|
|
253
290
|
}
|
|
254
|
-
const validGeometries = geometries.filter(point => validatePoint(point));
|
|
291
|
+
const validGeometries = geometries.filter((point) => validatePoint(point));
|
|
255
292
|
|
|
256
293
|
// no geometries, so early escape
|
|
257
294
|
if (!validGeometries.length) {
|
|
@@ -263,24 +300,66 @@ export default function pointToCesium(feature, style, geometries, vectorProperti
|
|
|
263
300
|
let { heightReference } = heightInfo;
|
|
264
301
|
const allowPicking = vectorProperties.getAllowPicking(feature);
|
|
265
302
|
|
|
266
|
-
const { positions, wgs84Positions } = getCartesian3AndWGS84FromCoordinates(
|
|
303
|
+
const { positions, wgs84Positions } = getCartesian3AndWGS84FromCoordinates(
|
|
304
|
+
coordinates,
|
|
305
|
+
heightInfo,
|
|
306
|
+
);
|
|
267
307
|
|
|
268
308
|
let modelOrPrimitiveOptions = null;
|
|
269
309
|
if (feature.get('olcs_modelUrl')) {
|
|
270
|
-
modelOrPrimitiveOptions = getModelOptions(
|
|
310
|
+
modelOrPrimitiveOptions = getModelOptions(
|
|
311
|
+
feature,
|
|
312
|
+
wgs84Positions,
|
|
313
|
+
positions,
|
|
314
|
+
vectorProperties,
|
|
315
|
+
scene,
|
|
316
|
+
);
|
|
271
317
|
} else if (feature.get('olcs_primitiveOptions')) {
|
|
272
|
-
modelOrPrimitiveOptions = getPrimitiveOptions(
|
|
318
|
+
modelOrPrimitiveOptions = getPrimitiveOptions(
|
|
319
|
+
feature,
|
|
320
|
+
style,
|
|
321
|
+
wgs84Positions,
|
|
322
|
+
positions,
|
|
323
|
+
vectorProperties,
|
|
324
|
+
scene,
|
|
325
|
+
);
|
|
273
326
|
} else {
|
|
274
|
-
modelOrPrimitiveOptions =
|
|
275
|
-
|
|
327
|
+
modelOrPrimitiveOptions =
|
|
328
|
+
getModelOptions(
|
|
329
|
+
feature,
|
|
330
|
+
wgs84Positions,
|
|
331
|
+
positions,
|
|
332
|
+
vectorProperties,
|
|
333
|
+
scene,
|
|
334
|
+
) ??
|
|
335
|
+
getPrimitiveOptions(
|
|
336
|
+
feature,
|
|
337
|
+
style,
|
|
338
|
+
wgs84Positions,
|
|
339
|
+
positions,
|
|
340
|
+
vectorProperties,
|
|
341
|
+
scene,
|
|
342
|
+
);
|
|
276
343
|
}
|
|
277
344
|
|
|
278
345
|
if (heightInfo.extruded && style.getStroke()) {
|
|
279
|
-
const lineGeometries = getLineGeometries(
|
|
346
|
+
const lineGeometries = getLineGeometries(
|
|
347
|
+
wgs84Positions,
|
|
348
|
+
heightInfo,
|
|
349
|
+
positions,
|
|
350
|
+
style,
|
|
351
|
+
);
|
|
280
352
|
if (lineGeometries.length) {
|
|
281
353
|
heightReference = HeightReference.NONE;
|
|
282
|
-
const linePrimitive =
|
|
283
|
-
|
|
354
|
+
const linePrimitive = createLinePrimitive(
|
|
355
|
+
scene,
|
|
356
|
+
vectorProperties,
|
|
357
|
+
allowPicking,
|
|
358
|
+
feature,
|
|
359
|
+
lineGeometries,
|
|
360
|
+
style,
|
|
361
|
+
false,
|
|
362
|
+
);
|
|
284
363
|
if (linePrimitive) {
|
|
285
364
|
context.addPrimitives([linePrimitive], feature, allowPicking);
|
|
286
365
|
}
|
|
@@ -288,12 +367,25 @@ export default function pointToCesium(feature, style, geometries, vectorProperti
|
|
|
288
367
|
}
|
|
289
368
|
if (modelOrPrimitiveOptions) {
|
|
290
369
|
if (modelOrPrimitiveOptions.options.autoScale) {
|
|
291
|
-
context.addScaledPrimitives(
|
|
370
|
+
context.addScaledPrimitives(
|
|
371
|
+
modelOrPrimitiveOptions.primitives,
|
|
372
|
+
feature,
|
|
373
|
+
allowPicking,
|
|
374
|
+
);
|
|
292
375
|
} else {
|
|
293
|
-
context.addPrimitives(
|
|
376
|
+
context.addPrimitives(
|
|
377
|
+
modelOrPrimitiveOptions.primitives,
|
|
378
|
+
feature,
|
|
379
|
+
allowPicking,
|
|
380
|
+
);
|
|
294
381
|
}
|
|
295
382
|
} else {
|
|
296
|
-
const bbOptions = getBillboardOptions(
|
|
383
|
+
const bbOptions = getBillboardOptions(
|
|
384
|
+
feature,
|
|
385
|
+
style,
|
|
386
|
+
heightReference,
|
|
387
|
+
vectorProperties,
|
|
388
|
+
);
|
|
297
389
|
if (bbOptions) {
|
|
298
390
|
const bbOptionsperPosition = positions.map((position) => {
|
|
299
391
|
return { ...bbOptions, position };
|
|
@@ -301,7 +393,12 @@ export default function pointToCesium(feature, style, geometries, vectorProperti
|
|
|
301
393
|
context.addBillboards(bbOptionsperPosition, feature, allowPicking);
|
|
302
394
|
}
|
|
303
395
|
|
|
304
|
-
const labelOptions = getLabelOptions(
|
|
396
|
+
const labelOptions = getLabelOptions(
|
|
397
|
+
feature,
|
|
398
|
+
style,
|
|
399
|
+
heightReference,
|
|
400
|
+
vectorProperties,
|
|
401
|
+
);
|
|
305
402
|
if (labelOptions) {
|
|
306
403
|
const labelOptionsPerPosition = positions.map((position) => {
|
|
307
404
|
return { ...labelOptions, position };
|
|
@@ -20,7 +20,12 @@ import { getFlatCoordinatesFromSimpleGeometry } from '../geometryHelpers.js';
|
|
|
20
20
|
* @returns {Array<import("@vcmap-cesium/engine").PolygonGeometry>}
|
|
21
21
|
* @private
|
|
22
22
|
*/
|
|
23
|
-
export function createSolidGeometries(
|
|
23
|
+
export function createSolidGeometries(
|
|
24
|
+
options,
|
|
25
|
+
height,
|
|
26
|
+
perPositionHeight,
|
|
27
|
+
extrudedHeight,
|
|
28
|
+
) {
|
|
24
29
|
const polygonOptions = {
|
|
25
30
|
...options,
|
|
26
31
|
perPositionHeight,
|
|
@@ -40,14 +45,21 @@ export function createSolidGeometries(options, height, perPositionHeight, extrud
|
|
|
40
45
|
* @returns {Array<import("@vcmap-cesium/engine").PolygonOutlineGeometry>}
|
|
41
46
|
* @private
|
|
42
47
|
*/
|
|
43
|
-
export function createOutlineGeometries(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
export function createOutlineGeometries(
|
|
49
|
+
options,
|
|
50
|
+
height,
|
|
51
|
+
perPositionHeight,
|
|
52
|
+
extrudedHeight,
|
|
53
|
+
) {
|
|
54
|
+
return [
|
|
55
|
+
new PolygonOutlineGeometry({
|
|
56
|
+
...options,
|
|
57
|
+
height: perPositionHeight ? undefined : height,
|
|
58
|
+
extrudedHeight,
|
|
59
|
+
perPositionHeight,
|
|
60
|
+
vertexFormat: PerInstanceColorAppearance.FLAT_VERTEX_FORMAT,
|
|
61
|
+
}),
|
|
62
|
+
];
|
|
51
63
|
}
|
|
52
64
|
|
|
53
65
|
/**
|
|
@@ -107,7 +119,6 @@ export function createLineGeometries(options, style) {
|
|
|
107
119
|
});
|
|
108
120
|
}
|
|
109
121
|
|
|
110
|
-
|
|
111
122
|
/**
|
|
112
123
|
* @param {import("ol/geom/Polygon").default} geometry
|
|
113
124
|
* @param {number} positionHeightAdjustment
|
|
@@ -125,7 +136,11 @@ export function getGeometryOptions(geometry, positionHeightAdjustment) {
|
|
|
125
136
|
if (wgs84Coords[2] != null) {
|
|
126
137
|
wgs84Coords[2] += positionHeightAdjustment;
|
|
127
138
|
}
|
|
128
|
-
return Cartesian3.fromDegrees(
|
|
139
|
+
return Cartesian3.fromDegrees(
|
|
140
|
+
wgs84Coords[0],
|
|
141
|
+
wgs84Coords[1],
|
|
142
|
+
wgs84Coords[2],
|
|
143
|
+
);
|
|
129
144
|
});
|
|
130
145
|
// make sure the last and first vertex is identical.
|
|
131
146
|
if (!Cartesian3.equals(positions[0], positions[positions.length - 1])) {
|
|
@@ -201,8 +216,12 @@ export function validatePolygon(polygon) {
|
|
|
201
216
|
}
|
|
202
217
|
// should have at least three coordinates for each linearRing and every value should be a number
|
|
203
218
|
const minimumValues = stride * 3 * polygon.getLinearRingCount();
|
|
204
|
-
if (
|
|
205
|
-
|
|
219
|
+
if (
|
|
220
|
+
flatCoordinates &&
|
|
221
|
+
flatCoordinates.length >= minimumValues &&
|
|
222
|
+
polygon.getLinearRingCount()
|
|
223
|
+
) {
|
|
224
|
+
return flatCoordinates.every((value) => Number.isFinite(value));
|
|
206
225
|
}
|
|
207
226
|
return false;
|
|
208
227
|
}
|
|
@@ -216,13 +235,28 @@ export function validatePolygon(polygon) {
|
|
|
216
235
|
* @param {import("@vcmap-cesium/engine").Scene} scene
|
|
217
236
|
* @param {import("@vcmap/core").VectorContext|import("@vcmap/core").ClusterContext} context
|
|
218
237
|
*/
|
|
219
|
-
export default function polygonToCesium(
|
|
238
|
+
export default function polygonToCesium(
|
|
239
|
+
feature,
|
|
240
|
+
style,
|
|
241
|
+
geometries,
|
|
242
|
+
vectorProperties,
|
|
243
|
+
scene,
|
|
244
|
+
context,
|
|
245
|
+
) {
|
|
220
246
|
if (!style.getFill() && !style.getStroke()) {
|
|
221
247
|
return;
|
|
222
248
|
}
|
|
223
249
|
const polygonGeometryFactory = getGeometryFactory();
|
|
224
|
-
const validGeometries = geometries.filter(polygon =>
|
|
250
|
+
const validGeometries = geometries.filter((polygon) =>
|
|
251
|
+
validatePolygon(polygon),
|
|
252
|
+
);
|
|
225
253
|
addPrimitivesToContext(
|
|
226
|
-
feature,
|
|
254
|
+
feature,
|
|
255
|
+
style,
|
|
256
|
+
validGeometries,
|
|
257
|
+
vectorProperties,
|
|
258
|
+
scene,
|
|
259
|
+
polygonGeometryFactory,
|
|
260
|
+
context,
|
|
227
261
|
);
|
|
228
262
|
}
|
package/src/util/fetch.js
CHANGED
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
export async function requestUrl(url, init) {
|
|
7
7
|
const response = await fetch(url, init);
|
|
8
8
|
if (!response.ok) {
|
|
9
|
-
throw new Error(
|
|
9
|
+
throw new Error(
|
|
10
|
+
`Failed fetching url ${url} with status: ${response.status}`,
|
|
11
|
+
);
|
|
10
12
|
}
|
|
11
13
|
return response;
|
|
12
14
|
}
|
|
@@ -48,11 +48,15 @@ export function getFlatCoordinatesFromGeometry(geometry, inputCoordinates) {
|
|
|
48
48
|
} else if (geometry instanceof LineString) {
|
|
49
49
|
flattenCoordinates = coordinates;
|
|
50
50
|
} else if (geometry instanceof Polygon) {
|
|
51
|
-
flattenCoordinates = coordinates.reduce((current, next) =>
|
|
51
|
+
flattenCoordinates = coordinates.reduce((current, next) =>
|
|
52
|
+
current.concat(next),
|
|
53
|
+
);
|
|
52
54
|
} else if (geometry instanceof MultiPoint) {
|
|
53
55
|
flattenCoordinates = coordinates;
|
|
54
56
|
} else if (geometry instanceof MultiLineString) {
|
|
55
|
-
flattenCoordinates = coordinates.reduce((current, next) =>
|
|
57
|
+
flattenCoordinates = coordinates.reduce((current, next) =>
|
|
58
|
+
current.concat(next),
|
|
59
|
+
);
|
|
56
60
|
} else if (geometry instanceof MultiPolygon) {
|
|
57
61
|
flattenCoordinates = coordinates
|
|
58
62
|
.reduce((current, next) => current.concat(next))
|
|
@@ -60,7 +64,8 @@ export function getFlatCoordinatesFromGeometry(geometry, inputCoordinates) {
|
|
|
60
64
|
} else if (geometry instanceof Circle) {
|
|
61
65
|
flattenCoordinates = coordinates;
|
|
62
66
|
} else if (geometry instanceof GeometryCollection) {
|
|
63
|
-
flattenCoordinates = geometry
|
|
67
|
+
flattenCoordinates = geometry
|
|
68
|
+
.getGeometries()
|
|
64
69
|
.map((g, i) => getFlatCoordinatesFromGeometry(g, coordinates?.[i]))
|
|
65
70
|
.reduce((current, next) => current.concat(next));
|
|
66
71
|
}
|
|
@@ -73,18 +78,18 @@ export function getFlatCoordinatesFromGeometry(geometry, inputCoordinates) {
|
|
|
73
78
|
* @returns {import("ol/geom/Circle").default}
|
|
74
79
|
*/
|
|
75
80
|
export function circleFromCenterRadius(center, radius) {
|
|
76
|
-
const offsetWGS84 = offsetSphere(
|
|
81
|
+
const offsetWGS84 = offsetSphere(
|
|
82
|
+
Projection.mercatorToWgs84(center),
|
|
83
|
+
radius,
|
|
84
|
+
Math.PI / 2,
|
|
85
|
+
);
|
|
77
86
|
const of = Projection.wgs84ToMercator(offsetWGS84);
|
|
78
87
|
const dx = center[0] - of[0];
|
|
79
88
|
const dy = center[1] - of[1];
|
|
80
89
|
const dx2 = dx * dx;
|
|
81
90
|
const dy2 = dy * dy;
|
|
82
91
|
const radiusProjected = Math.sqrt(dx2 + dy2);
|
|
83
|
-
return new Circle(
|
|
84
|
-
center,
|
|
85
|
-
radiusProjected,
|
|
86
|
-
'XYZ',
|
|
87
|
-
);
|
|
92
|
+
return new Circle(center, radiusProjected, 'XYZ');
|
|
88
93
|
}
|
|
89
94
|
|
|
90
95
|
/**
|
|
@@ -153,7 +158,7 @@ function ringArea(ring) {
|
|
|
153
158
|
for (let i = 0; i <= positions - 2; i++) {
|
|
154
159
|
const p1 = ring[i];
|
|
155
160
|
const p2 = ring[i + 1];
|
|
156
|
-
area +=
|
|
161
|
+
area += p1[0] * p2[1] - p1[1] * p2[0];
|
|
157
162
|
}
|
|
158
163
|
|
|
159
164
|
area /= 2;
|
|
@@ -19,7 +19,9 @@ class IndexedCollection extends Collection {
|
|
|
19
19
|
* @api
|
|
20
20
|
*/
|
|
21
21
|
static from(iterable, uniqueKey) {
|
|
22
|
-
const collection = /** @type {IndexedCollection<T>} */ (
|
|
22
|
+
const collection = /** @type {IndexedCollection<T>} */ (
|
|
23
|
+
new IndexedCollection(uniqueKey)
|
|
24
|
+
);
|
|
23
25
|
if (iterable) {
|
|
24
26
|
// eslint-disable-next-line no-restricted-syntax
|
|
25
27
|
for (const i of iterable) {
|
|
@@ -55,7 +57,9 @@ class IndexedCollection extends Collection {
|
|
|
55
57
|
* @type {symbol}
|
|
56
58
|
* @readonly
|
|
57
59
|
*/
|
|
58
|
-
get previousIndexSymbol() {
|
|
60
|
+
get previousIndexSymbol() {
|
|
61
|
+
return this._previousIndexSymbol;
|
|
62
|
+
}
|
|
59
63
|
|
|
60
64
|
/**
|
|
61
65
|
* Returns an item at index.
|
|
@@ -181,7 +185,7 @@ class IndexedCollection extends Collection {
|
|
|
181
185
|
if (!this.uniqueKey) {
|
|
182
186
|
return undefined;
|
|
183
187
|
}
|
|
184
|
-
return this._array.findIndex(e => e[this.uniqueKey] === value);
|
|
188
|
+
return this._array.findIndex((e) => e[this.uniqueKey] === value);
|
|
185
189
|
}
|
|
186
190
|
|
|
187
191
|
/**
|
package/src/util/isMobile.js
CHANGED
|
@@ -7,6 +7,12 @@
|
|
|
7
7
|
export function isMobile() {
|
|
8
8
|
// @ts-ignore
|
|
9
9
|
const agent = navigator.userAgent || navigator.vendor || window.opera;
|
|
10
|
-
return
|
|
11
|
-
/
|
|
10
|
+
return (
|
|
11
|
+
/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(
|
|
12
|
+
agent,
|
|
13
|
+
) ||
|
|
14
|
+
/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(
|
|
15
|
+
agent.substr(0, 4),
|
|
16
|
+
)
|
|
17
|
+
);
|
|
12
18
|
}
|
|
@@ -95,7 +95,9 @@ class LayerCollection extends IndexedCollection {
|
|
|
95
95
|
* @type {symbol}
|
|
96
96
|
* @readonly
|
|
97
97
|
*/
|
|
98
|
-
get zIndexSymbol() {
|
|
98
|
+
get zIndexSymbol() {
|
|
99
|
+
return this._zIndexSymbol;
|
|
100
|
+
}
|
|
99
101
|
|
|
100
102
|
/**
|
|
101
103
|
* The current global hider of these layers
|
|
@@ -157,15 +159,20 @@ class LayerCollection extends IndexedCollection {
|
|
|
157
159
|
this._zIndexChanged(layer);
|
|
158
160
|
});
|
|
159
161
|
|
|
160
|
-
const exclusiveGroupsListener =
|
|
161
|
-
|
|
162
|
-
|
|
162
|
+
const exclusiveGroupsListener =
|
|
163
|
+
layer.exclusiveGroupsChanged.addEventListener(() => {
|
|
164
|
+
this.exclusiveManager.handleExclusiveGroupsChanged(layer);
|
|
165
|
+
});
|
|
163
166
|
|
|
164
167
|
const listeners = [stateListener, zIndexListener, exclusiveGroupsListener];
|
|
165
168
|
if (/** @type {SplitLayer} */ (layer).splitDirectionChanged) {
|
|
166
|
-
listeners.push(
|
|
167
|
-
|
|
168
|
-
|
|
169
|
+
listeners.push(
|
|
170
|
+
/** @type {SplitLayer} */ (
|
|
171
|
+
layer
|
|
172
|
+
).splitDirectionChanged.addEventListener(() => {
|
|
173
|
+
this.exclusiveManager.handleSplitDirectionChanged(layer);
|
|
174
|
+
}),
|
|
175
|
+
);
|
|
169
176
|
}
|
|
170
177
|
this._layerEventListeners[layer.name] = listeners;
|
|
171
178
|
}
|
|
@@ -177,7 +184,9 @@ class LayerCollection extends IndexedCollection {
|
|
|
177
184
|
* @private
|
|
178
185
|
*/
|
|
179
186
|
_findZIndexPosition(zIndex) {
|
|
180
|
-
const usedIndex = this._array.findIndex(
|
|
187
|
+
const usedIndex = this._array.findIndex(
|
|
188
|
+
(l) => l[this._zIndexSymbol] > zIndex,
|
|
189
|
+
);
|
|
181
190
|
return usedIndex > -1 ? usedIndex : null;
|
|
182
191
|
}
|
|
183
192
|
|
|
@@ -195,7 +204,8 @@ class LayerCollection extends IndexedCollection {
|
|
|
195
204
|
if (zIndexPosition > 0 && zIndexPosition > currentIndex) {
|
|
196
205
|
zIndexPosition -= 1; // remove self from count
|
|
197
206
|
}
|
|
198
|
-
zIndexPosition =
|
|
207
|
+
zIndexPosition =
|
|
208
|
+
zIndexPosition != null ? zIndexPosition : this._array.length - 1;
|
|
199
209
|
this._move(layer, currentIndex, zIndexPosition);
|
|
200
210
|
this._ensureLocalZIndex(layer);
|
|
201
211
|
}
|
|
@@ -258,7 +268,9 @@ class LayerCollection extends IndexedCollection {
|
|
|
258
268
|
*/
|
|
259
269
|
_remove(layer) {
|
|
260
270
|
if (this._layerEventListeners[layer.name]) {
|
|
261
|
-
this._layerEventListeners[layer.name].forEach((cb) => {
|
|
271
|
+
this._layerEventListeners[layer.name].forEach((cb) => {
|
|
272
|
+
cb();
|
|
273
|
+
});
|
|
262
274
|
delete this._layerEventListeners[layer.name];
|
|
263
275
|
}
|
|
264
276
|
delete layer[this._zIndexSymbol];
|
|
@@ -270,7 +282,9 @@ class LayerCollection extends IndexedCollection {
|
|
|
270
282
|
clear() {
|
|
271
283
|
Object.values(this._layerEventListeners)
|
|
272
284
|
.flat()
|
|
273
|
-
.forEach((r) => {
|
|
285
|
+
.forEach((r) => {
|
|
286
|
+
r();
|
|
287
|
+
});
|
|
274
288
|
this._array.forEach((l) => {
|
|
275
289
|
delete l[this._zIndexSymbol];
|
|
276
290
|
});
|
|
@@ -283,7 +297,9 @@ class LayerCollection extends IndexedCollection {
|
|
|
283
297
|
destroy() {
|
|
284
298
|
Object.values(this._layerEventListeners)
|
|
285
299
|
.flat()
|
|
286
|
-
.forEach((r) => {
|
|
300
|
+
.forEach((r) => {
|
|
301
|
+
r();
|
|
302
|
+
});
|
|
287
303
|
|
|
288
304
|
this._layerEventListeners = {};
|
|
289
305
|
this.exclusiveManager.destroy();
|