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
|
@@ -0,0 +1,442 @@
|
|
|
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 _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; } }
|
|
5
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
6
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
7
|
+
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."); }
|
|
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
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
10
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
11
|
+
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; }
|
|
12
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
13
|
+
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); } }
|
|
14
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
15
|
+
function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
|
|
16
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
17
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
18
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
19
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
20
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
21
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
22
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
23
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
24
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
25
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
26
|
+
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); }
|
|
27
|
+
import * as Cesium from 'deeptwins-cesium';
|
|
28
|
+
import { isNil } from 'lodash';
|
|
29
|
+
import { getAttackArrowPoints } from "../common";
|
|
30
|
+
import * as utils from "../../tool/utils";
|
|
31
|
+
import { STATUS } from "../types";
|
|
32
|
+
import { normalizePolygonPositions } from "../utils";
|
|
33
|
+
import BaseShape from "./BaseShape";
|
|
34
|
+
import DragPoint from "./DragPoint";
|
|
35
|
+
import { ShapePolygon } from "./Polygon";
|
|
36
|
+
import { ShapePolyline } from "./Polyline";
|
|
37
|
+
|
|
38
|
+
// 攻击箭头至少需要 3 个控制点才能形成有效的面。
|
|
39
|
+
var MIN_ATTACK_ARROW_ANCHORS = 3;
|
|
40
|
+
var AttackArrow = /*#__PURE__*/function (_BaseShape) {
|
|
41
|
+
_inherits(AttackArrow, _BaseShape);
|
|
42
|
+
var _super = _createSuper(AttackArrow);
|
|
43
|
+
function AttackArrow(drawContext, config) {
|
|
44
|
+
var _this;
|
|
45
|
+
_classCallCheck(this, AttackArrow);
|
|
46
|
+
_this = _super.call(this, drawContext);
|
|
47
|
+
_defineProperty(_assertThisInitialized(_this), "type", 'attackArrow');
|
|
48
|
+
_defineProperty(_assertThisInitialized(_this), "shapePolylineLayer", void 0);
|
|
49
|
+
_defineProperty(_assertThisInitialized(_this), "shapePolygonLayer", void 0);
|
|
50
|
+
// 用户点击的控制点(用于编辑/还原),不同于 this.positions(渲染用特征点)。
|
|
51
|
+
_defineProperty(_assertThisInitialized(_this), "_anchorPositions", void 0);
|
|
52
|
+
// 绘制阶段用于预览的临时控制点(鼠标移动点)。
|
|
53
|
+
_defineProperty(_assertThisInitialized(_this), "_tempPosition", void 0);
|
|
54
|
+
_this._anchorPositions = [];
|
|
55
|
+
_this._tempPosition = null;
|
|
56
|
+
_this.clampToGround = isNil(config === null || config === void 0 ? void 0 : config.clampToGround) ? _this.clampToGround : config.clampToGround;
|
|
57
|
+
_this.pointStyle.heightReference = _this.clampToGround ? Cesium.HeightReference.CLAMP_TO_GROUND : Cesium.HeightReference.NONE;
|
|
58
|
+
_this.polylineStyle.clampToGround = _this.clampToGround;
|
|
59
|
+
if (_this.clampToGround) {
|
|
60
|
+
_this.polygonStyle.heightReference = Cesium.HeightReference.CLAMP_TO_GROUND;
|
|
61
|
+
_this.polygonStyle.perPositionHeight = false;
|
|
62
|
+
} else {
|
|
63
|
+
_this.polygonStyle.heightReference = Cesium.HeightReference.NONE;
|
|
64
|
+
_this.polygonStyle.perPositionHeight = true;
|
|
65
|
+
}
|
|
66
|
+
return _this;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// 鼠标事件位置统一转成内部经纬高三元组。
|
|
70
|
+
_createClass(AttackArrow, [{
|
|
71
|
+
key: "_toPositionTuple",
|
|
72
|
+
value: function _toPositionTuple(position) {
|
|
73
|
+
var lng = position.lng,
|
|
74
|
+
lat = position.lat,
|
|
75
|
+
_position$alt = position.alt,
|
|
76
|
+
alt = _position$alt === void 0 ? 0 : _position$alt;
|
|
77
|
+
return [lng, lat, alt];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// 贴地时高度统一为 0;非贴地时用所有控制点的平均高度近似。
|
|
81
|
+
}, {
|
|
82
|
+
key: "_getAltitudeBase",
|
|
83
|
+
value: function _getAltitudeBase(anchorPositions) {
|
|
84
|
+
if (this.clampToGround) {
|
|
85
|
+
return 0;
|
|
86
|
+
}
|
|
87
|
+
var altitudes = anchorPositions.map(function (position) {
|
|
88
|
+
return position === null || position === void 0 ? void 0 : position[2];
|
|
89
|
+
}).filter(function (altitude) {
|
|
90
|
+
return Number.isFinite(altitude);
|
|
91
|
+
});
|
|
92
|
+
if (!altitudes.length) {
|
|
93
|
+
return 0;
|
|
94
|
+
}
|
|
95
|
+
return altitudes.reduce(function (sum, altitude) {
|
|
96
|
+
return sum + altitude;
|
|
97
|
+
}, 0) / altitudes.length;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// 渲染外框始终闭合,便于绘制和编辑阶段预览边界。
|
|
101
|
+
}, {
|
|
102
|
+
key: "_getDrawPolylinePositions",
|
|
103
|
+
value: function _getDrawPolylinePositions() {
|
|
104
|
+
if (!this.positions.length) {
|
|
105
|
+
return [];
|
|
106
|
+
}
|
|
107
|
+
return [].concat(_toConsumableArray(this.positions), [this.positions[0]]);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// polygon 渲染末尾补首点形成闭环。
|
|
111
|
+
}, {
|
|
112
|
+
key: "_getDrawPolygonPositions",
|
|
113
|
+
value: function _getDrawPolygonPositions() {
|
|
114
|
+
if (!this.positions.length) {
|
|
115
|
+
return [];
|
|
116
|
+
}
|
|
117
|
+
return [].concat(_toConsumableArray(this.positions), [this.positions[0]]);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// 统一释放线框和面图层,避免绘制中断后残留几何。
|
|
121
|
+
}, {
|
|
122
|
+
key: "_destroyShapeLayers",
|
|
123
|
+
value: function _destroyShapeLayers() {
|
|
124
|
+
this.shapePolylineLayer && this.shapePolylineLayer.destroy();
|
|
125
|
+
this.shapePolylineLayer = null;
|
|
126
|
+
this.shapePolygonLayer && this.shapePolygonLayer.destroy();
|
|
127
|
+
this.shapePolygonLayer = null;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// 根据当前顶点数组同步线框和面图层。
|
|
131
|
+
}, {
|
|
132
|
+
key: "_syncShapeLayers",
|
|
133
|
+
value: function _syncShapeLayers() {
|
|
134
|
+
if (!this.positions.length) {
|
|
135
|
+
this._destroyShapeLayers();
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
var polylinePositions = this._getDrawPolylinePositions();
|
|
139
|
+
var polygonPositions = this._getDrawPolygonPositions();
|
|
140
|
+
if (!this.shapePolylineLayer) {
|
|
141
|
+
this.shapePolylineLayer = new ShapePolyline(this.getMap(), {
|
|
142
|
+
positions: polylinePositions,
|
|
143
|
+
style: this.polylineStyle
|
|
144
|
+
});
|
|
145
|
+
} else {
|
|
146
|
+
this.shapePolylineLayer.update(polylinePositions);
|
|
147
|
+
}
|
|
148
|
+
if (!this.shapePolygonLayer) {
|
|
149
|
+
this.shapePolygonLayer = new ShapePolygon(this.getMap(), {
|
|
150
|
+
positions: polygonPositions,
|
|
151
|
+
style: this.polygonStyle
|
|
152
|
+
});
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
this.shapePolygonLayer.update(polygonPositions);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// 参考 drawer/common.getAttackArrowPoints:用控制点计算攻击箭头特征点。
|
|
159
|
+
}, {
|
|
160
|
+
key: "_buildAttackArrowPositions",
|
|
161
|
+
value: function _buildAttackArrowPositions(anchorPositions) {
|
|
162
|
+
var _this2 = this;
|
|
163
|
+
if (anchorPositions.length < MIN_ATTACK_ARROW_ANCHORS) {
|
|
164
|
+
return [];
|
|
165
|
+
}
|
|
166
|
+
var anchorCartesians = anchorPositions.map(function (position) {
|
|
167
|
+
return _this2._toCartesian3(position);
|
|
168
|
+
}).filter(function (position) {
|
|
169
|
+
return Boolean(position);
|
|
170
|
+
});
|
|
171
|
+
if (anchorCartesians.length < MIN_ATTACK_ARROW_ANCHORS) {
|
|
172
|
+
return [];
|
|
173
|
+
}
|
|
174
|
+
var arrowPoints;
|
|
175
|
+
try {
|
|
176
|
+
arrowPoints = getAttackArrowPoints(anchorCartesians);
|
|
177
|
+
} catch (error) {
|
|
178
|
+
return [];
|
|
179
|
+
}
|
|
180
|
+
if (!Array.isArray(arrowPoints) || !arrowPoints.length) {
|
|
181
|
+
return [];
|
|
182
|
+
}
|
|
183
|
+
var altitudeBase = this._getAltitudeBase(anchorPositions);
|
|
184
|
+
var positions = arrowPoints.map(function (point) {
|
|
185
|
+
// 正常情况下这里返回 Cesium.Cartesian3[];仅兜底处理异常返回值。
|
|
186
|
+
if (Array.isArray(point) && point.length >= 2) {
|
|
187
|
+
var _point = _slicedToArray(point, 2),
|
|
188
|
+
_lng = _point[0],
|
|
189
|
+
_lat = _point[1];
|
|
190
|
+
if (!Number.isFinite(_lng) || !Number.isFinite(_lat)) {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
return [_lng, _lat, altitudeBase];
|
|
194
|
+
}
|
|
195
|
+
if (!point || _typeof(point) !== 'object' || !Number.isFinite(point.x) || !Number.isFinite(point.y) || !Number.isFinite(point.z)) {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
var _utils$cartesian3ToLn = utils.cartesian3ToLngLatAlt(point),
|
|
199
|
+
lng = _utils$cartesian3ToLn.lng,
|
|
200
|
+
lat = _utils$cartesian3ToLn.lat;
|
|
201
|
+
return [lng, lat, altitudeBase];
|
|
202
|
+
}).filter(function (position) {
|
|
203
|
+
return Boolean(position);
|
|
204
|
+
});
|
|
205
|
+
return normalizePolygonPositions(positions);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// 统一根据控制点更新特征点、渲染图层。
|
|
209
|
+
}, {
|
|
210
|
+
key: "_applyGeometry",
|
|
211
|
+
value: function _applyGeometry(anchorPositions) {
|
|
212
|
+
var positions = this._buildAttackArrowPositions(anchorPositions);
|
|
213
|
+
if (positions.length < 3) {
|
|
214
|
+
this.positions = [];
|
|
215
|
+
this._destroyShapeLayers();
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
this.positions = positions;
|
|
219
|
+
this._syncShapeLayers();
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// 绘制预览阶段透出当前攻击箭头面顶点数组。
|
|
224
|
+
}, {
|
|
225
|
+
key: "_emitMouseMoveChange",
|
|
226
|
+
value: function _emitMouseMoveChange() {
|
|
227
|
+
this._drawContext.options.onMouseMoveChange && this._drawContext.options.onMouseMoveChange({
|
|
228
|
+
layer: this,
|
|
229
|
+
positions: this.positions
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// 编辑态拖拽时透出最新攻击箭头面顶点数组。
|
|
234
|
+
}, {
|
|
235
|
+
key: "_emitPointsChange",
|
|
236
|
+
value: function _emitPointsChange() {
|
|
237
|
+
var _this$_drawContext$op, _this$_drawContext$op2;
|
|
238
|
+
((_this$_drawContext$op = this._drawContext.options) === null || _this$_drawContext$op === void 0 ? void 0 : _this$_drawContext$op.onPointsChange) && ((_this$_drawContext$op2 = this._drawContext.options) === null || _this$_drawContext$op2 === void 0 ? void 0 : _this$_drawContext$op2.onPointsChange({
|
|
239
|
+
layer: this,
|
|
240
|
+
positions: this.positions
|
|
241
|
+
}));
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// 统一完成绘制:入库、触发回调并进入编辑态。
|
|
245
|
+
}, {
|
|
246
|
+
key: "_finishDraw",
|
|
247
|
+
value: function _finishDraw() {
|
|
248
|
+
if (!this.positions.length) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
this._drawContext.setDrawerLayer(this.id, this);
|
|
252
|
+
this.drawEnd(this);
|
|
253
|
+
this.startEdit();
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// 基于 anchors 还原攻击箭头;缺少 anchors 时由 Drawer 回退为普通 polygon。
|
|
257
|
+
}, {
|
|
258
|
+
key: "transformData",
|
|
259
|
+
value: function transformData(_) {
|
|
260
|
+
var _this3 = this;
|
|
261
|
+
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
262
|
+
var anchors = config === null || config === void 0 ? void 0 : config.anchors;
|
|
263
|
+
if (!Array.isArray(anchors) || anchors.length < MIN_ATTACK_ARROW_ANCHORS) {
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
this._anchorPositions = anchors.filter(function (position) {
|
|
267
|
+
return Array.isArray(position) && position.length >= 2;
|
|
268
|
+
}).map(function (position) {
|
|
269
|
+
var _position = _slicedToArray(position, 3),
|
|
270
|
+
lng = _position[0],
|
|
271
|
+
lat = _position[1],
|
|
272
|
+
_position$ = _position[2],
|
|
273
|
+
alt = _position$ === void 0 ? 0 : _position$;
|
|
274
|
+
return [lng, lat, alt];
|
|
275
|
+
});
|
|
276
|
+
if (this._anchorPositions.length < MIN_ATTACK_ARROW_ANCHORS) {
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
279
|
+
if (!this._applyGeometry(this._anchorPositions)) {
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
this.dragPoints.forEach(function (point) {
|
|
283
|
+
return point.destroy();
|
|
284
|
+
});
|
|
285
|
+
this.dragPoints = [];
|
|
286
|
+
this._destroyMiddlePoints();
|
|
287
|
+
this._tempPosition = null;
|
|
288
|
+
this._anchorPositions.forEach(function (anchor, index) {
|
|
289
|
+
var point = new DragPoint(_this3.getMap(), {
|
|
290
|
+
positions: anchor,
|
|
291
|
+
style: _this3.pointStyle
|
|
292
|
+
});
|
|
293
|
+
point.isStart = index === 0;
|
|
294
|
+
point.endEdit();
|
|
295
|
+
point.show(false);
|
|
296
|
+
_this3.dragPoints.push(point);
|
|
297
|
+
});
|
|
298
|
+
this._drawContext.setDrawerLayer(this.id, this);
|
|
299
|
+
return true;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// 添加控制点;当控制点数满足算法要求时刷新特征点并渲染。
|
|
303
|
+
}, {
|
|
304
|
+
key: "addPoint",
|
|
305
|
+
value: function addPoint(position) {
|
|
306
|
+
var nextPosition = this._toPositionTuple(position);
|
|
307
|
+
this._anchorPositions.push(nextPosition);
|
|
308
|
+
this._tempPosition = null;
|
|
309
|
+
var point = new DragPoint(this.getMap(), {
|
|
310
|
+
positions: nextPosition,
|
|
311
|
+
style: this.pointStyle
|
|
312
|
+
});
|
|
313
|
+
point.isStart = this._anchorPositions.length === 1;
|
|
314
|
+
this.dragPoints.push(point);
|
|
315
|
+
if (this._anchorPositions.length >= MIN_ATTACK_ARROW_ANCHORS) {
|
|
316
|
+
this._applyGeometry(this._anchorPositions);
|
|
317
|
+
}
|
|
318
|
+
this.drawing(this);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// 删除上一个控制点(绘制阶段右键撤销)。
|
|
322
|
+
}, {
|
|
323
|
+
key: "removePrev",
|
|
324
|
+
value: function removePrev() {
|
|
325
|
+
if (!this._anchorPositions.length) {
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
var removeIndex = this._anchorPositions.length - 1;
|
|
329
|
+
this._anchorPositions.splice(removeIndex, 1);
|
|
330
|
+
if (this.dragPoints[removeIndex]) {
|
|
331
|
+
this.dragPoints[removeIndex].destroy();
|
|
332
|
+
this.dragPoints.splice(removeIndex, 1);
|
|
333
|
+
}
|
|
334
|
+
if (this._anchorPositions.length < 2) {
|
|
335
|
+
this.positions = [];
|
|
336
|
+
this._destroyShapeLayers();
|
|
337
|
+
} else {
|
|
338
|
+
var previewAnchors = this._tempPosition ? [].concat(_toConsumableArray(this._anchorPositions), [this._tempPosition]) : _toConsumableArray(this._anchorPositions);
|
|
339
|
+
this._applyGeometry(previewAnchors);
|
|
340
|
+
}
|
|
341
|
+
this.drawing(this);
|
|
342
|
+
this._emitMouseMoveChange();
|
|
343
|
+
if (!this._anchorPositions.length) {
|
|
344
|
+
this._drawContext._changeStatus(STATUS.START_DRAW);
|
|
345
|
+
this._drawContext._updateTooltip();
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// 更新临时控制点(绘制阶段鼠标移动预览)。
|
|
350
|
+
}, {
|
|
351
|
+
key: "updateTempPosition",
|
|
352
|
+
value: function updateTempPosition(position) {
|
|
353
|
+
if (this._anchorPositions.length < 2) {
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
var nextPosition = this._toPositionTuple(position);
|
|
357
|
+
this._tempPosition = nextPosition;
|
|
358
|
+
var previewAnchors = [].concat(_toConsumableArray(this._anchorPositions), [nextPosition]);
|
|
359
|
+
if (!this._applyGeometry(previewAnchors)) {
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
this._emitMouseMoveChange();
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// 结束绘制:收敛特征点并进入编辑态。
|
|
366
|
+
}, {
|
|
367
|
+
key: "endDraw",
|
|
368
|
+
value: function endDraw() {
|
|
369
|
+
if (this._anchorPositions.length < MIN_ATTACK_ARROW_ANCHORS) {
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
this._tempPosition = null;
|
|
373
|
+
if (!this._applyGeometry(this._anchorPositions)) {
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
this._finishDraw();
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// 开始编辑:沿用 Drawer 的多点编辑模式(端点+中间点插入)。
|
|
380
|
+
}, {
|
|
381
|
+
key: "startEdit",
|
|
382
|
+
value: function startEdit() {
|
|
383
|
+
if (this._anchorPositions.length < MIN_ATTACK_ARROW_ANCHORS) {
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
_get(_getPrototypeOf(AttackArrow.prototype), "startEdit", this).call(this);
|
|
387
|
+
this._startEdgeEditing();
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// 开始鼠标拖拽。
|
|
391
|
+
}, {
|
|
392
|
+
key: "mouseDragStart",
|
|
393
|
+
value: function mouseDragStart(position, dragLayer) {
|
|
394
|
+
this._handleDragStart(dragLayer);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// 鼠标拖拽:更新控制点并重新计算箭头特征点。
|
|
398
|
+
}, {
|
|
399
|
+
key: "mouseDragChange",
|
|
400
|
+
value: function mouseDragChange(position) {
|
|
401
|
+
if (!this.dragging || !this.dragLayer) {
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
this.dragLayer.mouseDragChange(position);
|
|
405
|
+
var anchorPositions = this._updatePositionsFromEdges();
|
|
406
|
+
if (!anchorPositions.length) {
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
this._anchorPositions = anchorPositions;
|
|
410
|
+
this._applyGeometry(this._anchorPositions);
|
|
411
|
+
this._emitPointsChange();
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// 拖拽结束:补齐新的中间点。
|
|
415
|
+
}, {
|
|
416
|
+
key: "mouseDragEnd",
|
|
417
|
+
value: function mouseDragEnd() {
|
|
418
|
+
this._handleDragEnd();
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// 结束编辑:隐藏控制点并销毁中间点。
|
|
422
|
+
}, {
|
|
423
|
+
key: "endEdit",
|
|
424
|
+
value: function endEdit(layer) {
|
|
425
|
+
var emitComplete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
426
|
+
_get(_getPrototypeOf(AttackArrow.prototype), "endEdit", this).call(this, layer, emitComplete);
|
|
427
|
+
this._stopEdgeEditing();
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// 销毁时同时清理渲染图层和内部几何状态。
|
|
431
|
+
}, {
|
|
432
|
+
key: "destroy",
|
|
433
|
+
value: function destroy() {
|
|
434
|
+
_get(_getPrototypeOf(AttackArrow.prototype), "destroy", this).call(this);
|
|
435
|
+
this._destroyShapeLayers();
|
|
436
|
+
this._anchorPositions = [];
|
|
437
|
+
this._tempPosition = null;
|
|
438
|
+
}
|
|
439
|
+
}]);
|
|
440
|
+
return AttackArrow;
|
|
441
|
+
}(BaseShape);
|
|
442
|
+
export default AttackArrow;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import * as Cesium from 'deeptwins-cesium';
|
|
2
|
+
import { DrawContext } from '../types';
|
|
3
|
+
import DragPoint from './DragPoint';
|
|
3
4
|
declare class BaseShape {
|
|
4
5
|
_drawContext: DrawContext;
|
|
5
6
|
id: string;
|
|
@@ -20,14 +21,23 @@ declare class BaseShape {
|
|
|
20
21
|
drawing(layer: any): void;
|
|
21
22
|
drawEnd(layer: any): void;
|
|
22
23
|
startEdit(): void;
|
|
23
|
-
endEdit(layer: any): void;
|
|
24
|
+
endEdit(layer: any, emitComplete?: boolean): void;
|
|
24
25
|
destroy(): void;
|
|
26
|
+
protected _toCartesian3(position: any): Cesium.Cartesian3 | null;
|
|
27
|
+
protected _createMiddlePointFromDragPoints(source: any, target: any): DragPoint | null;
|
|
25
28
|
_createEdgesAndMiddle(dragPoints: any[], isPolygon?: boolean): {
|
|
26
29
|
source: any;
|
|
27
30
|
target: any;
|
|
28
31
|
middlePoint: DragPoint;
|
|
29
32
|
}[];
|
|
33
|
+
protected _destroyMiddlePoints(): void;
|
|
34
|
+
protected _startEdgeEditing(isPolygon?: boolean): void;
|
|
35
|
+
protected _getChangedEdges(dragLayer?: any): any[];
|
|
36
|
+
protected _handleDragStart(dragLayer: any): void;
|
|
37
|
+
protected _handleDragChange(position: any): any;
|
|
38
|
+
protected _handleDragEnd(): void;
|
|
39
|
+
protected _stopEdgeEditing(): void;
|
|
30
40
|
_createTwoPointMiddle(position: any): DragPoint;
|
|
31
|
-
_updatePositionsFromEdges(): any[][]
|
|
41
|
+
_updatePositionsFromEdges(): any[][];
|
|
32
42
|
}
|
|
33
43
|
export default BaseShape;
|