@vcmap/core 5.0.0-rc.3 → 5.0.0-rc.31
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/LICENSE.md +1 -1
- package/README.md +12 -5
- package/build/postinstall.js +14 -3
- package/index.d.ts +3480 -2008
- package/index.js +169 -131
- package/package.json +25 -27
- package/src/category/category.js +483 -0
- package/src/category/categoryCollection.js +153 -0
- package/src/cesium/cesium3DTileFeature.js +2 -2
- package/src/cesium/cesium3DTilePointFeature.js +1 -1
- package/src/cesium/cesiumVcsCameraPrimitive.js +16 -8
- package/src/cesium/entity.js +29 -0
- package/src/cesium/wallpaperMaterial.js +5 -3
- package/src/classRegistry.js +169 -0
- package/src/{vcs/vcm/util/featureProvider → featureProvider}/abstractFeatureProvider.js +49 -46
- package/src/{vcs/vcm/util/featureProvider → featureProvider}/tileProviderFeatureProvider.js +13 -5
- package/src/{vcs/vcm/util/featureProvider → featureProvider}/wmsFeatureProvider.js +56 -26
- package/src/{vcs/vcm/interaction → interaction}/abstractInteraction.js +33 -21
- package/src/{vcs/vcm/interaction → interaction}/coordinateAtPixel.js +40 -21
- package/src/{vcs/vcm/interaction → interaction}/eventHandler.js +131 -26
- package/src/{vcs/vcm/interaction → interaction}/featureAtPixelInteraction.js +108 -53
- package/src/interaction/featureProviderInteraction.js +58 -0
- package/src/{vcs/vcm/interaction → interaction}/interactionChain.js +40 -41
- package/src/{vcs/vcm/interaction → interaction}/interactionType.js +24 -31
- package/src/{vcs/vcm/layer/cesium/cesiumTilesetCesium.js → layer/cesium/cesiumTilesetCesiumImpl.js} +83 -70
- package/src/{vcs/vcm/layer → layer}/cesium/clusterContext.js +33 -8
- package/src/{vcs/vcm/layer/cesium/dataSourceCesium.js → layer/cesium/dataSourceCesiumImpl.js} +24 -13
- package/src/layer/cesium/openStreetMapCesiumImpl.js +32 -0
- package/src/{vcs/vcm/layer/cesium/rasterLayerCesium.js → layer/cesium/rasterLayerCesiumImpl.js} +12 -9
- package/src/{vcs/vcm/layer/cesium/singleImageCesium.js → layer/cesium/singleImageCesiumImpl.js} +19 -9
- package/src/{vcs/vcm/layer/cesium/terrainCesium.js → layer/cesium/terrainCesiumImpl.js} +8 -9
- package/src/{vcs/vcm/layer/cesium/tmsCesium.js → layer/cesium/tmsCesiumImpl.js} +21 -10
- package/src/{vcs/vcm/layer/cesium/vectorCesium.js → layer/cesium/vectorCesiumImpl.js} +93 -35
- package/src/layer/cesium/vectorContext.js +363 -0
- package/src/{vcs/vcm/layer/cesium/vectorRasterTileCesium.js → layer/cesium/vectorRasterTileCesiumImpl.js} +21 -13
- package/src/{vcs/vcm/layer → layer}/cesium/vectorTileImageryProvider.js +58 -21
- package/src/{vcs/vcm/layer/cesium/wmsCesium.js → layer/cesium/wmsCesiumImpl.js} +20 -9
- package/src/{vcs/vcm/layer/cesium/wmtsCesium.js → layer/cesium/wmtsCesiumImpl.js} +24 -13
- package/src/{vcs/vcm/layer → layer}/cesium/x3dmHelper.js +6 -3
- package/src/{vcs/vcm/layer/cesiumTileset.js → layer/cesiumTilesetLayer.js} +71 -112
- package/src/{vcs/vcm/layer/czml.js → layer/czmlLayer.js} +23 -20
- package/src/{vcs/vcm/layer/dataSource.js → layer/dataSourceLayer.js} +55 -90
- package/src/{vcs/vcm/layer → layer}/featureLayer.js +89 -74
- package/src/{vcs/vcm/layer/featureStore.js → layer/featureStoreLayer.js} +197 -150
- package/src/{vcs/vcm/layer/featureStoreChanges.js → layer/featureStoreLayerChanges.js} +150 -92
- package/src/{vcs/vcm/layer/featureStoreState.js → layer/featureStoreLayerState.js} +1 -2
- package/src/{vcs/vcm/layer → layer}/featureVisibility.js +114 -82
- package/src/{vcs/vcm/layer → layer}/geojsonHelpers.js +84 -69
- package/src/{vcs/vcm/layer/geojson.js → layer/geojsonLayer.js} +30 -27
- package/src/{vcs/vcm/layer → layer}/globalHider.js +25 -39
- package/src/{vcs/vcm/layer → layer}/layer.js +171 -96
- package/src/{vcs/vcm/layer → layer}/layerImplementation.js +13 -6
- package/src/{vcs/vcm/layer → layer}/layerState.js +0 -1
- package/src/{vcs/vcm/layer → layer}/layerSymbols.js +2 -1
- package/src/{vcs/vcm/layer/oblique/layerOblique.js → layer/oblique/layerObliqueImpl.js} +7 -5
- package/src/{vcs/vcm/layer → layer}/oblique/obliqueHelpers.js +76 -31
- package/src/{vcs/vcm/layer/oblique/vectorOblique.js → layer/oblique/vectorObliqueImpl.js} +198 -80
- package/src/{vcs/vcm/layer/openStreetMap.js → layer/openStreetMapLayer.js} +59 -40
- package/src/layer/openlayers/layerOpenlayersImpl.js +165 -0
- package/src/layer/openlayers/openStreetMapOpenlayersImpl.js +28 -0
- package/src/layer/openlayers/rasterLayerOpenlayersImpl.js +44 -0
- package/src/{vcs/vcm/layer/openlayers/singleImageOpenlayers.js → layer/openlayers/singleImageOpenlayersImpl.js} +8 -7
- package/src/{vcs/vcm/layer/openlayers/tileDebugOpenlayers.js → layer/openlayers/tileDebugOpenlayersImpl.js} +7 -6
- package/src/{vcs/vcm/layer/openlayers/tmsOpenlayers.js → layer/openlayers/tmsOpenlayersImpl.js} +12 -10
- package/src/{vcs/vcm/layer/openlayers/vectorOpenlayers.js → layer/openlayers/vectorOpenlayersImpl.js} +21 -12
- package/src/{vcs/vcm/layer/openlayers/vectorTileOpenlayers.js → layer/openlayers/vectorTileOpenlayersImpl.js} +18 -12
- package/src/{vcs/vcm/layer/openlayers/wmsOpenlayers.js → layer/openlayers/wmsOpenlayersImpl.js} +9 -8
- package/src/{vcs/vcm/layer/openlayers/wmtsOpenlayers.js → layer/openlayers/wmtsOpenlayersImpl.js} +19 -12
- package/src/{vcs/vcm/layer/pointCloud.js → layer/pointCloudLayer.js} +42 -39
- package/src/{vcs/vcm/layer → layer}/rasterLayer.js +86 -37
- package/src/{vcs/vcm/layer/singleImage.js → layer/singleImageLayer.js} +25 -22
- package/src/layer/terrainHelpers.js +95 -0
- package/src/{vcs/vcm/layer/terrain.js → layer/terrainLayer.js} +28 -21
- package/src/{vcs/vcm/layer → layer}/tileLoadedHelper.js +13 -8
- package/src/{vcs/vcm/layer → layer}/tileProvider/mvtTileProvider.js +51 -8
- package/src/layer/tileProvider/staticGeojsonTileProvider.js +87 -0
- package/src/{vcs/vcm/layer → layer}/tileProvider/tileProvider.js +200 -89
- package/src/{vcs/vcm/layer → layer}/tileProvider/urlTemplateTileProvider.js +54 -13
- package/src/{vcs/vcm/layer/tms.js → layer/tmsLayer.js} +22 -22
- package/src/layer/vectorHelpers.js +129 -0
- package/src/{vcs/vcm/layer/vector.js → layer/vectorLayer.js} +124 -94
- package/src/{vcs/vcm/layer → layer}/vectorProperties.js +419 -107
- package/src/{vcs/vcm/layer → layer}/vectorSymbols.js +11 -1
- package/src/{vcs/vcm/layer/vectorTile.js → layer/vectorTileLayer.js} +181 -116
- package/src/{vcs/vcm/layer/wfs.js → layer/wfsLayer.js} +33 -23
- package/src/{vcs/vcm/layer → layer}/wmsHelpers.js +14 -7
- package/src/{vcs/vcm/layer/wms.js → layer/wmsLayer.js} +53 -32
- package/src/{vcs/vcm/layer/wmts.js → layer/wmtsLayer.js} +56 -42
- package/src/{vcs/vcm/maps → map}/baseOLMap.js +83 -35
- package/src/{vcs/vcm/maps → map}/cameraLimiter.js +64 -37
- package/src/{vcs/vcm/maps/cesium.js → map/cesiumMap.js} +431 -277
- package/src/{vcs/vcm/maps → map}/mapState.js +0 -1
- package/src/{vcs/vcm/maps/oblique.js → map/obliqueMap.js} +132 -97
- package/src/{vcs/vcm/maps/openlayers.js → map/openlayersMap.js} +69 -45
- package/src/{vcs/vcm/maps/map.js → map/vcsMap.js} +118 -46
- package/src/oblique/defaultObliqueCollection.js +62 -0
- package/src/{vcs/vcm/oblique → oblique}/helpers.js +221 -78
- package/src/{vcs/vcm/oblique/ObliqueCollection.js → oblique/obliqueCollection.js} +151 -55
- package/src/{vcs/vcm/oblique/ObliqueDataSet.js → oblique/obliqueDataSet.js} +77 -46
- package/src/{vcs/vcm/oblique/ObliqueImage.js → oblique/obliqueImage.js} +58 -26
- package/src/{vcs/vcm/oblique/ObliqueImageMeta.js → oblique/obliqueImageMeta.js} +9 -9
- package/src/{vcs/vcm/oblique/ObliqueProvider.js → oblique/obliqueProvider.js} +85 -35
- package/src/{vcs/vcm/oblique/ObliqueView.js → oblique/obliqueView.js} +45 -5
- package/src/{vcs/vcm/oblique/ObliqueViewDirection.js → oblique/obliqueViewDirection.js} +3 -5
- package/src/{vcs/vcm/oblique → oblique}/parseImageJson.js +62 -28
- package/src/ol/feature.js +34 -1
- package/src/ol/geom/circle.js +14 -5
- package/src/ol/geom/geometryCollection.js +14 -8
- package/src/ol/render/canvas/canvasTileRenderer.js +11 -10
- package/src/overrideClassRegistry.js +214 -0
- package/src/style/arcStyle.js +453 -0
- package/src/style/arrowStyle.js +304 -0
- package/src/{vcs/vcm/util/style → style}/declarativeStyleItem.js +147 -82
- package/src/{vcs/vcm/util/style → style}/shapesCategory.js +8 -8
- package/src/style/styleFactory.js +32 -0
- package/src/{vcs/vcm/util/style → style}/styleHelpers.js +24 -26
- package/src/style/styleItem.js +174 -0
- package/src/{vcs/vcm/util/style → style}/vectorStyleItem.js +230 -156
- package/src/{vcs/vcm/util/style → style}/writeStyle.js +7 -12
- package/src/{vcs/vcm/util → util}/clipping/clippingObject.js +79 -49
- package/src/{vcs/vcm/util → util}/clipping/clippingObjectManager.js +56 -23
- package/src/{vcs/vcm/util → util}/clipping/clippingPlaneHelper.js +149 -88
- package/src/{vcs/vcm/util → util}/collection.js +28 -10
- package/src/util/editor/createFeatureSession.js +195 -0
- package/src/util/editor/editFeaturesSession.js +325 -0
- package/src/util/editor/editGeometrySession.js +452 -0
- package/src/util/editor/editorHelpers.js +300 -0
- package/src/util/editor/editorSessionHelpers.js +132 -0
- package/src/util/editor/editorSymbols.js +21 -0
- package/src/util/editor/interactions/createBBoxInteraction.js +154 -0
- package/src/util/editor/interactions/createCircleInteraction.js +119 -0
- package/src/util/editor/interactions/createLineStringInteraction.js +119 -0
- package/src/util/editor/interactions/createPointInteraction.js +73 -0
- package/src/util/editor/interactions/createPolygonInteraction.js +136 -0
- package/src/util/editor/interactions/editFeaturesMouseOverInteraction.js +88 -0
- package/src/util/editor/interactions/editGeometryMouseOverInteraction.js +119 -0
- package/src/util/editor/interactions/ensureHandlerSelectionInteraction.js +50 -0
- package/src/util/editor/interactions/insertVertexInteraction.js +103 -0
- package/src/util/editor/interactions/mapInteractionController.js +119 -0
- package/src/util/editor/interactions/removeVertexInteraction.js +42 -0
- package/src/util/editor/interactions/selectFeatureMouseOverInteraction.js +152 -0
- package/src/util/editor/interactions/selectMultiFeatureInteraction.js +165 -0
- package/src/util/editor/interactions/selectSingleFeatureInteraction.js +120 -0
- package/src/util/editor/interactions/translateVertexInteraction.js +60 -0
- package/src/util/editor/selectFeaturesSession.js +303 -0
- package/src/util/editor/transformation/create2DHandlers.js +339 -0
- package/src/util/editor/transformation/create3DHandlers.js +678 -0
- package/src/util/editor/transformation/extrudeInteraction.js +106 -0
- package/src/util/editor/transformation/rotateInteraction.js +201 -0
- package/src/util/editor/transformation/scaleInteraction.js +201 -0
- package/src/util/editor/transformation/transformationHandler.js +178 -0
- package/src/util/editor/transformation/transformationTypes.js +88 -0
- package/src/util/editor/transformation/translateInteraction.js +263 -0
- package/src/util/editor/validateGeoemetry.js +24 -0
- package/src/{vcs/vcm/util → util}/exclusiveManager.js +6 -3
- package/src/{vcs/vcm/util → util}/extent.js +26 -20
- package/src/util/featureconverter/arcToCesium.js +121 -0
- package/src/{vcs/vcm/util → util}/featureconverter/circleToCesium.js +70 -37
- package/src/{vcs/vcm/util → util}/featureconverter/convert.js +94 -16
- package/src/util/featureconverter/extent3D.js +284 -0
- package/src/{vcs/vcm/util → util}/featureconverter/featureconverterHelper.js +253 -94
- package/src/util/featureconverter/lineStringToCesium.js +343 -0
- package/src/util/featureconverter/pointHelpers.js +413 -0
- package/src/{vcs/vcm/util → util}/featureconverter/pointToCesium.js +157 -107
- package/src/{vcs/vcm/util → util}/featureconverter/polygonToCesium.js +57 -24
- package/src/util/fetch.js +34 -0
- package/src/{vcs/vcm/util → util}/geometryHelpers.js +25 -17
- package/src/{vcs/vcm/util → util}/indexedCollection.js +27 -8
- package/src/{vcs/vcm/util → util}/isMobile.js +8 -2
- package/src/{vcs/vcm/util → util}/layerCollection.js +109 -19
- package/src/util/locale.js +12 -0
- package/src/{vcs/vcm/util → util}/mapCollection.js +170 -63
- package/src/util/math.js +193 -0
- package/src/util/overrideCollection.js +261 -0
- package/src/{vcs/vcm/util → util}/projection.js +23 -31
- package/src/{vcs/vcm/util → util}/urlHelpers.js +5 -3
- package/src/{vcs/vcm/util → util}/viewpoint.js +83 -57
- package/src/vcsApp.js +657 -0
- package/src/{vcs/vcm/event/vcsEvent.js → vcsEvent.js} +2 -3
- package/src/vcsModule.js +130 -0
- package/src/vcsModuleHelpers.js +136 -0
- package/src/{vcs/vcm/object.js → vcsObject.js} +3 -10
- package/tests/data/dynamicPointCzml.json +53 -0
- package/tests/data/oblique/imageData/imagev34.json +136 -0
- package/tests/data/oblique/imageData/imagev35.json +307 -0
- package/tests/data/oblique/imageData/imagev35PerImageSize.json +333 -0
- package/tests/data/oblique/tiledImageData/12/2199/1342.json +11056 -0
- package/tests/data/oblique/tiledImageData/12/2199/1343.json +11236 -0
- package/tests/data/oblique/tiledImageData/12/2199/1344.json +11077 -0
- package/tests/data/oblique/tiledImageData/12/2200/1342.json +11036 -0
- package/tests/data/oblique/tiledImageData/12/2200/1343.json +11277 -0
- package/tests/data/oblique/tiledImageData/12/2200/1344.json +11131 -0
- package/tests/data/oblique/tiledImageData/12/2201/1342.json +10870 -0
- package/tests/data/oblique/tiledImageData/12/2201/1343.json +11492 -0
- package/tests/data/oblique/tiledImageData/12/2201/1344.json +10909 -0
- package/tests/data/oblique/tiledImageData/image.json +70 -0
- package/tests/data/terrain/13/8800/6485.terrain +0 -0
- package/tests/data/terrain/13/8800/6486.terrain +0 -0
- package/tests/data/terrain/13/8801/6485.terrain +0 -0
- package/tests/data/terrain/13/8801/6486.terrain +0 -0
- package/tests/data/terrain/layer.json +127 -0
- package/tests/data/testGeoJSON.json +149 -0
- package/tests/data/tile.pbf +0 -0
- package/tests/unit/helpers/cesiumHelpers.js +326 -0
- package/tests/unit/helpers/getFileNameFromUrl.js +12 -0
- package/tests/unit/helpers/helpers.js +32 -0
- package/tests/unit/helpers/imageHelpers.js +24 -0
- package/tests/unit/helpers/importJSON.js +15 -0
- package/tests/unit/helpers/obliqueData.js +102 -0
- package/tests/unit/helpers/obliqueHelpers.js +115 -0
- package/tests/unit/helpers/openlayersHelpers.js +25 -0
- package/tests/unit/helpers/terrain/terrainData.js +45 -0
- package/src/vcs/vcm/classRegistry.js +0 -106
- package/src/vcs/vcm/globalCollections.js +0 -11
- package/src/vcs/vcm/interaction/featureProviderInteraction.js +0 -54
- package/src/vcs/vcm/layer/buildings.js +0 -17
- package/src/vcs/vcm/layer/cesium/openStreetMapCesium.js +0 -29
- package/src/vcs/vcm/layer/cesium/pointCloudCesium.js +0 -58
- package/src/vcs/vcm/layer/cesium/vectorContext.js +0 -167
- package/src/vcs/vcm/layer/openlayers/layerOpenlayers.js +0 -79
- package/src/vcs/vcm/layer/openlayers/openStreetMapOpenlayers.js +0 -27
- package/src/vcs/vcm/layer/openlayers/rasterLayerOpenlayers.js +0 -121
- package/src/vcs/vcm/layer/terrainHelpers.js +0 -119
- package/src/vcs/vcm/layer/tileProvider/staticGeojsonTileProvider.js +0 -67
- package/src/vcs/vcm/layer/tileProvider/tileProviderFactory.js +0 -28
- package/src/vcs/vcm/layer/vectorHelpers.js +0 -206
- package/src/vcs/vcm/util/dateTime.js +0 -60
- package/src/vcs/vcm/util/featureProvider/featureProviderHelpers.js +0 -51
- package/src/vcs/vcm/util/featureconverter/extent3d.js +0 -154
- package/src/vcs/vcm/util/featureconverter/lineStringToCesium.js +0 -171
- package/src/vcs/vcm/util/locale.js +0 -53
- package/src/vcs/vcm/util/math.js +0 -71
- package/src/vcs/vcm/util/splitScreen.js +0 -233
- package/src/vcs/vcm/util/style/styleFactory.js +0 -48
- package/src/vcs/vcm/util/style/styleItem.js +0 -243
- /package/src/{vcs/vcm/util/featureProvider → featureProvider}/featureProviderSymbols.js +0 -0
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import Point from 'ol/geom/Point.js';
|
|
2
|
+
import Feature from 'ol/Feature.js';
|
|
3
|
+
import {
|
|
4
|
+
Cartesian2,
|
|
5
|
+
Cartesian3,
|
|
6
|
+
Math as CesiumMath,
|
|
7
|
+
Plane,
|
|
8
|
+
Ray,
|
|
9
|
+
IntersectionTests,
|
|
10
|
+
Cartographic,
|
|
11
|
+
HeightReference,
|
|
12
|
+
} from '@vcmap-cesium/engine';
|
|
13
|
+
|
|
14
|
+
import { mercatorToCartesian } from '../math.js';
|
|
15
|
+
import { getFlatCoordinatesFromGeometry } from '../geometryHelpers.js';
|
|
16
|
+
import CesiumMap from '../../map/cesiumMap.js';
|
|
17
|
+
import { vertexSymbol } from './editorSymbols.js';
|
|
18
|
+
import Vector from '../../layer/vectorLayer.js';
|
|
19
|
+
import { createSync } from '../../layer/vectorSymbols.js';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param {import("ol/coordinate").Coordinate} coordinate
|
|
23
|
+
* @returns {Vertex}
|
|
24
|
+
*/
|
|
25
|
+
export function createVertex(coordinate) {
|
|
26
|
+
const geometry = new Point(coordinate);
|
|
27
|
+
geometry[Vector.alreadyTransformedToImage] = true;
|
|
28
|
+
const vertex = new Feature({
|
|
29
|
+
geometry,
|
|
30
|
+
});
|
|
31
|
+
vertex[vertexSymbol] = true;
|
|
32
|
+
vertex[Vector.doNotTransform] = true;
|
|
33
|
+
vertex[createSync] = true;
|
|
34
|
+
return vertex;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let scratchCartesian21 = new Cartesian2();
|
|
38
|
+
let scratchCartesian22 = new Cartesian2();
|
|
39
|
+
let scratchCartesian23 = new Cartesian2();
|
|
40
|
+
let scratchCartesian31 = new Cartesian3();
|
|
41
|
+
let scratchCartesian32 = new Cartesian3();
|
|
42
|
+
let scratchCartesian33 = new Cartesian3();
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Returns the closest point on a 2D line. the Z index is taken from the point.
|
|
46
|
+
* @param {import("ol/coordinate").Coordinate} start - line segment start
|
|
47
|
+
* @param {import("ol/coordinate").Coordinate} end - line segment end
|
|
48
|
+
* @param {import("ol/coordinate").Coordinate} point - point to project
|
|
49
|
+
* @returns {!import("ol/coordinate").Coordinate}
|
|
50
|
+
*/
|
|
51
|
+
export function getClosestPointOn2DLine(start, end, point) {
|
|
52
|
+
scratchCartesian21 = Cartesian2.fromElements(
|
|
53
|
+
end[0] - start[0],
|
|
54
|
+
end[1] - start[1],
|
|
55
|
+
scratchCartesian21,
|
|
56
|
+
);
|
|
57
|
+
if (scratchCartesian21.equals(Cartesian2.ZERO)) {
|
|
58
|
+
scratchCartesian21 = Cartesian2.fromElements(1, 1, scratchCartesian21);
|
|
59
|
+
}
|
|
60
|
+
scratchCartesian21 = Cartesian2.normalize(
|
|
61
|
+
scratchCartesian21,
|
|
62
|
+
scratchCartesian21,
|
|
63
|
+
);
|
|
64
|
+
scratchCartesian22 = Cartesian2.fromElements(
|
|
65
|
+
point[0] - start[0],
|
|
66
|
+
point[1] - start[1],
|
|
67
|
+
scratchCartesian22,
|
|
68
|
+
);
|
|
69
|
+
const lambda = Cartesian2.dot(scratchCartesian21, scratchCartesian22);
|
|
70
|
+
scratchCartesian21 = Cartesian2.multiplyByScalar(
|
|
71
|
+
scratchCartesian21,
|
|
72
|
+
lambda,
|
|
73
|
+
scratchCartesian21,
|
|
74
|
+
);
|
|
75
|
+
return [
|
|
76
|
+
scratchCartesian21.x + start[0],
|
|
77
|
+
scratchCartesian21.y + start[1],
|
|
78
|
+
point[2],
|
|
79
|
+
];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* @param {import("ol/coordinate").Coordinate} start - line segment start
|
|
84
|
+
* @param {import("ol/coordinate").Coordinate} end - line segment end
|
|
85
|
+
* @param {import("ol/coordinate").Coordinate} point - the point to project
|
|
86
|
+
* @param {number=} epsilon
|
|
87
|
+
* @returns {boolean}
|
|
88
|
+
*/
|
|
89
|
+
export function pointOnLine3D(start, end, point, epsilon) {
|
|
90
|
+
scratchCartesian31 = Cartesian3.fromElements(
|
|
91
|
+
end[0] - start[0],
|
|
92
|
+
end[1] - start[1],
|
|
93
|
+
end[2] - start[2],
|
|
94
|
+
scratchCartesian31,
|
|
95
|
+
);
|
|
96
|
+
scratchCartesian32 = Cartesian3.fromElements(
|
|
97
|
+
point[0] - start[0],
|
|
98
|
+
point[1] - start[1],
|
|
99
|
+
point[2] - start[2],
|
|
100
|
+
scratchCartesian32,
|
|
101
|
+
);
|
|
102
|
+
scratchCartesian33 = Cartesian3.fromElements(
|
|
103
|
+
point[0] - end[0],
|
|
104
|
+
point[1] - end[1],
|
|
105
|
+
point[2] - point[2],
|
|
106
|
+
scratchCartesian33,
|
|
107
|
+
);
|
|
108
|
+
const mag1 = Cartesian3.magnitude(scratchCartesian31);
|
|
109
|
+
if (
|
|
110
|
+
mag1 < Cartesian3.magnitude(scratchCartesian32) ||
|
|
111
|
+
mag1 < Cartesian3.magnitude(scratchCartesian33)
|
|
112
|
+
) {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
scratchCartesian31 = Cartesian3.normalize(
|
|
117
|
+
scratchCartesian31,
|
|
118
|
+
scratchCartesian31,
|
|
119
|
+
);
|
|
120
|
+
scratchCartesian32 = Cartesian3.normalize(
|
|
121
|
+
scratchCartesian32,
|
|
122
|
+
scratchCartesian32,
|
|
123
|
+
);
|
|
124
|
+
return scratchCartesian31.equalsEpsilon(
|
|
125
|
+
scratchCartesian32,
|
|
126
|
+
epsilon || CesiumMath.EPSILON5,
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @param {import("ol/coordinate").Coordinate} start - line segment start
|
|
132
|
+
* @param {import("ol/coordinate").Coordinate} end - line segment end
|
|
133
|
+
* @param {import("ol/coordinate").Coordinate} point - the point to project
|
|
134
|
+
* @param {number=} epsilon
|
|
135
|
+
* @returns {boolean}
|
|
136
|
+
*/
|
|
137
|
+
export function pointOnLine2D(start, end, point, epsilon) {
|
|
138
|
+
scratchCartesian21 = Cartesian2.fromElements(
|
|
139
|
+
end[0] - start[0],
|
|
140
|
+
end[1] - start[1],
|
|
141
|
+
scratchCartesian21,
|
|
142
|
+
);
|
|
143
|
+
scratchCartesian22 = Cartesian2.fromElements(
|
|
144
|
+
point[0] - start[0],
|
|
145
|
+
point[1] - start[1],
|
|
146
|
+
scratchCartesian22,
|
|
147
|
+
);
|
|
148
|
+
scratchCartesian23 = Cartesian2.fromElements(
|
|
149
|
+
point[0] - end[0],
|
|
150
|
+
point[1] - end[1],
|
|
151
|
+
scratchCartesian23,
|
|
152
|
+
);
|
|
153
|
+
const mag1 = Cartesian2.magnitude(scratchCartesian21);
|
|
154
|
+
if (
|
|
155
|
+
mag1 < Cartesian2.magnitude(scratchCartesian22) ||
|
|
156
|
+
mag1 < Cartesian2.magnitude(scratchCartesian23)
|
|
157
|
+
) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
scratchCartesian21 = Cartesian2.normalize(
|
|
162
|
+
scratchCartesian21,
|
|
163
|
+
scratchCartesian21,
|
|
164
|
+
);
|
|
165
|
+
scratchCartesian22 = Cartesian2.normalize(
|
|
166
|
+
scratchCartesian22,
|
|
167
|
+
scratchCartesian22,
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
return scratchCartesian21.equalsEpsilon(
|
|
171
|
+
scratchCartesian22,
|
|
172
|
+
epsilon || CesiumMath.EPSILON5,
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* @param {import("ol/coordinate").Coordinate} originCoordinates
|
|
178
|
+
* @param {import("@vcmap-cesium/engine").Scene} scene
|
|
179
|
+
* @returns {!import("@vcmap-cesium/engine").Plane}
|
|
180
|
+
*/
|
|
181
|
+
export function createCameraVerticalPlane(originCoordinates, scene) {
|
|
182
|
+
scratchCartesian31 = mercatorToCartesian(
|
|
183
|
+
originCoordinates,
|
|
184
|
+
scratchCartesian31,
|
|
185
|
+
);
|
|
186
|
+
scratchCartesian32 = scene.globe.ellipsoid.geodeticSurfaceNormal(
|
|
187
|
+
scratchCartesian31,
|
|
188
|
+
scratchCartesian32,
|
|
189
|
+
);
|
|
190
|
+
scratchCartesian32 = Cartesian3.cross(
|
|
191
|
+
scene.camera.rightWC,
|
|
192
|
+
scratchCartesian32,
|
|
193
|
+
scratchCartesian32,
|
|
194
|
+
);
|
|
195
|
+
scratchCartesian32 = Cartesian3.normalize(
|
|
196
|
+
scratchCartesian32,
|
|
197
|
+
scratchCartesian32,
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
return Plane.fromPointNormal(scratchCartesian31, scratchCartesian32);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* @param {import("ol/coordinate").Coordinate} originCoordinates
|
|
205
|
+
* @param {import("@vcmap-cesium/engine").Scene} scene
|
|
206
|
+
* @returns {!import("@vcmap-cesium/engine").Plane}
|
|
207
|
+
*/
|
|
208
|
+
export function createHorizontalPlane(originCoordinates, scene) {
|
|
209
|
+
scratchCartesian31 = mercatorToCartesian(
|
|
210
|
+
originCoordinates,
|
|
211
|
+
scratchCartesian31,
|
|
212
|
+
);
|
|
213
|
+
scratchCartesian32 = scene.globe.ellipsoid.geodeticSurfaceNormal(
|
|
214
|
+
scratchCartesian31,
|
|
215
|
+
scratchCartesian32,
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
return Plane.fromPointNormal(scratchCartesian31, scratchCartesian32);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* @param {import("@vcmap-cesium/engine").Plane} plane
|
|
223
|
+
* @param {import("@vcmap-cesium/engine").Camera} camera
|
|
224
|
+
* @param {import("@vcmap-cesium/engine").Cartesian2} windowPosition
|
|
225
|
+
* @returns {import("@vcmap-cesium/engine").Cartographic}
|
|
226
|
+
*/
|
|
227
|
+
export function getCartographicFromPlane(plane, camera, windowPosition) {
|
|
228
|
+
const ray = camera.getPickRay(windowPosition, new Ray());
|
|
229
|
+
const intersection = IntersectionTests.rayPlane(ray, plane);
|
|
230
|
+
if (intersection) {
|
|
231
|
+
return Cartographic.fromCartesian(intersection);
|
|
232
|
+
}
|
|
233
|
+
return Cartographic.ZERO;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Drapes a geometry onto the terrain by placing each coordinate at its height.
|
|
238
|
+
* @param {import("ol/geom").Geometry} geometry
|
|
239
|
+
* @param {import("@vcmap/core").VcsMap} map
|
|
240
|
+
* @returns {Promise<void>}
|
|
241
|
+
*/
|
|
242
|
+
export async function drapeGeometryOnTerrain(geometry, map) {
|
|
243
|
+
if (map instanceof CesiumMap) {
|
|
244
|
+
const coordinates = geometry.getCoordinates();
|
|
245
|
+
const flats = getFlatCoordinatesFromGeometry(geometry, coordinates);
|
|
246
|
+
await map.getHeightFromTerrain(flats);
|
|
247
|
+
geometry.setCoordinates(coordinates);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Places a geometry onto the terrain at its lowest point.
|
|
253
|
+
* @param {import("ol/geom").Geometry} geometry
|
|
254
|
+
* @param {import("@vcmap/core").VcsMap} map
|
|
255
|
+
* @returns {Promise<void>}
|
|
256
|
+
*/
|
|
257
|
+
export async function placeGeometryOnTerrain(geometry, map) {
|
|
258
|
+
if (map instanceof CesiumMap) {
|
|
259
|
+
const coordinates = geometry.getCoordinates();
|
|
260
|
+
const flats = getFlatCoordinatesFromGeometry(geometry, coordinates);
|
|
261
|
+
await map.getHeightFromTerrain(flats);
|
|
262
|
+
let minHeight = Infinity;
|
|
263
|
+
flats.forEach((coord) => {
|
|
264
|
+
if (minHeight > coord[2]) {
|
|
265
|
+
minHeight = coord[2];
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
flats.forEach((coord) => {
|
|
269
|
+
coord[2] = minHeight;
|
|
270
|
+
});
|
|
271
|
+
geometry.setCoordinates(coordinates);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* @param {import("ol").Feature} feature
|
|
277
|
+
* @param {import("@vcmap/core").VectorLayer} layer
|
|
278
|
+
* @param {import("@vcmap/core").VcsMap} cesiumMap
|
|
279
|
+
* @returns {Promise<void>}
|
|
280
|
+
*/
|
|
281
|
+
export async function ensureFeatureAbsolute(feature, layer, cesiumMap) {
|
|
282
|
+
// XXX this does not ensure 3D coordinates
|
|
283
|
+
const layerIsClamped =
|
|
284
|
+
layer.vectorProperties.altitudeMode === HeightReference.CLAMP_TO_GROUND;
|
|
285
|
+
const altitudeMode = feature.get('olcs_altitudeMode');
|
|
286
|
+
if (altitudeMode === 'clampToGround' || (!altitudeMode && layerIsClamped)) {
|
|
287
|
+
feature.set('olcs_altitudeMode', 'absolute', true);
|
|
288
|
+
const geometry = feature.getGeometry();
|
|
289
|
+
if (geometry) {
|
|
290
|
+
await placeGeometryOnTerrain(geometry, cesiumMap);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* @param {import("ol").Feature} feature
|
|
297
|
+
*/
|
|
298
|
+
export function clampFeature(feature) {
|
|
299
|
+
feature.set('olcs_altitudeMode', 'clampToGround');
|
|
300
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import VectorLayer from '../../layer/vectorLayer.js';
|
|
2
|
+
import { mercatorProjection } from '../projection.js';
|
|
3
|
+
import InteractionChain from '../../interaction/interactionChain.js';
|
|
4
|
+
import VcsEvent from '../../vcsEvent.js';
|
|
5
|
+
import { EventType } from '../../interaction/interactionType.js';
|
|
6
|
+
import { maxZIndex } from '../layerCollection.js';
|
|
7
|
+
import { markVolatile } from '../../vcsModule.js';
|
|
8
|
+
import { PrimitiveOptionsType } from '../../layer/vectorProperties.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* An editor session is a currently set of interactions to create or edit geometries & features.
|
|
12
|
+
* All editor sessions can be stopped and will be stopped, if their interactions get removed from the
|
|
13
|
+
* event handler.
|
|
14
|
+
* A stopped session will be destroyed and can no longer be used.
|
|
15
|
+
* @typedef {Object} EditorSession
|
|
16
|
+
* @property {SessionType} type
|
|
17
|
+
* @property {function():void} stop
|
|
18
|
+
* @property {VcsEvent<void>} stopped
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @enum {string}
|
|
23
|
+
* @property {string} CREATE
|
|
24
|
+
* @property {string} EDIT_GEOMETRY
|
|
25
|
+
* @property {string} EDIT_FEATURES
|
|
26
|
+
* @property {string} SELECT
|
|
27
|
+
*/
|
|
28
|
+
export const SessionType = {
|
|
29
|
+
CREATE: 'create',
|
|
30
|
+
EDIT_GEOMETRY: 'editGeometry',
|
|
31
|
+
EDIT_FEATURES: 'editFeatures',
|
|
32
|
+
SELECT: 'selectFeatures',
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Sets up an editor session scratch layer & activates it. Does not wait for the activation promise to resolve.
|
|
37
|
+
* Note: scratch layers are volatile.
|
|
38
|
+
* @param {import("@vcmap/core").LayerCollection} layerCollection
|
|
39
|
+
* @returns {VectorLayer}
|
|
40
|
+
*/
|
|
41
|
+
export function setupScratchLayer(layerCollection) {
|
|
42
|
+
// IDEA pass in stopped and cleanup ourselves?
|
|
43
|
+
const layer = new VectorLayer({
|
|
44
|
+
projection: mercatorProjection.toJSON(),
|
|
45
|
+
vectorProperties: {
|
|
46
|
+
altitudeMode: 'clampToGround',
|
|
47
|
+
eyeOffset: [0, 0, -1],
|
|
48
|
+
primitiveOptions: {
|
|
49
|
+
type: PrimitiveOptionsType.SPHERE,
|
|
50
|
+
geometryOptions: {
|
|
51
|
+
radius: 4,
|
|
52
|
+
},
|
|
53
|
+
depthFailColor: 'rgba(255,255,255,0.47)',
|
|
54
|
+
},
|
|
55
|
+
modelAutoScale: true,
|
|
56
|
+
},
|
|
57
|
+
isDynamic: true,
|
|
58
|
+
zIndex: maxZIndex,
|
|
59
|
+
style: {
|
|
60
|
+
image: {
|
|
61
|
+
radius: 5,
|
|
62
|
+
fill: {
|
|
63
|
+
color: 'rgba(255,255,255,0.47)',
|
|
64
|
+
},
|
|
65
|
+
stroke: {
|
|
66
|
+
width: 1,
|
|
67
|
+
color: '#000000',
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
markVolatile(layer);
|
|
73
|
+
layerCollection.add(layer);
|
|
74
|
+
layer.activate();
|
|
75
|
+
return layer;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Sets up the default interaction chain for the editors. This will set the provided event handlers
|
|
80
|
+
* feature interaction to be active on CLICKMOVE & DRAGSTART. Destroying the setup will reset the interaction
|
|
81
|
+
* to its previous active state.
|
|
82
|
+
* @param {import("@vcmap/core").EventHandler} eventHandler
|
|
83
|
+
* @param {string} [interactionId]
|
|
84
|
+
* @returns {{ interactionChain: InteractionChain, removed: VcsEvent<void>, destroy: function():void }}
|
|
85
|
+
* @private
|
|
86
|
+
*/
|
|
87
|
+
export function setupInteractionChain(eventHandler, interactionId) {
|
|
88
|
+
const interactionChain = new InteractionChain();
|
|
89
|
+
/**
|
|
90
|
+
* @type {VcsEvent<void>}
|
|
91
|
+
*/
|
|
92
|
+
const removed = new VcsEvent();
|
|
93
|
+
const listener = eventHandler.addExclusiveInteraction(
|
|
94
|
+
interactionChain,
|
|
95
|
+
() => {
|
|
96
|
+
removed.raiseEvent();
|
|
97
|
+
},
|
|
98
|
+
undefined,
|
|
99
|
+
interactionId,
|
|
100
|
+
);
|
|
101
|
+
const currentFeatureInteractionEvent = eventHandler.featureInteraction.active;
|
|
102
|
+
eventHandler.featureInteraction.setActive(
|
|
103
|
+
EventType.CLICKMOVE | EventType.DRAGSTART,
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
interactionChain,
|
|
108
|
+
destroy() {
|
|
109
|
+
listener();
|
|
110
|
+
removed.destroy();
|
|
111
|
+
interactionChain.destroy();
|
|
112
|
+
eventHandler.featureInteraction.setActive(currentFeatureInteractionEvent);
|
|
113
|
+
},
|
|
114
|
+
removed,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @enum {string}
|
|
120
|
+
* @property {string} Point
|
|
121
|
+
* @property {string} Circle
|
|
122
|
+
* @property {string} LineString
|
|
123
|
+
* @property {string} Polygon
|
|
124
|
+
* @property {string} BBox
|
|
125
|
+
*/
|
|
126
|
+
export const GeometryType = {
|
|
127
|
+
Point: 'Point',
|
|
128
|
+
Circle: 'Circle',
|
|
129
|
+
LineString: 'LineString',
|
|
130
|
+
Polygon: 'Polygon',
|
|
131
|
+
BBox: 'BBox',
|
|
132
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Symbol to identify a {@see Vertex}
|
|
3
|
+
* @type {symbol}
|
|
4
|
+
*/
|
|
5
|
+
export const vertexSymbol = Symbol('Vertex');
|
|
6
|
+
/**
|
|
7
|
+
* Symbol to denote the vertexes index in the vertices array. This is important for snapping & bbox operations
|
|
8
|
+
* @type {symbol}
|
|
9
|
+
*/
|
|
10
|
+
export const vertexIndex = Symbol('VertexIndex');
|
|
11
|
+
/**
|
|
12
|
+
* Symbol added to primitives and features to denote that these are handlers. It is expected, that the value of the symobl is
|
|
13
|
+
* equal to an {@see AXIS_AND_PLANES}
|
|
14
|
+
* @type {symbol}
|
|
15
|
+
*/
|
|
16
|
+
export const handlerSymbol = Symbol('Handler');
|
|
17
|
+
/**
|
|
18
|
+
* Symbol to identify which was the last editor mouse over handler that edited the cursor style.
|
|
19
|
+
* @type {symbol}
|
|
20
|
+
*/
|
|
21
|
+
export const mouseOverSymbol = Symbol('MouseOver');
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import Polygon from 'ol/geom/Polygon.js';
|
|
2
|
+
import AbstractInteraction from '../../../interaction/abstractInteraction.js';
|
|
3
|
+
import { EventType } from '../../../interaction/interactionType.js';
|
|
4
|
+
import VcsEvent from '../../../vcsEvent.js';
|
|
5
|
+
import { GeometryType } from '../editorSessionHelpers.js';
|
|
6
|
+
import {
|
|
7
|
+
alreadyTransformedToImage,
|
|
8
|
+
alreadyTransformedToMercator,
|
|
9
|
+
} from '../../../layer/vectorSymbols.js';
|
|
10
|
+
import ObliqueMap from '../../../map/obliqueMap.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Offset to prevent bbox from collapsing
|
|
14
|
+
* @type {number}
|
|
15
|
+
*/
|
|
16
|
+
const precisionOffset = 0.000001;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* This interaction allows you to create a bounding box geometry.
|
|
20
|
+
* @class
|
|
21
|
+
* @extends {AbstractInteraction}
|
|
22
|
+
* @implements {CreateInteraction<import("ol/geom").Polygon>}
|
|
23
|
+
*/
|
|
24
|
+
class CreateBBoxInteraction extends AbstractInteraction {
|
|
25
|
+
constructor() {
|
|
26
|
+
super(EventType.CLICKMOVE | EventType.DBLCLICK);
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @type {import("ol/geom").Polygon|null}
|
|
30
|
+
* @private
|
|
31
|
+
*/
|
|
32
|
+
this._geometry = null;
|
|
33
|
+
/**
|
|
34
|
+
* @type {import("ol/coordinate").Coordinate|null}
|
|
35
|
+
* @private
|
|
36
|
+
*/
|
|
37
|
+
this._origin = null;
|
|
38
|
+
/**
|
|
39
|
+
* @type {import("ol/coordinate").Coordinate|null}
|
|
40
|
+
* @private
|
|
41
|
+
*/
|
|
42
|
+
this._lastCoordinate = null;
|
|
43
|
+
/**
|
|
44
|
+
* @type {VcsEvent<import("ol/geom").Polygon|null>}
|
|
45
|
+
*/
|
|
46
|
+
this.finished = new VcsEvent();
|
|
47
|
+
/**
|
|
48
|
+
* @type {VcsEvent<import("ol/geom").Polygon>}
|
|
49
|
+
*/
|
|
50
|
+
this.created = new VcsEvent();
|
|
51
|
+
this.setActive();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Sets the coordinates given the last coordinate and the current origin
|
|
56
|
+
* @private
|
|
57
|
+
*/
|
|
58
|
+
_setCoordinates() {
|
|
59
|
+
if (this._geometry) {
|
|
60
|
+
const originXHigher = this._origin[0] >= this._lastCoordinate[0];
|
|
61
|
+
const originYHigher = this._origin[1] >= this._lastCoordinate[1];
|
|
62
|
+
if (this._origin[0] === this._lastCoordinate[0]) {
|
|
63
|
+
this._lastCoordinate[0] += precisionOffset;
|
|
64
|
+
}
|
|
65
|
+
if (this._origin[1] === this._lastCoordinate[1]) {
|
|
66
|
+
this._lastCoordinate[1] += precisionOffset;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
this._lastCoordinate[2] = this._origin[2];
|
|
70
|
+
let ringCoordinates;
|
|
71
|
+
if (
|
|
72
|
+
(originXHigher && originYHigher) ||
|
|
73
|
+
(!originXHigher && !originYHigher)
|
|
74
|
+
) {
|
|
75
|
+
ringCoordinates = [
|
|
76
|
+
this._origin,
|
|
77
|
+
[this._lastCoordinate[0], this._origin[1], this._origin[2]],
|
|
78
|
+
this._lastCoordinate,
|
|
79
|
+
[this._origin[0], this._lastCoordinate[1], this._origin[2]],
|
|
80
|
+
];
|
|
81
|
+
} else {
|
|
82
|
+
ringCoordinates = [
|
|
83
|
+
this._origin,
|
|
84
|
+
[this._origin[0], this._lastCoordinate[1], this._origin[2]],
|
|
85
|
+
this._lastCoordinate,
|
|
86
|
+
[this._lastCoordinate[0], this._origin[1], this._origin[2]],
|
|
87
|
+
];
|
|
88
|
+
}
|
|
89
|
+
this._geometry.setCoordinates([ringCoordinates]);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @param {InteractionEvent} event
|
|
95
|
+
* @returns {Promise<InteractionEvent>}
|
|
96
|
+
* @inheritDoc
|
|
97
|
+
*/
|
|
98
|
+
async pipe(event) {
|
|
99
|
+
if (event.type & EventType.CLICKMOVE && this._geometry) {
|
|
100
|
+
this._lastCoordinate.splice(
|
|
101
|
+
0,
|
|
102
|
+
event.positionOrPixel.length,
|
|
103
|
+
...event.positionOrPixel,
|
|
104
|
+
);
|
|
105
|
+
this._setCoordinates();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (event.type & EventType.CLICK) {
|
|
109
|
+
if (this._geometry) {
|
|
110
|
+
this.finish();
|
|
111
|
+
} else {
|
|
112
|
+
this._geometry = new Polygon([[event.positionOrPixel.slice()]], 'XYZ');
|
|
113
|
+
this._geometry.set('_vcsGeomType', GeometryType.BBox);
|
|
114
|
+
if (event.map instanceof ObliqueMap) {
|
|
115
|
+
this._geometry[alreadyTransformedToImage] = true;
|
|
116
|
+
} else {
|
|
117
|
+
this._geometry[alreadyTransformedToMercator] = true;
|
|
118
|
+
}
|
|
119
|
+
this.created.raiseEvent(this._geometry);
|
|
120
|
+
this._origin = event.positionOrPixel.slice();
|
|
121
|
+
this._lastCoordinate = this._origin.slice();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (event.type & EventType.DBLCLICK) {
|
|
126
|
+
this.finish();
|
|
127
|
+
}
|
|
128
|
+
return event;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Finish the current creation. Calls finish and sets the interaction to be inactive
|
|
133
|
+
*/
|
|
134
|
+
finish() {
|
|
135
|
+
if (this.active !== EventType.NONE) {
|
|
136
|
+
this._setCoordinates();
|
|
137
|
+
this.setActive(false);
|
|
138
|
+
this.finished.raiseEvent(this._geometry);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* @inheritDoc
|
|
144
|
+
*/
|
|
145
|
+
destroy() {
|
|
146
|
+
this._geometry = null;
|
|
147
|
+
this._coordinates = [];
|
|
148
|
+
this.finished.destroy();
|
|
149
|
+
this.created.destroy();
|
|
150
|
+
super.destroy();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export default CreateBBoxInteraction;
|