deeptwins-engine-3d 0.1.63 → 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/assets/Build/DeepTwins/Workers/MvtVector.worker.js +1 -0
- 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/{plot/utils/Coordinate.d.ts → drawer/coordinate.d.ts} +1 -1
- 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/graphicLayer/BaseSource.d.ts +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +5 -3
- 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/tileLayer/MvtVectorLoad.d.ts +241 -0
- package/dist/esm/tileLayer/MvtVectorLoad.js +1353 -0
- package/dist/esm/tileLayer/MvtVectorWorkerClient.d.ts +25 -0
- package/dist/esm/tileLayer/MvtVectorWorkerClient.js +126 -0
- package/dist/esm/tool/utils.js +1 -1
- package/dist/umd/deeptwins-engine-3d.min.js +1 -1
- package/package.json +2 -1
- package/dist/assets/Build/DeepTwins/Image/compass/pointer-white.png +0 -0
- 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.js → drawer/coordinate.js} +0 -0
- /package/dist/esm/{plot/utils → drawer}/plotUtil.d.ts +0 -0
package/dist/esm/measure/Area.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
5
3
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
|
-
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); }
|
|
7
4
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
8
5
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
7
|
+
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."); }
|
|
8
|
+
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); }
|
|
9
9
|
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; }
|
|
10
|
+
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; } }
|
|
11
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
+
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; }
|
|
13
|
+
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; }
|
|
10
14
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
15
|
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); } }
|
|
12
16
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
@@ -23,33 +27,45 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
23
27
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
24
28
|
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); }
|
|
25
29
|
import { centerOfMass, point, polygon } from '@turf/turf';
|
|
26
|
-
import { SceneTransforms } from 'deeptwins-cesium';
|
|
27
|
-
import { STATUS } from "../drawer";
|
|
28
|
-
import { lngLatAltToCartesian3 } from "../tool/utils";
|
|
29
30
|
import BaseDraw from "./BaseDraw";
|
|
31
|
+
import { AREA_SHAPE_TYPE, STATUS } from "./types";
|
|
30
32
|
import * as utils from "./utils";
|
|
31
33
|
var Area = /*#__PURE__*/function (_BaseDraw) {
|
|
32
34
|
_inherits(Area, _BaseDraw);
|
|
33
35
|
var _super = _createSuper(Area);
|
|
34
|
-
function Area(measureContext
|
|
36
|
+
function Area(measureContext) {
|
|
35
37
|
var _this;
|
|
38
|
+
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
36
39
|
_classCallCheck(this, Area);
|
|
37
40
|
_this = _super.call(this, measureContext);
|
|
38
|
-
_defineProperty(_assertThisInitialized(_this), "_type", 'area');
|
|
39
41
|
_defineProperty(_assertThisInitialized(_this), "_config", void 0);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
_defineProperty(_assertThisInitialized(_this), "_shapeType", void 0);
|
|
43
|
+
// 图形图层
|
|
44
|
+
_defineProperty(_assertThisInitialized(_this), "_instance", null);
|
|
42
45
|
_defineProperty(_assertThisInitialized(_this), "_area", 0);
|
|
43
46
|
// 鼠标移动的label
|
|
44
|
-
_defineProperty(_assertThisInitialized(_this), "_areaLayer",
|
|
47
|
+
_defineProperty(_assertThisInitialized(_this), "_areaLayer", null);
|
|
45
48
|
_this._config = config;
|
|
49
|
+
_this._shapeType = _this._resolveShapeType(config.shapeType);
|
|
46
50
|
_this._init();
|
|
47
51
|
return _this;
|
|
48
52
|
}
|
|
49
53
|
_createClass(Area, [{
|
|
50
54
|
key: "_init",
|
|
51
55
|
value: function _init() {
|
|
52
|
-
this._instance = this._drawer.startDraw(
|
|
56
|
+
this._instance = this._drawer.startDraw(this._shapeType, this._getDrawerConfig());
|
|
57
|
+
}
|
|
58
|
+
}, {
|
|
59
|
+
key: "_resolveShapeType",
|
|
60
|
+
value: function _resolveShapeType(shapeType) {
|
|
61
|
+
return Object.values(AREA_SHAPE_TYPE).includes(shapeType) ? shapeType : AREA_SHAPE_TYPE.POLYGON;
|
|
62
|
+
}
|
|
63
|
+
}, {
|
|
64
|
+
key: "_getDrawerConfig",
|
|
65
|
+
value: function _getDrawerConfig() {
|
|
66
|
+
var drawerConfig = _objectSpread({}, this._config);
|
|
67
|
+
delete drawerConfig.shapeType;
|
|
68
|
+
return drawerConfig;
|
|
53
69
|
}
|
|
54
70
|
|
|
55
71
|
// 绘制
|
|
@@ -58,48 +74,30 @@ var Area = /*#__PURE__*/function (_BaseDraw) {
|
|
|
58
74
|
value: function drawing(positions) {
|
|
59
75
|
if (!this._canOperate()) return;
|
|
60
76
|
this._measureContext._changeStatus(STATUS.DRAWING);
|
|
61
|
-
|
|
62
|
-
this._destroyAreaLabel();
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
var polygonPositions = [].concat(_toConsumableArray(positions), [positions[0]]);
|
|
66
|
-
this._area = this._calculateArea(polygonPositions);
|
|
67
|
-
var center = centerOfMass(polygon([polygonPositions]));
|
|
68
|
-
this._createAreaLabel(center.geometry.coordinates, "\u9762\u79EF".concat(utils.formatArea(this._area)));
|
|
69
|
-
return {
|
|
70
|
-
area: this._area
|
|
71
|
-
};
|
|
77
|
+
return this._updateArea(positions);
|
|
72
78
|
}
|
|
73
79
|
|
|
74
80
|
// 点位修改
|
|
75
81
|
}, {
|
|
76
82
|
key: "pointsChange",
|
|
77
|
-
value: function pointsChange(
|
|
78
|
-
if (!this._canOperate()) return
|
|
79
|
-
|
|
80
|
-
this._destroyAreaLabel();
|
|
81
|
-
return {
|
|
82
|
-
area: 0
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
var polygonPositions = [].concat(_toConsumableArray(positions), [positions[0]]);
|
|
86
|
-
this._area = this._calculateArea(polygonPositions);
|
|
87
|
-
var center = centerOfMass(polygon([polygonPositions]));
|
|
88
|
-
this._createAreaLabel(center.geometry.coordinates, "\u9762\u79EF".concat(utils.formatArea(this._area)));
|
|
89
|
-
return {
|
|
90
|
-
area: this._area
|
|
83
|
+
value: function pointsChange(_layer, positions) {
|
|
84
|
+
if (!this._canOperate()) return {
|
|
85
|
+
area: 0
|
|
91
86
|
};
|
|
87
|
+
return this._updateArea(positions);
|
|
92
88
|
}
|
|
93
89
|
|
|
94
90
|
// 结束绘制
|
|
95
91
|
}, {
|
|
96
92
|
key: "drawEnd",
|
|
97
|
-
value: function drawEnd(
|
|
98
|
-
|
|
93
|
+
value: function drawEnd() {
|
|
94
|
+
var positions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
95
|
+
if (!this._canOperate()) return {
|
|
96
|
+
area: 0
|
|
97
|
+
};
|
|
99
98
|
this._measureContext._changeStatus(STATUS.END_DRAW);
|
|
100
99
|
this._measureContext.setDrawerLayer(this.id, this);
|
|
101
|
-
|
|
102
|
-
this._area = this._calculateArea(polygonPositions);
|
|
100
|
+
this._area = this._calculateArea(this._toPolygonPositions(positions));
|
|
103
101
|
this.startEdit();
|
|
104
102
|
return {
|
|
105
103
|
area: this._area
|
|
@@ -117,10 +115,12 @@ var Area = /*#__PURE__*/function (_BaseDraw) {
|
|
|
117
115
|
// 结束编辑
|
|
118
116
|
}, {
|
|
119
117
|
key: "endEdit",
|
|
120
|
-
value: function endEdit(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
118
|
+
value: function endEdit() {
|
|
119
|
+
var positions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
120
|
+
if (!this._canOperate()) return {
|
|
121
|
+
area: 0
|
|
122
|
+
};
|
|
123
|
+
this._area = this._calculateArea(this._toPolygonPositions(positions));
|
|
124
124
|
return {
|
|
125
125
|
area: this._area
|
|
126
126
|
};
|
|
@@ -131,21 +131,25 @@ var Area = /*#__PURE__*/function (_BaseDraw) {
|
|
|
131
131
|
key: "_calculateArea",
|
|
132
132
|
value: function _calculateArea(positions) {
|
|
133
133
|
var _this2 = this;
|
|
134
|
-
if (
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
var config =
|
|
138
|
-
var positionsC3 = positions.map(function (
|
|
139
|
-
return
|
|
134
|
+
if (positions.length < 4) {
|
|
135
|
+
return 0;
|
|
136
|
+
}
|
|
137
|
+
var config = this.getMeasureConfig(this._config);
|
|
138
|
+
var positionsC3 = positions.map(function (item) {
|
|
139
|
+
return _this2.toCartesian3(item);
|
|
140
140
|
});
|
|
141
141
|
if (config.clampToGround) {
|
|
142
|
-
|
|
143
|
-
return
|
|
144
|
-
})
|
|
145
|
-
|
|
146
|
-
|
|
142
|
+
var windowPositions = positions.map(function (item) {
|
|
143
|
+
return _this2.toWindowPosition(item);
|
|
144
|
+
});
|
|
145
|
+
if (windowPositions.some(function (item) {
|
|
146
|
+
return !item;
|
|
147
|
+
})) {
|
|
148
|
+
return 0;
|
|
149
|
+
}
|
|
150
|
+
return utils.calculateSurfaceArea(this.getMap(), windowPositions, config.splitNum);
|
|
147
151
|
}
|
|
148
|
-
return
|
|
152
|
+
return utils.getArea(this.getMap(), positionsC3);
|
|
149
153
|
}
|
|
150
154
|
|
|
151
155
|
// 绘制area label
|
|
@@ -167,8 +171,36 @@ var Area = /*#__PURE__*/function (_BaseDraw) {
|
|
|
167
171
|
}, {
|
|
168
172
|
key: "_destroyAreaLabel",
|
|
169
173
|
value: function _destroyAreaLabel() {
|
|
170
|
-
this._areaLayer
|
|
171
|
-
|
|
174
|
+
this._areaLayer = this.destroyLabelLayer(this._areaLayer);
|
|
175
|
+
}
|
|
176
|
+
}, {
|
|
177
|
+
key: "_updateArea",
|
|
178
|
+
value: function _updateArea(positions) {
|
|
179
|
+
if (positions.length < 3) {
|
|
180
|
+
this._area = 0;
|
|
181
|
+
this._destroyAreaLabel();
|
|
182
|
+
return {
|
|
183
|
+
area: 0
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
var polygonPositions = this._toPolygonPositions(positions);
|
|
187
|
+
this._area = this._calculateArea(polygonPositions);
|
|
188
|
+
var center = centerOfMass(polygon([polygonPositions]));
|
|
189
|
+
var _center$geometry$coor = _slicedToArray(center.geometry.coordinates, 2),
|
|
190
|
+
lng = _center$geometry$coor[0],
|
|
191
|
+
lat = _center$geometry$coor[1];
|
|
192
|
+
this._createAreaLabel([lng, lat, 0], "\u9762\u79EF".concat(utils.formatArea(this._area)));
|
|
193
|
+
return {
|
|
194
|
+
area: this._area
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
}, {
|
|
198
|
+
key: "_toPolygonPositions",
|
|
199
|
+
value: function _toPolygonPositions(positions) {
|
|
200
|
+
if (positions.length < 3) {
|
|
201
|
+
return [];
|
|
202
|
+
}
|
|
203
|
+
return [].concat(_toConsumableArray(positions), [positions[0]]);
|
|
172
204
|
}
|
|
173
205
|
|
|
174
206
|
// 销毁
|
|
@@ -176,11 +208,11 @@ var Area = /*#__PURE__*/function (_BaseDraw) {
|
|
|
176
208
|
key: "destroy",
|
|
177
209
|
value: function destroy() {
|
|
178
210
|
if (!this._canOperate()) return;
|
|
179
|
-
|
|
180
|
-
this.
|
|
211
|
+
var layer = this._instance;
|
|
212
|
+
this._destroyAreaLabel();
|
|
181
213
|
this._instance = null;
|
|
182
|
-
|
|
183
|
-
this.
|
|
214
|
+
_get(_getPrototypeOf(Area.prototype), "destroy", this).call(this);
|
|
215
|
+
layer && this._drawer.removeDrawerLayer(layer);
|
|
184
216
|
}
|
|
185
217
|
}]);
|
|
186
218
|
return Area;
|
|
@@ -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;
|