@vcmap/core 6.0.0-rc.4 → 6.0.0-rc.6
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/dist/cesium.d.ts +11 -0
- package/dist/index.d.ts +23 -16
- package/dist/index.js +21 -14
- package/dist/index.js.map +1 -1
- package/dist/ol.d.ts +15 -2
- package/dist/src/layer/cesium/clusterContext.d.ts +8 -14
- package/dist/src/layer/cesium/clusterContext.js +62 -41
- package/dist/src/layer/cesium/clusterContext.js.map +1 -1
- package/dist/src/layer/cesium/vectorCesiumImpl.d.ts +2 -3
- package/dist/src/layer/cesium/vectorCesiumImpl.js +16 -10
- package/dist/src/layer/cesium/vectorCesiumImpl.js.map +1 -1
- package/dist/src/layer/cesium/vectorContext.d.ts +10 -53
- package/dist/src/layer/cesium/vectorContext.js +88 -172
- package/dist/src/layer/cesium/vectorContext.js.map +1 -1
- package/dist/src/layer/geojsonHelpers.d.ts +1 -1
- package/dist/src/layer/geojsonHelpers.js +5 -10
- package/dist/src/layer/geojsonHelpers.js.map +1 -1
- package/dist/src/layer/oblique/obliqueHelpers.js +6 -6
- package/dist/src/layer/oblique/obliqueHelpers.js.map +1 -1
- package/dist/src/layer/vectorLayer.d.ts +0 -37
- package/dist/src/layer/vectorLayer.js.map +1 -1
- package/dist/src/layer/vectorProperties.d.ts +8 -3
- package/dist/src/layer/vectorProperties.js +30 -5
- package/dist/src/layer/vectorProperties.js.map +1 -1
- package/dist/src/map/baseOLMap.js +1 -1
- package/dist/src/map/baseOLMap.js.map +1 -1
- package/dist/src/map/obliqueMap.d.ts +3 -0
- package/dist/src/map/obliqueMap.js +27 -6
- package/dist/src/map/obliqueMap.js.map +1 -1
- package/dist/src/map/vcsMap.d.ts +8 -0
- package/dist/src/map/vcsMap.js +11 -0
- package/dist/src/map/vcsMap.js.map +1 -1
- package/dist/src/oblique/helpers.js +5 -5
- package/dist/src/oblique/helpers.js.map +1 -1
- package/dist/src/oblique/obliqueDataSet.js +4 -4
- package/dist/src/oblique/obliqueDataSet.js.map +1 -1
- package/dist/src/ol/geom/geometryCollection.js +19 -2
- package/dist/src/ol/geom/geometryCollection.js.map +1 -1
- package/dist/src/style/arcStyle.js +1 -0
- package/dist/src/style/arcStyle.js.map +1 -1
- package/dist/src/util/editor/createFeatureSession.d.ts +5 -1
- package/dist/src/util/editor/createFeatureSession.js +48 -4
- package/dist/src/util/editor/createFeatureSession.js.map +1 -1
- package/dist/src/util/editor/editFeaturesSession.d.ts +10 -4
- package/dist/src/util/editor/editFeaturesSession.js +74 -37
- package/dist/src/util/editor/editFeaturesSession.js.map +1 -1
- package/dist/src/util/editor/editGeometrySession.d.ts +5 -1
- package/dist/src/util/editor/editGeometrySession.js +77 -55
- package/dist/src/util/editor/editGeometrySession.js.map +1 -1
- package/dist/src/util/editor/editorHelpers.d.ts +12 -6
- package/dist/src/util/editor/editorHelpers.js +47 -20
- package/dist/src/util/editor/editorHelpers.js.map +1 -1
- package/dist/src/util/editor/editorSessionHelpers.d.ts +5 -0
- package/dist/src/util/editor/editorSessionHelpers.js +1 -0
- package/dist/src/util/editor/editorSessionHelpers.js.map +1 -1
- package/dist/src/util/editor/editorSymbols.d.ts +1 -1
- package/dist/src/util/editor/editorSymbols.js +1 -1
- package/dist/src/util/editor/editorSymbols.js.map +1 -1
- package/dist/src/util/editor/interactions/createBBoxInteraction.d.ts +1 -0
- package/dist/src/util/editor/interactions/createBBoxInteraction.js +20 -16
- package/dist/src/util/editor/interactions/createBBoxInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/createCircleInteraction.js +1 -1
- package/dist/src/util/editor/interactions/createCircleInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/createLineStringInteraction.js +3 -3
- package/dist/src/util/editor/interactions/createLineStringInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/createPointInteraction.js +1 -1
- package/dist/src/util/editor/interactions/createPointInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/createPolygonInteraction.d.ts +4 -0
- package/dist/src/util/editor/interactions/createPolygonInteraction.js +9 -3
- package/dist/src/util/editor/interactions/createPolygonInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/creationSnapping.d.ts +26 -0
- package/dist/src/util/editor/interactions/creationSnapping.js +139 -0
- package/dist/src/util/editor/interactions/creationSnapping.js.map +1 -0
- package/dist/src/util/editor/interactions/editGeometryMouseOverInteraction.js +3 -2
- package/dist/src/util/editor/interactions/editGeometryMouseOverInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/insertVertexInteraction.d.ts +3 -1
- package/dist/src/util/editor/interactions/insertVertexInteraction.js +14 -6
- package/dist/src/util/editor/interactions/insertVertexInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/layerSnapping.d.ts +19 -0
- package/dist/src/util/editor/interactions/layerSnapping.js +87 -0
- package/dist/src/util/editor/interactions/layerSnapping.js.map +1 -0
- package/dist/src/util/editor/interactions/translateVertexInteraction.js +2 -2
- package/dist/src/util/editor/interactions/translateVertexInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/translationSnapping.d.ts +25 -0
- package/dist/src/util/editor/interactions/translationSnapping.js +179 -0
- package/dist/src/util/editor/interactions/translationSnapping.js.map +1 -0
- package/dist/src/util/editor/snappingHelpers.d.ts +44 -0
- package/dist/src/util/editor/snappingHelpers.js +329 -0
- package/dist/src/util/editor/snappingHelpers.js.map +1 -0
- package/dist/src/util/editor/transformation/create2DHandlers.js +26 -26
- package/dist/src/util/editor/transformation/create2DHandlers.js.map +1 -1
- package/dist/src/util/editor/transformation/create3DHandlers.js +65 -14
- package/dist/src/util/editor/transformation/create3DHandlers.js.map +1 -1
- package/dist/src/util/editor/transformation/scaleInteraction.js +27 -5
- package/dist/src/util/editor/transformation/scaleInteraction.js.map +1 -1
- package/dist/src/util/editor/transformation/transformationHandler.js +56 -38
- package/dist/src/util/editor/transformation/transformationHandler.js.map +1 -1
- package/dist/src/util/editor/transformation/transformationTypes.d.ts +2 -0
- package/dist/src/util/editor/transformation/transformationTypes.js +4 -0
- package/dist/src/util/editor/transformation/transformationTypes.js.map +1 -1
- package/dist/src/util/featureconverter/arcToCesium.d.ts +5 -19
- package/dist/src/util/featureconverter/arcToCesium.js +15 -42
- package/dist/src/util/featureconverter/arcToCesium.js.map +1 -1
- package/dist/src/util/featureconverter/circleToCesium.d.ts +2 -27
- package/dist/src/util/featureconverter/circleToCesium.js +84 -63
- package/dist/src/util/featureconverter/circleToCesium.js.map +1 -1
- package/dist/src/util/featureconverter/clampedPrimitive.d.ts +2 -0
- package/dist/src/util/featureconverter/clampedPrimitive.js +29 -0
- package/dist/src/util/featureconverter/clampedPrimitive.js.map +1 -0
- package/dist/src/util/featureconverter/convert.d.ts +26 -7
- package/dist/src/util/featureconverter/convert.js +221 -44
- package/dist/src/util/featureconverter/convert.js.map +1 -1
- package/dist/src/util/featureconverter/extent3D.d.ts +4 -3
- package/dist/src/util/featureconverter/extent3D.js +4 -3
- package/dist/src/util/featureconverter/extent3D.js.map +1 -1
- package/dist/src/util/featureconverter/lineStringToCesium.d.ts +12 -27
- package/dist/src/util/featureconverter/lineStringToCesium.js +85 -107
- package/dist/src/util/featureconverter/lineStringToCesium.js.map +1 -1
- package/dist/src/util/featureconverter/pointHelpers.d.ts +8 -11
- package/dist/src/util/featureconverter/pointHelpers.js +134 -120
- package/dist/src/util/featureconverter/pointHelpers.js.map +1 -1
- package/dist/src/util/featureconverter/pointToCesium.d.ts +14 -17
- package/dist/src/util/featureconverter/pointToCesium.js +47 -96
- package/dist/src/util/featureconverter/pointToCesium.js.map +1 -1
- package/dist/src/util/featureconverter/polygonToCesium.d.ts +2 -26
- package/dist/src/util/featureconverter/polygonToCesium.js +62 -72
- package/dist/src/util/featureconverter/polygonToCesium.js.map +1 -1
- package/dist/src/util/featureconverter/storeyHelpers.d.ts +17 -0
- package/dist/src/util/featureconverter/storeyHelpers.js +78 -0
- package/dist/src/util/featureconverter/storeyHelpers.js.map +1 -0
- package/dist/src/util/featureconverter/vectorGeometryFactory.d.ts +54 -0
- package/dist/src/util/featureconverter/vectorGeometryFactory.js +278 -0
- package/dist/src/util/featureconverter/vectorGeometryFactory.js.map +1 -0
- package/dist/src/util/featureconverter/vectorHeightInfo.d.ts +86 -0
- package/dist/src/util/featureconverter/vectorHeightInfo.js +242 -0
- package/dist/src/util/featureconverter/vectorHeightInfo.js.map +1 -0
- package/dist/src/util/geometryHelpers.d.ts +22 -1
- package/dist/src/util/geometryHelpers.js +65 -2
- package/dist/src/util/geometryHelpers.js.map +1 -1
- package/dist/src/util/mapCollection.js +8 -0
- package/dist/src/util/mapCollection.js.map +1 -1
- package/dist/src/util/math.d.ts +6 -2
- package/dist/src/util/math.js +34 -12
- package/dist/src/util/math.js.map +1 -1
- package/dist/tests/unit/helpers/cesiumHelpers.js +3 -1
- package/dist/tests/unit/helpers/cesiumHelpers.js.map +1 -1
- package/dist/tests/unit/helpers/helpers.d.ts +2 -9
- package/dist/tests/unit/helpers/helpers.js +2 -8
- package/dist/tests/unit/helpers/helpers.js.map +1 -1
- package/index.ts +74 -35
- package/package.json +3 -3
- package/src/cesium/cesium.d.ts +11 -0
- package/src/layer/cesium/clusterContext.ts +82 -91
- package/src/layer/cesium/vectorCesiumImpl.ts +17 -11
- package/src/layer/cesium/vectorContext.ts +120 -348
- package/src/layer/geojsonHelpers.ts +9 -12
- package/src/layer/oblique/obliqueHelpers.ts +6 -6
- package/src/layer/vectorLayer.ts +0 -71
- package/src/layer/vectorProperties.ts +46 -9
- package/src/map/baseOLMap.ts +1 -1
- package/src/map/obliqueMap.ts +46 -6
- package/src/map/vcsMap.ts +20 -2
- package/src/oblique/helpers.ts +11 -5
- package/src/oblique/obliqueDataSet.ts +4 -4
- package/src/ol/geom/geometryCollection.js +21 -2
- package/src/ol/ol.d.ts +15 -2
- package/src/style/arcStyle.ts +1 -0
- package/src/util/editor/createFeatureSession.ts +64 -6
- package/src/util/editor/editFeaturesSession.ts +105 -39
- package/src/util/editor/editGeometrySession.ts +118 -75
- package/src/util/editor/editorHelpers.ts +78 -30
- package/src/util/editor/editorSessionHelpers.ts +7 -0
- package/src/util/editor/editorSymbols.ts +1 -1
- package/src/util/editor/interactions/createBBoxInteraction.ts +25 -16
- package/src/util/editor/interactions/createCircleInteraction.ts +1 -1
- package/src/util/editor/interactions/createLineStringInteraction.ts +9 -3
- package/src/util/editor/interactions/createPointInteraction.ts +1 -1
- package/src/util/editor/interactions/createPolygonInteraction.ts +16 -3
- package/src/util/editor/interactions/creationSnapping.ts +226 -0
- package/src/util/editor/interactions/editGeometryMouseOverInteraction.ts +3 -2
- package/src/util/editor/interactions/insertVertexInteraction.ts +27 -7
- package/src/util/editor/interactions/layerSnapping.ts +136 -0
- package/src/util/editor/interactions/translateVertexInteraction.ts +8 -2
- package/src/util/editor/interactions/translationSnapping.ts +302 -0
- package/src/util/editor/snappingHelpers.ts +490 -0
- package/src/util/editor/transformation/create2DHandlers.ts +38 -26
- package/src/util/editor/transformation/create3DHandlers.ts +84 -22
- package/src/util/editor/transformation/scaleInteraction.ts +28 -5
- package/src/util/editor/transformation/transformationHandler.ts +72 -41
- package/src/util/editor/transformation/transformationTypes.ts +5 -0
- package/src/util/featureconverter/arcToCesium.ts +25 -95
- package/src/util/featureconverter/circleToCesium.ts +127 -113
- package/src/util/featureconverter/clampedPrimitive.ts +70 -0
- package/src/util/featureconverter/convert.ts +446 -114
- package/src/util/featureconverter/extent3D.ts +13 -6
- package/src/util/featureconverter/lineStringToCesium.ts +132 -179
- package/src/util/featureconverter/pointHelpers.ts +271 -214
- package/src/util/featureconverter/pointToCesium.ts +111 -175
- package/src/util/featureconverter/polygonToCesium.ts +98 -117
- package/src/util/featureconverter/storeyHelpers.ts +104 -0
- package/src/util/featureconverter/vectorGeometryFactory.ts +601 -0
- package/src/util/featureconverter/vectorHeightInfo.ts +393 -0
- package/src/util/geometryHelpers.ts +79 -5
- package/src/util/mapCollection.ts +8 -0
- package/src/util/math.ts +59 -12
- package/dist/src/util/featureconverter/featureconverterHelper.d.ts +0 -35
- package/dist/src/util/featureconverter/featureconverterHelper.js +0 -404
- package/dist/src/util/featureconverter/featureconverterHelper.js.map +0 -1
- package/src/util/featureconverter/featureconverterHelper.ts +0 -672
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
import { Coordinate } from 'ol/coordinate.js';
|
|
2
|
+
import { Fill, Icon, Stroke, Style } from 'ol/style.js';
|
|
3
|
+
import { Feature } from 'ol';
|
|
4
|
+
import { Geometry, Point } from 'ol/geom.js';
|
|
5
|
+
import RegularShape from 'ol/style/RegularShape.js';
|
|
6
|
+
import { Cartesian2, Matrix2, Math as CesiumMath } from '@vcmap-cesium/engine';
|
|
7
|
+
import {
|
|
8
|
+
cartesian2DDistanceSquared,
|
|
9
|
+
cartesian2Intersection,
|
|
10
|
+
getCartesianBearing,
|
|
11
|
+
getMidPoint,
|
|
12
|
+
} from '../math.js';
|
|
13
|
+
import { getClosestPointOn2DLine } from './editorHelpers.js';
|
|
14
|
+
import VectorLayer from '../../layer/vectorLayer.js';
|
|
15
|
+
import {
|
|
16
|
+
alreadyTransformedToImage,
|
|
17
|
+
alreadyTransformedToMercator,
|
|
18
|
+
doNotTransform,
|
|
19
|
+
} from '../../layer/vectorSymbols.js';
|
|
20
|
+
import { blackColor } from '../../style/styleHelpers.js';
|
|
21
|
+
import { PrimitiveOptionsType } from '../../layer/vectorProperties.js';
|
|
22
|
+
import { isRelativeHeightReference } from '../featureconverter/vectorHeightInfo.js';
|
|
23
|
+
|
|
24
|
+
export const snapTypes = ['orthogonal', 'parallel', 'vertex', 'edge'] as const;
|
|
25
|
+
|
|
26
|
+
export type SnapType = (typeof snapTypes)[number];
|
|
27
|
+
|
|
28
|
+
export type SnapResult<T extends SnapType = SnapType> = T extends 'orthogonal'
|
|
29
|
+
? {
|
|
30
|
+
type: T;
|
|
31
|
+
snapped: Coordinate;
|
|
32
|
+
otherVertexIndex: number;
|
|
33
|
+
}
|
|
34
|
+
: T extends 'parallel'
|
|
35
|
+
? {
|
|
36
|
+
type: T;
|
|
37
|
+
parallelIndex: number;
|
|
38
|
+
snapped: Coordinate;
|
|
39
|
+
otherVertexIndex: number;
|
|
40
|
+
}
|
|
41
|
+
: T extends 'vertex'
|
|
42
|
+
? {
|
|
43
|
+
type: T;
|
|
44
|
+
snapped: Coordinate;
|
|
45
|
+
}
|
|
46
|
+
: T extends 'edge'
|
|
47
|
+
? {
|
|
48
|
+
type: T;
|
|
49
|
+
snapped: Coordinate;
|
|
50
|
+
}
|
|
51
|
+
: never;
|
|
52
|
+
|
|
53
|
+
let scratchCartesian21 = new Cartesian2();
|
|
54
|
+
let scratchCartesian22 = new Cartesian2();
|
|
55
|
+
|
|
56
|
+
const orothogonalSrc =
|
|
57
|
+
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABkCAYAAAA2VDb+AAACmElEQVR4Xu2a3zHFQBjFz60AFeDNGypABcaTVzqgAlSADuiACuiADtCBDpgzk525Yyb5cpNNzibOvt652f1+3/n+bbIA8IP6tWj4bRY/0UADsAIcArUEnANmkemCGHcSdBJ0EnQSrCPgKuAqMHMCngU8DHka9DjsVtitsFtht8JuhWsIeBaYeScMt8Juhd0KuxV2K+xWuJ7ANoDPOZfCqAzSdgJ4AvAK4HluMNoA+GszYdxXQCbPowuAZDRBXE49RPoASCAeANxMFUQOAAnEXaWISYVFTgA0nInyBMD3VCjkBpCqBiG8TwHCEACS3ecAmB+KXhGAfQCHAM4A7HawhOXyosP/RvtLBGD5RoggrgEcrHi6opWwCoBkdxcQxULoAiCBoLRvW6qBVeGoxMTYBwBtpxrYEa61AFEkhL4AaPdWBaFNkuRgxQmzmJUDAI1Zr5qgNhDYNjOZFrFyAVgFAkOB5bWIe4acAFI4sAOMcgLzBrtF+coNgAbtVeEQQWBV4OwgXUMAoEGM8avAsiIS4lAAaDsN3AwgMBdIh6YhAbBHeAkAyGeFIQHQdia74wYI8jAYGgAT4lugAlYDgpKsoQG0yQWP1bg9WwBRRWBjtCGxHhjl+wDOCh+BgQQguUccIwRoO0td05wga4rGAhBVA75g4bX66GssAFEekPUDEQCOrjnWDoDThgd9qW6QIwA5jC/6GQYQfCVWtPdyHM4KsAKavxPMobKin8EQKOaGVkFq+d2fYn/5ngYgd4H4AFaA2AHy7a0AuQvEB7ACxA6Qb28FyF0gPoAVIHaAfHsrQO4C8QGsALED5NtbAXIXiA9gBYgdIN/eCpC7QHwAK0DsAPn2VoDcBeIDWAFiB8i3twLkLhAf4N8r4Bch+4Nf5+N6mQAAAABJRU5ErkJggg==';
|
|
58
|
+
|
|
59
|
+
let orthogonalStyle: Style | undefined;
|
|
60
|
+
function getOrthogonalStyle(): Style {
|
|
61
|
+
if (!orthogonalStyle) {
|
|
62
|
+
orthogonalStyle = new Style({
|
|
63
|
+
image: new Icon({
|
|
64
|
+
src: orothogonalSrc,
|
|
65
|
+
scale: 0.25,
|
|
66
|
+
anchor: [0.5, 1],
|
|
67
|
+
}),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return orthogonalStyle;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const parallelSrc =
|
|
74
|
+
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEwAACxMBAJqcGAAAAd1JREFUeJzt00EKwkAQRcFEPGyOpKfVE/iyiDIzWLVv+DS8bQMAAAAAAAAAAAAAAAAAAAAAAAAAAID/so8esIDj4v3jKys+m33f0gRy7nXx/tc/nn3f0m6jB8DMBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBDuowcs4Dl6wInZ9wEAAAAAAAAAAAAAAAAAAAAAAAAAAAALeQNcNQZTV+qErgAAAABJRU5ErkJggg==';
|
|
75
|
+
|
|
76
|
+
let parallelStyle: Style | undefined;
|
|
77
|
+
function getParallelStyle(): Style {
|
|
78
|
+
if (!parallelStyle) {
|
|
79
|
+
parallelStyle = new Style({
|
|
80
|
+
image: new Icon({
|
|
81
|
+
src: parallelSrc,
|
|
82
|
+
scale: 0.1,
|
|
83
|
+
anchor: [0.5, 1],
|
|
84
|
+
}),
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return parallelStyle;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
let vertexStyle: Style | undefined;
|
|
91
|
+
function getVertexStyle(): Style {
|
|
92
|
+
if (!vertexStyle) {
|
|
93
|
+
vertexStyle = new Style({
|
|
94
|
+
image: new RegularShape({
|
|
95
|
+
radius: 6,
|
|
96
|
+
points: 4,
|
|
97
|
+
fill: new Fill({
|
|
98
|
+
color: [255, 255, 255, 0.4],
|
|
99
|
+
}),
|
|
100
|
+
stroke: new Stroke({
|
|
101
|
+
color: blackColor,
|
|
102
|
+
width: 1,
|
|
103
|
+
}),
|
|
104
|
+
}),
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return vertexStyle;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const FIVE_DEGREES = CesiumMath.toRadians(5);
|
|
111
|
+
|
|
112
|
+
function getClosestOrthogonal(
|
|
113
|
+
start: Coordinate,
|
|
114
|
+
end: Coordinate,
|
|
115
|
+
point: Coordinate,
|
|
116
|
+
): Coordinate {
|
|
117
|
+
scratchCartesian21 = Cartesian2.fromElements(
|
|
118
|
+
end[0] - start[0],
|
|
119
|
+
end[1] - start[1],
|
|
120
|
+
scratchCartesian21,
|
|
121
|
+
); // segment;
|
|
122
|
+
const matrix = Matrix2.fromArray([0, 1, -1, 0]);
|
|
123
|
+
scratchCartesian22 = Matrix2.multiplyByVector(
|
|
124
|
+
matrix,
|
|
125
|
+
scratchCartesian21,
|
|
126
|
+
scratchCartesian22,
|
|
127
|
+
);
|
|
128
|
+
scratchCartesian22 = Cartesian2.normalize(
|
|
129
|
+
scratchCartesian22,
|
|
130
|
+
scratchCartesian22,
|
|
131
|
+
);
|
|
132
|
+
scratchCartesian22 = Cartesian2.multiplyByScalar(
|
|
133
|
+
scratchCartesian22,
|
|
134
|
+
0.0001,
|
|
135
|
+
scratchCartesian22,
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
const newSegment = [
|
|
139
|
+
scratchCartesian22.x + end[0],
|
|
140
|
+
scratchCartesian22.y + end[1],
|
|
141
|
+
point[2],
|
|
142
|
+
];
|
|
143
|
+
return getClosestPointOn2DLine(end, newSegment, point);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function findClosestOrthogonalOrLinear(
|
|
147
|
+
start: Coordinate,
|
|
148
|
+
end: Coordinate,
|
|
149
|
+
point: Coordinate,
|
|
150
|
+
): Coordinate {
|
|
151
|
+
const c1 = getClosestPointOn2DLine(start, end, point);
|
|
152
|
+
const c2 = getClosestOrthogonal(start, end, point);
|
|
153
|
+
const d1 = cartesian2DDistanceSquared(c1, point);
|
|
154
|
+
const d2 = cartesian2DDistanceSquared(c2, point);
|
|
155
|
+
if (d1 > d2) {
|
|
156
|
+
return c2;
|
|
157
|
+
}
|
|
158
|
+
return c1;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* projects the point onto the imaginary line from origin in direction theta
|
|
163
|
+
* @param origin
|
|
164
|
+
* @param point
|
|
165
|
+
* @param theta - direction from north in radians
|
|
166
|
+
* @returns
|
|
167
|
+
*/
|
|
168
|
+
function getClosestInDirection(
|
|
169
|
+
origin: Coordinate,
|
|
170
|
+
point: Coordinate,
|
|
171
|
+
theta: number,
|
|
172
|
+
): Coordinate {
|
|
173
|
+
let alpha = theta + CesiumMath.PI_OVER_TWO;
|
|
174
|
+
alpha = alpha > CesiumMath.TWO_PI ? alpha - CesiumMath.TWO_PI : alpha;
|
|
175
|
+
const unityP1 = [
|
|
176
|
+
origin[0] + 100 * Math.cos(alpha),
|
|
177
|
+
origin[1] - 100 * Math.sin(alpha),
|
|
178
|
+
origin[2],
|
|
179
|
+
];
|
|
180
|
+
|
|
181
|
+
return getClosestPointOn2DLine(origin, unityP1, point);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function getOrthogonalSnapResult(
|
|
185
|
+
coordinate: Coordinate,
|
|
186
|
+
p1: Coordinate,
|
|
187
|
+
p2: Coordinate,
|
|
188
|
+
otherVertexIndex: number,
|
|
189
|
+
): SnapResult<'orthogonal'> | undefined {
|
|
190
|
+
const currentBearing = getCartesianBearing(p1, coordinate);
|
|
191
|
+
const previousBearing = getCartesianBearing(p2, p1);
|
|
192
|
+
const previousBearingDiff = Math.abs(previousBearing - currentBearing);
|
|
193
|
+
if (
|
|
194
|
+
previousBearingDiff < FIVE_DEGREES || // 5
|
|
195
|
+
(previousBearingDiff > CesiumMath.PI_OVER_TWO - FIVE_DEGREES &&
|
|
196
|
+
previousBearingDiff < CesiumMath.PI_OVER_TWO + FIVE_DEGREES) || // 90 +/- 5
|
|
197
|
+
(previousBearingDiff > CesiumMath.PI - FIVE_DEGREES &&
|
|
198
|
+
previousBearingDiff < CesiumMath.PI + FIVE_DEGREES) || // 180 +/- 5
|
|
199
|
+
(previousBearingDiff > CesiumMath.THREE_PI_OVER_TWO - FIVE_DEGREES &&
|
|
200
|
+
previousBearingDiff < CesiumMath.THREE_PI_OVER_TWO + FIVE_DEGREES) || // 280 +/- 5
|
|
201
|
+
previousBearingDiff > CesiumMath.TWO_PI - FIVE_DEGREES // 360 - 5
|
|
202
|
+
) {
|
|
203
|
+
const snapped = findClosestOrthogonalOrLinear(p2, p1, coordinate);
|
|
204
|
+
|
|
205
|
+
return {
|
|
206
|
+
type: 'orthogonal',
|
|
207
|
+
snapped,
|
|
208
|
+
otherVertexIndex,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return undefined;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function getParallelSnapResult(
|
|
216
|
+
coordinate: Coordinate,
|
|
217
|
+
p1: Coordinate,
|
|
218
|
+
geometryBearings: number[],
|
|
219
|
+
otherVertexIndex: number,
|
|
220
|
+
): SnapResult<'parallel'> | undefined {
|
|
221
|
+
const currentBearing = getCartesianBearing(p1, coordinate);
|
|
222
|
+
const bearingsLength = geometryBearings.length;
|
|
223
|
+
for (let parallelIndex = 0; parallelIndex < bearingsLength; parallelIndex++) {
|
|
224
|
+
const bearing = geometryBearings[parallelIndex];
|
|
225
|
+
if (bearing >= 0) {
|
|
226
|
+
const bearingDiff = Math.abs(bearing - currentBearing);
|
|
227
|
+
if (
|
|
228
|
+
bearingDiff < FIVE_DEGREES || // 5
|
|
229
|
+
(bearingDiff > CesiumMath.PI - FIVE_DEGREES &&
|
|
230
|
+
bearingDiff < CesiumMath.PI + FIVE_DEGREES) || // 180 +/- 5
|
|
231
|
+
bearingDiff > CesiumMath.TWO_PI - FIVE_DEGREES // 360 - 5
|
|
232
|
+
) {
|
|
233
|
+
const snapped = getClosestInDirection(p1, coordinate, bearing);
|
|
234
|
+
return {
|
|
235
|
+
type: 'parallel',
|
|
236
|
+
snapped,
|
|
237
|
+
otherVertexIndex,
|
|
238
|
+
parallelIndex,
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return undefined;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Try to create an orthogonal for p2 - p1 - coordinate. otherwise snaps p1 - coordinate to any of the given geometry bearings
|
|
249
|
+
* @param coordinate
|
|
250
|
+
* @param p1
|
|
251
|
+
* @param p2
|
|
252
|
+
* @param geometryBearings
|
|
253
|
+
* @param otherVertexIndex
|
|
254
|
+
* @param maxDistanceSquared
|
|
255
|
+
* @param snapOrthogonal
|
|
256
|
+
* @param snapParallel
|
|
257
|
+
*/
|
|
258
|
+
export function getAngleSnapResult(
|
|
259
|
+
coordinate: Coordinate,
|
|
260
|
+
p1: Coordinate,
|
|
261
|
+
p2: Coordinate,
|
|
262
|
+
geometryBearings: number[],
|
|
263
|
+
otherVertexIndex: number,
|
|
264
|
+
maxDistanceSquared: number,
|
|
265
|
+
snapOrthogonal = true,
|
|
266
|
+
snapParallel = true,
|
|
267
|
+
): SnapResult<'orthogonal' | 'parallel'> | undefined {
|
|
268
|
+
let snapResult: SnapResult<'orthogonal' | 'parallel'> | undefined =
|
|
269
|
+
snapOrthogonal
|
|
270
|
+
? getOrthogonalSnapResult(coordinate, p1, p2, otherVertexIndex)
|
|
271
|
+
: undefined;
|
|
272
|
+
|
|
273
|
+
if (!snapResult && snapParallel) {
|
|
274
|
+
snapResult = getParallelSnapResult(
|
|
275
|
+
coordinate,
|
|
276
|
+
p1,
|
|
277
|
+
geometryBearings,
|
|
278
|
+
otherVertexIndex,
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (
|
|
283
|
+
snapResult?.snapped &&
|
|
284
|
+
cartesian2DDistanceSquared(snapResult.snapped, coordinate) <=
|
|
285
|
+
maxDistanceSquared
|
|
286
|
+
) {
|
|
287
|
+
return snapResult;
|
|
288
|
+
}
|
|
289
|
+
return undefined;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Snaps to the vertices of the provided geometries, otherwise tries to snap to the edges.
|
|
294
|
+
* @param geometries
|
|
295
|
+
* @param coordinate
|
|
296
|
+
* @param maxDistanceSquared
|
|
297
|
+
* @param snapToVertex
|
|
298
|
+
* @param snapToEdge
|
|
299
|
+
*/
|
|
300
|
+
export function getGeometrySnapResult(
|
|
301
|
+
geometries: Geometry[],
|
|
302
|
+
coordinate: Coordinate,
|
|
303
|
+
maxDistanceSquared: number,
|
|
304
|
+
snapToVertex = true,
|
|
305
|
+
snapToEdge = true,
|
|
306
|
+
): SnapResult<'edge' | 'vertex'> | undefined {
|
|
307
|
+
let distanceSquared = Infinity;
|
|
308
|
+
let result: SnapResult<'vertex' | 'edge'> | undefined;
|
|
309
|
+
|
|
310
|
+
if (snapToVertex) {
|
|
311
|
+
geometries.forEach((geometry) => {
|
|
312
|
+
const coordinates = geometry.getFlatCoordinates();
|
|
313
|
+
const stride = geometry.getStride();
|
|
314
|
+
|
|
315
|
+
const { length } = coordinates;
|
|
316
|
+
for (let i = 0; i < length; i += stride) {
|
|
317
|
+
const vertex = [coordinates[i], coordinates[i + 1]];
|
|
318
|
+
if (stride > 2) {
|
|
319
|
+
vertex[2] = coordinates[i + 2];
|
|
320
|
+
}
|
|
321
|
+
const currentDistanceSquared = cartesian2DDistanceSquared(
|
|
322
|
+
vertex,
|
|
323
|
+
coordinate,
|
|
324
|
+
);
|
|
325
|
+
|
|
326
|
+
if (
|
|
327
|
+
currentDistanceSquared < distanceSquared &&
|
|
328
|
+
currentDistanceSquared <= maxDistanceSquared
|
|
329
|
+
) {
|
|
330
|
+
distanceSquared = currentDistanceSquared;
|
|
331
|
+
if (!result) {
|
|
332
|
+
result = {
|
|
333
|
+
type: 'vertex',
|
|
334
|
+
snapped: vertex,
|
|
335
|
+
};
|
|
336
|
+
} else {
|
|
337
|
+
result.type = 'vertex';
|
|
338
|
+
result.snapped = vertex;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
if (!result && snapToEdge) {
|
|
346
|
+
distanceSquared = Infinity;
|
|
347
|
+
geometries.forEach((geometry) => {
|
|
348
|
+
const closestPoint = geometry.getClosestPoint(coordinate);
|
|
349
|
+
const currentDistanceSquared = cartesian2DDistanceSquared(
|
|
350
|
+
closestPoint,
|
|
351
|
+
coordinate,
|
|
352
|
+
);
|
|
353
|
+
|
|
354
|
+
if (
|
|
355
|
+
currentDistanceSquared < distanceSquared &&
|
|
356
|
+
currentDistanceSquared <= maxDistanceSquared
|
|
357
|
+
) {
|
|
358
|
+
distanceSquared = currentDistanceSquared;
|
|
359
|
+
if (!result) {
|
|
360
|
+
result = {
|
|
361
|
+
type: 'edge',
|
|
362
|
+
snapped: closestPoint,
|
|
363
|
+
};
|
|
364
|
+
} else {
|
|
365
|
+
result.type = 'edge';
|
|
366
|
+
result.snapped = closestPoint;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
return result;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
export function setSnappingFeatures(
|
|
376
|
+
results: (SnapResult | undefined)[],
|
|
377
|
+
coordinates: Coordinate[],
|
|
378
|
+
layer: VectorLayer,
|
|
379
|
+
): () => void {
|
|
380
|
+
const features = results
|
|
381
|
+
.map((result) => {
|
|
382
|
+
let feature: Feature | undefined;
|
|
383
|
+
if (result?.type === 'orthogonal' && result.otherVertexIndex > -1) {
|
|
384
|
+
feature = new Feature({
|
|
385
|
+
geometry: new Point(coordinates[result.otherVertexIndex]),
|
|
386
|
+
});
|
|
387
|
+
feature.setStyle(getOrthogonalStyle);
|
|
388
|
+
} else if (result?.type === 'parallel' && result.parallelIndex > -1) {
|
|
389
|
+
const { parallelIndex } = result;
|
|
390
|
+
const other =
|
|
391
|
+
parallelIndex !== coordinates.length - 1 ? parallelIndex + 1 : 0;
|
|
392
|
+
const midPoint = getMidPoint(
|
|
393
|
+
coordinates[parallelIndex],
|
|
394
|
+
coordinates[other],
|
|
395
|
+
);
|
|
396
|
+
feature = new Feature({
|
|
397
|
+
geometry: new Point(midPoint),
|
|
398
|
+
});
|
|
399
|
+
feature.setStyle(getParallelStyle());
|
|
400
|
+
} else if (result?.type === 'vertex') {
|
|
401
|
+
feature = new Feature({
|
|
402
|
+
geometry: new Point(result.snapped),
|
|
403
|
+
olcs_allowPicking: false,
|
|
404
|
+
olcs_primitiveOptions: {
|
|
405
|
+
type: PrimitiveOptionsType.BOX,
|
|
406
|
+
geometryOptions: {
|
|
407
|
+
minimum: [-3, -3, -3],
|
|
408
|
+
maximum: [3, 3, 3],
|
|
409
|
+
},
|
|
410
|
+
depthFailColor: 'rgba(150,147,147,0.47)',
|
|
411
|
+
},
|
|
412
|
+
olcs_modelAutoScale: true,
|
|
413
|
+
});
|
|
414
|
+
feature.setStyle(getVertexStyle());
|
|
415
|
+
} else if (result?.type === 'edge') {
|
|
416
|
+
feature = new Feature({
|
|
417
|
+
geometry: new Point(result.snapped),
|
|
418
|
+
olcs_allowPicking: false,
|
|
419
|
+
olcs_primitiveOptions: {
|
|
420
|
+
type: PrimitiveOptionsType.SPHERE,
|
|
421
|
+
geometryOptions: {
|
|
422
|
+
radius: 3,
|
|
423
|
+
},
|
|
424
|
+
depthFailColor: 'rgba(150,147,147,0.47)',
|
|
425
|
+
},
|
|
426
|
+
olcs_modelAutoScale: true,
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
if (feature) {
|
|
431
|
+
const geometry = feature.getGeometry()!;
|
|
432
|
+
geometry[alreadyTransformedToImage] = true;
|
|
433
|
+
geometry[alreadyTransformedToMercator] = true;
|
|
434
|
+
feature[doNotTransform] = true;
|
|
435
|
+
}
|
|
436
|
+
return feature;
|
|
437
|
+
})
|
|
438
|
+
.filter((f): f is Feature => !!f);
|
|
439
|
+
|
|
440
|
+
if (isRelativeHeightReference(layer.vectorProperties.altitudeMode)) {
|
|
441
|
+
features.forEach((feature) => {
|
|
442
|
+
feature.set('olcs_altitudeMode', 'absolute');
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
layer.addFeatures(features);
|
|
446
|
+
return () => {
|
|
447
|
+
layer.removeFeaturesById(features.map((f) => f.getId()!));
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
export function getSnappedCoordinateForResults(
|
|
452
|
+
results: (SnapResult | undefined)[],
|
|
453
|
+
coordinates: Coordinate[],
|
|
454
|
+
maxDistanceSquared: number,
|
|
455
|
+
): Coordinate | undefined {
|
|
456
|
+
const snapped0 = results[0]?.snapped;
|
|
457
|
+
const snapped1 = results[1]?.snapped;
|
|
458
|
+
|
|
459
|
+
if (
|
|
460
|
+
snapped0 &&
|
|
461
|
+
snapped1 &&
|
|
462
|
+
(results[0]!.type === 'orthogonal' || results[0]!.type === 'parallel') &&
|
|
463
|
+
(results[1]!.type === 'orthogonal' || results[1]!.type === 'parallel')
|
|
464
|
+
) {
|
|
465
|
+
const other0 = coordinates[results[0]!.otherVertexIndex];
|
|
466
|
+
const other1 = coordinates[results[1]!.otherVertexIndex];
|
|
467
|
+
if (other0 && other1) {
|
|
468
|
+
const intersection = cartesian2Intersection(
|
|
469
|
+
[snapped0, other0],
|
|
470
|
+
[snapped1, other1],
|
|
471
|
+
);
|
|
472
|
+
if (
|
|
473
|
+
intersection &&
|
|
474
|
+
cartesian2DDistanceSquared(intersection, snapped0) <= maxDistanceSquared
|
|
475
|
+
) {
|
|
476
|
+
return [intersection[0], intersection[1], snapped0[2]];
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
if (snapped1) {
|
|
482
|
+
return snapped1;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
if (snapped0) {
|
|
486
|
+
return snapped0;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
return undefined;
|
|
490
|
+
}
|
|
@@ -30,16 +30,16 @@ function createAxisPositions(
|
|
|
30
30
|
): Coordinate[] {
|
|
31
31
|
if (axis === AxisAndPlanes.X) {
|
|
32
32
|
return [
|
|
33
|
-
[extent[0], center[1]
|
|
34
|
-
[center[0], center[1]
|
|
35
|
-
[extent[2], center[1]
|
|
33
|
+
[extent[0], center[1]],
|
|
34
|
+
[center[0], center[1]],
|
|
35
|
+
[extent[2], center[1]],
|
|
36
36
|
];
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
return [
|
|
40
|
-
[center[0], extent[1]
|
|
41
|
-
[center[0], center[1]
|
|
42
|
-
[center[0], extent[3]
|
|
40
|
+
[center[0], extent[1]],
|
|
41
|
+
[center[0], center[1]],
|
|
42
|
+
[center[0], extent[3]],
|
|
43
43
|
];
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -122,15 +122,15 @@ function createLineAxisFeatures(
|
|
|
122
122
|
if (axis === AxisAndPlanes.X) {
|
|
123
123
|
color = Color.RED.toCssColorString();
|
|
124
124
|
coordinates = [
|
|
125
|
-
[0, 0
|
|
126
|
-
[1, 0
|
|
125
|
+
[0, 0],
|
|
126
|
+
[1, 0],
|
|
127
127
|
];
|
|
128
128
|
rotation = Math.PI / 2;
|
|
129
129
|
} else {
|
|
130
130
|
color = Color.GREEN.toCssColorString();
|
|
131
131
|
coordinates = [
|
|
132
|
-
[0, 0
|
|
133
|
-
[0, 1
|
|
132
|
+
[0, 0],
|
|
133
|
+
[0, 1],
|
|
134
134
|
];
|
|
135
135
|
}
|
|
136
136
|
color = colorOverride ?? color;
|
|
@@ -176,11 +176,11 @@ function createPlaneFeature(colorOverride?: string): Feature<Polygon> {
|
|
|
176
176
|
const feature = new Feature({
|
|
177
177
|
geometry: new Polygon([
|
|
178
178
|
[
|
|
179
|
-
[0.2, 0.2
|
|
180
|
-
[0.2, 0.4
|
|
181
|
-
[0.4, 0.4
|
|
182
|
-
[0.4, 0.2
|
|
183
|
-
[0.2, 0.2
|
|
179
|
+
[0.2, 0.2],
|
|
180
|
+
[0.2, 0.4],
|
|
181
|
+
[0.4, 0.4],
|
|
182
|
+
[0.4, 0.2],
|
|
183
|
+
[0.2, 0.2],
|
|
184
184
|
],
|
|
185
185
|
]),
|
|
186
186
|
axis: AxisAndPlanes.XY,
|
|
@@ -220,12 +220,15 @@ function createShowShadowFeatures(
|
|
|
220
220
|
}
|
|
221
221
|
features.forEach((f) => {
|
|
222
222
|
f.getGeometry()!.applyTransform(
|
|
223
|
-
(
|
|
223
|
+
(
|
|
224
|
+
input: number[],
|
|
225
|
+
output: number[] | undefined,
|
|
226
|
+
stride = 2,
|
|
227
|
+
): number[] => {
|
|
224
228
|
const inputLength = input.length;
|
|
225
|
-
for (let i = 0; i < inputLength; i +=
|
|
229
|
+
for (let i = 0; i < inputLength; i += stride) {
|
|
226
230
|
output![i] = input[i] * scale + center[0];
|
|
227
231
|
output![i + 1] = input[i + 1] * scale + center[1];
|
|
228
|
-
output![i + 2] = 0;
|
|
229
232
|
}
|
|
230
233
|
return output as number[];
|
|
231
234
|
},
|
|
@@ -249,7 +252,7 @@ export default function create2DHandlers(
|
|
|
249
252
|
scratchLayer: VectorLayer,
|
|
250
253
|
mode: TransformationMode,
|
|
251
254
|
): Handlers {
|
|
252
|
-
let center = [0, 0
|
|
255
|
+
let center = [0, 0];
|
|
253
256
|
let scale = 1;
|
|
254
257
|
let features: Feature[] = [];
|
|
255
258
|
if (
|
|
@@ -283,19 +286,22 @@ export default function create2DHandlers(
|
|
|
283
286
|
});
|
|
284
287
|
|
|
285
288
|
const postRenderListenerKey = map.olMap!.on('postrender', () => {
|
|
286
|
-
if (!(center[0] === 0 && center[1] === 0
|
|
289
|
+
if (!(center[0] === 0 && center[1] === 0)) {
|
|
287
290
|
const res = map.getCurrentResolution(center) * 60;
|
|
288
291
|
const factor = res / scale;
|
|
289
292
|
if (factor !== 1) {
|
|
290
293
|
features.forEach((f) => {
|
|
291
294
|
f.getGeometry()!.applyTransform(
|
|
292
|
-
(
|
|
295
|
+
(
|
|
296
|
+
input: number[],
|
|
297
|
+
output: number[] | undefined,
|
|
298
|
+
stride = 2,
|
|
299
|
+
): number[] => {
|
|
293
300
|
const inputLength = input.length;
|
|
294
|
-
for (let i = 0; i < inputLength; i +=
|
|
301
|
+
for (let i = 0; i < inputLength; i += stride) {
|
|
295
302
|
output![i] = (input[i] - center[0]) * factor + center[0];
|
|
296
303
|
output![i + 1] =
|
|
297
304
|
(input[i + 1] - center[1]) * factor + center[1];
|
|
298
|
-
output![i + 2] = 0;
|
|
299
305
|
}
|
|
300
306
|
return output as number[];
|
|
301
307
|
},
|
|
@@ -343,12 +349,18 @@ export default function create2DHandlers(
|
|
|
343
349
|
const dy = newCenter[1] - center[1];
|
|
344
350
|
features.forEach((f) => {
|
|
345
351
|
f.getGeometry()!.applyTransform(
|
|
346
|
-
(
|
|
352
|
+
(
|
|
353
|
+
input: number[],
|
|
354
|
+
output: number[] | undefined,
|
|
355
|
+
stride = 2,
|
|
356
|
+
): number[] => {
|
|
347
357
|
const inputLength = input.length;
|
|
348
|
-
for (let i = 0; i < inputLength; i +=
|
|
358
|
+
for (let i = 0; i < inputLength; i += stride) {
|
|
349
359
|
output![i] = input[i] + dx;
|
|
350
360
|
output![i + 1] = input[i + 1] + dy;
|
|
351
|
-
|
|
361
|
+
if (stride > 2) {
|
|
362
|
+
output![i + 2] = input[i + 2];
|
|
363
|
+
}
|
|
352
364
|
}
|
|
353
365
|
return output as number[];
|
|
354
366
|
},
|