deeptwins-engine-3d 0.1.64 → 0.1.65
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/esm/{plot/utils/Algorithm.js → drawer/algorithm.js} +1 -3
- package/dist/esm/drawer/common.d.ts +61 -0
- package/dist/esm/{plot/utils/PlotCommon.js → drawer/common.js} +104 -551
- package/dist/esm/drawer/index.d.ts +11 -18
- package/dist/esm/drawer/index.js +329 -80
- package/dist/esm/{plot/utils → drawer}/plotUtil.js +1 -3
- package/dist/esm/drawer/shape/Assemble.d.ts +34 -0
- package/dist/esm/drawer/shape/Assemble.js +415 -0
- package/dist/esm/drawer/shape/AttackArrow.d.ts +32 -0
- package/dist/esm/drawer/shape/AttackArrow.js +442 -0
- package/dist/esm/drawer/shape/BaseShape.d.ts +14 -4
- package/dist/esm/drawer/shape/BaseShape.js +175 -20
- package/dist/esm/drawer/shape/Bow.d.ts +31 -0
- package/dist/esm/drawer/shape/Bow.js +375 -0
- package/dist/esm/drawer/shape/Circle.d.ts +37 -0
- package/dist/esm/drawer/shape/Circle.js +461 -0
- package/dist/esm/drawer/shape/Curve.d.ts +29 -0
- package/dist/esm/drawer/shape/Curve.js +386 -0
- package/dist/esm/drawer/shape/DragPoint.d.ts +32 -0
- package/dist/esm/drawer/shape/DragPoint.js +211 -0
- package/dist/esm/drawer/shape/Elliptic.d.ts +38 -0
- package/dist/esm/drawer/shape/Elliptic.js +491 -0
- package/dist/esm/drawer/shape/Formation.d.ts +33 -0
- package/dist/esm/drawer/shape/Formation.js +395 -0
- package/dist/esm/drawer/shape/PincerArrow.d.ts +32 -0
- package/dist/esm/drawer/shape/PincerArrow.js +445 -0
- package/dist/esm/drawer/shape/Point.d.ts +2 -31
- package/dist/esm/drawer/shape/Point.js +7 -201
- package/dist/esm/drawer/shape/Polygon.d.ts +1 -1
- package/dist/esm/drawer/shape/Polygon.js +10 -81
- package/dist/esm/drawer/shape/Polyline.d.ts +1 -1
- package/dist/esm/drawer/shape/Polyline.js +10 -81
- package/dist/esm/drawer/shape/RegularPolygon.d.ts +37 -0
- package/dist/esm/drawer/shape/RegularPolygon.js +468 -0
- package/dist/esm/drawer/shape/RightAngleArrow.d.ts +34 -0
- package/dist/esm/drawer/shape/RightAngleArrow.js +423 -0
- package/dist/esm/drawer/shape/Sector.d.ts +37 -0
- package/dist/esm/drawer/shape/Sector.js +568 -0
- package/dist/esm/drawer/shape/StraightArrow.d.ts +34 -0
- package/dist/esm/drawer/shape/StraightArrow.js +422 -0
- package/dist/esm/drawer/shape/SwallowtailArrow.d.ts +36 -0
- package/dist/esm/drawer/shape/SwallowtailArrow.js +438 -0
- package/dist/esm/drawer/types.d.ts +23 -0
- package/dist/esm/drawer/types.js +11 -0
- package/dist/esm/drawer/utils.d.ts +14 -0
- package/dist/esm/drawer/utils.js +320 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/measure/Area.d.ts +17 -17
- package/dist/esm/measure/Area.js +95 -63
- package/dist/esm/measure/BaseDraw.d.ts +9 -4
- package/dist/esm/measure/BaseDraw.js +37 -2
- package/dist/esm/measure/Distance.d.ts +9 -9
- package/dist/esm/measure/Distance.js +52 -68
- package/dist/esm/measure/index.d.ts +16 -26
- package/dist/esm/measure/index.js +72 -84
- package/dist/esm/measure/types.d.ts +94 -0
- package/dist/esm/measure/types.js +17 -0
- package/dist/esm/measure/utils.d.ts +7 -7
- package/dist/esm/measure/utils.js +43 -24
- package/dist/esm/tool/utils.js +1 -1
- package/dist/umd/deeptwins-engine-3d.min.js +1 -1
- package/package.json +1 -1
- package/dist/esm/plot/create/CreateAssemble.d.ts +0 -2
- package/dist/esm/plot/create/CreateAssemble.js +0 -63
- package/dist/esm/plot/create/CreateAttackArrow.d.ts +0 -5
- package/dist/esm/plot/create/CreateAttackArrow.js +0 -75
- package/dist/esm/plot/create/CreateBillboard.d.ts +0 -2
- package/dist/esm/plot/create/CreateBillboard.js +0 -47
- package/dist/esm/plot/create/CreateBow.d.ts +0 -2
- package/dist/esm/plot/create/CreateBow.js +0 -63
- package/dist/esm/plot/create/CreateCircle.d.ts +0 -2
- package/dist/esm/plot/create/CreateCircle.js +0 -68
- package/dist/esm/plot/create/CreateCurve.d.ts +0 -2
- package/dist/esm/plot/create/CreateCurve.js +0 -76
- package/dist/esm/plot/create/CreateElliptic.d.ts +0 -2
- package/dist/esm/plot/create/CreateElliptic.js +0 -69
- package/dist/esm/plot/create/CreateFlag.d.ts +0 -2
- package/dist/esm/plot/create/CreateFlag.js +0 -80
- package/dist/esm/plot/create/CreateFormation.d.ts +0 -2
- package/dist/esm/plot/create/CreateFormation.js +0 -65
- package/dist/esm/plot/create/CreateFreeLine.d.ts +0 -2
- package/dist/esm/plot/create/CreateFreeLine.js +0 -69
- package/dist/esm/plot/create/CreateFreePolygon.d.ts +0 -2
- package/dist/esm/plot/create/CreateFreePolygon.js +0 -65
- package/dist/esm/plot/create/CreateLabel.d.ts +0 -2
- package/dist/esm/plot/create/CreateLabel.js +0 -55
- package/dist/esm/plot/create/CreateLineArrow.d.ts +0 -2
- package/dist/esm/plot/create/CreateLineArrow.js +0 -79
- package/dist/esm/plot/create/CreatePincerArrow.d.ts +0 -5
- package/dist/esm/plot/create/CreatePincerArrow.js +0 -73
- package/dist/esm/plot/create/CreatePoint.d.ts +0 -2
- package/dist/esm/plot/create/CreatePoint.js +0 -47
- package/dist/esm/plot/create/CreatePolygon.d.ts +0 -2
- package/dist/esm/plot/create/CreatePolygon.js +0 -80
- package/dist/esm/plot/create/CreatePolyline.d.ts +0 -2
- package/dist/esm/plot/create/CreatePolyline.js +0 -70
- package/dist/esm/plot/create/CreateRectangle.d.ts +0 -2
- package/dist/esm/plot/create/CreateRectangle.js +0 -60
- package/dist/esm/plot/create/CreateRegularPolygon.d.ts +0 -2
- package/dist/esm/plot/create/CreateRegularPolygon.js +0 -75
- package/dist/esm/plot/create/CreateRightAngleArrow.d.ts +0 -5
- package/dist/esm/plot/create/CreateRightAngleArrow.js +0 -73
- package/dist/esm/plot/create/CreateRoundRectangle.d.ts +0 -2
- package/dist/esm/plot/create/CreateRoundRectangle.js +0 -63
- package/dist/esm/plot/create/CreateSector.d.ts +0 -2
- package/dist/esm/plot/create/CreateSector.js +0 -65
- package/dist/esm/plot/create/CreateStraightArrow.d.ts +0 -5
- package/dist/esm/plot/create/CreateStraightArrow.js +0 -65
- package/dist/esm/plot/create/CreateSwallowtailArrow.d.ts +0 -5
- package/dist/esm/plot/create/CreateSwallowtailArrow.js +0 -67
- package/dist/esm/plot/create/index.d.ts +0 -25
- package/dist/esm/plot/create/index.js +0 -25
- package/dist/esm/plot/edit/EditAssemble.d.ts +0 -8
- package/dist/esm/plot/edit/EditAssemble.js +0 -120
- package/dist/esm/plot/edit/EditAttackArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditAttackArrow.js +0 -182
- package/dist/esm/plot/edit/EditBillboard.d.ts +0 -7
- package/dist/esm/plot/edit/EditBillboard.js +0 -70
- package/dist/esm/plot/edit/EditBow.d.ts +0 -8
- package/dist/esm/plot/edit/EditBow.js +0 -119
- package/dist/esm/plot/edit/EditCircle.d.ts +0 -8
- package/dist/esm/plot/edit/EditCircle.js +0 -133
- package/dist/esm/plot/edit/EditCurve.d.ts +0 -8
- package/dist/esm/plot/edit/EditCurve.js +0 -180
- package/dist/esm/plot/edit/EditElliptic.d.ts +0 -8
- package/dist/esm/plot/edit/EditElliptic.js +0 -144
- package/dist/esm/plot/edit/EditFlag.d.ts +0 -8
- package/dist/esm/plot/edit/EditFlag.js +0 -121
- package/dist/esm/plot/edit/EditFormation.d.ts +0 -8
- package/dist/esm/plot/edit/EditFormation.js +0 -120
- package/dist/esm/plot/edit/EditLabel.d.ts +0 -7
- package/dist/esm/plot/edit/EditLabel.js +0 -100
- package/dist/esm/plot/edit/EditLineArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditLineArrow.js +0 -180
- package/dist/esm/plot/edit/EditPincerArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditPincerArrow.js +0 -121
- package/dist/esm/plot/edit/EditPoint.d.ts +0 -7
- package/dist/esm/plot/edit/EditPoint.js +0 -70
- package/dist/esm/plot/edit/EditPolygon.d.ts +0 -8
- package/dist/esm/plot/edit/EditPolygon.js +0 -181
- package/dist/esm/plot/edit/EditPolyline.d.ts +0 -8
- package/dist/esm/plot/edit/EditPolyline.js +0 -179
- package/dist/esm/plot/edit/EditRectangle.d.ts +0 -8
- package/dist/esm/plot/edit/EditRectangle.js +0 -119
- package/dist/esm/plot/edit/EditRegularPolygon.d.ts +0 -8
- package/dist/esm/plot/edit/EditRegularPolygon.js +0 -170
- package/dist/esm/plot/edit/EditRightAngleArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditRightAngleArrow.js +0 -143
- package/dist/esm/plot/edit/EditRoundRectangle.d.ts +0 -8
- package/dist/esm/plot/edit/EditRoundRectangle.js +0 -119
- package/dist/esm/plot/edit/EditSector.d.ts +0 -8
- package/dist/esm/plot/edit/EditSector.js +0 -120
- package/dist/esm/plot/edit/EditStraightArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditStraightArrow.js +0 -120
- package/dist/esm/plot/edit/EditSwallowtailArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditSwallowtailArrow.js +0 -121
- package/dist/esm/plot/edit/index.d.ts +0 -23
- package/dist/esm/plot/edit/index.js +0 -23
- package/dist/esm/plot/utils/DomUtil.d.ts +0 -34
- package/dist/esm/plot/utils/DomUtil.js +0 -100
- package/dist/esm/plot/utils/PlotCommon.d.ts +0 -101
- package/dist/esm/plot/utils/ReminderTip.d.ts +0 -10
- package/dist/esm/plot/utils/ReminderTip.js +0 -67
- package/dist/esm/plot/utils/Tooltip.d.ts +0 -3
- package/dist/esm/plot/utils/Tooltip.js +0 -97
- /package/dist/esm/{plot/utils/Algorithm.d.ts → drawer/algorithm.d.ts} +0 -0
- /package/dist/esm/{plot/utils/Coordinate.d.ts → drawer/coordinate.d.ts} +0 -0
- /package/dist/esm/{plot/utils/Coordinate.js → drawer/coordinate.js} +0 -0
- /package/dist/esm/{plot/utils → drawer}/plotUtil.d.ts +0 -0
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type Cartesian2, type Cartesian3 } from 'deeptwins-cesium';
|
|
2
|
+
import { MeasureContext, MeasureDrawConfig, MeasureLabelLayer, MeasureMap, MeasurePosition, ResolvedMeasureConfig } from './types';
|
|
2
3
|
declare class BaseDraw {
|
|
3
4
|
_measureContext: MeasureContext;
|
|
4
5
|
id: string;
|
|
5
|
-
_drawer:
|
|
6
|
+
_drawer: MeasureContext['drawer'];
|
|
6
7
|
isDestroyed: boolean;
|
|
7
8
|
constructor(measureContext: MeasureContext);
|
|
8
9
|
_canOperate(): boolean;
|
|
9
|
-
getMap():
|
|
10
|
-
createLabelLayer(position:
|
|
10
|
+
getMap(): MeasureMap;
|
|
11
|
+
createLabelLayer(position: MeasurePosition, text: string, style?: Record<string, any>): MeasureLabelLayer;
|
|
12
|
+
protected getMeasureConfig(config?: MeasureDrawConfig): ResolvedMeasureConfig;
|
|
13
|
+
protected toCartesian3(position: MeasurePosition): Cartesian3;
|
|
14
|
+
protected toWindowPosition(position: MeasurePosition): Cartesian2 | undefined;
|
|
15
|
+
protected destroyLabelLayer<T extends MeasureLabelLayer | null | undefined>(layer: T): null;
|
|
11
16
|
destroy(): void;
|
|
12
17
|
}
|
|
13
18
|
export default BaseDraw;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
6
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
7
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
2
8
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
9
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
10
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
@@ -9,9 +15,10 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
9
15
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
16
|
import { point } from '@turf/turf';
|
|
11
17
|
import * as Cesium from 'deeptwins-cesium';
|
|
18
|
+
import { SceneTransforms } from 'deeptwins-cesium';
|
|
12
19
|
import { v4 as uuidV4 } from 'uuid';
|
|
13
20
|
import PositionProperty from "../property/PositionProperty";
|
|
14
|
-
import { error } from "../tool/utils";
|
|
21
|
+
import { error, lngLatAltToCartesian3 } from "../tool/utils";
|
|
15
22
|
var BaseDraw = /*#__PURE__*/function () {
|
|
16
23
|
function BaseDraw(measureContext) {
|
|
17
24
|
_classCallCheck(this, BaseDraw);
|
|
@@ -37,7 +44,7 @@ var BaseDraw = /*#__PURE__*/function () {
|
|
|
37
44
|
}, {
|
|
38
45
|
key: "getMap",
|
|
39
46
|
value: function getMap() {
|
|
40
|
-
return this._measureContext
|
|
47
|
+
return this._measureContext.getMap();
|
|
41
48
|
}
|
|
42
49
|
|
|
43
50
|
// 创建label图层
|
|
@@ -58,6 +65,34 @@ var BaseDraw = /*#__PURE__*/function () {
|
|
|
58
65
|
positionProperty: new PositionProperty()
|
|
59
66
|
});
|
|
60
67
|
}
|
|
68
|
+
}, {
|
|
69
|
+
key: "getMeasureConfig",
|
|
70
|
+
value: function getMeasureConfig() {
|
|
71
|
+
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
72
|
+
return _objectSpread(_objectSpread({}, this._measureContext.options), config);
|
|
73
|
+
}
|
|
74
|
+
}, {
|
|
75
|
+
key: "toCartesian3",
|
|
76
|
+
value: function toCartesian3(position) {
|
|
77
|
+
var _position = _slicedToArray(position, 3),
|
|
78
|
+
lng = _position[0],
|
|
79
|
+
lat = _position[1],
|
|
80
|
+
_position$ = _position[2],
|
|
81
|
+
alt = _position$ === void 0 ? 0 : _position$;
|
|
82
|
+
return lngLatAltToCartesian3(lng, lat, alt);
|
|
83
|
+
}
|
|
84
|
+
}, {
|
|
85
|
+
key: "toWindowPosition",
|
|
86
|
+
value: function toWindowPosition(position) {
|
|
87
|
+
var _SceneTransforms$worl;
|
|
88
|
+
return (_SceneTransforms$worl = SceneTransforms.worldToWindowCoordinates(this.getMap().scene, this.toCartesian3(position))) !== null && _SceneTransforms$worl !== void 0 ? _SceneTransforms$worl : undefined;
|
|
89
|
+
}
|
|
90
|
+
}, {
|
|
91
|
+
key: "destroyLabelLayer",
|
|
92
|
+
value: function destroyLabelLayer(layer) {
|
|
93
|
+
layer === null || layer === void 0 || layer.destroy();
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
61
96
|
}, {
|
|
62
97
|
key: "destroy",
|
|
63
98
|
value: function destroy() {
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import BaseDraw from './BaseDraw';
|
|
2
|
-
import { MeasureContext } from './
|
|
3
|
-
declare class Distance extends BaseDraw {
|
|
4
|
-
private readonly _type;
|
|
2
|
+
import { DistanceMeasureResult, MeasureContext, MeasureDrawConfig, MeasureLayer, MeasurePosition, MeasureShapeLayer } from './types';
|
|
3
|
+
declare class Distance extends BaseDraw implements MeasureLayer {
|
|
5
4
|
private _config;
|
|
6
|
-
|
|
5
|
+
_instance: MeasureShapeLayer | null;
|
|
7
6
|
private _measureCache;
|
|
8
7
|
private _mouseLabelLayer;
|
|
9
|
-
constructor(measureContext: MeasureContext, config
|
|
8
|
+
constructor(measureContext: MeasureContext, config?: MeasureDrawConfig);
|
|
10
9
|
private _init;
|
|
11
|
-
drawing(positions:
|
|
12
|
-
pointsChange(layer:
|
|
13
|
-
drawEnd():
|
|
10
|
+
drawing(positions: MeasurePosition[]): {} | undefined;
|
|
11
|
+
pointsChange(layer: MeasureShapeLayer, positions: MeasurePosition[]): DistanceMeasureResult;
|
|
12
|
+
drawEnd(): DistanceMeasureResult;
|
|
14
13
|
startEdit(): void;
|
|
15
|
-
endEdit():
|
|
14
|
+
endEdit(): DistanceMeasureResult;
|
|
16
15
|
private _createMouseMoveLabel;
|
|
17
16
|
private _destroyMouseMoveLabel;
|
|
18
17
|
private _calculateDistance;
|
|
19
18
|
private _calculateMouseDistance;
|
|
19
|
+
private _calculateSegmentDistance;
|
|
20
20
|
private _createMeasureCacheText;
|
|
21
21
|
destroy(): void;
|
|
22
22
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
2
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
5
3
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
6
4
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
@@ -18,26 +16,24 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
18
16
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
19
17
|
import { point } from '@turf/turf';
|
|
20
18
|
import * as Cesium from 'deeptwins-cesium';
|
|
21
|
-
import { SceneTransforms } from 'deeptwins-cesium';
|
|
22
|
-
import { STATUS } from "../drawer";
|
|
23
|
-
import { lngLatAltToCartesian3 } from "../tool/utils";
|
|
24
19
|
import BaseDraw from "./BaseDraw";
|
|
20
|
+
import { STATUS } from "./types";
|
|
25
21
|
import * as utils from "./utils";
|
|
26
22
|
var Distance = /*#__PURE__*/function (_BaseDraw) {
|
|
27
23
|
_inherits(Distance, _BaseDraw);
|
|
28
24
|
var _super = _createSuper(Distance);
|
|
29
|
-
function Distance(measureContext
|
|
25
|
+
function Distance(measureContext) {
|
|
30
26
|
var _this;
|
|
27
|
+
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
31
28
|
_classCallCheck(this, Distance);
|
|
32
29
|
_this = _super.call(this, measureContext);
|
|
33
|
-
_defineProperty(_assertThisInitialized(_this), "_type", 'distance');
|
|
34
30
|
_defineProperty(_assertThisInitialized(_this), "_config", void 0);
|
|
35
31
|
// 线图层
|
|
36
|
-
_defineProperty(_assertThisInitialized(_this), "_instance",
|
|
32
|
+
_defineProperty(_assertThisInitialized(_this), "_instance", null);
|
|
37
33
|
// 测量缓存数据
|
|
38
34
|
_defineProperty(_assertThisInitialized(_this), "_measureCache", []);
|
|
39
35
|
// 鼠标移动的label
|
|
40
|
-
_defineProperty(_assertThisInitialized(_this), "_mouseLabelLayer",
|
|
36
|
+
_defineProperty(_assertThisInitialized(_this), "_mouseLabelLayer", null);
|
|
41
37
|
_this._config = config;
|
|
42
38
|
_this._init();
|
|
43
39
|
return _this;
|
|
@@ -54,9 +50,12 @@ var Distance = /*#__PURE__*/function (_BaseDraw) {
|
|
|
54
50
|
value: function drawing(positions) {
|
|
55
51
|
if (!this._canOperate()) return;
|
|
56
52
|
this._measureContext._changeStatus(STATUS.DRAWING);
|
|
57
|
-
if (positions.length < 2)
|
|
53
|
+
if (positions.length < 2) {
|
|
54
|
+
this._destroyMouseMoveLabel();
|
|
55
|
+
return {};
|
|
56
|
+
}
|
|
58
57
|
var mouseDistance = this._calculateMouseDistance(positions);
|
|
59
|
-
this._createMouseMoveLabel(positions.
|
|
58
|
+
this._createMouseMoveLabel(positions[positions.length - 1], "\u603B\u8BA1".concat(utils.formatLength(mouseDistance.allDistance), "\n(+").concat(utils.formatLength(mouseDistance.distance), ")"));
|
|
60
59
|
return mouseDistance;
|
|
61
60
|
}
|
|
62
61
|
|
|
@@ -64,26 +63,19 @@ var Distance = /*#__PURE__*/function (_BaseDraw) {
|
|
|
64
63
|
}, {
|
|
65
64
|
key: "pointsChange",
|
|
66
65
|
value: function pointsChange(layer, positions) {
|
|
67
|
-
if (!this._canOperate()) return;
|
|
68
|
-
// 未返回点位 销毁随鼠标移动的label
|
|
69
|
-
if (!positions.length) {
|
|
70
|
-
this._destroyMouseMoveLabel();
|
|
71
|
-
return [];
|
|
72
|
-
}
|
|
73
|
-
// 小于两个点时清除测量缓存数据
|
|
66
|
+
if (!this._canOperate()) return [];
|
|
74
67
|
if (positions.length < 2) {
|
|
68
|
+
var _layer$dragPoints$;
|
|
75
69
|
this._measureCache = [];
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
if (!this._measureCache.length) {
|
|
80
|
-
layer.dragPoints[0].labelLayer.setStyle({
|
|
70
|
+
this._destroyMouseMoveLabel();
|
|
71
|
+
(_layer$dragPoints$ = layer.dragPoints[0]) === null || _layer$dragPoints$ === void 0 || _layer$dragPoints$.labelLayer.setStyle({
|
|
81
72
|
show: true,
|
|
82
73
|
text: '起点'
|
|
83
74
|
});
|
|
84
|
-
|
|
85
|
-
this._createMeasureCacheText(layer.dragPoints);
|
|
75
|
+
return this._measureCache;
|
|
86
76
|
}
|
|
77
|
+
this._calculateDistance(positions);
|
|
78
|
+
this._createMeasureCacheText(layer.dragPoints);
|
|
87
79
|
return this._measureCache;
|
|
88
80
|
}
|
|
89
81
|
|
|
@@ -91,7 +83,7 @@ var Distance = /*#__PURE__*/function (_BaseDraw) {
|
|
|
91
83
|
}, {
|
|
92
84
|
key: "drawEnd",
|
|
93
85
|
value: function drawEnd() {
|
|
94
|
-
if (!this._canOperate()) return;
|
|
86
|
+
if (!this._canOperate()) return [];
|
|
95
87
|
this._measureContext._changeStatus(STATUS.END_DRAW);
|
|
96
88
|
this._measureContext.setDrawerLayer(this.id, this);
|
|
97
89
|
this._destroyMouseMoveLabel();
|
|
@@ -111,7 +103,7 @@ var Distance = /*#__PURE__*/function (_BaseDraw) {
|
|
|
111
103
|
}, {
|
|
112
104
|
key: "endEdit",
|
|
113
105
|
value: function endEdit() {
|
|
114
|
-
if (!this._canOperate()) return;
|
|
106
|
+
if (!this._canOperate()) return [];
|
|
115
107
|
return this._measureCache;
|
|
116
108
|
}
|
|
117
109
|
|
|
@@ -139,40 +131,30 @@ var Distance = /*#__PURE__*/function (_BaseDraw) {
|
|
|
139
131
|
}, {
|
|
140
132
|
key: "_destroyMouseMoveLabel",
|
|
141
133
|
value: function _destroyMouseMoveLabel() {
|
|
142
|
-
this._mouseLabelLayer
|
|
143
|
-
this._mouseLabelLayer = null;
|
|
134
|
+
this._mouseLabelLayer = this.destroyLabelLayer(this._mouseLabelLayer);
|
|
144
135
|
}
|
|
145
136
|
|
|
146
137
|
// 计算距离
|
|
147
138
|
}, {
|
|
148
139
|
key: "_calculateDistance",
|
|
149
140
|
value: function _calculateDistance(positions) {
|
|
150
|
-
if (
|
|
151
|
-
|
|
152
|
-
|
|
141
|
+
if (positions.length < 2) {
|
|
142
|
+
this._measureCache = [];
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
var config = this.getMeasureConfig(this._config);
|
|
146
|
+
var allDistance = 0;
|
|
153
147
|
this._measureCache = [];
|
|
154
|
-
var config = _objectSpread(_objectSpread({}, this._measureContext.options), this._config);
|
|
155
148
|
for (var i = 0; i < positions.length - 1; i++) {
|
|
156
149
|
var start = positions[i];
|
|
157
150
|
var end = positions[i + 1];
|
|
158
|
-
var
|
|
159
|
-
|
|
160
|
-
var distance = 0;
|
|
161
|
-
if (config.clampToGround) {
|
|
162
|
-
var startC2 = SceneTransforms.worldToWindowCoordinates(this.getMap().scene, startC3);
|
|
163
|
-
var endC2 = SceneTransforms.worldToWindowCoordinates(this.getMap().scene, endC3);
|
|
164
|
-
distance = utils.calculateSurfaceDistance(this.getMap(), startC2, endC2, config.splitNum);
|
|
165
|
-
} else {
|
|
166
|
-
distance = utils.getDistance(startC3, endC3);
|
|
167
|
-
}
|
|
168
|
-
distanceList.push(distance);
|
|
151
|
+
var distance = this._calculateSegmentDistance(start, end, config);
|
|
152
|
+
allDistance += distance;
|
|
169
153
|
this._measureCache.push({
|
|
170
154
|
start: start,
|
|
171
155
|
end: end,
|
|
172
156
|
distance: distance,
|
|
173
|
-
allDistance:
|
|
174
|
-
return sum + distance;
|
|
175
|
-
}, 0)
|
|
157
|
+
allDistance: allDistance
|
|
176
158
|
});
|
|
177
159
|
}
|
|
178
160
|
}
|
|
@@ -181,21 +163,10 @@ var Distance = /*#__PURE__*/function (_BaseDraw) {
|
|
|
181
163
|
}, {
|
|
182
164
|
key: "_calculateMouseDistance",
|
|
183
165
|
value: function _calculateMouseDistance(positions) {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
var
|
|
187
|
-
var
|
|
188
|
-
var startC3 = lngLatAltToCartesian3(start[0], start[1], start[2]);
|
|
189
|
-
var endC3 = lngLatAltToCartesian3(end[0], end[1], end[2]);
|
|
190
|
-
var distance = 0;
|
|
191
|
-
var config = _objectSpread(_objectSpread({}, this._measureContext.options), this._config);
|
|
192
|
-
if (config.clampToGround) {
|
|
193
|
-
var startC2 = SceneTransforms.worldToWindowCoordinates(this.getMap().scene, startC3);
|
|
194
|
-
var endC2 = SceneTransforms.worldToWindowCoordinates(this.getMap().scene, endC3);
|
|
195
|
-
distance = utils.calculateSurfaceDistance(this.getMap(), startC2, endC2, config.splitNum);
|
|
196
|
-
} else {
|
|
197
|
-
distance = utils.getDistance(startC3, endC3);
|
|
198
|
-
}
|
|
166
|
+
var start = positions[positions.length - 2];
|
|
167
|
+
var end = positions[positions.length - 1];
|
|
168
|
+
var config = this.getMeasureConfig(this._config);
|
|
169
|
+
var distance = this._calculateSegmentDistance(start, end, config);
|
|
199
170
|
return {
|
|
200
171
|
distance: distance,
|
|
201
172
|
allDistance: this._measureCache.reduce(function (sum, item) {
|
|
@@ -203,6 +174,19 @@ var Distance = /*#__PURE__*/function (_BaseDraw) {
|
|
|
203
174
|
}, distance)
|
|
204
175
|
};
|
|
205
176
|
}
|
|
177
|
+
}, {
|
|
178
|
+
key: "_calculateSegmentDistance",
|
|
179
|
+
value: function _calculateSegmentDistance(start, end, config) {
|
|
180
|
+
if (!config.clampToGround) {
|
|
181
|
+
return utils.getDistance(this.toCartesian3(start), this.toCartesian3(end));
|
|
182
|
+
}
|
|
183
|
+
var startC2 = this.toWindowPosition(start);
|
|
184
|
+
var endC2 = this.toWindowPosition(end);
|
|
185
|
+
if (!startC2 || !endC2) {
|
|
186
|
+
return 0;
|
|
187
|
+
}
|
|
188
|
+
return utils.calculateSurfaceDistance(this.getMap(), startC2, endC2, config.splitNum);
|
|
189
|
+
}
|
|
206
190
|
|
|
207
191
|
// 根据缓存数据创建文字
|
|
208
192
|
}, {
|
|
@@ -210,10 +194,11 @@ var Distance = /*#__PURE__*/function (_BaseDraw) {
|
|
|
210
194
|
value: function _createMeasureCacheText(dragPoints) {
|
|
211
195
|
if (!this._canOperate()) return;
|
|
212
196
|
for (var i = 0; i < this._measureCache.length; i++) {
|
|
197
|
+
var _dragPoints;
|
|
213
198
|
var _this$_measureCache$i = this._measureCache[i],
|
|
214
199
|
distance = _this$_measureCache$i.distance,
|
|
215
200
|
allDistance = _this$_measureCache$i.allDistance;
|
|
216
|
-
dragPoints[i + 1].labelLayer.setStyle({
|
|
201
|
+
(_dragPoints = dragPoints[i + 1]) === null || _dragPoints === void 0 || _dragPoints.labelLayer.setStyle({
|
|
217
202
|
show: true,
|
|
218
203
|
text: "".concat(utils.formatLength(allDistance), "\n(+").concat(utils.formatLength(distance), ")")
|
|
219
204
|
});
|
|
@@ -225,13 +210,12 @@ var Distance = /*#__PURE__*/function (_BaseDraw) {
|
|
|
225
210
|
key: "destroy",
|
|
226
211
|
value: function destroy() {
|
|
227
212
|
if (!this._canOperate()) return;
|
|
228
|
-
|
|
229
|
-
this._drawer.removeDrawerLayer(this._instance);
|
|
230
|
-
this._instance = null;
|
|
231
|
-
this._mouseLabelLayer && this._mouseLabelLayer.remove();
|
|
232
|
-
this._mouseLabelLayer = null;
|
|
213
|
+
var layer = this._instance;
|
|
233
214
|
this._measureCache = [];
|
|
234
215
|
this._destroyMouseMoveLabel();
|
|
216
|
+
this._instance = null;
|
|
217
|
+
_get(_getPrototypeOf(Distance.prototype), "destroy", this).call(this);
|
|
218
|
+
layer && this._drawer.removeDrawerLayer(layer);
|
|
235
219
|
}
|
|
236
220
|
}]);
|
|
237
221
|
return Distance;
|
|
@@ -1,44 +1,34 @@
|
|
|
1
1
|
import Drawer from '../drawer';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
getMap: any;
|
|
5
|
-
drawer: any;
|
|
6
|
-
setDrawerLayer: any;
|
|
7
|
-
_changeStatus: any;
|
|
8
|
-
}
|
|
9
|
-
export declare const STATUS: {
|
|
10
|
-
readonly INIT: "INIT";
|
|
11
|
-
readonly START_DRAW: "START_DRAW";
|
|
12
|
-
readonly DRAWING: "DRAWING";
|
|
13
|
-
readonly END_DRAW: "END_DRAW";
|
|
14
|
-
readonly EDITING: "EDITING";
|
|
15
|
-
readonly END_EDIT: "END_EDIT";
|
|
16
|
-
};
|
|
17
|
-
export type Status = (typeof STATUS)[keyof typeof STATUS];
|
|
2
|
+
import { MapContext } from '../map/Map';
|
|
3
|
+
import { MeasureContext, MeasureDrawConfig, MeasureLayer, MeasureMap, MeasureOptions, MeasureType, Status } from './types';
|
|
18
4
|
declare class Measure implements MeasureContext {
|
|
19
5
|
private readonly _mapContext;
|
|
20
6
|
private readonly _measureContext;
|
|
21
|
-
options:
|
|
7
|
+
options: MeasureOptions;
|
|
22
8
|
isDestroyed: boolean;
|
|
23
9
|
private _status;
|
|
24
10
|
drawer: Drawer;
|
|
25
11
|
private _instance;
|
|
26
12
|
private _measureDrawLayers;
|
|
27
|
-
constructor(map:
|
|
13
|
+
constructor(map: {
|
|
14
|
+
_mapContext: MapContext;
|
|
15
|
+
}, options?: MeasureDrawConfig);
|
|
28
16
|
private _canOperate;
|
|
29
|
-
getMap():
|
|
30
|
-
_changeStatus(status:
|
|
31
|
-
startDraw(type:
|
|
17
|
+
getMap(): MeasureMap;
|
|
18
|
+
_changeStatus(status: Status): void;
|
|
19
|
+
startDraw(type: MeasureType, config?: MeasureDrawConfig): MeasureLayer | undefined;
|
|
32
20
|
private _stopDraw;
|
|
33
21
|
endDraw(): void;
|
|
34
|
-
startEdit(id:
|
|
22
|
+
startEdit(id: string | MeasureLayer): void;
|
|
35
23
|
endEdit(): void;
|
|
36
|
-
getDrawerLayer(id:
|
|
37
|
-
setDrawerLayer(id:
|
|
38
|
-
removeDrawerLayer(id:
|
|
39
|
-
getAllDrawerLayers():
|
|
24
|
+
getDrawerLayer(id: string | MeasureLayer): MeasureLayer | undefined;
|
|
25
|
+
setDrawerLayer(id: string, value: MeasureLayer): void;
|
|
26
|
+
removeDrawerLayer(id: string | MeasureLayer): void;
|
|
27
|
+
getAllDrawerLayers(): MeasureLayer[] | undefined;
|
|
40
28
|
clearAllDrawerLayers(): void;
|
|
41
29
|
clear(): void;
|
|
42
30
|
destroy(): void;
|
|
31
|
+
private _emitCallback;
|
|
43
32
|
}
|
|
33
|
+
export { AREA_SHAPE_TYPE, MEASURE_TYPE, STATUS, type AreaMeasureResult, type AreaShapeType, type DistanceMeasureCacheItem, type DistanceMeasureResult, type DistancePreviewResult, type MeasureCallbackPayload, type MeasureContext, type MeasureDrawConfig, type MeasureLayer, type MeasureOptions, type MeasurePosition, type MeasureResult, type Status, } from './types';
|
|
44
34
|
export default Measure;
|