deeptwins-engine-3d 0.1.32 → 0.1.34

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 (178) hide show
  1. package/dist/assets/Build/DeepTwins/Image/f_point.png +0 -0
  2. package/dist/esm/analyze/SubmergenceAnalysis.d.ts +19 -0
  3. package/dist/esm/analyze/SubmergenceAnalysis.js +137 -0
  4. package/dist/esm/constant.d.ts +29 -0
  5. package/dist/esm/constant.js +47 -0
  6. package/dist/esm/drawer/index.d.ts +56 -59
  7. package/dist/esm/drawer/index.js +380 -292
  8. package/dist/esm/drawer/shape/BaseShape.d.ts +33 -0
  9. package/dist/esm/drawer/shape/BaseShape.js +228 -0
  10. package/dist/esm/drawer/shape/Point.d.ts +44 -11
  11. package/dist/esm/drawer/shape/Point.js +299 -35
  12. package/dist/esm/drawer/shape/Polygon.d.ts +43 -9
  13. package/dist/esm/drawer/shape/Polygon.js +408 -56
  14. package/dist/esm/drawer/shape/Polyline.d.ts +41 -10
  15. package/dist/esm/drawer/shape/Polyline.js +373 -31
  16. package/dist/esm/drawer/utils.d.ts +1 -0
  17. package/dist/esm/drawer/utils.js +63 -0
  18. package/dist/esm/graphicLayer/BaseLayer.d.ts +1 -0
  19. package/dist/esm/graphicLayer/BaseLayer.js +8 -3
  20. package/dist/esm/graphicLayer/BaseSource.d.ts +1 -1
  21. package/dist/esm/graphicLayer/BaseSource.js +13 -3
  22. package/dist/esm/graphicLayer/GraphicLayerCollection.d.ts +2 -0
  23. package/dist/esm/graphicLayer/GraphicLayerCollection.js +46 -4
  24. package/dist/esm/graphicLayer/HtmlEntity.js +1 -2
  25. package/dist/esm/index.d.ts +1 -1
  26. package/dist/esm/index.js +7 -4
  27. package/dist/esm/map/Map.d.ts +1 -0
  28. package/dist/esm/map/Map.js +10 -0
  29. package/dist/esm/measure/Area.d.ts +29 -0
  30. package/dist/esm/measure/{AreaMeasure.js → Area.js} +156 -65
  31. package/dist/esm/measure/BaseDraw.d.ts +13 -0
  32. package/dist/esm/measure/BaseDraw.js +70 -0
  33. package/dist/esm/measure/Distance.d.ts +23 -0
  34. package/dist/esm/measure/Distance.js +239 -0
  35. package/dist/esm/measure/index.d.ts +44 -5
  36. package/dist/esm/measure/index.js +278 -5
  37. package/dist/esm/measure/utils.d.ts +108 -14
  38. package/dist/esm/measure/utils.js +262 -20
  39. package/dist/esm/plot/create/CreateAssemble.d.ts +2 -0
  40. package/dist/esm/plot/create/CreateAssemble.js +63 -0
  41. package/dist/esm/plot/create/CreateAttackArrow.d.ts +5 -0
  42. package/dist/esm/plot/create/CreateAttackArrow.js +75 -0
  43. package/dist/esm/plot/create/CreateBillboard.d.ts +2 -0
  44. package/dist/esm/plot/create/CreateBillboard.js +47 -0
  45. package/dist/esm/plot/create/CreateBow.d.ts +2 -0
  46. package/dist/esm/plot/create/CreateBow.js +63 -0
  47. package/dist/esm/plot/create/CreateCircle.d.ts +2 -0
  48. package/dist/esm/plot/create/CreateCircle.js +68 -0
  49. package/dist/esm/plot/create/CreateCurve.d.ts +2 -0
  50. package/dist/esm/plot/create/CreateCurve.js +76 -0
  51. package/dist/esm/plot/create/CreateElliptic.d.ts +2 -0
  52. package/dist/esm/plot/create/CreateElliptic.js +69 -0
  53. package/dist/esm/plot/create/CreateFlag.d.ts +2 -0
  54. package/dist/esm/plot/create/CreateFlag.js +80 -0
  55. package/dist/esm/plot/create/CreateFormation.d.ts +2 -0
  56. package/dist/esm/plot/create/CreateFormation.js +65 -0
  57. package/dist/esm/plot/create/CreateFreeLine.d.ts +2 -0
  58. package/dist/esm/plot/create/CreateFreeLine.js +69 -0
  59. package/dist/esm/plot/create/CreateFreePolygon.d.ts +2 -0
  60. package/dist/esm/plot/create/CreateFreePolygon.js +65 -0
  61. package/dist/esm/plot/create/CreateLabel.d.ts +2 -0
  62. package/dist/esm/plot/create/CreateLabel.js +55 -0
  63. package/dist/esm/plot/create/CreateLineArrow.d.ts +2 -0
  64. package/dist/esm/plot/create/CreateLineArrow.js +79 -0
  65. package/dist/esm/plot/create/CreatePincerArrow.d.ts +5 -0
  66. package/dist/esm/plot/create/CreatePincerArrow.js +73 -0
  67. package/dist/esm/plot/create/CreatePoint.d.ts +2 -0
  68. package/dist/esm/plot/create/CreatePoint.js +47 -0
  69. package/dist/esm/plot/create/CreatePolygon.d.ts +2 -0
  70. package/dist/esm/plot/create/CreatePolygon.js +80 -0
  71. package/dist/esm/plot/create/CreatePolyline.d.ts +2 -0
  72. package/dist/esm/plot/create/CreatePolyline.js +70 -0
  73. package/dist/esm/plot/create/CreateRectangle.d.ts +2 -0
  74. package/dist/esm/plot/create/CreateRectangle.js +60 -0
  75. package/dist/esm/plot/create/CreateRegularPolygon.d.ts +2 -0
  76. package/dist/esm/plot/create/CreateRegularPolygon.js +75 -0
  77. package/dist/esm/plot/create/CreateRightAngleArrow.d.ts +5 -0
  78. package/dist/esm/plot/create/CreateRightAngleArrow.js +73 -0
  79. package/dist/esm/plot/create/CreateRoundRectangle.d.ts +2 -0
  80. package/dist/esm/plot/create/CreateRoundRectangle.js +63 -0
  81. package/dist/esm/plot/create/CreateSector.d.ts +2 -0
  82. package/dist/esm/plot/create/CreateSector.js +65 -0
  83. package/dist/esm/plot/create/CreateStraightArrow.d.ts +5 -0
  84. package/dist/esm/plot/create/CreateStraightArrow.js +65 -0
  85. package/dist/esm/plot/create/CreateSwallowtailArrow.d.ts +5 -0
  86. package/dist/esm/plot/create/CreateSwallowtailArrow.js +67 -0
  87. package/dist/esm/plot/create/index.d.ts +25 -0
  88. package/dist/esm/plot/create/index.js +25 -0
  89. package/dist/esm/plot/edit/EditAssemble.d.ts +8 -0
  90. package/dist/esm/plot/edit/EditAssemble.js +120 -0
  91. package/dist/esm/plot/edit/EditAttackArrow.d.ts +8 -0
  92. package/dist/esm/plot/edit/EditAttackArrow.js +182 -0
  93. package/dist/esm/plot/edit/EditBillboard.d.ts +7 -0
  94. package/dist/esm/plot/edit/EditBillboard.js +70 -0
  95. package/dist/esm/plot/edit/EditBow.d.ts +8 -0
  96. package/dist/esm/plot/edit/EditBow.js +119 -0
  97. package/dist/esm/plot/edit/EditCircle.d.ts +8 -0
  98. package/dist/esm/plot/edit/EditCircle.js +133 -0
  99. package/dist/esm/plot/edit/EditCurve.d.ts +8 -0
  100. package/dist/esm/plot/edit/EditCurve.js +180 -0
  101. package/dist/esm/plot/edit/EditElliptic.d.ts +8 -0
  102. package/dist/esm/plot/edit/EditElliptic.js +144 -0
  103. package/dist/esm/plot/edit/EditFlag.d.ts +8 -0
  104. package/dist/esm/plot/edit/EditFlag.js +121 -0
  105. package/dist/esm/plot/edit/EditFormation.d.ts +8 -0
  106. package/dist/esm/plot/edit/EditFormation.js +120 -0
  107. package/dist/esm/plot/edit/EditLabel.d.ts +7 -0
  108. package/dist/esm/plot/edit/EditLabel.js +100 -0
  109. package/dist/esm/plot/edit/EditLineArrow.d.ts +8 -0
  110. package/dist/esm/plot/edit/EditLineArrow.js +180 -0
  111. package/dist/esm/plot/edit/EditPincerArrow.d.ts +8 -0
  112. package/dist/esm/plot/edit/EditPincerArrow.js +121 -0
  113. package/dist/esm/plot/edit/EditPoint.d.ts +7 -0
  114. package/dist/esm/plot/edit/EditPoint.js +70 -0
  115. package/dist/esm/plot/edit/EditPolygon.d.ts +8 -0
  116. package/dist/esm/plot/edit/EditPolygon.js +181 -0
  117. package/dist/esm/plot/edit/EditPolyline.d.ts +8 -0
  118. package/dist/esm/plot/edit/EditPolyline.js +179 -0
  119. package/dist/esm/plot/edit/EditRectangle.d.ts +8 -0
  120. package/dist/esm/plot/edit/EditRectangle.js +119 -0
  121. package/dist/esm/plot/edit/EditRegularPolygon.d.ts +8 -0
  122. package/dist/esm/plot/edit/EditRegularPolygon.js +170 -0
  123. package/dist/esm/plot/edit/EditRightAngleArrow.d.ts +8 -0
  124. package/dist/esm/plot/edit/EditRightAngleArrow.js +143 -0
  125. package/dist/esm/plot/edit/EditRoundRectangle.d.ts +8 -0
  126. package/dist/esm/plot/edit/EditRoundRectangle.js +119 -0
  127. package/dist/esm/plot/edit/EditSector.d.ts +8 -0
  128. package/dist/esm/plot/edit/EditSector.js +120 -0
  129. package/dist/esm/plot/edit/EditStraightArrow.d.ts +8 -0
  130. package/dist/esm/plot/edit/EditStraightArrow.js +120 -0
  131. package/dist/esm/plot/edit/EditSwallowtailArrow.d.ts +8 -0
  132. package/dist/esm/plot/edit/EditSwallowtailArrow.js +121 -0
  133. package/dist/esm/plot/edit/index.d.ts +23 -0
  134. package/dist/esm/plot/edit/index.js +23 -0
  135. package/dist/esm/plot/utils/Algorithm.d.ts +2 -0
  136. package/dist/esm/plot/utils/Algorithm.js +316 -0
  137. package/dist/esm/plot/utils/Coordinate.d.ts +98 -0
  138. package/dist/esm/plot/utils/Coordinate.js +184 -0
  139. package/dist/esm/plot/utils/DomUtil.d.ts +34 -0
  140. package/dist/esm/plot/utils/DomUtil.js +100 -0
  141. package/dist/esm/plot/utils/PlotCommon.d.ts +101 -0
  142. package/dist/esm/plot/utils/PlotCommon.js +1412 -0
  143. package/dist/esm/plot/utils/ReminderTip.d.ts +10 -0
  144. package/dist/esm/plot/utils/ReminderTip.js +67 -0
  145. package/dist/esm/plot/utils/Tooltip.d.ts +3 -0
  146. package/dist/esm/plot/utils/Tooltip.js +97 -0
  147. package/dist/esm/plot/utils/plotUtil.d.ts +5 -0
  148. package/dist/esm/plot/utils/plotUtil.js +268 -0
  149. package/dist/esm/tool/utils.d.ts +8 -7
  150. package/dist/esm/tool/utils.js +20 -16
  151. package/dist/esm/toolTip/index.d.ts +2 -1
  152. package/dist/esm/toolTip/index.js +12 -6
  153. package/dist/esm/typings.d.ts +1 -0
  154. package/dist/umd/deeptwins-engine-3d.min.js +1 -1
  155. package/package.json +1 -1
  156. package/dist/esm/drawer/base.d.ts +0 -51
  157. package/dist/esm/drawer/base.js +0 -179
  158. package/dist/esm/drawer/painter.d.ts +0 -41
  159. package/dist/esm/drawer/painter.js +0 -115
  160. package/dist/esm/drawer/shape/Ellipse.d.ts +0 -10
  161. package/dist/esm/drawer/shape/Ellipse.js +0 -62
  162. package/dist/esm/drawer/shape/Rectangle.d.ts +0 -10
  163. package/dist/esm/drawer/shape/Rectangle.js +0 -85
  164. package/dist/esm/drawer/typings.d.ts +0 -106
  165. package/dist/esm/drawer/typings.js +0 -1
  166. package/dist/esm/measure/AreaMeasure.d.ts +0 -19
  167. package/dist/esm/measure/AreaSurfaceMeasure.d.ts +0 -30
  168. package/dist/esm/measure/AreaSurfaceMeasure.js +0 -151
  169. package/dist/esm/measure/DistanceMeasure.d.ts +0 -19
  170. package/dist/esm/measure/DistanceMeasure.js +0 -91
  171. package/dist/esm/measure/DistanceSurfaceMeasure.d.ts +0 -37
  172. package/dist/esm/measure/DistanceSurfaceMeasure.js +0 -122
  173. package/dist/esm/measure/Measure.d.ts +0 -111
  174. package/dist/esm/measure/Measure.js +0 -177
  175. package/dist/esm/tool/cesiumExtends/Subscriber/index.d.ts +0 -66
  176. package/dist/esm/tool/cesiumExtends/Subscriber/index.js +0 -246
  177. package/dist/esm/tool/kriging.d.ts +0 -10
  178. package/dist/esm/tool/kriging.js +0 -436
@@ -0,0 +1,239 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
6
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
7
+ 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); }
8
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
9
+ 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); }
10
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
11
+ 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); }; }
12
+ 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); }
13
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
14
+ 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; } }
15
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
16
+ 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; }
17
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
18
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
19
+ import { point } from '@turf/turf';
20
+ import * as Cesium from 'deeptwins-cesium';
21
+ import { SceneTransforms } from 'deeptwins-cesium';
22
+ import { STATUS } from "../drawer";
23
+ import { lngLatAltToCartesian3 } from "../tool/utils";
24
+ import BaseDraw from "./BaseDraw";
25
+ import * as utils from "./utils";
26
+ var Distance = /*#__PURE__*/function (_BaseDraw) {
27
+ _inherits(Distance, _BaseDraw);
28
+ var _super = _createSuper(Distance);
29
+ function Distance(measureContext, config) {
30
+ var _this;
31
+ _classCallCheck(this, Distance);
32
+ _this = _super.call(this, measureContext);
33
+ _defineProperty(_assertThisInitialized(_this), "_type", 'distance');
34
+ _defineProperty(_assertThisInitialized(_this), "_config", void 0);
35
+ // 线图层
36
+ _defineProperty(_assertThisInitialized(_this), "_instance", void 0);
37
+ // 测量缓存数据
38
+ _defineProperty(_assertThisInitialized(_this), "_measureCache", []);
39
+ // 鼠标移动的label
40
+ _defineProperty(_assertThisInitialized(_this), "_mouseLabelLayer", void 0);
41
+ _this._config = config;
42
+ _this._init();
43
+ return _this;
44
+ }
45
+ _createClass(Distance, [{
46
+ key: "_init",
47
+ value: function _init() {
48
+ this._instance = this._drawer.startDraw('polyline', this._config);
49
+ }
50
+
51
+ // 绘制
52
+ }, {
53
+ key: "drawing",
54
+ value: function drawing(positions) {
55
+ if (!this._canOperate()) return;
56
+ this._measureContext._changeStatus(STATUS.DRAWING);
57
+ if (positions.length < 2) return {};
58
+ var mouseDistance = this._calculateMouseDistance(positions);
59
+ this._createMouseMoveLabel(positions.slice(-1)[0], "\u603B\u8BA1".concat(utils.formatLength(mouseDistance.allDistance), "\n(+").concat(utils.formatLength(mouseDistance.distance), ")"));
60
+ return mouseDistance;
61
+ }
62
+
63
+ // 点位修改
64
+ }, {
65
+ key: "pointsChange",
66
+ value: function pointsChange(layer, positions) {
67
+ if (!this._canOperate()) return;
68
+ // 未返回点位 销毁随鼠标移动的label
69
+ if (!positions.length) {
70
+ this._destroyMouseMoveLabel();
71
+ return [];
72
+ }
73
+ // 小于两个点时清除测量缓存数据
74
+ if (positions.length < 2) {
75
+ this._measureCache = [];
76
+ } else {
77
+ this._calculateDistance(positions);
78
+ }
79
+ if (!this._measureCache.length) {
80
+ layer.dragPoints[0].labelLayer.setStyle({
81
+ show: true,
82
+ text: '起点'
83
+ });
84
+ } else {
85
+ this._createMeasureCacheText(layer.dragPoints);
86
+ }
87
+ return this._measureCache;
88
+ }
89
+
90
+ // 结束绘制
91
+ }, {
92
+ key: "drawEnd",
93
+ value: function drawEnd() {
94
+ if (!this._canOperate()) return;
95
+ this._measureContext._changeStatus(STATUS.END_DRAW);
96
+ this._measureContext.setDrawerLayer(this.id, this);
97
+ this._destroyMouseMoveLabel();
98
+ this.startEdit();
99
+ return this._measureCache;
100
+ }
101
+
102
+ // 开始编辑
103
+ }, {
104
+ key: "startEdit",
105
+ value: function startEdit() {
106
+ if (!this._canOperate()) return;
107
+ this._measureContext._changeStatus(STATUS.EDITING);
108
+ }
109
+
110
+ // 结束编辑
111
+ }, {
112
+ key: "endEdit",
113
+ value: function endEdit() {
114
+ if (!this._canOperate()) return;
115
+ return this._measureCache;
116
+ }
117
+
118
+ // 绘制随鼠标移动的label
119
+ }, {
120
+ key: "_createMouseMoveLabel",
121
+ value: function _createMouseMoveLabel(position, text) {
122
+ if (!this._canOperate()) return;
123
+ if (this._mouseLabelLayer) {
124
+ this._mouseLabelLayer.setData(point(position));
125
+ this._mouseLabelLayer.setStyle({
126
+ text: text,
127
+ eyeOffset: [-20, 0, 0],
128
+ horizontalOrigin: Cesium.HorizontalOrigin.RIGHT
129
+ });
130
+ } else {
131
+ this._mouseLabelLayer = this.createLabelLayer(position, text, {
132
+ eyeOffset: [-20, 0, 0],
133
+ horizontalOrigin: Cesium.HorizontalOrigin.RIGHT
134
+ });
135
+ }
136
+ }
137
+
138
+ // 销毁随鼠标移动的label
139
+ }, {
140
+ key: "_destroyMouseMoveLabel",
141
+ value: function _destroyMouseMoveLabel() {
142
+ this._mouseLabelLayer && this._mouseLabelLayer.destroy();
143
+ this._mouseLabelLayer = null;
144
+ }
145
+
146
+ // 计算距离
147
+ }, {
148
+ key: "_calculateDistance",
149
+ value: function _calculateDistance(positions) {
150
+ if (!this._canOperate()) return;
151
+ if (positions.length < 2) return;
152
+ var distanceList = [];
153
+ this._measureCache = [];
154
+ var config = _objectSpread(_objectSpread({}, this._measureContext.options), this._config);
155
+ for (var i = 0; i < positions.length - 1; i++) {
156
+ var start = positions[i];
157
+ var end = positions[i + 1];
158
+ var startC3 = lngLatAltToCartesian3(start[0], start[1], start[2]);
159
+ var endC3 = lngLatAltToCartesian3(end[0], end[1], end[2]);
160
+ var distance = 0;
161
+ if (config.clampToGround) {
162
+ var startC2 = SceneTransforms.worldToWindowCoordinates(this.getMap().scene, startC3);
163
+ var endC2 = SceneTransforms.worldToWindowCoordinates(this.getMap().scene, endC3);
164
+ distance = utils.calculateSurfaceDistance(this.getMap(), startC2, endC2, config.splitNum);
165
+ } else {
166
+ distance = utils.getDistance(startC3, endC3);
167
+ }
168
+ distanceList.push(distance);
169
+ this._measureCache.push({
170
+ start: start,
171
+ end: end,
172
+ distance: distance,
173
+ allDistance: distanceList.reduce(function (sum, distance) {
174
+ return sum + distance;
175
+ }, 0)
176
+ });
177
+ }
178
+ }
179
+
180
+ // 计算鼠标和线之间的距离
181
+ }, {
182
+ key: "_calculateMouseDistance",
183
+ value: function _calculateMouseDistance(positions) {
184
+ if (!this._canOperate()) return;
185
+ if (positions.length < 2) return;
186
+ var start = positions.slice(-2, -1)[0];
187
+ var end = positions.slice(-1)[0];
188
+ var startC3 = lngLatAltToCartesian3(start[0], start[1], start[2]);
189
+ var endC3 = lngLatAltToCartesian3(end[0], end[1], end[2]);
190
+ var distance = 0;
191
+ var config = _objectSpread(_objectSpread({}, this._measureContext.options), this._config);
192
+ if (config.clampToGround) {
193
+ var startC2 = SceneTransforms.worldToWindowCoordinates(this.getMap().scene, startC3);
194
+ var endC2 = SceneTransforms.worldToWindowCoordinates(this.getMap().scene, endC3);
195
+ distance = utils.calculateSurfaceDistance(this.getMap(), startC2, endC2, config.splitNum);
196
+ } else {
197
+ distance = utils.getDistance(startC3, endC3);
198
+ }
199
+ return {
200
+ distance: distance,
201
+ allDistance: this._measureCache.reduce(function (sum, item) {
202
+ return sum + item.distance;
203
+ }, distance)
204
+ };
205
+ }
206
+
207
+ // 根据缓存数据创建文字
208
+ }, {
209
+ key: "_createMeasureCacheText",
210
+ value: function _createMeasureCacheText(dragPoints) {
211
+ if (!this._canOperate()) return;
212
+ for (var i = 0; i < this._measureCache.length; i++) {
213
+ var _this$_measureCache$i = this._measureCache[i],
214
+ distance = _this$_measureCache$i.distance,
215
+ allDistance = _this$_measureCache$i.allDistance;
216
+ dragPoints[i + 1].labelLayer.setStyle({
217
+ show: true,
218
+ text: "".concat(utils.formatLength(allDistance), "\n(+").concat(utils.formatLength(distance), ")")
219
+ });
220
+ }
221
+ }
222
+
223
+ // 销毁
224
+ }, {
225
+ key: "destroy",
226
+ value: function destroy() {
227
+ if (!this._canOperate()) return;
228
+ _get(_getPrototypeOf(Distance.prototype), "destroy", this).call(this);
229
+ this._drawer.removeDrawerLayer(this._instance);
230
+ this._instance = null;
231
+ this._mouseLabelLayer && this._mouseLabelLayer.remove();
232
+ this._mouseLabelLayer = null;
233
+ this._measureCache = [];
234
+ this._destroyMouseMoveLabel();
235
+ }
236
+ }]);
237
+ return Distance;
238
+ }(BaseDraw);
239
+ export default Distance;
@@ -1,5 +1,44 @@
1
- export { default as AreaMeasure } from './AreaMeasure';
2
- export { default as AreaSurfaceMeasure } from './AreaSurfaceMeasure';
3
- export { default as DistanceMeasure } from './DistanceMeasure';
4
- export { default as DistanceSurfaceMeasure } from './DistanceSurfaceMeasure';
5
- export { default as Measure } from './Measure';
1
+ import Drawer from '../drawer';
2
+ export interface MeasureContext {
3
+ options: any;
4
+ getMap: any;
5
+ drawer: any;
6
+ setDrawerLayer: any;
7
+ _changeStatus: any;
8
+ }
9
+ export declare const STATUS: {
10
+ readonly INIT: "INIT";
11
+ readonly START_DRAW: "START_DRAW";
12
+ readonly DRAWING: "DRAWING";
13
+ readonly END_DRAW: "END_DRAW";
14
+ readonly EDITING: "EDITING";
15
+ readonly END_EDIT: "END_EDIT";
16
+ };
17
+ export type Status = (typeof STATUS)[keyof typeof STATUS];
18
+ declare class Measure implements MeasureContext {
19
+ private readonly _mapContext;
20
+ private readonly _measureContext;
21
+ options: any;
22
+ isDestroyed: boolean;
23
+ private _status;
24
+ drawer: Drawer;
25
+ private _instance;
26
+ private _measureDrawLayers;
27
+ constructor(map: any, options?: any);
28
+ private _canOperate;
29
+ getMap(): any;
30
+ _changeStatus(status: any): void;
31
+ startDraw(type: any, config?: any): any;
32
+ private _stopDraw;
33
+ endDraw(): void;
34
+ startEdit(id: any): void;
35
+ endEdit(): void;
36
+ getDrawerLayer(id: any): any;
37
+ setDrawerLayer(id: any, value: any): void;
38
+ removeDrawerLayer(id: any): void;
39
+ getAllDrawerLayers(): unknown[] | undefined;
40
+ clearAllDrawerLayers(): void;
41
+ clear(): void;
42
+ destroy(): void;
43
+ }
44
+ export default Measure;
@@ -1,5 +1,278 @@
1
- export { default as AreaMeasure } from "./AreaMeasure";
2
- export { default as AreaSurfaceMeasure } from "./AreaSurfaceMeasure";
3
- export { default as DistanceMeasure } from "./DistanceMeasure";
4
- export { default as DistanceSurfaceMeasure } from "./DistanceSurfaceMeasure";
5
- export { default as Measure } from "./Measure";
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
4
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
5
+ 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; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ 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); }
8
+ import { isString, merge } from 'lodash';
9
+ import { DEFAULT_MEASURE_STYLE } from "../constant";
10
+ import Drawer from "../drawer";
11
+ import { error } from "../tool/utils";
12
+ import Area from "./Area";
13
+ import Distance from "./Distance";
14
+ var MEASURE_TYPE = {
15
+ DISTANCE: 'distance',
16
+ AREA: 'area'
17
+ };
18
+
19
+ // 状态表定义
20
+ export var STATUS = {
21
+ INIT: 'INIT',
22
+ START_DRAW: 'START_DRAW',
23
+ DRAWING: 'DRAWING',
24
+ END_DRAW: 'END_DRAW',
25
+ EDITING: 'EDITING',
26
+ END_EDIT: 'END_EDIT'
27
+ };
28
+
29
+ // 从状态表推导类型
30
+ var Measure = /*#__PURE__*/function () {
31
+ function Measure(map) {
32
+ var _this = this;
33
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
34
+ _classCallCheck(this, Measure);
35
+ _defineProperty(this, "_mapContext", void 0);
36
+ _defineProperty(this, "_measureContext", void 0);
37
+ _defineProperty(this, "options", void 0);
38
+ _defineProperty(this, "isDestroyed", false);
39
+ _defineProperty(this, "_status", STATUS.INIT);
40
+ _defineProperty(this, "drawer", void 0);
41
+ // 绘制的实例
42
+ _defineProperty(this, "_instance", void 0);
43
+ // 绘制完成的图层
44
+ _defineProperty(this, "_measureDrawLayers", new Map());
45
+ this._mapContext = map._mapContext;
46
+ this.options = merge(DEFAULT_MEASURE_STYLE(), options);
47
+ this.drawer = new Drawer(this.getMap(), {
48
+ onMouseMoveChange: function onMouseMoveChange(e) {
49
+ if (_this._instance) {
50
+ _this._instance.drawing(e.positions);
51
+ }
52
+ },
53
+ onPointsChange: function onPointsChange(e) {
54
+ if (_this._instance) {
55
+ var data = _this._instance.pointsChange(e.layer, e.positions);
56
+ _this.options.onPointsChange && _this.options.onPointsChange({
57
+ layer: _this._instance,
58
+ positions: e.positions,
59
+ measure: data
60
+ });
61
+ }
62
+ },
63
+ onComplete: function onComplete(e) {
64
+ if (_this._instance) {
65
+ var data = {};
66
+ if (_this._status === 'END_DRAW' || _this._status === 'DRAWING') {
67
+ data = _this._instance.drawEnd(e.positions);
68
+ _this.options.onComplete && _this.options.onComplete({
69
+ layer: _this._instance,
70
+ positions: e.positions,
71
+ measure: data
72
+ });
73
+ }
74
+ if (_this._status === 'END_EDIT') {
75
+ data = _this._instance.endEdit(e.positions);
76
+ _this.options.onComplete && _this.options.onComplete({
77
+ layer: _this._instance,
78
+ positions: e.positions,
79
+ measure: data
80
+ });
81
+ }
82
+ }
83
+ }
84
+ });
85
+ this._measureContext = {
86
+ options: this.options,
87
+ getMap: this.getMap.bind(this),
88
+ drawer: this.drawer,
89
+ setDrawerLayer: this.setDrawerLayer.bind(this),
90
+ _changeStatus: this._changeStatus.bind(this)
91
+ };
92
+ }
93
+
94
+ // 是否能进行操作
95
+ _createClass(Measure, [{
96
+ key: "_canOperate",
97
+ value: function _canOperate() {
98
+ if (this.isDestroyed) {
99
+ error('Drawer实例已销毁');
100
+ return false;
101
+ }
102
+ return true;
103
+ }
104
+ }, {
105
+ key: "getMap",
106
+ value: function getMap() {
107
+ return this._mapContext && this._mapContext.getMap();
108
+ }
109
+
110
+ // 修改状态
111
+ }, {
112
+ key: "_changeStatus",
113
+ value: function _changeStatus(status) {
114
+ this._status = status;
115
+ }
116
+
117
+ // 开始绘制
118
+ }, {
119
+ key: "startDraw",
120
+ value: function startDraw(type) {
121
+ var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
122
+ if (!this._canOperate()) return;
123
+ if (!Object.values(MEASURE_TYPE).includes(type)) return;
124
+ if (this._instance) {
125
+ this._stopDraw();
126
+ }
127
+ this._changeStatus(STATUS.START_DRAW);
128
+ if (type === MEASURE_TYPE.DISTANCE) {
129
+ this._instance = new Distance(this._measureContext, config);
130
+ }
131
+ if (type === MEASURE_TYPE.AREA) {
132
+ this._instance = new Area(this._measureContext, config);
133
+ }
134
+ return this._instance;
135
+ }
136
+
137
+ // 中止当前绘制
138
+ }, {
139
+ key: "_stopDraw",
140
+ value: function _stopDraw() {
141
+ if (!this._canOperate()) return;
142
+ if (!this._instance) return;
143
+ if (this._status === STATUS.INIT || this._status === STATUS.START_DRAW || this._status === STATUS.END_EDIT) {
144
+ var layer = this.getDrawerLayer(this._instance);
145
+ // layer未存入
146
+ if (!layer) {
147
+ this._instance.destroy();
148
+ }
149
+ this._instance = null;
150
+ return;
151
+ }
152
+ if (this._status === STATUS.DRAWING) {
153
+ this.removeDrawerLayer(this._instance);
154
+ this._instance = null;
155
+ return;
156
+ }
157
+ if (this._status === STATUS.END_DRAW || this._status === STATUS.EDITING) {
158
+ this.endEdit();
159
+ return;
160
+ }
161
+ }
162
+
163
+ // 结束绘制
164
+ }, {
165
+ key: "endDraw",
166
+ value: function endDraw() {
167
+ if (!this._canOperate()) return;
168
+ }
169
+
170
+ // 开始编辑
171
+ }, {
172
+ key: "startEdit",
173
+ value: function startEdit(id) {
174
+ if (!this._canOperate()) return;
175
+ if (!id) return;
176
+ if (this._instance) {
177
+ this.drawer.endEdit();
178
+ this.setDrawerLayer(this._instance.id, this._instance);
179
+ this._instance = null;
180
+ }
181
+ this._changeStatus(STATUS.EDITING);
182
+ this._instance = this.getDrawerLayer(id);
183
+ if (!this._instance) return;
184
+ this._changeStatus(STATUS.EDITING);
185
+ this.drawer.startEdit(this._instance._instance);
186
+ }
187
+
188
+ // 结束编辑
189
+ }, {
190
+ key: "endEdit",
191
+ value: function endEdit() {
192
+ if (!this._canOperate()) return;
193
+ this._changeStatus(STATUS.END_EDIT);
194
+ if (!this._instance) return;
195
+ this.drawer.endEdit();
196
+ this.setDrawerLayer(this._instance.id, this._instance);
197
+ this._instance = null;
198
+ }
199
+
200
+ // 获取绘制的图层
201
+ }, {
202
+ key: "getDrawerLayer",
203
+ value: function getDrawerLayer(id) {
204
+ if (!this._canOperate) return;
205
+ if (!id) return;
206
+ return isString(id) ? this._measureDrawLayers.get(id) : id;
207
+ }
208
+
209
+ // 添加完成绘制的图层
210
+ }, {
211
+ key: "setDrawerLayer",
212
+ value: function setDrawerLayer(id, value) {
213
+ if (!this._instance) return;
214
+ this._measureDrawLayers.set(id, value);
215
+ }
216
+
217
+ // 移除绘制的图层
218
+ }, {
219
+ key: "removeDrawerLayer",
220
+ value: function removeDrawerLayer(id) {
221
+ if (!this._canOperate) return;
222
+ var layer = this.getDrawerLayer(id);
223
+ if (layer) {
224
+ var _this$_instance;
225
+ if (layer.id === (this === null || this === void 0 || (_this$_instance = this._instance) === null || _this$_instance === void 0 ? void 0 : _this$_instance.id)) {
226
+ this._instance = null;
227
+ this._status = STATUS.INIT;
228
+ }
229
+ this._measureDrawLayers.delete(layer.id);
230
+ layer.destroy();
231
+ layer = null;
232
+ }
233
+ }
234
+
235
+ // 获取所有绘制的图层
236
+ }, {
237
+ key: "getAllDrawerLayers",
238
+ value: function getAllDrawerLayers() {
239
+ if (!this._canOperate) return;
240
+ return Array.from(this._measureDrawLayers.values());
241
+ }
242
+
243
+ // 清除所有绘制的图层
244
+ }, {
245
+ key: "clearAllDrawerLayers",
246
+ value: function clearAllDrawerLayers() {
247
+ if (!this._canOperate) return;
248
+ this._measureDrawLayers.forEach(function (t) {
249
+ return t.destroy();
250
+ });
251
+ this._measureDrawLayers.clear();
252
+ }
253
+
254
+ // 清除
255
+ }, {
256
+ key: "clear",
257
+ value: function clear() {
258
+ if (!this._canOperate) return;
259
+ this.getMap().canvas.style.cursor = 'default';
260
+ this._changeStatus(STATUS.INIT);
261
+ this._instance && this._instance.destroy();
262
+ this._instance = null;
263
+ this.clearAllDrawerLayers();
264
+ }
265
+
266
+ // 销毁
267
+ }, {
268
+ key: "destroy",
269
+ value: function destroy() {
270
+ if (!this._canOperate) return;
271
+ this.clear();
272
+ this.drawer.destroy();
273
+ this.isDestroyed = true;
274
+ }
275
+ }]);
276
+ return Measure;
277
+ }();
278
+ export default Measure;