@deck.gl-community/editable-layers 9.3.0-beta.2 → 9.3.1
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/edit-modes/coordinate-system.d.ts +94 -0
- package/dist/edit-modes/coordinate-system.d.ts.map +1 -0
- package/dist/edit-modes/coordinate-system.js +105 -0
- package/dist/edit-modes/coordinate-system.js.map +1 -0
- package/dist/edit-modes/draw-circle-by-diameter-mode.d.ts +1 -1
- package/dist/edit-modes/draw-circle-by-diameter-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-circle-from-center-mode.d.ts +1 -1
- package/dist/edit-modes/draw-circle-from-center-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-line-string-mode.d.ts +5 -4
- package/dist/edit-modes/draw-line-string-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-line-string-mode.js +15 -9
- package/dist/edit-modes/draw-line-string-mode.js.map +1 -1
- package/dist/edit-modes/geojson-edit-mode.d.ts +9 -9
- package/dist/edit-modes/geojson-edit-mode.d.ts.map +1 -1
- package/dist/edit-modes/geojson-edit-mode.js +9 -9
- package/dist/edit-modes/geojson-edit-mode.js.map +1 -1
- package/dist/edit-modes/measure-angle-mode.d.ts +6 -1
- package/dist/edit-modes/measure-angle-mode.d.ts.map +1 -1
- package/dist/edit-modes/measure-angle-mode.js.map +1 -1
- package/dist/edit-modes/measure-distance-mode.d.ts +2 -1
- package/dist/edit-modes/measure-distance-mode.d.ts.map +1 -1
- package/dist/edit-modes/measure-distance-mode.js +12 -10
- package/dist/edit-modes/measure-distance-mode.js.map +1 -1
- package/dist/edit-modes/modify-mode.d.ts +2 -1
- package/dist/edit-modes/modify-mode.d.ts.map +1 -1
- package/dist/edit-modes/modify-mode.js +4 -4
- package/dist/edit-modes/modify-mode.js.map +1 -1
- package/dist/edit-modes/translate-mode.d.ts.map +1 -1
- package/dist/edit-modes/translate-mode.js +5 -8
- package/dist/edit-modes/translate-mode.js.map +1 -1
- package/dist/edit-modes/types.d.ts +7 -0
- package/dist/edit-modes/types.d.ts.map +1 -1
- package/dist/edit-modes/utils.d.ts +5 -3
- package/dist/edit-modes/utils.d.ts.map +1 -1
- package/dist/edit-modes/utils.js +41 -43
- package/dist/edit-modes/utils.js.map +1 -1
- package/dist/editable-layers/editable-geojson-layer.d.ts.map +1 -1
- package/dist/editable-layers/editable-geojson-layer.js +5 -0
- package/dist/editable-layers/editable-geojson-layer.js.map +1 -1
- package/dist/index.cjs +224 -152
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/memoize.d.ts +1 -1
- package/dist/utils/memoize.d.ts.map +1 -1
- package/dist/utils/memoize.js +8 -2
- package/dist/utils/memoize.js.map +1 -1
- package/dist/utils/translate-from-center.d.ts +2 -1
- package/dist/utils/translate-from-center.d.ts.map +1 -1
- package/dist/utils/translate-from-center.js +7 -10
- package/dist/utils/translate-from-center.js.map +1 -1
- package/package.json +2 -2
- package/src/edit-modes/coordinate-system.ts +164 -0
- package/src/edit-modes/draw-line-string-mode.ts +25 -12
- package/src/edit-modes/geojson-edit-mode.ts +12 -11
- package/src/edit-modes/measure-angle-mode.ts +1 -1
- package/src/edit-modes/measure-distance-mode.ts +13 -11
- package/src/edit-modes/modify-mode.ts +7 -4
- package/src/edit-modes/translate-mode.ts +5 -8
- package/src/edit-modes/types.ts +10 -0
- package/src/edit-modes/utils.ts +85 -51
- package/src/editable-layers/editable-geojson-layer.ts +5 -0
- package/src/index.ts +9 -0
- package/src/utils/memoize.ts +10 -4
- package/src/utils/translate-from-center.ts +13 -15
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,9 @@ export { getPickedEditHandle, getEditHandlesForGeometry } from "./edit-modes/uti
|
|
|
15
15
|
export type { EditMode } from "./edit-modes/edit-mode.js";
|
|
16
16
|
export type { GeoJsonEditModeType } from "./edit-modes/geojson-edit-mode.js";
|
|
17
17
|
export type { GeoJsonEditModeConstructor } from "./edit-modes/geojson-edit-mode.js";
|
|
18
|
+
export type { EditModeCoordinateSystem } from "./edit-modes/coordinate-system.js";
|
|
19
|
+
export { GeoCoordinateSystem, CartesianCoordinateSystem } from "./edit-modes/coordinate-system.js";
|
|
20
|
+
export { geoCoordinateSystem, cartesianCoordinateSystem, getEditModeCoordinateSystem, fromDeckCoordinateSystem } from "./edit-modes/coordinate-system.js";
|
|
18
21
|
export type { EditableGeoJsonLayerProps } from "./editable-layers/editable-geojson-layer.js";
|
|
19
22
|
export type { SelectionLayerProps } from "./editable-layers/selection-layer.js";
|
|
20
23
|
export { GeoJsonEditMode } from "./edit-modes/geojson-edit-mode.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,WAAW,EAAC,yBAAsB;AAG1C,YAAY,EAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAC,yBAAsB;AAG1D,OAAO,EAAC,oBAAoB,EAAC,oDAAiD;AAC9E,OAAO,EAAC,sBAAsB,EAAC,uDAAoD;AACnF,OAAO,EAAC,cAAc,EAAC,6CAA0C;AACjE,OAAO,EAAC,uBAAuB,EAAC,wDAAqD;AAGrF,OAAO,EAAC,kBAAkB,EAAC,2CAAwC;AACnE,YAAY,EACV,uBAAuB,EACvB,4BAA4B,EAC5B,6BAA6B,EAC9B,2CAAwC;AAEzC,OAAO,EAAC,mBAAmB,EAAC,2CAAwC;AACpE,YAAY,EAAC,wBAAwB,EAAE,gBAAgB,EAAC,2CAAwC;AAGhG,OAAO,EAAC,wBAAwB,EAAC,wDAAqD;AAItF,OAAO,KAAK,KAAK,yBAAsB;AAEvC,OAAO,EAAC,KAAK,EAAC,CAAC;AAEf,OAAO,EAAC,mBAAmB,EAAE,yBAAyB,EAAC,8BAA2B;AAElF,YAAY,EAA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terplotLayer } from "./editable-layers/junction-scatterplot
|
|
|
17
17
|
import * as utils from "./utils/utils.js";
|
|
18
18
|
export { utils };
|
|
19
19
|
export { getPickedEditHandle, getEditHandlesForGeometry } from "./edit-modes/utils.js";
|
|
20
|
+
export { GeoCoordinateSystem, CartesianCoordinateSystem } from "./edit-modes/coordinate-system.js";
|
|
21
|
+
export { geoCoordinateSystem, cartesianCoordinateSystem, getEditModeCoordinateSystem, fromDeckCoordinateSystem } from "./edit-modes/coordinate-system.js";
|
|
20
22
|
export { GeoJsonEditMode } from "./edit-modes/geojson-edit-mode.js";
|
|
21
23
|
// Alter modes
|
|
22
24
|
export { DeleteMode } from "./edit-modes/delete-mode.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,+BAA+B;AAC/B,oCAAoC;AAEpC,QAAQ;AACR,OAAO,EAAC,WAAW,EAAC,yBAAsB;AAK1C,SAAS;AACT,OAAO,EAAC,oBAAoB,EAAC,oDAAiD;AAC9E,OAAO,EAAC,sBAAsB,EAAC,uDAAoD;AACnF,OAAO,EAAC,cAAc,EAAC,6CAA0C;AACjE,OAAO,EAAC,uBAAuB,EAAC,wDAAqD;AAErF,UAAU;AACV,OAAO,EAAC,kBAAkB,EAAC,2CAAwC;AAOnE,OAAO,EAAC,mBAAmB,EAAC,2CAAwC;AAGpE,2CAA2C;AAC3C,OAAO,EAAC,wBAAwB,EAAC,wDAAqD;AAEtF,QAAQ;AAER,OAAO,KAAK,KAAK,yBAAsB;AAEvC,OAAO,EAAC,KAAK,EAAC,CAAC;AAEf,OAAO,EAAC,mBAAmB,EAAE,yBAAyB,EAAC,8BAA2B;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,+BAA+B;AAC/B,oCAAoC;AAEpC,QAAQ;A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EAAC,kBAAkB,EAAC,8CAA2C;AACtE,OAAO,EAAC,eAAe,EAAC,0CAAuC;AAC/D,OAAO,EAAC,iBAAiB,EAAC,4CAAyC;AACnE,OAAO,EAAC,cAAc,EAAC,yCAAsC;AAC7D,OAAO,EAAC,2BAA2B,EAAC,wDAAqD;AACzF,OAAO,EAAC,wBAAwB,EAAC,qDAAkD;AACnF,OAAO,EAAC,wBAAwB,EAAC,qDAAkD;AACnF,OAAO,EAAC,wBAAwB,EAAC,qDAAkD;AACnF,OAAO,EAAC,4BAA4B,EAAC,0DAAuD;AAC5F,OAAO,EAAC,+BAA+B,EAAC,6DAA0D;AAClG,OAAO,EAAC,iCAAiC,EAAC,+DAA4D;AACtG,OAAO,EAAC,uBAAuB,EAAC,mDAAgD;AAChF,OAAO,EAAC,yBAAyB,EAAC,sDAAmD;AACrF,OAAO,EAAC,0BAA0B,EAAC,qDAAkD;AAErF,cAAc;AACd,OAAO,EAAC,QAAQ,EAAC,kCAA+B;AAChD,OAAO,EAAC,mBAAmB,EAAC,8CAA2C;AACvE,OAAO,EAAC,eAAe,EAAC,0CAAuC;AAC/D,OAAO,EAAC,gBAAgB,EAAC,2CAAwC;AACjE,OAAO,EAAC,aAAa,EAAC,uCAAoC;AAC1D,OAAO,EAAC,aAAa,EAAC,uCAAoC;AAmC1D,eAAe;AACf,OAAO,EAAC,OAAO,IAAI,QAAQ,EAAC,2BAAwB"}
|
package/dist/utils/memoize.d.ts
CHANGED
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* https://en.wikipedia.org/wiki/Memoization
|
|
4
4
|
* @param {function} compute - the function to be memoized
|
|
5
5
|
*/
|
|
6
|
-
export declare function memoize(compute:
|
|
6
|
+
export declare function memoize<T, R>(compute: (args: T) => R): (args: T) => R;
|
|
7
7
|
//# sourceMappingURL=memoize.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memoize.d.ts","sourceRoot":"","sources":["../../src/utils/memoize.ts"],"names":[],"mappings":"AA2BA;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"memoize.d.ts","sourceRoot":"","sources":["../../src/utils/memoize.ts"],"names":[],"mappings":"AA2BA;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAoBrE"}
|
package/dist/utils/memoize.js
CHANGED
|
@@ -28,9 +28,15 @@ function isEqual(a, b) {
|
|
|
28
28
|
* @param {function} compute - the function to be memoized
|
|
29
29
|
*/
|
|
30
30
|
export function memoize(compute) {
|
|
31
|
-
let cachedArgs =
|
|
32
|
-
let cachedResult;
|
|
31
|
+
let cachedArgs = null;
|
|
32
|
+
let cachedResult = null;
|
|
33
33
|
return (args) => {
|
|
34
|
+
// check for null args on first run
|
|
35
|
+
if (!cachedArgs) {
|
|
36
|
+
cachedResult = compute(args);
|
|
37
|
+
cachedArgs = args;
|
|
38
|
+
return cachedResult;
|
|
39
|
+
}
|
|
34
40
|
for (const key in args) {
|
|
35
41
|
if (!isEqual(args[key], cachedArgs[key])) {
|
|
36
42
|
cachedResult = compute(args);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memoize.js","sourceRoot":"","sources":["../../src/utils/memoize.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,+BAA+B;AAC/B,oCAAoC;AAEpC,0BAA0B;AAC1B,SAAS,OAAO,CAAC,CAAM,EAAE,CAAM;IAC7B,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QACrB,qDAAqD;QACrD,yDAAyD;QACzD,MAAM,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC;QACrB,IAAI,CAAC,CAAC,I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O,OAAuB;IACnD,IAAI,UAAU,GAAa,IAAI,CAAC;IAChC,IAAI,YAAY,GAAa,IAAI,CAAC;IAElC,OAAO,CAAC,IAAO,EAAE,EAAE;QACjB,oCAAoC;QACpC,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;YAC7B,UAAU,GAAG,IAAI,CAAC;YAClB,OAAO,YAAY,CAAC;QACtB,CAAC;QACD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;gBACzC,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;gBAC7B,UAAU,GAAG,IAAI,CAAC;gBAClB,MAAM;YACR,CAAC;QACH,CAAC;QACD,OAAO,YAAY,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { EditModeCoordinateSystem } from "../edit-modes/coordinate-system.js";
|
|
1
2
|
import type { SimpleFeature } from "./geojson-types.js";
|
|
2
|
-
export declare function translateFromCenter(feature: SimpleFeature, distance: number, direction: number): SimpleFeature;
|
|
3
|
+
export declare function translateFromCenter(feature: SimpleFeature, distance: number, direction: number, coordinateSystem?: EditModeCoordinateSystem): SimpleFeature;
|
|
3
4
|
//# sourceMappingURL=translate-from-center.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translate-from-center.d.ts","sourceRoot":"","sources":["../../src/utils/translate-from-center.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"translate-from-center.d.ts","sourceRoot":"","sources":["../../src/utils/translate-from-center.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAC,wBAAwB,EAAC,2CAAwC;AAC9E,OAAO,KAAK,EAAC,aAAa,EAAC,2BAAwB;AAInD,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,gBAAgB,GAAE,wBAA8C,iBAejE"}
|
|
@@ -2,20 +2,17 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
import turfCenter from '@turf/center';
|
|
5
|
-
import turfRhumbBearing from '@turf/rhumb-bearing';
|
|
6
|
-
import turfRhumbDistance from '@turf/rhumb-distance';
|
|
7
|
-
import turfRhumbDestination from '@turf/rhumb-destination';
|
|
8
5
|
import { mapCoords } from "../edit-modes/utils.js";
|
|
6
|
+
import { geoCoordinateSystem } from "../edit-modes/coordinate-system.js";
|
|
9
7
|
// This function takes feature's center, moves it,
|
|
10
8
|
// and builds new feature around it keeping the proportions
|
|
11
|
-
export function translateFromCenter(feature, distance, direction) {
|
|
12
|
-
const
|
|
13
|
-
const
|
|
9
|
+
export function translateFromCenter(feature, distance, direction, coordinateSystem = geoCoordinateSystem) {
|
|
10
|
+
const initialCenter = turfCenter(feature).geometry.coordinates;
|
|
11
|
+
const movedCenter = coordinateSystem.destination(initialCenter, distance, direction);
|
|
14
12
|
const movedCoordinates = mapCoords(feature.geometry.coordinates, (coordinate) => {
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
return movedPosition;
|
|
13
|
+
const dist = coordinateSystem.distance(initialCenter, coordinate);
|
|
14
|
+
const dir = coordinateSystem.bearing(initialCenter, coordinate);
|
|
15
|
+
return coordinateSystem.destination(movedCenter, dist, dir);
|
|
19
16
|
});
|
|
20
17
|
feature.geometry.coordinates = movedCoordinates;
|
|
21
18
|
return feature;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translate-from-center.js","sourceRoot":"","sources":["../../src/utils/translate-from-center.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,
|
|
1
|
+
{"version":3,"file":"translate-from-center.js","sourceRoot":"","sources":["../../src/utils/translate-from-center.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,EAAC,SAAS,EAAC,+BAA4B;AAC9C,OAAO,EAAC,mBAAmB,EAAC,2CAAwC;AAIpE,kDAAkD;AAClD,2DAA2D;AAC3D,MAAM,UAAU,mBAAmB,CACjC,OAAsB,EACtB,QAAgB,EAChB,SAAiB,EACjB,mBAA6C,mBAAmB;IAEhE,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC;IAE/D,MAAM,WAAW,GAAG,gBAAgB,CAAC,WAAW,CAAC,aAAa,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;IAErF,MAAM,gBAAgB,GAAG,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,UAAU,EAAE,EAAE;QAC9E,MAAM,IAAI,GAAG,gBAAgB,CAAC,QAAQ,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;QAClE,MAAM,GAAG,GAAG,gBAAgB,CAAC,OAAO,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;QAChE,OAAO,gBAAgB,CAAC,WAAW,CAAC,WAAW,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,QAAQ,CAAC,WAAW,GAAG,gBAAgB,CAAC;IAEhD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@deck.gl-community/editable-layers",
|
|
3
3
|
"description": "A suite of 3D-enabled data editing overlays, suitable for deck.gl",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "9.3.
|
|
5
|
+
"version": "9.3.1",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"@luma.gl/engine": "~9.3.2",
|
|
89
89
|
"h3-js": "^4.2.1"
|
|
90
90
|
},
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "9bc327e5ca881aa2e7098412d117ca6a93ae9849"
|
|
92
92
|
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import turfBearing from '@turf/bearing';
|
|
6
|
+
import turfDistance from '@turf/distance';
|
|
7
|
+
import turfDestination from '@turf/destination';
|
|
8
|
+
import turfMidpoint from '@turf/midpoint';
|
|
9
|
+
import {point} from '@turf/helpers';
|
|
10
|
+
import {COORDINATE_SYSTEM} from '@deck.gl/core';
|
|
11
|
+
import type {CoordinateSystem} from '@deck.gl/core';
|
|
12
|
+
|
|
13
|
+
import {Position} from '../utils/geojson-types';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Abstraction layer for coordinate system math used by edit modes.
|
|
17
|
+
*
|
|
18
|
+
* Allows edit modes to be used with geographic (WGS84) or Cartesian (screen/local)
|
|
19
|
+
* coordinate systems without changing the mode logic.
|
|
20
|
+
*
|
|
21
|
+
* Naming note: this interface is intentionally distinct from deck.gl's own
|
|
22
|
+
* `CoordinateSystem` type (a numeric enum from `@deck.gl/core`), which describes how
|
|
23
|
+
* positions are projected for *rendering*. `EditModeCoordinateSystem` describes how edit
|
|
24
|
+
* modes should perform *geometric math* on those positions.
|
|
25
|
+
*
|
|
26
|
+
* - GeoCoordinateSystem: wraps turf.js — uses geodesic math, assumes WGS84 lon/lat.
|
|
27
|
+
* - CartesianCoordinateSystem: uses Euclidean math — suitable for OrthographicView or pixel space.
|
|
28
|
+
*/
|
|
29
|
+
export interface EditModeCoordinateSystem {
|
|
30
|
+
/**
|
|
31
|
+
* Returns the distance between two positions.
|
|
32
|
+
* For GeoCoordinateSystem the unit is kilometers; for CartesianCoordinateSystem it is the
|
|
33
|
+
* native coordinate unit (consistent with destination()).
|
|
34
|
+
*/
|
|
35
|
+
distance(a: Position, b: Position): number;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Returns the bearing from position `a` to position `b`.
|
|
39
|
+
* Uses compass convention: 0° = north, clockwise, range [-180, 180].
|
|
40
|
+
*/
|
|
41
|
+
bearing(a: Position, b: Position): number;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Returns a new position reached by traveling `distance` units in the given `bearing`
|
|
45
|
+
* direction from `origin`.
|
|
46
|
+
*/
|
|
47
|
+
destination(origin: Position, distance: number, bearing: number): Position;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Returns the midpoint between two positions.
|
|
51
|
+
*/
|
|
52
|
+
midpoint(a: Position, b: Position): Position;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Geographic coordinate system using turf.js (WGS84 lon/lat, geodesic math).
|
|
57
|
+
* This is the default and preserves the existing behavior of all edit modes.
|
|
58
|
+
*/
|
|
59
|
+
export class GeoCoordinateSystem implements EditModeCoordinateSystem {
|
|
60
|
+
distance(a: Position, b: Position): number {
|
|
61
|
+
return turfDistance(point(a), point(b));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
bearing(a: Position, b: Position): number {
|
|
65
|
+
return turfBearing(point(a), point(b));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
destination(origin: Position, distance: number, bearing: number): Position {
|
|
69
|
+
return turfDestination(point(origin), distance, bearing).geometry.coordinates;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
midpoint(a: Position, b: Position): Position {
|
|
73
|
+
return turfMidpoint(point(a), point(b)).geometry.coordinates;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Cartesian (Euclidean) coordinate system for non-geographic use cases such as
|
|
79
|
+
* OrthographicView or pixel/local coordinates.
|
|
80
|
+
*
|
|
81
|
+
* Bearing follows the same compass convention as the geographic system so that
|
|
82
|
+
* destination() and bearing() are consistent with each other:
|
|
83
|
+
* 0° = +Y axis, 90° = +X axis (clockwise from north/up).
|
|
84
|
+
*/
|
|
85
|
+
export class CartesianCoordinateSystem implements EditModeCoordinateSystem {
|
|
86
|
+
distance(a: Position, b: Position): number {
|
|
87
|
+
const dx = b[0] - a[0];
|
|
88
|
+
const dy = b[1] - a[1];
|
|
89
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
bearing(a: Position, b: Position): number {
|
|
93
|
+
const dx = b[0] - a[0];
|
|
94
|
+
const dy = b[1] - a[1];
|
|
95
|
+
// atan2(dx, dy): angle from the +Y axis, clockwise — matches compass bearing convention
|
|
96
|
+
const angle = Math.atan2(dx, dy) * (180 / Math.PI);
|
|
97
|
+
// Normalize to [-180, 180] to match turf's bearing range
|
|
98
|
+
return angle > 180 ? angle - 360 : angle <= -180 ? angle + 360 : angle;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
destination(origin: Position, distance: number, bearing: number): Position {
|
|
102
|
+
const bearingRad = bearing * (Math.PI / 180);
|
|
103
|
+
return [
|
|
104
|
+
origin[0] + distance * Math.sin(bearingRad),
|
|
105
|
+
origin[1] + distance * Math.cos(bearingRad)
|
|
106
|
+
] as Position;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
midpoint(a: Position, b: Position): Position {
|
|
110
|
+
return [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2] as Position;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Default geographic coordinate system instance.
|
|
116
|
+
* Used by edit modes when no coordinate system is provided.
|
|
117
|
+
*/
|
|
118
|
+
export const geoCoordinateSystem = new GeoCoordinateSystem();
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Default Cartesian coordinate system instance.
|
|
122
|
+
* Use this with OrthographicView or any non-geographic coordinate system.
|
|
123
|
+
*/
|
|
124
|
+
export const cartesianCoordinateSystem = new CartesianCoordinateSystem();
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Returns the provided coordinate system, or `geoCoordinateSystem` as the default.
|
|
128
|
+
* Use this helper inside edit modes to avoid null checks scattered throughout the code.
|
|
129
|
+
*/
|
|
130
|
+
export function getEditModeCoordinateSystem(
|
|
131
|
+
coordinateSystem?: EditModeCoordinateSystem
|
|
132
|
+
): EditModeCoordinateSystem {
|
|
133
|
+
return coordinateSystem ?? geoCoordinateSystem;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Maps a deck.gl `COORDINATE_SYSTEM` constant to the appropriate `EditModeCoordinateSystem`
|
|
138
|
+
* implementation for edit-mode geometric math.
|
|
139
|
+
*
|
|
140
|
+
* This allows the `EditableGeoJsonLayer` to automatically derive the correct math from
|
|
141
|
+
* its own `coordinateSystem` prop without requiring consumers to configure it separately.
|
|
142
|
+
*
|
|
143
|
+
* | deck.gl constant | Math used |
|
|
144
|
+
* |------------------------------------|-----------------------|
|
|
145
|
+
* | `COORDINATE_SYSTEM.LNGLAT` | GeoCoordinateSystem |
|
|
146
|
+
* | `COORDINATE_SYSTEM.DEFAULT` | GeoCoordinateSystem |
|
|
147
|
+
* | `COORDINATE_SYSTEM.CARTESIAN` | CartesianCoordinateSystem |
|
|
148
|
+
* | `COORDINATE_SYSTEM.METER_OFFSETS` | CartesianCoordinateSystem |
|
|
149
|
+
* | `COORDINATE_SYSTEM.LNGLAT_OFFSETS` | GeoCoordinateSystem |
|
|
150
|
+
*/
|
|
151
|
+
export function fromDeckCoordinateSystem(
|
|
152
|
+
deckCoordSystem: CoordinateSystem | undefined
|
|
153
|
+
): EditModeCoordinateSystem {
|
|
154
|
+
switch (deckCoordSystem) {
|
|
155
|
+
case COORDINATE_SYSTEM.CARTESIAN:
|
|
156
|
+
case COORDINATE_SYSTEM.METER_OFFSETS:
|
|
157
|
+
return cartesianCoordinateSystem;
|
|
158
|
+
case COORDINATE_SYSTEM.LNGLAT:
|
|
159
|
+
case COORDINATE_SYSTEM.LNGLAT_OFFSETS:
|
|
160
|
+
case COORDINATE_SYSTEM.DEFAULT:
|
|
161
|
+
default:
|
|
162
|
+
return geoCoordinateSystem;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import distance from '@turf/distance';
|
|
6
5
|
import {memoize} from '../utils/memoize';
|
|
7
6
|
import {
|
|
8
7
|
LineString,
|
|
@@ -21,6 +20,11 @@ import {
|
|
|
21
20
|
} from './types';
|
|
22
21
|
import {getPickedEditHandle} from './utils';
|
|
23
22
|
import {GeoJsonEditMode} from './geojson-edit-mode';
|
|
23
|
+
import {
|
|
24
|
+
EditModeCoordinateSystem,
|
|
25
|
+
GeoCoordinateSystem,
|
|
26
|
+
getEditModeCoordinateSystem
|
|
27
|
+
} from './coordinate-system';
|
|
24
28
|
|
|
25
29
|
export class DrawLineStringMode extends GeoJsonEditMode {
|
|
26
30
|
// declaration of variables for the calculation of the distance of linestring
|
|
@@ -37,11 +41,11 @@ export class DrawLineStringMode extends GeoJsonEditMode {
|
|
|
37
41
|
this.addClickSequence(event);
|
|
38
42
|
positionAdded = true;
|
|
39
43
|
}
|
|
40
|
-
const clickSequence = this.getClickSequence();
|
|
44
|
+
const clickSequence: Position[] = this.getClickSequence();
|
|
41
45
|
|
|
42
46
|
// check if the pointer is on editable state calculate the distance of new point
|
|
43
47
|
if (!clickedEditHandle) {
|
|
44
|
-
this.calculateInfoDraw(clickSequence);
|
|
48
|
+
this.calculateInfoDraw(clickSequence, props?.coordinateSystem);
|
|
45
49
|
}
|
|
46
50
|
|
|
47
51
|
if (
|
|
@@ -67,7 +71,7 @@ export class DrawLineStringMode extends GeoJsonEditMode {
|
|
|
67
71
|
}
|
|
68
72
|
}
|
|
69
73
|
|
|
70
|
-
handleDoubleClick(
|
|
74
|
+
handleDoubleClick(_event: DoubleClickEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
71
75
|
this.finishDrawing(props);
|
|
72
76
|
}
|
|
73
77
|
|
|
@@ -112,7 +116,7 @@ export class DrawLineStringMode extends GeoJsonEditMode {
|
|
|
112
116
|
features: []
|
|
113
117
|
};
|
|
114
118
|
|
|
115
|
-
let tentativeFeature;
|
|
119
|
+
let tentativeFeature: GuideFeature;
|
|
116
120
|
if (clickSequence.length > 0) {
|
|
117
121
|
tentativeFeature = {
|
|
118
122
|
type: 'Feature',
|
|
@@ -148,7 +152,7 @@ export class DrawLineStringMode extends GeoJsonEditMode {
|
|
|
148
152
|
return guides;
|
|
149
153
|
}
|
|
150
154
|
|
|
151
|
-
handlePointerMove(
|
|
155
|
+
handlePointerMove(_event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {
|
|
152
156
|
props.onUpdateCursor('cell');
|
|
153
157
|
}
|
|
154
158
|
|
|
@@ -160,19 +164,24 @@ export class DrawLineStringMode extends GeoJsonEditMode {
|
|
|
160
164
|
getTooltips(props: ModeProps<FeatureCollection>): Tooltip[] {
|
|
161
165
|
return this._getTooltips({
|
|
162
166
|
modeConfig: props.modeConfig,
|
|
163
|
-
dist: this.dist
|
|
167
|
+
dist: this.dist,
|
|
168
|
+
coordinateSystem: props?.coordinateSystem
|
|
164
169
|
});
|
|
165
170
|
}
|
|
166
171
|
|
|
167
172
|
// utility function
|
|
168
|
-
calculateInfoDraw(
|
|
173
|
+
calculateInfoDraw(
|
|
174
|
+
clickSequence: Position[],
|
|
175
|
+
coordinateSystem: EditModeCoordinateSystem = new GeoCoordinateSystem()
|
|
176
|
+
) {
|
|
169
177
|
// check if the selected points are at least 2
|
|
170
178
|
if (clickSequence.length > 1) {
|
|
171
179
|
// setting the last point
|
|
172
180
|
this.position = clickSequence[clickSequence.length - 1];
|
|
173
181
|
// calculate the new distance by adding the
|
|
174
182
|
// distance of the new drawn linestring
|
|
175
|
-
|
|
183
|
+
const coordSys = getEditModeCoordinateSystem(coordinateSystem);
|
|
184
|
+
this.dist += coordSys.distance(
|
|
176
185
|
clickSequence[clickSequence.length - 2],
|
|
177
186
|
clickSequence[clickSequence.length - 1]
|
|
178
187
|
);
|
|
@@ -184,16 +193,20 @@ export class DrawLineStringMode extends GeoJsonEditMode {
|
|
|
184
193
|
* @param modeConfig
|
|
185
194
|
* @param dist
|
|
186
195
|
*/
|
|
187
|
-
_getTooltips = memoize(({modeConfig, dist}) => {
|
|
196
|
+
_getTooltips = memoize(({modeConfig, dist, coordinateSystem}) => {
|
|
188
197
|
let tooltips: Tooltip[] = [];
|
|
189
198
|
const {formatTooltip} = modeConfig || {};
|
|
190
|
-
let text;
|
|
199
|
+
let text: string;
|
|
191
200
|
if (dist) {
|
|
192
201
|
if (formatTooltip) {
|
|
193
202
|
text = formatTooltip(dist);
|
|
194
203
|
} else {
|
|
204
|
+
const coordSys = coordinateSystem
|
|
205
|
+
? getEditModeCoordinateSystem(coordinateSystem)
|
|
206
|
+
: new GeoCoordinateSystem();
|
|
207
|
+
const labelUnits = coordSys instanceof GeoCoordinateSystem ? 'kilometers' : 'pixels';
|
|
195
208
|
// By default, round to 2 decimal places and append units
|
|
196
|
-
text = `Distance: ${parseFloat(dist).toFixed(2)}
|
|
209
|
+
text = `Distance: ${parseFloat(dist).toFixed(2)} ${labelUnits}`;
|
|
197
210
|
}
|
|
198
211
|
|
|
199
212
|
tooltips = [
|
|
@@ -28,7 +28,8 @@ import {
|
|
|
28
28
|
SimpleGeometry,
|
|
29
29
|
Position,
|
|
30
30
|
SimpleFeatureCollection,
|
|
31
|
-
SimpleFeature
|
|
31
|
+
SimpleFeature,
|
|
32
|
+
MultiPolygon
|
|
32
33
|
} from '../utils/geojson-types';
|
|
33
34
|
import {getPickedEditHandles, getNonGuidePicks} from './utils';
|
|
34
35
|
import {EditMode} from './edit-mode';
|
|
@@ -52,11 +53,11 @@ export interface GeoJsonEditModeConstructor {
|
|
|
52
53
|
export class GeoJsonEditMode implements EditMode<FeatureCollection, GuideFeatureCollection> {
|
|
53
54
|
_clickSequence: Position[] = [];
|
|
54
55
|
|
|
55
|
-
getGuides(
|
|
56
|
+
getGuides(_props: ModeProps<FeatureCollection>): GuideFeatureCollection {
|
|
56
57
|
return DEFAULT_GUIDES;
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
getTooltips(
|
|
60
|
+
getTooltips(_props: ModeProps<FeatureCollection>): Tooltip[] {
|
|
60
61
|
return DEFAULT_TOOLTIPS;
|
|
61
62
|
}
|
|
62
63
|
|
|
@@ -219,7 +220,7 @@ export class GeoJsonEditMode implements EditMode<FeatureCollection, GuideFeature
|
|
|
219
220
|
geometry: featureOrGeometryAsAny
|
|
220
221
|
};
|
|
221
222
|
|
|
222
|
-
let updatedGeometry;
|
|
223
|
+
let updatedGeometry: Feature<Polygon | MultiPolygon> | null;
|
|
223
224
|
if (modeConfig.booleanOperation === 'union') {
|
|
224
225
|
updatedGeometry = turfUnion(featureCollection([selectedFeature, feature]));
|
|
225
226
|
} else if (modeConfig.booleanOperation === 'difference') {
|
|
@@ -257,14 +258,14 @@ export class GeoJsonEditMode implements EditMode<FeatureCollection, GuideFeature
|
|
|
257
258
|
return this.getAddFeatureAction(featureOrGeometry, props.data, featureProperties);
|
|
258
259
|
}
|
|
259
260
|
|
|
260
|
-
createTentativeFeature(
|
|
261
|
+
createTentativeFeature(_props: ModeProps<FeatureCollection>): TentativeFeature | null {
|
|
261
262
|
return null;
|
|
262
263
|
}
|
|
263
264
|
|
|
264
|
-
handleClick(
|
|
265
|
-
handleDoubleClick(
|
|
265
|
+
handleClick(_event: ClickEvent, _props: ModeProps<FeatureCollection>): void {}
|
|
266
|
+
handleDoubleClick(_event: ClickEvent, _props: ModeProps<FeatureCollection>): void {}
|
|
266
267
|
|
|
267
|
-
handlePointerMove(
|
|
268
|
+
handlePointerMove(_event: PointerMoveEvent, props: ModeProps<FeatureCollection>): void {
|
|
268
269
|
const tentativeFeature = this.createTentativeFeature(props);
|
|
269
270
|
if (tentativeFeature) {
|
|
270
271
|
props.onEdit({
|
|
@@ -276,9 +277,9 @@ export class GeoJsonEditMode implements EditMode<FeatureCollection, GuideFeature
|
|
|
276
277
|
});
|
|
277
278
|
}
|
|
278
279
|
}
|
|
279
|
-
handleStartDragging(
|
|
280
|
-
handleStopDragging(
|
|
281
|
-
handleDragging(
|
|
280
|
+
handleStartDragging(_event: StartDraggingEvent, _props: ModeProps<FeatureCollection>): void {}
|
|
281
|
+
handleStopDragging(_event: StopDraggingEvent, _props: ModeProps<FeatureCollection>): void {}
|
|
282
|
+
handleDragging(_event: DraggingEvent, _props: ModeProps<FeatureCollection>): void {}
|
|
282
283
|
|
|
283
284
|
handleKeyUp(event: KeyboardEvent, props: ModeProps<FeatureCollection>): void {
|
|
284
285
|
if (event.key === 'Escape') {
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import turfDistance from '@turf/distance';
|
|
6
|
-
import turfMidpoint from '@turf/midpoint';
|
|
7
5
|
import {FeatureCollection} from '../utils/geojson-types';
|
|
8
6
|
import {
|
|
9
7
|
ClickEvent,
|
|
@@ -15,15 +13,16 @@ import {
|
|
|
15
13
|
} from './types';
|
|
16
14
|
import {getPickedEditHandle} from './utils';
|
|
17
15
|
import {GeoJsonEditMode} from './geojson-edit-mode';
|
|
16
|
+
import {getEditModeCoordinateSystem} from './coordinate-system';
|
|
18
17
|
|
|
19
18
|
export class MeasureDistanceMode extends GeoJsonEditMode {
|
|
20
19
|
_isMeasuringSessionFinished = false;
|
|
21
20
|
_currentTooltips: Tooltip[] = [];
|
|
22
21
|
_currentDistance = 0;
|
|
23
22
|
|
|
24
|
-
_calculateDistanceForTooltip = ({positionA, positionB, modeConfig}) => {
|
|
25
|
-
const {
|
|
26
|
-
const distance =
|
|
23
|
+
_calculateDistanceForTooltip = ({positionA, positionB, modeConfig, coordinateSystem}) => {
|
|
24
|
+
const {measurementCallback} = modeConfig || {};
|
|
25
|
+
const distance = getEditModeCoordinateSystem(coordinateSystem).distance(positionA, positionB);
|
|
27
26
|
|
|
28
27
|
if (measurementCallback) {
|
|
29
28
|
measurementCallback(distance);
|
|
@@ -50,6 +49,7 @@ export class MeasureDistanceMode extends GeoJsonEditMode {
|
|
|
50
49
|
handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>) {
|
|
51
50
|
const {modeConfig, data, onEdit} = props;
|
|
52
51
|
const {centerTooltipsOnLine = false} = modeConfig || {};
|
|
52
|
+
const coordSys = getEditModeCoordinateSystem(props.coordinateSystem);
|
|
53
53
|
|
|
54
54
|
// restart measuring session
|
|
55
55
|
if (this._isMeasuringSessionFinished) {
|
|
@@ -83,14 +83,15 @@ export class MeasureDistanceMode extends GeoJsonEditMode {
|
|
|
83
83
|
this._currentDistance += this._calculateDistanceForTooltip({
|
|
84
84
|
positionA: clickSequence[clickSequence.length - 2],
|
|
85
85
|
positionB: clickSequence[clickSequence.length - 1],
|
|
86
|
-
modeConfig
|
|
86
|
+
modeConfig,
|
|
87
|
+
coordinateSystem: coordSys
|
|
87
88
|
});
|
|
88
89
|
|
|
89
90
|
const tooltipPosition = centerTooltipsOnLine
|
|
90
|
-
?
|
|
91
|
+
? coordSys.midpoint(
|
|
91
92
|
clickSequence[clickSequence.length - 2],
|
|
92
93
|
clickSequence[clickSequence.length - 1]
|
|
93
|
-
)
|
|
94
|
+
)
|
|
94
95
|
: event.mapCoords;
|
|
95
96
|
|
|
96
97
|
this._currentTooltips.push({
|
|
@@ -192,17 +193,18 @@ export class MeasureDistanceMode extends GeoJsonEditMode {
|
|
|
192
193
|
const {lastPointerMoveEvent, modeConfig} = props;
|
|
193
194
|
const {centerTooltipsOnLine = false} = modeConfig || {};
|
|
194
195
|
const positions = this.getClickSequence();
|
|
196
|
+
const coordSys = getEditModeCoordinateSystem(props.coordinateSystem);
|
|
195
197
|
|
|
196
198
|
if (positions.length > 0 && lastPointerMoveEvent && !this._isMeasuringSessionFinished) {
|
|
197
199
|
const distance = this._calculateDistanceForTooltip({
|
|
198
200
|
positionA: positions[positions.length - 1],
|
|
199
201
|
positionB: lastPointerMoveEvent.mapCoords,
|
|
200
|
-
modeConfig: props.modeConfig
|
|
202
|
+
modeConfig: props.modeConfig,
|
|
203
|
+
coordinateSystem: coordSys
|
|
201
204
|
});
|
|
202
205
|
|
|
203
206
|
const tooltipPosition = centerTooltipsOnLine
|
|
204
|
-
?
|
|
205
|
-
.coordinates
|
|
207
|
+
? coordSys.midpoint(positions[positions.length - 1], lastPointerMoveEvent.mapCoords)
|
|
206
208
|
: lastPointerMoveEvent.mapCoords;
|
|
207
209
|
|
|
208
210
|
return [
|
|
@@ -38,6 +38,7 @@ import {
|
|
|
38
38
|
} from './types';
|
|
39
39
|
import {GeoJsonEditMode} from './geojson-edit-mode';
|
|
40
40
|
import {ImmutableFeatureCollection} from './immutable-feature-collection';
|
|
41
|
+
import {EditModeCoordinateSystem} from './coordinate-system';
|
|
41
42
|
|
|
42
43
|
export class ModifyMode extends GeoJsonEditMode {
|
|
43
44
|
// eslint-disable-next-line complexity
|
|
@@ -85,7 +86,8 @@ export class ModifyMode extends GeoJsonEditMode {
|
|
|
85
86
|
const candidateIntermediatePoint = this.getNearestPoint(
|
|
86
87
|
lineStringFeature,
|
|
87
88
|
referencePoint,
|
|
88
|
-
props.modeConfig && props.modeConfig.viewport
|
|
89
|
+
props.modeConfig && props.modeConfig.viewport,
|
|
90
|
+
props.coordinateSystem
|
|
89
91
|
);
|
|
90
92
|
if (
|
|
91
93
|
!intermediatePoint ||
|
|
@@ -129,20 +131,21 @@ export class ModifyMode extends GeoJsonEditMode {
|
|
|
129
131
|
getNearestPoint(
|
|
130
132
|
line: Feature<LineString>,
|
|
131
133
|
inPoint: Feature<Point>,
|
|
132
|
-
viewport: Viewport | null | undefined
|
|
134
|
+
viewport: Viewport | null | undefined,
|
|
135
|
+
coordinateSystem?: EditModeCoordinateSystem
|
|
133
136
|
): NearestPointType {
|
|
134
137
|
const {coordinates} = line.geometry;
|
|
135
138
|
if (coordinates.some((coord) => coord.length > 2)) {
|
|
136
139
|
if (viewport) {
|
|
137
140
|
// This line has elevation, we need to use alternative algorithm
|
|
138
|
-
return nearestPointOnProjectedLine(line, inPoint, viewport);
|
|
141
|
+
return nearestPointOnProjectedLine(line, inPoint, viewport, coordinateSystem);
|
|
139
142
|
}
|
|
140
143
|
// eslint-disable-next-line no-console,no-undef
|
|
141
144
|
console.log(
|
|
142
145
|
'Editing 3D point but modeConfig.viewport not provided. Falling back to 2D logic.'
|
|
143
146
|
);
|
|
144
147
|
}
|
|
145
|
-
return nearestPointOnLine(line, inPoint, viewport);
|
|
148
|
+
return nearestPointOnLine(line, inPoint, viewport, coordinateSystem);
|
|
146
149
|
}
|
|
147
150
|
|
|
148
151
|
handleClick(event: ClickEvent, props: ModeProps<SimpleFeatureCollection>) {
|