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.
Files changed (177) hide show
  1. package/dist/assets/Build/DeepTwins/Workers/MvtVector.worker.js +1 -0
  2. package/dist/esm/{plot/utils/Algorithm.js → drawer/algorithm.js} +1 -3
  3. package/dist/esm/drawer/common.d.ts +61 -0
  4. package/dist/esm/{plot/utils/PlotCommon.js → drawer/common.js} +104 -551
  5. package/dist/esm/{plot/utils/Coordinate.d.ts → drawer/coordinate.d.ts} +1 -1
  6. package/dist/esm/drawer/index.d.ts +11 -18
  7. package/dist/esm/drawer/index.js +329 -80
  8. package/dist/esm/{plot/utils → drawer}/plotUtil.js +1 -3
  9. package/dist/esm/drawer/shape/Assemble.d.ts +34 -0
  10. package/dist/esm/drawer/shape/Assemble.js +415 -0
  11. package/dist/esm/drawer/shape/AttackArrow.d.ts +32 -0
  12. package/dist/esm/drawer/shape/AttackArrow.js +442 -0
  13. package/dist/esm/drawer/shape/BaseShape.d.ts +14 -4
  14. package/dist/esm/drawer/shape/BaseShape.js +175 -20
  15. package/dist/esm/drawer/shape/Bow.d.ts +31 -0
  16. package/dist/esm/drawer/shape/Bow.js +375 -0
  17. package/dist/esm/drawer/shape/Circle.d.ts +37 -0
  18. package/dist/esm/drawer/shape/Circle.js +461 -0
  19. package/dist/esm/drawer/shape/Curve.d.ts +29 -0
  20. package/dist/esm/drawer/shape/Curve.js +386 -0
  21. package/dist/esm/drawer/shape/DragPoint.d.ts +32 -0
  22. package/dist/esm/drawer/shape/DragPoint.js +211 -0
  23. package/dist/esm/drawer/shape/Elliptic.d.ts +38 -0
  24. package/dist/esm/drawer/shape/Elliptic.js +491 -0
  25. package/dist/esm/drawer/shape/Formation.d.ts +33 -0
  26. package/dist/esm/drawer/shape/Formation.js +395 -0
  27. package/dist/esm/drawer/shape/PincerArrow.d.ts +32 -0
  28. package/dist/esm/drawer/shape/PincerArrow.js +445 -0
  29. package/dist/esm/drawer/shape/Point.d.ts +2 -31
  30. package/dist/esm/drawer/shape/Point.js +7 -201
  31. package/dist/esm/drawer/shape/Polygon.d.ts +1 -1
  32. package/dist/esm/drawer/shape/Polygon.js +10 -81
  33. package/dist/esm/drawer/shape/Polyline.d.ts +1 -1
  34. package/dist/esm/drawer/shape/Polyline.js +10 -81
  35. package/dist/esm/drawer/shape/RegularPolygon.d.ts +37 -0
  36. package/dist/esm/drawer/shape/RegularPolygon.js +468 -0
  37. package/dist/esm/drawer/shape/RightAngleArrow.d.ts +34 -0
  38. package/dist/esm/drawer/shape/RightAngleArrow.js +423 -0
  39. package/dist/esm/drawer/shape/Sector.d.ts +37 -0
  40. package/dist/esm/drawer/shape/Sector.js +568 -0
  41. package/dist/esm/drawer/shape/StraightArrow.d.ts +34 -0
  42. package/dist/esm/drawer/shape/StraightArrow.js +422 -0
  43. package/dist/esm/drawer/shape/SwallowtailArrow.d.ts +36 -0
  44. package/dist/esm/drawer/shape/SwallowtailArrow.js +438 -0
  45. package/dist/esm/drawer/types.d.ts +23 -0
  46. package/dist/esm/drawer/types.js +11 -0
  47. package/dist/esm/drawer/utils.d.ts +14 -0
  48. package/dist/esm/drawer/utils.js +320 -2
  49. package/dist/esm/graphicLayer/BaseSource.d.ts +1 -1
  50. package/dist/esm/index.d.ts +1 -0
  51. package/dist/esm/index.js +5 -3
  52. package/dist/esm/measure/Area.d.ts +17 -17
  53. package/dist/esm/measure/Area.js +95 -63
  54. package/dist/esm/measure/BaseDraw.d.ts +9 -4
  55. package/dist/esm/measure/BaseDraw.js +37 -2
  56. package/dist/esm/measure/Distance.d.ts +9 -9
  57. package/dist/esm/measure/Distance.js +52 -68
  58. package/dist/esm/measure/index.d.ts +16 -26
  59. package/dist/esm/measure/index.js +72 -84
  60. package/dist/esm/measure/types.d.ts +94 -0
  61. package/dist/esm/measure/types.js +17 -0
  62. package/dist/esm/measure/utils.d.ts +7 -7
  63. package/dist/esm/measure/utils.js +43 -24
  64. package/dist/esm/tileLayer/MvtVectorLoad.d.ts +241 -0
  65. package/dist/esm/tileLayer/MvtVectorLoad.js +1353 -0
  66. package/dist/esm/tileLayer/MvtVectorWorkerClient.d.ts +25 -0
  67. package/dist/esm/tileLayer/MvtVectorWorkerClient.js +126 -0
  68. package/dist/esm/tool/utils.js +1 -1
  69. package/dist/umd/deeptwins-engine-3d.min.js +1 -1
  70. package/package.json +2 -1
  71. package/dist/assets/Build/DeepTwins/Image/compass/pointer-white.png +0 -0
  72. package/dist/esm/plot/create/CreateAssemble.d.ts +0 -2
  73. package/dist/esm/plot/create/CreateAssemble.js +0 -63
  74. package/dist/esm/plot/create/CreateAttackArrow.d.ts +0 -5
  75. package/dist/esm/plot/create/CreateAttackArrow.js +0 -75
  76. package/dist/esm/plot/create/CreateBillboard.d.ts +0 -2
  77. package/dist/esm/plot/create/CreateBillboard.js +0 -47
  78. package/dist/esm/plot/create/CreateBow.d.ts +0 -2
  79. package/dist/esm/plot/create/CreateBow.js +0 -63
  80. package/dist/esm/plot/create/CreateCircle.d.ts +0 -2
  81. package/dist/esm/plot/create/CreateCircle.js +0 -68
  82. package/dist/esm/plot/create/CreateCurve.d.ts +0 -2
  83. package/dist/esm/plot/create/CreateCurve.js +0 -76
  84. package/dist/esm/plot/create/CreateElliptic.d.ts +0 -2
  85. package/dist/esm/plot/create/CreateElliptic.js +0 -69
  86. package/dist/esm/plot/create/CreateFlag.d.ts +0 -2
  87. package/dist/esm/plot/create/CreateFlag.js +0 -80
  88. package/dist/esm/plot/create/CreateFormation.d.ts +0 -2
  89. package/dist/esm/plot/create/CreateFormation.js +0 -65
  90. package/dist/esm/plot/create/CreateFreeLine.d.ts +0 -2
  91. package/dist/esm/plot/create/CreateFreeLine.js +0 -69
  92. package/dist/esm/plot/create/CreateFreePolygon.d.ts +0 -2
  93. package/dist/esm/plot/create/CreateFreePolygon.js +0 -65
  94. package/dist/esm/plot/create/CreateLabel.d.ts +0 -2
  95. package/dist/esm/plot/create/CreateLabel.js +0 -55
  96. package/dist/esm/plot/create/CreateLineArrow.d.ts +0 -2
  97. package/dist/esm/plot/create/CreateLineArrow.js +0 -79
  98. package/dist/esm/plot/create/CreatePincerArrow.d.ts +0 -5
  99. package/dist/esm/plot/create/CreatePincerArrow.js +0 -73
  100. package/dist/esm/plot/create/CreatePoint.d.ts +0 -2
  101. package/dist/esm/plot/create/CreatePoint.js +0 -47
  102. package/dist/esm/plot/create/CreatePolygon.d.ts +0 -2
  103. package/dist/esm/plot/create/CreatePolygon.js +0 -80
  104. package/dist/esm/plot/create/CreatePolyline.d.ts +0 -2
  105. package/dist/esm/plot/create/CreatePolyline.js +0 -70
  106. package/dist/esm/plot/create/CreateRectangle.d.ts +0 -2
  107. package/dist/esm/plot/create/CreateRectangle.js +0 -60
  108. package/dist/esm/plot/create/CreateRegularPolygon.d.ts +0 -2
  109. package/dist/esm/plot/create/CreateRegularPolygon.js +0 -75
  110. package/dist/esm/plot/create/CreateRightAngleArrow.d.ts +0 -5
  111. package/dist/esm/plot/create/CreateRightAngleArrow.js +0 -73
  112. package/dist/esm/plot/create/CreateRoundRectangle.d.ts +0 -2
  113. package/dist/esm/plot/create/CreateRoundRectangle.js +0 -63
  114. package/dist/esm/plot/create/CreateSector.d.ts +0 -2
  115. package/dist/esm/plot/create/CreateSector.js +0 -65
  116. package/dist/esm/plot/create/CreateStraightArrow.d.ts +0 -5
  117. package/dist/esm/plot/create/CreateStraightArrow.js +0 -65
  118. package/dist/esm/plot/create/CreateSwallowtailArrow.d.ts +0 -5
  119. package/dist/esm/plot/create/CreateSwallowtailArrow.js +0 -67
  120. package/dist/esm/plot/create/index.d.ts +0 -25
  121. package/dist/esm/plot/create/index.js +0 -25
  122. package/dist/esm/plot/edit/EditAssemble.d.ts +0 -8
  123. package/dist/esm/plot/edit/EditAssemble.js +0 -120
  124. package/dist/esm/plot/edit/EditAttackArrow.d.ts +0 -8
  125. package/dist/esm/plot/edit/EditAttackArrow.js +0 -182
  126. package/dist/esm/plot/edit/EditBillboard.d.ts +0 -7
  127. package/dist/esm/plot/edit/EditBillboard.js +0 -70
  128. package/dist/esm/plot/edit/EditBow.d.ts +0 -8
  129. package/dist/esm/plot/edit/EditBow.js +0 -119
  130. package/dist/esm/plot/edit/EditCircle.d.ts +0 -8
  131. package/dist/esm/plot/edit/EditCircle.js +0 -133
  132. package/dist/esm/plot/edit/EditCurve.d.ts +0 -8
  133. package/dist/esm/plot/edit/EditCurve.js +0 -180
  134. package/dist/esm/plot/edit/EditElliptic.d.ts +0 -8
  135. package/dist/esm/plot/edit/EditElliptic.js +0 -144
  136. package/dist/esm/plot/edit/EditFlag.d.ts +0 -8
  137. package/dist/esm/plot/edit/EditFlag.js +0 -121
  138. package/dist/esm/plot/edit/EditFormation.d.ts +0 -8
  139. package/dist/esm/plot/edit/EditFormation.js +0 -120
  140. package/dist/esm/plot/edit/EditLabel.d.ts +0 -7
  141. package/dist/esm/plot/edit/EditLabel.js +0 -100
  142. package/dist/esm/plot/edit/EditLineArrow.d.ts +0 -8
  143. package/dist/esm/plot/edit/EditLineArrow.js +0 -180
  144. package/dist/esm/plot/edit/EditPincerArrow.d.ts +0 -8
  145. package/dist/esm/plot/edit/EditPincerArrow.js +0 -121
  146. package/dist/esm/plot/edit/EditPoint.d.ts +0 -7
  147. package/dist/esm/plot/edit/EditPoint.js +0 -70
  148. package/dist/esm/plot/edit/EditPolygon.d.ts +0 -8
  149. package/dist/esm/plot/edit/EditPolygon.js +0 -181
  150. package/dist/esm/plot/edit/EditPolyline.d.ts +0 -8
  151. package/dist/esm/plot/edit/EditPolyline.js +0 -179
  152. package/dist/esm/plot/edit/EditRectangle.d.ts +0 -8
  153. package/dist/esm/plot/edit/EditRectangle.js +0 -119
  154. package/dist/esm/plot/edit/EditRegularPolygon.d.ts +0 -8
  155. package/dist/esm/plot/edit/EditRegularPolygon.js +0 -170
  156. package/dist/esm/plot/edit/EditRightAngleArrow.d.ts +0 -8
  157. package/dist/esm/plot/edit/EditRightAngleArrow.js +0 -143
  158. package/dist/esm/plot/edit/EditRoundRectangle.d.ts +0 -8
  159. package/dist/esm/plot/edit/EditRoundRectangle.js +0 -119
  160. package/dist/esm/plot/edit/EditSector.d.ts +0 -8
  161. package/dist/esm/plot/edit/EditSector.js +0 -120
  162. package/dist/esm/plot/edit/EditStraightArrow.d.ts +0 -8
  163. package/dist/esm/plot/edit/EditStraightArrow.js +0 -120
  164. package/dist/esm/plot/edit/EditSwallowtailArrow.d.ts +0 -8
  165. package/dist/esm/plot/edit/EditSwallowtailArrow.js +0 -121
  166. package/dist/esm/plot/edit/index.d.ts +0 -23
  167. package/dist/esm/plot/edit/index.js +0 -23
  168. package/dist/esm/plot/utils/DomUtil.d.ts +0 -34
  169. package/dist/esm/plot/utils/DomUtil.js +0 -100
  170. package/dist/esm/plot/utils/PlotCommon.d.ts +0 -101
  171. package/dist/esm/plot/utils/ReminderTip.d.ts +0 -10
  172. package/dist/esm/plot/utils/ReminderTip.js +0 -67
  173. package/dist/esm/plot/utils/Tooltip.d.ts +0 -3
  174. package/dist/esm/plot/utils/Tooltip.js +0 -97
  175. /package/dist/esm/{plot/utils/Algorithm.d.ts → drawer/algorithm.d.ts} +0 -0
  176. /package/dist/esm/{plot/utils/Coordinate.js → drawer/coordinate.js} +0 -0
  177. /package/dist/esm/{plot/utils → drawer}/plotUtil.d.ts +0 -0
@@ -0,0 +1,438 @@
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
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."); }
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 _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
+ 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; }
8
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9
+ 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); } }
10
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
11
+ 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); }
12
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
13
+ 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); }
14
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
15
+ 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); }; }
16
+ 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); }
17
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
18
+ 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; } }
19
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
20
+ 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; }
21
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
22
+ 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); }
23
+ import * as Cesium from 'deeptwins-cesium';
24
+ import { isNil } from 'lodash';
25
+ import { calculateSwallowPoints } from "../common";
26
+ import { STATUS } from "../types";
27
+ import { normalizePolygonPositions } from "../utils";
28
+ import BaseShape from "./BaseShape";
29
+ import DragPoint from "./DragPoint";
30
+ import { ShapePolygon } from "./Polygon";
31
+ import { ShapePolyline } from "./Polyline";
32
+ var SwallowtailArrow = /*#__PURE__*/function (_BaseShape) {
33
+ _inherits(SwallowtailArrow, _BaseShape);
34
+ var _super = _createSuper(SwallowtailArrow);
35
+ function SwallowtailArrow(drawContext, config) {
36
+ var _config$swallowtailTy;
37
+ var _this;
38
+ _classCallCheck(this, SwallowtailArrow);
39
+ _this = _super.call(this, drawContext);
40
+ _defineProperty(_assertThisInitialized(_this), "type", 'swallowtailArrow');
41
+ _defineProperty(_assertThisInitialized(_this), "shapePolylineLayer", void 0);
42
+ _defineProperty(_assertThisInitialized(_this), "shapePolygonLayer", void 0);
43
+ _defineProperty(_assertThisInitialized(_this), "_startPosition", void 0);
44
+ _defineProperty(_assertThisInitialized(_this), "_endPosition", void 0);
45
+ _defineProperty(_assertThisInitialized(_this), "_swallowtailType", void 0);
46
+ _this._startPosition = null;
47
+ _this._endPosition = null;
48
+ _this._swallowtailType = _this._normalizeSwallowtailType((_config$swallowtailTy = config === null || config === void 0 ? void 0 : config.swallowtailType) !== null && _config$swallowtailTy !== void 0 ? _config$swallowtailTy : config === null || config === void 0 ? void 0 : config.type);
49
+ _this.clampToGround = isNil(config === null || config === void 0 ? void 0 : config.clampToGround) ? _this.clampToGround : config.clampToGround;
50
+ _this.pointStyle.heightReference = _this.clampToGround ? Cesium.HeightReference.CLAMP_TO_GROUND : Cesium.HeightReference.NONE;
51
+ _this.polylineStyle.clampToGround = _this.clampToGround;
52
+ if (_this.clampToGround) {
53
+ _this.polygonStyle.heightReference = Cesium.HeightReference.CLAMP_TO_GROUND;
54
+ _this.polygonStyle.perPositionHeight = false;
55
+ } else {
56
+ _this.polygonStyle.heightReference = Cesium.HeightReference.NONE;
57
+ _this.polygonStyle.perPositionHeight = true;
58
+ }
59
+ return _this;
60
+ }
61
+
62
+ // 统一收敛燕尾箭头类型,避免外部传入非法值。
63
+ _createClass(SwallowtailArrow, [{
64
+ key: "_normalizeSwallowtailType",
65
+ value: function _normalizeSwallowtailType(value) {
66
+ var numericValue = Number(value);
67
+ if (!Number.isFinite(numericValue)) {
68
+ return 1;
69
+ }
70
+ return numericValue === 2 ? 2 : 1;
71
+ }
72
+
73
+ // 鼠标事件位置统一转成内部经纬高三元组。
74
+ }, {
75
+ key: "_toPositionTuple",
76
+ value: function _toPositionTuple(position) {
77
+ var lng = position.lng,
78
+ lat = position.lat,
79
+ _position$alt = position.alt,
80
+ alt = _position$alt === void 0 ? 0 : _position$alt;
81
+ return [lng, lat, alt];
82
+ }
83
+
84
+ // 贴地时高度统一为 0;非贴地时用两个控制点的平均高度近似。
85
+ }, {
86
+ key: "_getAltitudeBase",
87
+ value: function _getAltitudeBase(startPosition, endPosition) {
88
+ if (this.clampToGround) {
89
+ return 0;
90
+ }
91
+ var altitudes = [startPosition === null || startPosition === void 0 ? void 0 : startPosition[2], endPosition === null || endPosition === void 0 ? void 0 : endPosition[2]].filter(function (altitude) {
92
+ return Number.isFinite(altitude);
93
+ });
94
+ if (!altitudes.length) {
95
+ return 0;
96
+ }
97
+ return altitudes.reduce(function (sum, altitude) {
98
+ return sum + altitude;
99
+ }, 0) / altitudes.length;
100
+ }
101
+
102
+ // 渲染外框始终闭合,便于绘制和编辑阶段预览边界。
103
+ }, {
104
+ key: "_getDrawPolylinePositions",
105
+ value: function _getDrawPolylinePositions() {
106
+ if (!this.positions.length) {
107
+ return [];
108
+ }
109
+ return [].concat(_toConsumableArray(this.positions), [this.positions[0]]);
110
+ }
111
+
112
+ // polygon 渲染末尾补首点形成闭环。
113
+ }, {
114
+ key: "_getDrawPolygonPositions",
115
+ value: function _getDrawPolygonPositions() {
116
+ if (!this.positions.length) {
117
+ return [];
118
+ }
119
+ return [].concat(_toConsumableArray(this.positions), [this.positions[0]]);
120
+ }
121
+
122
+ // 统一释放线框和面图层,避免绘制中断后残留几何。
123
+ }, {
124
+ key: "_destroyShapeLayers",
125
+ value: function _destroyShapeLayers() {
126
+ this.shapePolylineLayer && this.shapePolylineLayer.destroy();
127
+ this.shapePolylineLayer = null;
128
+ this.shapePolygonLayer && this.shapePolygonLayer.destroy();
129
+ this.shapePolygonLayer = null;
130
+ }
131
+
132
+ // 根据当前顶点数组同步线框和面图层。
133
+ }, {
134
+ key: "_syncShapeLayers",
135
+ value: function _syncShapeLayers() {
136
+ if (!this.positions.length) {
137
+ this._destroyShapeLayers();
138
+ return;
139
+ }
140
+ var polylinePositions = this._getDrawPolylinePositions();
141
+ var polygonPositions = this._getDrawPolygonPositions();
142
+ if (!this.shapePolylineLayer) {
143
+ this.shapePolylineLayer = new ShapePolyline(this.getMap(), {
144
+ positions: polylinePositions,
145
+ style: this.polylineStyle
146
+ });
147
+ } else {
148
+ this.shapePolylineLayer.update(polylinePositions);
149
+ }
150
+ if (!this.shapePolygonLayer) {
151
+ this.shapePolygonLayer = new ShapePolygon(this.getMap(), {
152
+ positions: polygonPositions,
153
+ style: this.polygonStyle
154
+ });
155
+ return;
156
+ }
157
+ this.shapePolygonLayer.update(polygonPositions);
158
+ }
159
+
160
+ // 参考 drawer/common.calculateSwallowPoints(type=1/2):用两端点计算燕尾箭头特征点。
161
+ }, {
162
+ key: "_buildSwallowtailArrowPositions",
163
+ value: function _buildSwallowtailArrowPositions(startPosition, endPosition, swallowtailType) {
164
+ var startCartesian = this._toCartesian3(startPosition);
165
+ var endCartesian = this._toCartesian3(endPosition);
166
+ if (!startCartesian) {
167
+ return [];
168
+ }
169
+ var anchorCartesians = endCartesian ? [startCartesian, endCartesian] : [startCartesian];
170
+ var degreeHeights;
171
+ try {
172
+ degreeHeights = calculateSwallowPoints(anchorCartesians, swallowtailType);
173
+ } catch (error) {
174
+ return [];
175
+ }
176
+ if (!Array.isArray(degreeHeights) || degreeHeights.length < 6) {
177
+ return [];
178
+ }
179
+ var altitudeBase = this._getAltitudeBase(startPosition, endPosition);
180
+ var positions = [];
181
+ for (var index = 0; index < degreeHeights.length; index += 3) {
182
+ var lng = degreeHeights[index];
183
+ var lat = degreeHeights[index + 1];
184
+ if (!Number.isFinite(lng) || !Number.isFinite(lat)) {
185
+ continue;
186
+ }
187
+ positions.push([lng, lat, altitudeBase]);
188
+ }
189
+ return normalizePolygonPositions(positions);
190
+ }
191
+
192
+ // 统一更新两个控制点、箭头类型、顶点数组和渲染图层。
193
+ }, {
194
+ key: "_applyGeometry",
195
+ value: function _applyGeometry(startPosition, endPosition) {
196
+ var swallowtailType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this._swallowtailType;
197
+ var positions = this._buildSwallowtailArrowPositions(startPosition, endPosition, swallowtailType);
198
+ if (positions.length < 3) {
199
+ this.positions = [];
200
+ this._destroyShapeLayers();
201
+ return false;
202
+ }
203
+ this._startPosition = startPosition ? _toConsumableArray(startPosition) : null;
204
+ this._endPosition = endPosition ? _toConsumableArray(endPosition) : null;
205
+ this._swallowtailType = swallowtailType;
206
+ this.positions = positions;
207
+ this._syncShapeLayers();
208
+ return true;
209
+ }
210
+
211
+ // 编辑结束或销毁时统一释放两个控制点。
212
+ }, {
213
+ key: "_destroyEditHandles",
214
+ value: function _destroyEditHandles() {
215
+ this.dragPoints.forEach(function (point) {
216
+ return point.destroy();
217
+ });
218
+ this.dragPoints = [];
219
+ this.dragLayer = null;
220
+ this.dragging = false;
221
+ }
222
+
223
+ // 创建编辑控制点:起点/终点负责调整燕尾箭头尺寸和朝向。
224
+ }, {
225
+ key: "_createEditHandle",
226
+ value: function _createEditHandle(position, role) {
227
+ var handle = new DragPoint(this.getMap(), {
228
+ positions: position,
229
+ style: this.pointStyle
230
+ });
231
+ handle.handleRole = role;
232
+ handle.startEdit();
233
+ return handle;
234
+ }
235
+
236
+ // 几何变化后把两个控制点同步到最新位置。
237
+ }, {
238
+ key: "_syncEditHandles",
239
+ value: function _syncEditHandles() {
240
+ var startHandle = this.dragPoints.find(function (point) {
241
+ return point.handleRole === 'start';
242
+ });
243
+ var endHandle = this.dragPoints.find(function (point) {
244
+ return point.handleRole === 'end';
245
+ });
246
+ if (startHandle && this._startPosition) {
247
+ startHandle.mouseDragChange({
248
+ lng: this._startPosition[0],
249
+ lat: this._startPosition[1],
250
+ alt: this._startPosition[2]
251
+ });
252
+ }
253
+ if (endHandle && this._endPosition) {
254
+ endHandle.mouseDragChange({
255
+ lng: this._endPosition[0],
256
+ lat: this._endPosition[1],
257
+ alt: this._endPosition[2]
258
+ });
259
+ }
260
+ }
261
+
262
+ // 绘制预览阶段透出当前燕尾箭头面顶点数组。
263
+ }, {
264
+ key: "_emitMouseMoveChange",
265
+ value: function _emitMouseMoveChange() {
266
+ this._drawContext.options.onMouseMoveChange && this._drawContext.options.onMouseMoveChange({
267
+ layer: this,
268
+ positions: this.positions
269
+ });
270
+ }
271
+
272
+ // 编辑态拖拽时透出最新燕尾箭头面顶点数组。
273
+ }, {
274
+ key: "_emitPointsChange",
275
+ value: function _emitPointsChange() {
276
+ var _this$_drawContext$op, _this$_drawContext$op2;
277
+ ((_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({
278
+ layer: this,
279
+ positions: this.positions
280
+ }));
281
+ }
282
+
283
+ // 统一完成绘制:入库、触发回调并进入编辑态。
284
+ }, {
285
+ key: "_finishDraw",
286
+ value: function _finishDraw() {
287
+ if (!this.positions.length) {
288
+ return;
289
+ }
290
+ this._drawContext.setDrawerLayer(this.id, this);
291
+ this.drawEnd(this);
292
+ this.startEdit();
293
+ }
294
+
295
+ // 基于 anchors 还原燕尾箭头;缺少 anchors 时由 Drawer 回退为普通 polygon。
296
+ }, {
297
+ key: "transformData",
298
+ value: function transformData(_) {
299
+ var _config$swallowtailTy2;
300
+ var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
301
+ var anchors = config === null || config === void 0 ? void 0 : config.anchors;
302
+ if (!Array.isArray(anchors) || anchors.length < 2) {
303
+ return false;
304
+ }
305
+ var swallowtailType = this._normalizeSwallowtailType((_config$swallowtailTy2 = config === null || config === void 0 ? void 0 : config.swallowtailType) !== null && _config$swallowtailTy2 !== void 0 ? _config$swallowtailTy2 : config === null || config === void 0 ? void 0 : config.type);
306
+ var startPosition = [anchors[0][0], anchors[0][1], anchors[0][2] || 0];
307
+ var endPosition = [anchors[1][0], anchors[1][1], anchors[1][2] || 0];
308
+ if (!this._applyGeometry(startPosition, endPosition, swallowtailType)) {
309
+ return false;
310
+ }
311
+ this._drawContext.setDrawerLayer(this.id, this);
312
+ return true;
313
+ }
314
+
315
+ // 第一次点击记录起点,第二次点击根据终点完成燕尾箭头绘制。
316
+ }, {
317
+ key: "addPoint",
318
+ value: function addPoint(position) {
319
+ var nextPosition = this._toPositionTuple(position);
320
+ if (!this._startPosition) {
321
+ this._startPosition = nextPosition;
322
+ this._endPosition = null;
323
+ this.positions = [];
324
+ this._drawContext._changeStatus(STATUS.DRAWING);
325
+ this._drawContext._updateTooltip();
326
+ return;
327
+ }
328
+ if (!this._applyGeometry(this._startPosition, nextPosition, this._swallowtailType)) {
329
+ return;
330
+ }
331
+ this.drawing(this);
332
+ this._finishDraw();
333
+ }
334
+
335
+ // 鼠标移动时根据当前终点实时预览燕尾箭头。
336
+ }, {
337
+ key: "updateTempPosition",
338
+ value: function updateTempPosition(position) {
339
+ if (!this._startPosition) {
340
+ return;
341
+ }
342
+ var nextPosition = this._toPositionTuple(position);
343
+ if (!this._applyGeometry(this._startPosition, nextPosition, this._swallowtailType)) {
344
+ return;
345
+ }
346
+ this._emitMouseMoveChange();
347
+ }
348
+
349
+ // 兼容外部显式结束绘制的调用,按当前控制点收敛最终 geometry。
350
+ }, {
351
+ key: "endDraw",
352
+ value: function endDraw() {
353
+ if (!this._startPosition || !this._endPosition) {
354
+ return;
355
+ }
356
+ if (!this._applyGeometry(this._startPosition, this._endPosition, this._swallowtailType)) {
357
+ return;
358
+ }
359
+ this._finishDraw();
360
+ }
361
+
362
+ // 编辑态只保留两个控制点,避免退化为普通 polygon 的逐点编辑。
363
+ }, {
364
+ key: "startEdit",
365
+ value: function startEdit() {
366
+ if (!this._startPosition || !this._endPosition) {
367
+ return;
368
+ }
369
+ _get(_getPrototypeOf(SwallowtailArrow.prototype), "startEdit", this).call(this);
370
+ this._destroyEditHandles();
371
+ this.dragPoints = [this._createEditHandle(this._startPosition, 'start'), this._createEditHandle(this._endPosition, 'end')];
372
+ }
373
+
374
+ // 记录当前拖拽的控制点。
375
+ }, {
376
+ key: "mouseDragStart",
377
+ value: function mouseDragStart(position, dragLayer) {
378
+ var _this$dragLayer;
379
+ this.dragging = true;
380
+ this.dragLayer = dragLayer;
381
+ (_this$dragLayer = this.dragLayer) === null || _this$dragLayer === void 0 || _this$dragLayer.mouseDragStart();
382
+ }
383
+
384
+ // 拖拽起点/终点时重新计算燕尾箭头特征点。
385
+ }, {
386
+ key: "mouseDragChange",
387
+ value: function mouseDragChange(position) {
388
+ if (!this.dragging || !this.dragLayer) {
389
+ return;
390
+ }
391
+ if (!this._startPosition || !this._endPosition) {
392
+ return;
393
+ }
394
+ var nextPosition = this._toPositionTuple(position);
395
+ var nextStartPosition = _toConsumableArray(this._startPosition);
396
+ var nextEndPosition = _toConsumableArray(this._endPosition);
397
+ if (this.dragLayer.handleRole === 'start') {
398
+ nextStartPosition = nextPosition;
399
+ } else {
400
+ nextEndPosition = nextPosition;
401
+ }
402
+ if (!this._applyGeometry(nextStartPosition, nextEndPosition, this._swallowtailType)) {
403
+ return;
404
+ }
405
+ this._syncEditHandles();
406
+ this._emitPointsChange();
407
+ }
408
+
409
+ // 结束拖拽时只清理状态。
410
+ }, {
411
+ key: "mouseDragEnd",
412
+ value: function mouseDragEnd() {
413
+ this.dragging = false;
414
+ this.dragLayer = null;
415
+ }
416
+
417
+ // 结束编辑后销毁两个控制点。
418
+ }, {
419
+ key: "endEdit",
420
+ value: function endEdit(layer) {
421
+ var emitComplete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
422
+ _get(_getPrototypeOf(SwallowtailArrow.prototype), "endEdit", this).call(this, layer, emitComplete);
423
+ this._destroyEditHandles();
424
+ }
425
+
426
+ // 销毁时同时清理渲染图层和内部几何状态。
427
+ }, {
428
+ key: "destroy",
429
+ value: function destroy() {
430
+ _get(_getPrototypeOf(SwallowtailArrow.prototype), "destroy", this).call(this);
431
+ this._destroyShapeLayers();
432
+ this._startPosition = null;
433
+ this._endPosition = null;
434
+ }
435
+ }]);
436
+ return SwallowtailArrow;
437
+ }(BaseShape);
438
+ export default SwallowtailArrow;
@@ -0,0 +1,23 @@
1
+ export interface DrawContext {
2
+ options: any;
3
+ getMap: any;
4
+ setDrawerLayer: any;
5
+ _changeStatus: any;
6
+ _updateTooltip: any;
7
+ }
8
+ export interface DataTransformDrawOptions {
9
+ type?: string;
10
+ center?: [number, number] | [number, number, number];
11
+ featureTypeField?: string;
12
+ featureConfigField?: string;
13
+ [key: string]: any;
14
+ }
15
+ export declare const STATUS: {
16
+ readonly INIT: "INIT";
17
+ readonly START_DRAW: "START_DRAW";
18
+ readonly DRAWING: "DRAWING";
19
+ readonly END_DRAW: "END_DRAW";
20
+ readonly EDITING: "EDITING";
21
+ readonly END_EDIT: "END_EDIT";
22
+ };
23
+ export type Status = (typeof STATUS)[keyof typeof STATUS];
@@ -0,0 +1,11 @@
1
+ // 状态表定义
2
+ export var STATUS = {
3
+ INIT: 'INIT',
4
+ START_DRAW: 'START_DRAW',
5
+ DRAWING: 'DRAWING',
6
+ END_DRAW: 'END_DRAW',
7
+ EDITING: 'EDITING',
8
+ END_EDIT: 'END_EDIT'
9
+ };
10
+
11
+ // 从状态表推导类型
@@ -1 +1,15 @@
1
+ import type { DataTransformDrawOptions } from './types';
1
2
  export declare const HANDLE_FEATURE_DATA_TYPE_FUN: any;
3
+ export declare function normalizePolygonPositions(positions?: any[]): any[][];
4
+ export declare function getPolygonRestoreCenterPosition(positions: any[]): [number, number, number] | null;
5
+ export declare function getPolygonRestoreHandlePosition(positions: any[]): [number, number, number] | null;
6
+ export declare function getSectorRestoreAnchors(positions: any[]): [[number, number, number], [number, number, number], [number, number, number]] | null;
7
+ export declare function normalizeDataTransformDrawOptions(options?: DataTransformDrawOptions): {
8
+ type: string | undefined;
9
+ shapeOptions: any;
10
+ featureTypeField: string;
11
+ featureConfigField: string;
12
+ };
13
+ export declare function getDefaultDrawerShapeType(geometryType: string): string;
14
+ export declare function isShapeTypeCompatible(shapeType: string, geometryType: string): boolean;
15
+ export declare function getDrawerRestoreItems(feature: any, options?: DataTransformDrawOptions): any[];