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
|
@@ -0,0 +1,445 @@
|
|
|
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 { calculatePincerArrowPoint } 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 个控制点,绘制阶段最多保留 5 个控制点。
|
|
39
|
+
var MIN_PINCER_ARROW_ANCHORS = 3;
|
|
40
|
+
var MAX_PINCER_ARROW_ANCHORS = 5;
|
|
41
|
+
var PincerArrow = /*#__PURE__*/function (_BaseShape) {
|
|
42
|
+
_inherits(PincerArrow, _BaseShape);
|
|
43
|
+
var _super = _createSuper(PincerArrow);
|
|
44
|
+
function PincerArrow(drawContext, config) {
|
|
45
|
+
var _this;
|
|
46
|
+
_classCallCheck(this, PincerArrow);
|
|
47
|
+
_this = _super.call(this, drawContext);
|
|
48
|
+
_defineProperty(_assertThisInitialized(_this), "type", 'pincerArrow');
|
|
49
|
+
_defineProperty(_assertThisInitialized(_this), "shapePolylineLayer", void 0);
|
|
50
|
+
_defineProperty(_assertThisInitialized(_this), "shapePolygonLayer", void 0);
|
|
51
|
+
// 用户控制点用于编辑/还原,渲染时使用算法输出的特征点。
|
|
52
|
+
_defineProperty(_assertThisInitialized(_this), "_anchorPositions", void 0);
|
|
53
|
+
// 绘制阶段的鼠标预览点,不会写入最终控制点数组。
|
|
54
|
+
_defineProperty(_assertThisInitialized(_this), "_tempPosition", void 0);
|
|
55
|
+
_this._anchorPositions = [];
|
|
56
|
+
_this._tempPosition = null;
|
|
57
|
+
_this.clampToGround = isNil(config === null || config === void 0 ? void 0 : config.clampToGround) ? _this.clampToGround : config.clampToGround;
|
|
58
|
+
_this.pointStyle.heightReference = _this.clampToGround ? Cesium.HeightReference.CLAMP_TO_GROUND : Cesium.HeightReference.NONE;
|
|
59
|
+
_this.polylineStyle.clampToGround = _this.clampToGround;
|
|
60
|
+
if (_this.clampToGround) {
|
|
61
|
+
_this.polygonStyle.heightReference = Cesium.HeightReference.CLAMP_TO_GROUND;
|
|
62
|
+
_this.polygonStyle.perPositionHeight = false;
|
|
63
|
+
} else {
|
|
64
|
+
_this.polygonStyle.heightReference = Cesium.HeightReference.NONE;
|
|
65
|
+
_this.polygonStyle.perPositionHeight = true;
|
|
66
|
+
}
|
|
67
|
+
return _this;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// 鼠标事件位置统一转成内部经纬高三元组。
|
|
71
|
+
_createClass(PincerArrow, [{
|
|
72
|
+
key: "_toPositionTuple",
|
|
73
|
+
value: function _toPositionTuple(position) {
|
|
74
|
+
var lng = position.lng,
|
|
75
|
+
lat = position.lat,
|
|
76
|
+
_position$alt = position.alt,
|
|
77
|
+
alt = _position$alt === void 0 ? 0 : _position$alt;
|
|
78
|
+
return [lng, lat, alt];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// 贴地时高度统一为 0;非贴地时用控制点平均高度近似。
|
|
82
|
+
}, {
|
|
83
|
+
key: "_getAltitudeBase",
|
|
84
|
+
value: function _getAltitudeBase(anchorPositions) {
|
|
85
|
+
if (this.clampToGround) {
|
|
86
|
+
return 0;
|
|
87
|
+
}
|
|
88
|
+
var altitudes = anchorPositions.map(function (position) {
|
|
89
|
+
return position === null || position === void 0 ? void 0 : position[2];
|
|
90
|
+
}).filter(function (altitude) {
|
|
91
|
+
return Number.isFinite(altitude);
|
|
92
|
+
});
|
|
93
|
+
if (!altitudes.length) {
|
|
94
|
+
return 0;
|
|
95
|
+
}
|
|
96
|
+
return altitudes.reduce(function (sum, altitude) {
|
|
97
|
+
return sum + altitude;
|
|
98
|
+
}, 0) / altitudes.length;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// 渲染外框始终闭合,便于绘制和编辑阶段预览边界。
|
|
102
|
+
}, {
|
|
103
|
+
key: "_getDrawPolylinePositions",
|
|
104
|
+
value: function _getDrawPolylinePositions() {
|
|
105
|
+
if (!this.positions.length) {
|
|
106
|
+
return [];
|
|
107
|
+
}
|
|
108
|
+
return [].concat(_toConsumableArray(this.positions), [this.positions[0]]);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// polygon 渲染末尾补首点形成闭环。
|
|
112
|
+
}, {
|
|
113
|
+
key: "_getDrawPolygonPositions",
|
|
114
|
+
value: function _getDrawPolygonPositions() {
|
|
115
|
+
if (!this.positions.length) {
|
|
116
|
+
return [];
|
|
117
|
+
}
|
|
118
|
+
return [].concat(_toConsumableArray(this.positions), [this.positions[0]]);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// 统一释放线框和面图层,避免绘制中断后残留几何。
|
|
122
|
+
}, {
|
|
123
|
+
key: "_destroyShapeLayers",
|
|
124
|
+
value: function _destroyShapeLayers() {
|
|
125
|
+
this.shapePolylineLayer && this.shapePolylineLayer.destroy();
|
|
126
|
+
this.shapePolylineLayer = null;
|
|
127
|
+
this.shapePolygonLayer && this.shapePolygonLayer.destroy();
|
|
128
|
+
this.shapePolygonLayer = null;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// 根据当前顶点数组同步线框和面图层。
|
|
132
|
+
}, {
|
|
133
|
+
key: "_syncShapeLayers",
|
|
134
|
+
value: function _syncShapeLayers() {
|
|
135
|
+
if (!this.positions.length) {
|
|
136
|
+
this._destroyShapeLayers();
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
var polylinePositions = this._getDrawPolylinePositions();
|
|
140
|
+
var polygonPositions = this._getDrawPolygonPositions();
|
|
141
|
+
if (!this.shapePolylineLayer) {
|
|
142
|
+
this.shapePolylineLayer = new ShapePolyline(this.getMap(), {
|
|
143
|
+
positions: polylinePositions,
|
|
144
|
+
style: this.polylineStyle
|
|
145
|
+
});
|
|
146
|
+
} else {
|
|
147
|
+
this.shapePolylineLayer.update(polylinePositions);
|
|
148
|
+
}
|
|
149
|
+
if (!this.shapePolygonLayer) {
|
|
150
|
+
this.shapePolygonLayer = new ShapePolygon(this.getMap(), {
|
|
151
|
+
positions: polygonPositions,
|
|
152
|
+
style: this.polygonStyle
|
|
153
|
+
});
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
this.shapePolygonLayer.update(polygonPositions);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// 参考 drawer/common.calculatePincerArrowPoint:用控制点计算钳击箭头特征点。
|
|
160
|
+
}, {
|
|
161
|
+
key: "_buildPincerArrowPositions",
|
|
162
|
+
value: function _buildPincerArrowPositions(anchorPositions) {
|
|
163
|
+
var _this2 = this;
|
|
164
|
+
if (anchorPositions.length < MIN_PINCER_ARROW_ANCHORS) {
|
|
165
|
+
return [];
|
|
166
|
+
}
|
|
167
|
+
var anchorCartesians = anchorPositions.map(function (position) {
|
|
168
|
+
return _this2._toCartesian3(position);
|
|
169
|
+
}).filter(function (position) {
|
|
170
|
+
return Boolean(position);
|
|
171
|
+
});
|
|
172
|
+
if (anchorCartesians.length < MIN_PINCER_ARROW_ANCHORS) {
|
|
173
|
+
return [];
|
|
174
|
+
}
|
|
175
|
+
var arrowPoints;
|
|
176
|
+
try {
|
|
177
|
+
arrowPoints = calculatePincerArrowPoint(anchorCartesians);
|
|
178
|
+
} catch (error) {
|
|
179
|
+
return [];
|
|
180
|
+
}
|
|
181
|
+
if (!Array.isArray(arrowPoints) || !arrowPoints.length) {
|
|
182
|
+
return [];
|
|
183
|
+
}
|
|
184
|
+
var altitudeBase = this._getAltitudeBase(anchorPositions);
|
|
185
|
+
var positions = arrowPoints.map(function (point) {
|
|
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._buildPincerArrowPositions(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_PINCER_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_PINCER_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
|
+
if (this._anchorPositions.length >= MAX_PINCER_ARROW_ANCHORS) {
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
var nextPosition = this._toPositionTuple(position);
|
|
310
|
+
this._anchorPositions.push(nextPosition);
|
|
311
|
+
this._tempPosition = null;
|
|
312
|
+
var point = new DragPoint(this.getMap(), {
|
|
313
|
+
positions: nextPosition,
|
|
314
|
+
style: this.pointStyle
|
|
315
|
+
});
|
|
316
|
+
point.isStart = this._anchorPositions.length === 1;
|
|
317
|
+
this.dragPoints.push(point);
|
|
318
|
+
if (this._anchorPositions.length >= MIN_PINCER_ARROW_ANCHORS) {
|
|
319
|
+
this._applyGeometry(this._anchorPositions);
|
|
320
|
+
}
|
|
321
|
+
this.drawing(this);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// 删除上一个控制点(绘制阶段右键撤销)。
|
|
325
|
+
}, {
|
|
326
|
+
key: "removePrev",
|
|
327
|
+
value: function removePrev() {
|
|
328
|
+
if (!this._anchorPositions.length) {
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
var removeIndex = this._anchorPositions.length - 1;
|
|
332
|
+
this._anchorPositions.splice(removeIndex, 1);
|
|
333
|
+
if (this.dragPoints[removeIndex]) {
|
|
334
|
+
this.dragPoints[removeIndex].destroy();
|
|
335
|
+
this.dragPoints.splice(removeIndex, 1);
|
|
336
|
+
}
|
|
337
|
+
var previewAnchors = this._tempPosition ? [].concat(_toConsumableArray(this._anchorPositions), [this._tempPosition]) : _toConsumableArray(this._anchorPositions);
|
|
338
|
+
if (previewAnchors.length >= MIN_PINCER_ARROW_ANCHORS) {
|
|
339
|
+
this._applyGeometry(previewAnchors);
|
|
340
|
+
} else {
|
|
341
|
+
this.positions = [];
|
|
342
|
+
this._destroyShapeLayers();
|
|
343
|
+
}
|
|
344
|
+
this.drawing(this);
|
|
345
|
+
this._emitMouseMoveChange();
|
|
346
|
+
if (!this._anchorPositions.length) {
|
|
347
|
+
this._drawContext._changeStatus(STATUS.START_DRAW);
|
|
348
|
+
this._drawContext._updateTooltip();
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// 更新临时控制点(绘制阶段鼠标移动预览)。
|
|
353
|
+
}, {
|
|
354
|
+
key: "updateTempPosition",
|
|
355
|
+
value: function updateTempPosition(position) {
|
|
356
|
+
if (this._anchorPositions.length < 2 || this._anchorPositions.length >= MAX_PINCER_ARROW_ANCHORS) {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
var nextPosition = this._toPositionTuple(position);
|
|
360
|
+
this._tempPosition = nextPosition;
|
|
361
|
+
var previewAnchors = [].concat(_toConsumableArray(this._anchorPositions), [nextPosition]);
|
|
362
|
+
if (!this._applyGeometry(previewAnchors)) {
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
this._emitMouseMoveChange();
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// 结束绘制:收敛特征点并进入编辑态。
|
|
369
|
+
}, {
|
|
370
|
+
key: "endDraw",
|
|
371
|
+
value: function endDraw() {
|
|
372
|
+
if (this._anchorPositions.length < MIN_PINCER_ARROW_ANCHORS) {
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
this._tempPosition = null;
|
|
376
|
+
if (!this._applyGeometry(this._anchorPositions)) {
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
this._finishDraw();
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// 开始编辑:沿用 Drawer 的多点编辑模式(端点 + 中间点插入)。
|
|
383
|
+
}, {
|
|
384
|
+
key: "startEdit",
|
|
385
|
+
value: function startEdit() {
|
|
386
|
+
if (this._anchorPositions.length < MIN_PINCER_ARROW_ANCHORS) {
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
_get(_getPrototypeOf(PincerArrow.prototype), "startEdit", this).call(this);
|
|
390
|
+
this._startEdgeEditing();
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// 开始鼠标拖拽。
|
|
394
|
+
}, {
|
|
395
|
+
key: "mouseDragStart",
|
|
396
|
+
value: function mouseDragStart(position, dragLayer) {
|
|
397
|
+
this._handleDragStart(dragLayer);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// 鼠标拖拽:更新控制点并重新计算钳击箭头特征点。
|
|
401
|
+
}, {
|
|
402
|
+
key: "mouseDragChange",
|
|
403
|
+
value: function mouseDragChange(position) {
|
|
404
|
+
if (!this.dragging || !this.dragLayer) {
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
this.dragLayer.mouseDragChange(position);
|
|
408
|
+
var anchorPositions = this._updatePositionsFromEdges();
|
|
409
|
+
if (!anchorPositions.length) {
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
this._anchorPositions = anchorPositions;
|
|
413
|
+
this._applyGeometry(this._anchorPositions);
|
|
414
|
+
this._emitPointsChange();
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// 拖拽结束:补齐新的中间点。
|
|
418
|
+
}, {
|
|
419
|
+
key: "mouseDragEnd",
|
|
420
|
+
value: function mouseDragEnd() {
|
|
421
|
+
this._handleDragEnd();
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// 结束编辑:隐藏控制点并销毁中间点。
|
|
425
|
+
}, {
|
|
426
|
+
key: "endEdit",
|
|
427
|
+
value: function endEdit(layer) {
|
|
428
|
+
var emitComplete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
429
|
+
_get(_getPrototypeOf(PincerArrow.prototype), "endEdit", this).call(this, layer, emitComplete);
|
|
430
|
+
this._stopEdgeEditing();
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// 销毁时同时清理渲染图层和内部几何状态。
|
|
434
|
+
}, {
|
|
435
|
+
key: "destroy",
|
|
436
|
+
value: function destroy() {
|
|
437
|
+
_get(_getPrototypeOf(PincerArrow.prototype), "destroy", this).call(this);
|
|
438
|
+
this._destroyShapeLayers();
|
|
439
|
+
this._anchorPositions = [];
|
|
440
|
+
this._tempPosition = null;
|
|
441
|
+
}
|
|
442
|
+
}]);
|
|
443
|
+
return PincerArrow;
|
|
444
|
+
}(BaseShape);
|
|
445
|
+
export default PincerArrow;
|
|
@@ -1,34 +1,5 @@
|
|
|
1
1
|
import BaseShape from './BaseShape';
|
|
2
|
-
export
|
|
3
|
-
private readonly _mapContext;
|
|
4
|
-
id: string;
|
|
5
|
-
layer: any;
|
|
6
|
-
isEditing: boolean;
|
|
7
|
-
isMiddlePoint: boolean;
|
|
8
|
-
isDestroyed: boolean;
|
|
9
|
-
labelLayer: any;
|
|
10
|
-
private _geoJson;
|
|
11
|
-
private _style;
|
|
12
|
-
/**
|
|
13
|
-
* 构造函数,用于创建一个地图元素实例
|
|
14
|
-
* @param map 地图对象,包含地图上下文信息
|
|
15
|
-
* @param options 配置选项对象
|
|
16
|
-
* @param options.positions 点的坐标位置数组
|
|
17
|
-
* @param options.style 样式配置
|
|
18
|
-
* @param options.isMiddlePoint 是否为中间点的标识,默认为false
|
|
19
|
-
*/
|
|
20
|
-
constructor(map: any, { positions, style, isMiddlePoint }: any);
|
|
21
|
-
getMap(): any;
|
|
22
|
-
private _canOperate;
|
|
23
|
-
private _create;
|
|
24
|
-
private _createLabel;
|
|
25
|
-
startEdit(): void;
|
|
26
|
-
mouseDragStart(): void;
|
|
27
|
-
mouseDragChange(position: any): void;
|
|
28
|
-
endEdit(): void;
|
|
29
|
-
show(isShow: boolean): void;
|
|
30
|
-
destroy(): void;
|
|
31
|
-
}
|
|
2
|
+
export { default as DragPoint } from './DragPoint';
|
|
32
3
|
declare class Point extends BaseShape {
|
|
33
4
|
readonly type: string;
|
|
34
5
|
shapePointLayer: any;
|
|
@@ -39,7 +10,7 @@ declare class Point extends BaseShape {
|
|
|
39
10
|
mouseDragStart(position: any, dragLayer: any): void;
|
|
40
11
|
mouseDragChange(position: any): void;
|
|
41
12
|
mouseDragEnd(): void;
|
|
42
|
-
endEdit(layer: any): void;
|
|
13
|
+
endEdit(layer: any, emitComplete?: boolean): void;
|
|
43
14
|
destroy(): void;
|
|
44
15
|
}
|
|
45
16
|
export default Point;
|