@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,302 @@
|
|
|
1
|
+
import { LineString, MultiLineString, Polygon } from 'ol/geom.js';
|
|
2
|
+
import { Coordinate } from 'ol/coordinate.js';
|
|
3
|
+
import AbstractInteraction from '../../../interaction/abstractInteraction.js';
|
|
4
|
+
import {
|
|
5
|
+
EventType,
|
|
6
|
+
ModificationKeyType,
|
|
7
|
+
} from '../../../interaction/interactionType.js';
|
|
8
|
+
import type VectorLayer from '../../../layer/vectorLayer.js';
|
|
9
|
+
import { getCartesianBearing } from '../../math.js';
|
|
10
|
+
import {
|
|
11
|
+
getSnappedCoordinateForResults,
|
|
12
|
+
getAngleSnapResult,
|
|
13
|
+
setSnappingFeatures,
|
|
14
|
+
SnapResult,
|
|
15
|
+
getGeometrySnapResult,
|
|
16
|
+
SnapType,
|
|
17
|
+
snapTypes,
|
|
18
|
+
} from '../snappingHelpers.js';
|
|
19
|
+
import { vertexIndexSymbol, vertexSymbol } from '../editorSymbols.js';
|
|
20
|
+
import { Vertex } from '../editorHelpers.js';
|
|
21
|
+
import {
|
|
22
|
+
alreadySnapped,
|
|
23
|
+
SnappingInteractionEvent,
|
|
24
|
+
} from '../editorSessionHelpers.js';
|
|
25
|
+
|
|
26
|
+
function getBearings(coordinates: Coordinate[], isPolygon: boolean): number[] {
|
|
27
|
+
const length = isPolygon ? coordinates.length : coordinates.length - 1;
|
|
28
|
+
if (length > 0) {
|
|
29
|
+
const bearings = new Array<number>(length);
|
|
30
|
+
for (let i = 0; i < length; i++) {
|
|
31
|
+
if (i === coordinates.length - 1) {
|
|
32
|
+
bearings[i] = getCartesianBearing(coordinates[i], coordinates[0]);
|
|
33
|
+
} else {
|
|
34
|
+
bearings[i] = getCartesianBearing(coordinates[i], coordinates[i + 1]);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return bearings;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export default class TranslationSnapping extends AbstractInteraction {
|
|
44
|
+
private _coordinates: Coordinate[] = [];
|
|
45
|
+
|
|
46
|
+
private _bearings: number[] = [];
|
|
47
|
+
|
|
48
|
+
private _scratchLayer: VectorLayer;
|
|
49
|
+
|
|
50
|
+
private _isPolygon = false;
|
|
51
|
+
|
|
52
|
+
private _getCoordinates: () => Coordinate[];
|
|
53
|
+
|
|
54
|
+
private _removeFeatures: (() => void) | undefined;
|
|
55
|
+
|
|
56
|
+
private _lastCoordinate: Coordinate | undefined;
|
|
57
|
+
|
|
58
|
+
private _snappingGeometry: LineString | MultiLineString | undefined;
|
|
59
|
+
|
|
60
|
+
private _snapToVertex = true;
|
|
61
|
+
|
|
62
|
+
private _snapToEdge = true;
|
|
63
|
+
|
|
64
|
+
private _snapOrthogonal = true;
|
|
65
|
+
|
|
66
|
+
private _snapParallel = true;
|
|
67
|
+
|
|
68
|
+
constructor(
|
|
69
|
+
scratchLayer: VectorLayer,
|
|
70
|
+
geometry: LineString | Polygon,
|
|
71
|
+
snapTo: SnapType[] = [...snapTypes],
|
|
72
|
+
) {
|
|
73
|
+
super(
|
|
74
|
+
EventType.DRAGEVENTS,
|
|
75
|
+
ModificationKeyType.NONE | ModificationKeyType.CTRL,
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
this._scratchLayer = scratchLayer;
|
|
79
|
+
|
|
80
|
+
if (geometry instanceof Polygon) {
|
|
81
|
+
this._isPolygon = true;
|
|
82
|
+
this._getCoordinates = (): Coordinate[] => geometry.getCoordinates()[0];
|
|
83
|
+
} else {
|
|
84
|
+
this._isPolygon = false;
|
|
85
|
+
this._getCoordinates = (): Coordinate[] => geometry.getCoordinates();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
this.snapTo = snapTo;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
get snapTo(): SnapType[] {
|
|
92
|
+
const snapTo: SnapType[] = [];
|
|
93
|
+
if (this._snapToVertex) {
|
|
94
|
+
snapTo.push('vertex');
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (this._snapToEdge) {
|
|
98
|
+
snapTo.push('edge');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (this._snapOrthogonal) {
|
|
102
|
+
snapTo.push('orthogonal');
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (this._snapParallel) {
|
|
106
|
+
snapTo.push('parallel');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return snapTo;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
set snapTo(snapTo: SnapType[]) {
|
|
113
|
+
this._snapToVertex = snapTo.includes('vertex');
|
|
114
|
+
this._snapToEdge = snapTo.includes('edge');
|
|
115
|
+
this._snapOrthogonal = snapTo.includes('orthogonal');
|
|
116
|
+
this._snapParallel = snapTo.includes('parallel');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
private _setCoordinates(vertexIndex: number): void {
|
|
120
|
+
this._coordinates = this._getCoordinates();
|
|
121
|
+
this._bearings = getBearings(this._coordinates, this._isPolygon);
|
|
122
|
+
if (this._coordinates.length > 2) {
|
|
123
|
+
if (this._isPolygon) {
|
|
124
|
+
const lineCoordinates = [
|
|
125
|
+
...this._coordinates.slice(0, vertexIndex),
|
|
126
|
+
...this._coordinates.slice(vertexIndex + 1),
|
|
127
|
+
];
|
|
128
|
+
lineCoordinates.push(lineCoordinates[0]);
|
|
129
|
+
this._snappingGeometry = new LineString(lineCoordinates);
|
|
130
|
+
} else {
|
|
131
|
+
this._snappingGeometry = new MultiLineString([
|
|
132
|
+
this._coordinates.slice(0, vertexIndex),
|
|
133
|
+
this._coordinates.slice(vertexIndex + 1),
|
|
134
|
+
]);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
pipe(event: SnappingInteractionEvent): Promise<SnappingInteractionEvent> {
|
|
140
|
+
this._removeFeatures?.();
|
|
141
|
+
if (event[alreadySnapped]) {
|
|
142
|
+
this._lastCoordinate = undefined;
|
|
143
|
+
this._snappingGeometry = undefined;
|
|
144
|
+
return Promise.resolve(event);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (event.type === EventType.DRAGEND && this._lastCoordinate) {
|
|
148
|
+
event.positionOrPixel = this._lastCoordinate;
|
|
149
|
+
this._lastCoordinate = undefined;
|
|
150
|
+
} else if (
|
|
151
|
+
event.key !== ModificationKeyType.CTRL &&
|
|
152
|
+
(event.feature as Vertex | undefined)?.[vertexSymbol]
|
|
153
|
+
) {
|
|
154
|
+
const index = (event.feature as Vertex)[vertexIndexSymbol];
|
|
155
|
+
if (event.type === EventType.DRAGSTART) {
|
|
156
|
+
this._setCoordinates(index);
|
|
157
|
+
}
|
|
158
|
+
const results = new Array<SnapResult | undefined>(2);
|
|
159
|
+
const maxDistanceSquared =
|
|
160
|
+
(event.map.getCurrentResolution(event.positionOrPixel!) * 12) ** 2;
|
|
161
|
+
const coordinate = event.positionOrPixel!;
|
|
162
|
+
|
|
163
|
+
if (this._snappingGeometry) {
|
|
164
|
+
results[0] = getGeometrySnapResult(
|
|
165
|
+
[this._snappingGeometry],
|
|
166
|
+
event.positionOrPixel!,
|
|
167
|
+
maxDistanceSquared,
|
|
168
|
+
this._snapToVertex,
|
|
169
|
+
this._snapToEdge,
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (!results[0] && (this._snapOrthogonal || this._snapParallel)) {
|
|
174
|
+
const bearings = this._bearings.map((b, i) => {
|
|
175
|
+
if (i === index || i === index - 1) {
|
|
176
|
+
return -1;
|
|
177
|
+
}
|
|
178
|
+
if (
|
|
179
|
+
this._isPolygon &&
|
|
180
|
+
index === 0 &&
|
|
181
|
+
i === this._bearings.length - 1
|
|
182
|
+
) {
|
|
183
|
+
return -1;
|
|
184
|
+
}
|
|
185
|
+
return b;
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
if (index > 1) {
|
|
189
|
+
results[0] = getAngleSnapResult(
|
|
190
|
+
coordinate,
|
|
191
|
+
this._coordinates[index - 1],
|
|
192
|
+
this._coordinates[index - 2],
|
|
193
|
+
bearings,
|
|
194
|
+
index - 1,
|
|
195
|
+
maxDistanceSquared,
|
|
196
|
+
this._snapOrthogonal,
|
|
197
|
+
this._snapParallel,
|
|
198
|
+
);
|
|
199
|
+
} else if (this._isPolygon) {
|
|
200
|
+
if (index === 1) {
|
|
201
|
+
results[0] = getAngleSnapResult(
|
|
202
|
+
coordinate,
|
|
203
|
+
this._coordinates[index - 1],
|
|
204
|
+
this._coordinates.at(-1)!,
|
|
205
|
+
bearings,
|
|
206
|
+
index - 1,
|
|
207
|
+
maxDistanceSquared,
|
|
208
|
+
this._snapOrthogonal,
|
|
209
|
+
this._snapParallel,
|
|
210
|
+
);
|
|
211
|
+
} else {
|
|
212
|
+
results[0] = getAngleSnapResult(
|
|
213
|
+
coordinate,
|
|
214
|
+
this._coordinates.at(-1)!,
|
|
215
|
+
this._coordinates.at(-2)!,
|
|
216
|
+
bearings,
|
|
217
|
+
this._coordinates.length - 1,
|
|
218
|
+
maxDistanceSquared,
|
|
219
|
+
this._snapOrthogonal,
|
|
220
|
+
this._snapParallel,
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (this._coordinates.length > 2) {
|
|
226
|
+
const candidate = results[0]?.snapped ?? coordinate;
|
|
227
|
+
if (index < this._coordinates.length - 2) {
|
|
228
|
+
// snap to following segment
|
|
229
|
+
results[1] = getAngleSnapResult(
|
|
230
|
+
candidate,
|
|
231
|
+
this._coordinates[index + 1],
|
|
232
|
+
this._coordinates[index + 2],
|
|
233
|
+
bearings,
|
|
234
|
+
index + 1,
|
|
235
|
+
maxDistanceSquared,
|
|
236
|
+
this._snapOrthogonal,
|
|
237
|
+
this._snapParallel,
|
|
238
|
+
);
|
|
239
|
+
} else if (this._isPolygon) {
|
|
240
|
+
if (index === this._coordinates.length - 1) {
|
|
241
|
+
// snap to first segment
|
|
242
|
+
results[1] = getAngleSnapResult(
|
|
243
|
+
candidate,
|
|
244
|
+
this._coordinates[0],
|
|
245
|
+
this._coordinates[1],
|
|
246
|
+
bearings,
|
|
247
|
+
0,
|
|
248
|
+
maxDistanceSquared,
|
|
249
|
+
this._snapOrthogonal,
|
|
250
|
+
this._snapParallel,
|
|
251
|
+
);
|
|
252
|
+
} else {
|
|
253
|
+
// we need to wrap around: snap to _last segment
|
|
254
|
+
results[1] = getAngleSnapResult(
|
|
255
|
+
candidate,
|
|
256
|
+
this._coordinates.at(-1)!,
|
|
257
|
+
this._coordinates[0],
|
|
258
|
+
bearings,
|
|
259
|
+
this._coordinates.length - 1,
|
|
260
|
+
maxDistanceSquared,
|
|
261
|
+
this._snapOrthogonal,
|
|
262
|
+
this._snapParallel,
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const lastResult = getSnappedCoordinateForResults(
|
|
270
|
+
results,
|
|
271
|
+
this._coordinates,
|
|
272
|
+
maxDistanceSquared,
|
|
273
|
+
);
|
|
274
|
+
|
|
275
|
+
if (lastResult) {
|
|
276
|
+
if (coordinate.length > lastResult.length) {
|
|
277
|
+
lastResult[2] = event.positionOrPixel![2];
|
|
278
|
+
} else if (coordinate.length < lastResult.length) {
|
|
279
|
+
lastResult.pop();
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
event.positionOrPixel = lastResult;
|
|
283
|
+
|
|
284
|
+
this._removeFeatures = setSnappingFeatures(
|
|
285
|
+
results,
|
|
286
|
+
this._coordinates,
|
|
287
|
+
this._scratchLayer,
|
|
288
|
+
);
|
|
289
|
+
this._lastCoordinate = event.positionOrPixel;
|
|
290
|
+
} else {
|
|
291
|
+
this._lastCoordinate = undefined;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
return Promise.resolve(event);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
destroy(): void {
|
|
299
|
+
this._removeFeatures?.();
|
|
300
|
+
super.destroy();
|
|
301
|
+
}
|
|
302
|
+
}
|