deeptwins-engine-3d 0.1.63 → 0.1.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/Build/DeepTwins/Workers/MvtVector.worker.js +1 -0
- package/dist/esm/{plot/utils/Algorithm.js → drawer/algorithm.js} +1 -3
- package/dist/esm/drawer/common.d.ts +61 -0
- package/dist/esm/{plot/utils/PlotCommon.js → drawer/common.js} +104 -551
- package/dist/esm/{plot/utils/Coordinate.d.ts → drawer/coordinate.d.ts} +1 -1
- package/dist/esm/drawer/index.d.ts +11 -18
- package/dist/esm/drawer/index.js +329 -80
- package/dist/esm/{plot/utils → drawer}/plotUtil.js +1 -3
- package/dist/esm/drawer/shape/Assemble.d.ts +34 -0
- package/dist/esm/drawer/shape/Assemble.js +415 -0
- package/dist/esm/drawer/shape/AttackArrow.d.ts +32 -0
- package/dist/esm/drawer/shape/AttackArrow.js +442 -0
- package/dist/esm/drawer/shape/BaseShape.d.ts +14 -4
- package/dist/esm/drawer/shape/BaseShape.js +175 -20
- package/dist/esm/drawer/shape/Bow.d.ts +31 -0
- package/dist/esm/drawer/shape/Bow.js +375 -0
- package/dist/esm/drawer/shape/Circle.d.ts +37 -0
- package/dist/esm/drawer/shape/Circle.js +461 -0
- package/dist/esm/drawer/shape/Curve.d.ts +29 -0
- package/dist/esm/drawer/shape/Curve.js +386 -0
- package/dist/esm/drawer/shape/DragPoint.d.ts +32 -0
- package/dist/esm/drawer/shape/DragPoint.js +211 -0
- package/dist/esm/drawer/shape/Elliptic.d.ts +38 -0
- package/dist/esm/drawer/shape/Elliptic.js +491 -0
- package/dist/esm/drawer/shape/Formation.d.ts +33 -0
- package/dist/esm/drawer/shape/Formation.js +395 -0
- package/dist/esm/drawer/shape/PincerArrow.d.ts +32 -0
- package/dist/esm/drawer/shape/PincerArrow.js +445 -0
- package/dist/esm/drawer/shape/Point.d.ts +2 -31
- package/dist/esm/drawer/shape/Point.js +7 -201
- package/dist/esm/drawer/shape/Polygon.d.ts +1 -1
- package/dist/esm/drawer/shape/Polygon.js +10 -81
- package/dist/esm/drawer/shape/Polyline.d.ts +1 -1
- package/dist/esm/drawer/shape/Polyline.js +10 -81
- package/dist/esm/drawer/shape/RegularPolygon.d.ts +37 -0
- package/dist/esm/drawer/shape/RegularPolygon.js +468 -0
- package/dist/esm/drawer/shape/RightAngleArrow.d.ts +34 -0
- package/dist/esm/drawer/shape/RightAngleArrow.js +423 -0
- package/dist/esm/drawer/shape/Sector.d.ts +37 -0
- package/dist/esm/drawer/shape/Sector.js +568 -0
- package/dist/esm/drawer/shape/StraightArrow.d.ts +34 -0
- package/dist/esm/drawer/shape/StraightArrow.js +422 -0
- package/dist/esm/drawer/shape/SwallowtailArrow.d.ts +36 -0
- package/dist/esm/drawer/shape/SwallowtailArrow.js +438 -0
- package/dist/esm/drawer/types.d.ts +23 -0
- package/dist/esm/drawer/types.js +11 -0
- package/dist/esm/drawer/utils.d.ts +14 -0
- package/dist/esm/drawer/utils.js +320 -2
- package/dist/esm/graphicLayer/BaseSource.d.ts +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +5 -3
- package/dist/esm/measure/Area.d.ts +17 -17
- package/dist/esm/measure/Area.js +95 -63
- package/dist/esm/measure/BaseDraw.d.ts +9 -4
- package/dist/esm/measure/BaseDraw.js +37 -2
- package/dist/esm/measure/Distance.d.ts +9 -9
- package/dist/esm/measure/Distance.js +52 -68
- package/dist/esm/measure/index.d.ts +16 -26
- package/dist/esm/measure/index.js +72 -84
- package/dist/esm/measure/types.d.ts +94 -0
- package/dist/esm/measure/types.js +17 -0
- package/dist/esm/measure/utils.d.ts +7 -7
- package/dist/esm/measure/utils.js +43 -24
- package/dist/esm/tileLayer/MvtVectorLoad.d.ts +241 -0
- package/dist/esm/tileLayer/MvtVectorLoad.js +1353 -0
- package/dist/esm/tileLayer/MvtVectorWorkerClient.d.ts +25 -0
- package/dist/esm/tileLayer/MvtVectorWorkerClient.js +126 -0
- package/dist/esm/tool/utils.js +1 -1
- package/dist/umd/deeptwins-engine-3d.min.js +1 -1
- package/package.json +2 -1
- package/dist/assets/Build/DeepTwins/Image/compass/pointer-white.png +0 -0
- package/dist/esm/plot/create/CreateAssemble.d.ts +0 -2
- package/dist/esm/plot/create/CreateAssemble.js +0 -63
- package/dist/esm/plot/create/CreateAttackArrow.d.ts +0 -5
- package/dist/esm/plot/create/CreateAttackArrow.js +0 -75
- package/dist/esm/plot/create/CreateBillboard.d.ts +0 -2
- package/dist/esm/plot/create/CreateBillboard.js +0 -47
- package/dist/esm/plot/create/CreateBow.d.ts +0 -2
- package/dist/esm/plot/create/CreateBow.js +0 -63
- package/dist/esm/plot/create/CreateCircle.d.ts +0 -2
- package/dist/esm/plot/create/CreateCircle.js +0 -68
- package/dist/esm/plot/create/CreateCurve.d.ts +0 -2
- package/dist/esm/plot/create/CreateCurve.js +0 -76
- package/dist/esm/plot/create/CreateElliptic.d.ts +0 -2
- package/dist/esm/plot/create/CreateElliptic.js +0 -69
- package/dist/esm/plot/create/CreateFlag.d.ts +0 -2
- package/dist/esm/plot/create/CreateFlag.js +0 -80
- package/dist/esm/plot/create/CreateFormation.d.ts +0 -2
- package/dist/esm/plot/create/CreateFormation.js +0 -65
- package/dist/esm/plot/create/CreateFreeLine.d.ts +0 -2
- package/dist/esm/plot/create/CreateFreeLine.js +0 -69
- package/dist/esm/plot/create/CreateFreePolygon.d.ts +0 -2
- package/dist/esm/plot/create/CreateFreePolygon.js +0 -65
- package/dist/esm/plot/create/CreateLabel.d.ts +0 -2
- package/dist/esm/plot/create/CreateLabel.js +0 -55
- package/dist/esm/plot/create/CreateLineArrow.d.ts +0 -2
- package/dist/esm/plot/create/CreateLineArrow.js +0 -79
- package/dist/esm/plot/create/CreatePincerArrow.d.ts +0 -5
- package/dist/esm/plot/create/CreatePincerArrow.js +0 -73
- package/dist/esm/plot/create/CreatePoint.d.ts +0 -2
- package/dist/esm/plot/create/CreatePoint.js +0 -47
- package/dist/esm/plot/create/CreatePolygon.d.ts +0 -2
- package/dist/esm/plot/create/CreatePolygon.js +0 -80
- package/dist/esm/plot/create/CreatePolyline.d.ts +0 -2
- package/dist/esm/plot/create/CreatePolyline.js +0 -70
- package/dist/esm/plot/create/CreateRectangle.d.ts +0 -2
- package/dist/esm/plot/create/CreateRectangle.js +0 -60
- package/dist/esm/plot/create/CreateRegularPolygon.d.ts +0 -2
- package/dist/esm/plot/create/CreateRegularPolygon.js +0 -75
- package/dist/esm/plot/create/CreateRightAngleArrow.d.ts +0 -5
- package/dist/esm/plot/create/CreateRightAngleArrow.js +0 -73
- package/dist/esm/plot/create/CreateRoundRectangle.d.ts +0 -2
- package/dist/esm/plot/create/CreateRoundRectangle.js +0 -63
- package/dist/esm/plot/create/CreateSector.d.ts +0 -2
- package/dist/esm/plot/create/CreateSector.js +0 -65
- package/dist/esm/plot/create/CreateStraightArrow.d.ts +0 -5
- package/dist/esm/plot/create/CreateStraightArrow.js +0 -65
- package/dist/esm/plot/create/CreateSwallowtailArrow.d.ts +0 -5
- package/dist/esm/plot/create/CreateSwallowtailArrow.js +0 -67
- package/dist/esm/plot/create/index.d.ts +0 -25
- package/dist/esm/plot/create/index.js +0 -25
- package/dist/esm/plot/edit/EditAssemble.d.ts +0 -8
- package/dist/esm/plot/edit/EditAssemble.js +0 -120
- package/dist/esm/plot/edit/EditAttackArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditAttackArrow.js +0 -182
- package/dist/esm/plot/edit/EditBillboard.d.ts +0 -7
- package/dist/esm/plot/edit/EditBillboard.js +0 -70
- package/dist/esm/plot/edit/EditBow.d.ts +0 -8
- package/dist/esm/plot/edit/EditBow.js +0 -119
- package/dist/esm/plot/edit/EditCircle.d.ts +0 -8
- package/dist/esm/plot/edit/EditCircle.js +0 -133
- package/dist/esm/plot/edit/EditCurve.d.ts +0 -8
- package/dist/esm/plot/edit/EditCurve.js +0 -180
- package/dist/esm/plot/edit/EditElliptic.d.ts +0 -8
- package/dist/esm/plot/edit/EditElliptic.js +0 -144
- package/dist/esm/plot/edit/EditFlag.d.ts +0 -8
- package/dist/esm/plot/edit/EditFlag.js +0 -121
- package/dist/esm/plot/edit/EditFormation.d.ts +0 -8
- package/dist/esm/plot/edit/EditFormation.js +0 -120
- package/dist/esm/plot/edit/EditLabel.d.ts +0 -7
- package/dist/esm/plot/edit/EditLabel.js +0 -100
- package/dist/esm/plot/edit/EditLineArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditLineArrow.js +0 -180
- package/dist/esm/plot/edit/EditPincerArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditPincerArrow.js +0 -121
- package/dist/esm/plot/edit/EditPoint.d.ts +0 -7
- package/dist/esm/plot/edit/EditPoint.js +0 -70
- package/dist/esm/plot/edit/EditPolygon.d.ts +0 -8
- package/dist/esm/plot/edit/EditPolygon.js +0 -181
- package/dist/esm/plot/edit/EditPolyline.d.ts +0 -8
- package/dist/esm/plot/edit/EditPolyline.js +0 -179
- package/dist/esm/plot/edit/EditRectangle.d.ts +0 -8
- package/dist/esm/plot/edit/EditRectangle.js +0 -119
- package/dist/esm/plot/edit/EditRegularPolygon.d.ts +0 -8
- package/dist/esm/plot/edit/EditRegularPolygon.js +0 -170
- package/dist/esm/plot/edit/EditRightAngleArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditRightAngleArrow.js +0 -143
- package/dist/esm/plot/edit/EditRoundRectangle.d.ts +0 -8
- package/dist/esm/plot/edit/EditRoundRectangle.js +0 -119
- package/dist/esm/plot/edit/EditSector.d.ts +0 -8
- package/dist/esm/plot/edit/EditSector.js +0 -120
- package/dist/esm/plot/edit/EditStraightArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditStraightArrow.js +0 -120
- package/dist/esm/plot/edit/EditSwallowtailArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditSwallowtailArrow.js +0 -121
- package/dist/esm/plot/edit/index.d.ts +0 -23
- package/dist/esm/plot/edit/index.js +0 -23
- package/dist/esm/plot/utils/DomUtil.d.ts +0 -34
- package/dist/esm/plot/utils/DomUtil.js +0 -100
- package/dist/esm/plot/utils/PlotCommon.d.ts +0 -101
- package/dist/esm/plot/utils/ReminderTip.d.ts +0 -10
- package/dist/esm/plot/utils/ReminderTip.js +0 -67
- package/dist/esm/plot/utils/Tooltip.d.ts +0 -3
- package/dist/esm/plot/utils/Tooltip.js +0 -97
- /package/dist/esm/{plot/utils/Algorithm.d.ts → drawer/algorithm.d.ts} +0 -0
- /package/dist/esm/{plot/utils/Coordinate.js → drawer/coordinate.js} +0 -0
- /package/dist/esm/{plot/utils → drawer}/plotUtil.d.ts +0 -0
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
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."); }
|
|
3
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
4
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
5
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
+
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."); }
|
|
7
|
+
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); }
|
|
8
|
+
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; }
|
|
9
|
+
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; } }
|
|
10
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
+
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); }
|
|
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 { createBezierPoints } from "../common";
|
|
30
|
+
import * as utils from "../../tool/utils";
|
|
31
|
+
import { STATUS } from "../types";
|
|
32
|
+
import BaseShape from "./BaseShape";
|
|
33
|
+
import DragPoint from "./DragPoint";
|
|
34
|
+
import { ShapePolyline } from "./Polyline";
|
|
35
|
+
// 曲线至少需要 2 个控制点才能形成有效线段。
|
|
36
|
+
var MIN_CURVE_ANCHORS = 2;
|
|
37
|
+
var Curve = /*#__PURE__*/function (_BaseShape) {
|
|
38
|
+
_inherits(Curve, _BaseShape);
|
|
39
|
+
var _super = _createSuper(Curve);
|
|
40
|
+
function Curve(drawContext, config) {
|
|
41
|
+
var _this;
|
|
42
|
+
_classCallCheck(this, Curve);
|
|
43
|
+
_this = _super.call(this, drawContext);
|
|
44
|
+
_defineProperty(_assertThisInitialized(_this), "type", 'curve');
|
|
45
|
+
_defineProperty(_assertThisInitialized(_this), "shapePolylineLayer", void 0);
|
|
46
|
+
// 用户点击的控制点(用于编辑/还原),不同于 this.positions(渲染用特征点)。
|
|
47
|
+
_defineProperty(_assertThisInitialized(_this), "_anchorPositions", void 0);
|
|
48
|
+
// 绘制阶段用于预览的临时控制点(鼠标移动点)。
|
|
49
|
+
_defineProperty(_assertThisInitialized(_this), "_tempPosition", void 0);
|
|
50
|
+
_this._anchorPositions = [];
|
|
51
|
+
_this._tempPosition = null;
|
|
52
|
+
_this.clampToGround = isNil(config === null || config === void 0 ? void 0 : config.clampToGround) ? _this.clampToGround : config.clampToGround;
|
|
53
|
+
_this.pointStyle.heightReference = _this.clampToGround ? Cesium.HeightReference.CLAMP_TO_GROUND : Cesium.HeightReference.NONE;
|
|
54
|
+
_this.polylineStyle.clampToGround = _this.clampToGround;
|
|
55
|
+
return _this;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// 鼠标事件位置统一转成内部经纬高三元组。
|
|
59
|
+
_createClass(Curve, [{
|
|
60
|
+
key: "_toPositionTuple",
|
|
61
|
+
value: function _toPositionTuple(position) {
|
|
62
|
+
var lng = position.lng,
|
|
63
|
+
lat = position.lat,
|
|
64
|
+
_position$alt = position.alt,
|
|
65
|
+
alt = _position$alt === void 0 ? 0 : _position$alt;
|
|
66
|
+
return [lng, lat, alt];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// 贴地时高度统一为 0;非贴地时用控制点平均高度近似。
|
|
70
|
+
}, {
|
|
71
|
+
key: "_getAltitudeBase",
|
|
72
|
+
value: function _getAltitudeBase(anchorPositions) {
|
|
73
|
+
if (this.clampToGround) {
|
|
74
|
+
return 0;
|
|
75
|
+
}
|
|
76
|
+
var altitudes = anchorPositions.map(function (position) {
|
|
77
|
+
return position === null || position === void 0 ? void 0 : position[2];
|
|
78
|
+
}).filter(function (altitude) {
|
|
79
|
+
return Number.isFinite(altitude);
|
|
80
|
+
});
|
|
81
|
+
if (!altitudes.length) {
|
|
82
|
+
return 0;
|
|
83
|
+
}
|
|
84
|
+
return altitudes.reduce(function (sum, altitude) {
|
|
85
|
+
return sum + altitude;
|
|
86
|
+
}, 0) / altitudes.length;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// 统一释放线图层,避免绘制中断后残留几何。
|
|
90
|
+
}, {
|
|
91
|
+
key: "_destroyShapeLayer",
|
|
92
|
+
value: function _destroyShapeLayer() {
|
|
93
|
+
this.shapePolylineLayer && this.shapePolylineLayer.destroy();
|
|
94
|
+
this.shapePolylineLayer = null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// 根据当前点数组同步线图层。
|
|
98
|
+
}, {
|
|
99
|
+
key: "_syncShapeLayer",
|
|
100
|
+
value: function _syncShapeLayer() {
|
|
101
|
+
if (!this.positions.length) {
|
|
102
|
+
this._destroyShapeLayer();
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (!this.shapePolylineLayer) {
|
|
106
|
+
this.shapePolylineLayer = new ShapePolyline(this.getMap(), {
|
|
107
|
+
positions: this.positions,
|
|
108
|
+
style: this.polylineStyle
|
|
109
|
+
});
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
this.shapePolylineLayer.update(this.positions);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// 参考 drawer/common.createBezierPoints:用控制点计算贝塞尔曲线点集。
|
|
116
|
+
}, {
|
|
117
|
+
key: "_buildCurvePositions",
|
|
118
|
+
value: function _buildCurvePositions(anchorPositions) {
|
|
119
|
+
var _this2 = this;
|
|
120
|
+
if (anchorPositions.length < MIN_CURVE_ANCHORS) {
|
|
121
|
+
return anchorPositions.length ? [anchorPositions[0]] : [];
|
|
122
|
+
}
|
|
123
|
+
var anchorCartesians = anchorPositions.map(function (position) {
|
|
124
|
+
return _this2._toCartesian3(position);
|
|
125
|
+
}).filter(function (position) {
|
|
126
|
+
return Boolean(position);
|
|
127
|
+
});
|
|
128
|
+
if (anchorCartesians.length < MIN_CURVE_ANCHORS) {
|
|
129
|
+
return [];
|
|
130
|
+
}
|
|
131
|
+
var curvePoints;
|
|
132
|
+
try {
|
|
133
|
+
curvePoints = createBezierPoints(anchorCartesians);
|
|
134
|
+
} catch (error) {
|
|
135
|
+
return [];
|
|
136
|
+
}
|
|
137
|
+
if (!Array.isArray(curvePoints) || !curvePoints.length) {
|
|
138
|
+
return [];
|
|
139
|
+
}
|
|
140
|
+
var altitudeBase = this._getAltitudeBase(anchorPositions);
|
|
141
|
+
return curvePoints.map(function (cartesian) {
|
|
142
|
+
if (!cartesian || _typeof(cartesian) !== 'object' || !Number.isFinite(cartesian.x) || !Number.isFinite(cartesian.y) || !Number.isFinite(cartesian.z)) {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
var _utils$cartesian3ToLn = utils.cartesian3ToLngLatAlt(cartesian),
|
|
146
|
+
lng = _utils$cartesian3ToLn.lng,
|
|
147
|
+
lat = _utils$cartesian3ToLn.lat;
|
|
148
|
+
return [lng, lat, altitudeBase];
|
|
149
|
+
}).filter(function (position) {
|
|
150
|
+
return Boolean(position);
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// 统一根据控制点更新曲线点集、渲染图层。
|
|
155
|
+
}, {
|
|
156
|
+
key: "_applyGeometry",
|
|
157
|
+
value: function _applyGeometry(anchorPositions) {
|
|
158
|
+
var positions = this._buildCurvePositions(anchorPositions);
|
|
159
|
+
if (positions.length < 2) {
|
|
160
|
+
this.positions = positions;
|
|
161
|
+
this._syncShapeLayer();
|
|
162
|
+
return positions.length > 0;
|
|
163
|
+
}
|
|
164
|
+
this.positions = positions;
|
|
165
|
+
this._syncShapeLayer();
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// 绘制预览阶段透出当前曲线点集。
|
|
170
|
+
}, {
|
|
171
|
+
key: "_emitMouseMoveChange",
|
|
172
|
+
value: function _emitMouseMoveChange() {
|
|
173
|
+
this._drawContext.options.onMouseMoveChange && this._drawContext.options.onMouseMoveChange({
|
|
174
|
+
layer: this,
|
|
175
|
+
positions: this.positions
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// 编辑态拖拽时透出最新曲线点集。
|
|
180
|
+
}, {
|
|
181
|
+
key: "_emitPointsChange",
|
|
182
|
+
value: function _emitPointsChange() {
|
|
183
|
+
var _this$_drawContext$op, _this$_drawContext$op2;
|
|
184
|
+
((_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({
|
|
185
|
+
layer: this,
|
|
186
|
+
positions: this.positions
|
|
187
|
+
}));
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// 统一完成绘制:入库、触发回调并进入编辑态。
|
|
191
|
+
}, {
|
|
192
|
+
key: "_finishDraw",
|
|
193
|
+
value: function _finishDraw() {
|
|
194
|
+
if (this._anchorPositions.length < MIN_CURVE_ANCHORS) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
this._drawContext.setDrawerLayer(this.id, this);
|
|
198
|
+
this.drawEnd(this);
|
|
199
|
+
this.startEdit();
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// 基于 anchors 还原曲线;缺少 anchors 时由 Drawer 回退为普通 polyline。
|
|
203
|
+
}, {
|
|
204
|
+
key: "transformData",
|
|
205
|
+
value: function transformData(_) {
|
|
206
|
+
var _this3 = this;
|
|
207
|
+
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
208
|
+
var anchors = config === null || config === void 0 ? void 0 : config.anchors;
|
|
209
|
+
if (!Array.isArray(anchors) || anchors.length < MIN_CURVE_ANCHORS) {
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
this._anchorPositions = anchors.filter(function (position) {
|
|
213
|
+
return Array.isArray(position) && position.length >= 2;
|
|
214
|
+
}).map(function (position) {
|
|
215
|
+
var _position = _slicedToArray(position, 3),
|
|
216
|
+
lng = _position[0],
|
|
217
|
+
lat = _position[1],
|
|
218
|
+
_position$ = _position[2],
|
|
219
|
+
alt = _position$ === void 0 ? 0 : _position$;
|
|
220
|
+
return [lng, lat, alt];
|
|
221
|
+
});
|
|
222
|
+
if (this._anchorPositions.length < MIN_CURVE_ANCHORS) {
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
if (!this._applyGeometry(this._anchorPositions)) {
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
this.dragPoints.forEach(function (point) {
|
|
229
|
+
return point.destroy();
|
|
230
|
+
});
|
|
231
|
+
this.dragPoints = [];
|
|
232
|
+
this._destroyMiddlePoints();
|
|
233
|
+
this._tempPosition = null;
|
|
234
|
+
this._anchorPositions.forEach(function (anchor, index) {
|
|
235
|
+
var point = new DragPoint(_this3.getMap(), {
|
|
236
|
+
positions: anchor,
|
|
237
|
+
style: _this3.pointStyle
|
|
238
|
+
});
|
|
239
|
+
point.isStart = index === 0;
|
|
240
|
+
point.endEdit();
|
|
241
|
+
point.show(false);
|
|
242
|
+
_this3.dragPoints.push(point);
|
|
243
|
+
});
|
|
244
|
+
this._drawContext.setDrawerLayer(this.id, this);
|
|
245
|
+
return true;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// 添加控制点;当控制点数满足算法要求时刷新曲线点集并渲染。
|
|
249
|
+
}, {
|
|
250
|
+
key: "addPoint",
|
|
251
|
+
value: function addPoint(position) {
|
|
252
|
+
var nextPosition = this._toPositionTuple(position);
|
|
253
|
+
this._anchorPositions.push(nextPosition);
|
|
254
|
+
this._tempPosition = null;
|
|
255
|
+
var point = new DragPoint(this.getMap(), {
|
|
256
|
+
positions: nextPosition,
|
|
257
|
+
style: this.pointStyle
|
|
258
|
+
});
|
|
259
|
+
point.isStart = this._anchorPositions.length === 1;
|
|
260
|
+
this.dragPoints.push(point);
|
|
261
|
+
this._applyGeometry(this._anchorPositions);
|
|
262
|
+
this.drawing(this);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// 删除上一个控制点(绘制阶段右键撤销)。
|
|
266
|
+
}, {
|
|
267
|
+
key: "removePrev",
|
|
268
|
+
value: function removePrev() {
|
|
269
|
+
if (!this._anchorPositions.length) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
var removeIndex = this._anchorPositions.length - 1;
|
|
273
|
+
this._anchorPositions.splice(removeIndex, 1);
|
|
274
|
+
if (this.dragPoints[removeIndex]) {
|
|
275
|
+
this.dragPoints[removeIndex].destroy();
|
|
276
|
+
this.dragPoints.splice(removeIndex, 1);
|
|
277
|
+
}
|
|
278
|
+
if (!this._anchorPositions.length) {
|
|
279
|
+
this.positions = [];
|
|
280
|
+
this._destroyShapeLayer();
|
|
281
|
+
} else {
|
|
282
|
+
var previewAnchors = this._tempPosition ? [].concat(_toConsumableArray(this._anchorPositions), [this._tempPosition]) : _toConsumableArray(this._anchorPositions);
|
|
283
|
+
this._applyGeometry(previewAnchors);
|
|
284
|
+
}
|
|
285
|
+
this.drawing(this);
|
|
286
|
+
this._emitMouseMoveChange();
|
|
287
|
+
if (!this._anchorPositions.length) {
|
|
288
|
+
this._drawContext._changeStatus(STATUS.START_DRAW);
|
|
289
|
+
this._drawContext._updateTooltip();
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// 更新临时控制点(绘制阶段鼠标移动预览)。
|
|
294
|
+
}, {
|
|
295
|
+
key: "updateTempPosition",
|
|
296
|
+
value: function updateTempPosition(position) {
|
|
297
|
+
if (!this._anchorPositions.length) {
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
var nextPosition = this._toPositionTuple(position);
|
|
301
|
+
this._tempPosition = nextPosition;
|
|
302
|
+
var previewAnchors = [].concat(_toConsumableArray(this._anchorPositions), [nextPosition]);
|
|
303
|
+
if (!this._applyGeometry(previewAnchors)) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
this._emitMouseMoveChange();
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// 结束绘制:收敛曲线点集并进入编辑态。
|
|
310
|
+
}, {
|
|
311
|
+
key: "endDraw",
|
|
312
|
+
value: function endDraw() {
|
|
313
|
+
if (this._anchorPositions.length < MIN_CURVE_ANCHORS) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
this._tempPosition = null;
|
|
317
|
+
if (!this._applyGeometry(this._anchorPositions)) {
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
this._finishDraw();
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// 开始编辑:沿用 Drawer 的多点编辑模式(端点+中间点插入)。
|
|
324
|
+
}, {
|
|
325
|
+
key: "startEdit",
|
|
326
|
+
value: function startEdit() {
|
|
327
|
+
if (this._anchorPositions.length < MIN_CURVE_ANCHORS) {
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
_get(_getPrototypeOf(Curve.prototype), "startEdit", this).call(this);
|
|
331
|
+
this._startEdgeEditing();
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// 开始鼠标拖拽。
|
|
335
|
+
}, {
|
|
336
|
+
key: "mouseDragStart",
|
|
337
|
+
value: function mouseDragStart(position, dragLayer) {
|
|
338
|
+
this._handleDragStart(dragLayer);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// 鼠标拖拽:更新控制点并重新计算曲线点集。
|
|
342
|
+
}, {
|
|
343
|
+
key: "mouseDragChange",
|
|
344
|
+
value: function mouseDragChange(position) {
|
|
345
|
+
if (!this.dragging || !this.dragLayer) {
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
this.dragLayer.mouseDragChange(position);
|
|
349
|
+
var anchorPositions = this._updatePositionsFromEdges();
|
|
350
|
+
if (!anchorPositions.length) {
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
this._anchorPositions = anchorPositions;
|
|
354
|
+
this._applyGeometry(this._anchorPositions);
|
|
355
|
+
this._emitPointsChange();
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// 拖拽结束:补齐新的中间点。
|
|
359
|
+
}, {
|
|
360
|
+
key: "mouseDragEnd",
|
|
361
|
+
value: function mouseDragEnd() {
|
|
362
|
+
this._handleDragEnd();
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// 结束编辑:隐藏控制点并销毁中间点。
|
|
366
|
+
}, {
|
|
367
|
+
key: "endEdit",
|
|
368
|
+
value: function endEdit(layer) {
|
|
369
|
+
var emitComplete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
370
|
+
_get(_getPrototypeOf(Curve.prototype), "endEdit", this).call(this, layer, emitComplete);
|
|
371
|
+
this._stopEdgeEditing();
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// 销毁时同时清理渲染图层和内部几何状态。
|
|
375
|
+
}, {
|
|
376
|
+
key: "destroy",
|
|
377
|
+
value: function destroy() {
|
|
378
|
+
_get(_getPrototypeOf(Curve.prototype), "destroy", this).call(this);
|
|
379
|
+
this._destroyShapeLayer();
|
|
380
|
+
this._anchorPositions = [];
|
|
381
|
+
this._tempPosition = null;
|
|
382
|
+
}
|
|
383
|
+
}]);
|
|
384
|
+
return Curve;
|
|
385
|
+
}(BaseShape);
|
|
386
|
+
export default Curve;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
declare class DragPoint {
|
|
2
|
+
private readonly _mapContext;
|
|
3
|
+
id: string;
|
|
4
|
+
layer: any;
|
|
5
|
+
isEditing: boolean;
|
|
6
|
+
isMiddlePoint: boolean;
|
|
7
|
+
isDestroyed: boolean;
|
|
8
|
+
labelLayer: any;
|
|
9
|
+
private _geoJson;
|
|
10
|
+
private _style;
|
|
11
|
+
/**
|
|
12
|
+
* 构造函数,用于创建一个地图元素实例
|
|
13
|
+
* @param map 地图对象,包含地图上下文信息
|
|
14
|
+
* @param options 配置选项对象
|
|
15
|
+
* @param options.positions 点的坐标位置数组
|
|
16
|
+
* @param options.style 样式配置
|
|
17
|
+
* @param options.isMiddlePoint 是否为中间点的标识,默认为false
|
|
18
|
+
*/
|
|
19
|
+
constructor(map: any, { positions, style, isMiddlePoint }: any);
|
|
20
|
+
getMap(): any;
|
|
21
|
+
getPosition(): 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
|
+
}
|
|
32
|
+
export default DragPoint;
|
|
@@ -0,0 +1,211 @@
|
|
|
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
5
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
7
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
8
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
9
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
10
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
12
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
|
+
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; }
|
|
14
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
15
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
16
|
+
import * as Cesium from 'deeptwins-cesium';
|
|
17
|
+
import { v4 as uuidV4 } from 'uuid';
|
|
18
|
+
import PositionProperty from "../../property/PositionProperty";
|
|
19
|
+
import * as utils from "../../tool/utils";
|
|
20
|
+
|
|
21
|
+
// 拖动点样式
|
|
22
|
+
var DRAG_POINT_STYLE = {
|
|
23
|
+
pixelSize: 10,
|
|
24
|
+
color: '#ffffff',
|
|
25
|
+
outline: true,
|
|
26
|
+
outlineColor: '#1890FF',
|
|
27
|
+
outlineWidth: 2
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// 临时拖动点样式
|
|
31
|
+
var TEMP_DRAG_POINT_STYLE = {
|
|
32
|
+
pixelSize: 10,
|
|
33
|
+
color: '#1890FF',
|
|
34
|
+
outline: true,
|
|
35
|
+
outlineColor: '#ffffff',
|
|
36
|
+
outlineWidth: 2
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// 创建可拖动的点
|
|
40
|
+
var DragPoint = /*#__PURE__*/function () {
|
|
41
|
+
/**
|
|
42
|
+
* 构造函数,用于创建一个地图元素实例
|
|
43
|
+
* @param map 地图对象,包含地图上下文信息
|
|
44
|
+
* @param options 配置选项对象
|
|
45
|
+
* @param options.positions 点的坐标位置数组
|
|
46
|
+
* @param options.style 样式配置
|
|
47
|
+
* @param options.isMiddlePoint 是否为中间点的标识,默认为false
|
|
48
|
+
*/
|
|
49
|
+
function DragPoint(map, _ref) {
|
|
50
|
+
var positions = _ref.positions,
|
|
51
|
+
style = _ref.style,
|
|
52
|
+
_ref$isMiddlePoint = _ref.isMiddlePoint,
|
|
53
|
+
isMiddlePoint = _ref$isMiddlePoint === void 0 ? false : _ref$isMiddlePoint;
|
|
54
|
+
_classCallCheck(this, DragPoint);
|
|
55
|
+
_defineProperty(this, "_mapContext", void 0);
|
|
56
|
+
_defineProperty(this, "id", '');
|
|
57
|
+
_defineProperty(this, "layer", void 0);
|
|
58
|
+
// 是否编辑中
|
|
59
|
+
_defineProperty(this, "isEditing", false);
|
|
60
|
+
// 是否是中间点
|
|
61
|
+
_defineProperty(this, "isMiddlePoint", false);
|
|
62
|
+
_defineProperty(this, "isDestroyed", false);
|
|
63
|
+
_defineProperty(this, "labelLayer", void 0);
|
|
64
|
+
_defineProperty(this, "_geoJson", void 0);
|
|
65
|
+
_defineProperty(this, "_style", void 0);
|
|
66
|
+
this._mapContext = map._mapContext;
|
|
67
|
+
this.id = uuidV4();
|
|
68
|
+
this.isMiddlePoint = isMiddlePoint;
|
|
69
|
+
this._geoJson = {
|
|
70
|
+
type: 'Feature',
|
|
71
|
+
geometry: {
|
|
72
|
+
type: 'Point',
|
|
73
|
+
coordinates: positions
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
this._style = style;
|
|
77
|
+
this._create();
|
|
78
|
+
}
|
|
79
|
+
_createClass(DragPoint, [{
|
|
80
|
+
key: "getMap",
|
|
81
|
+
value: function getMap() {
|
|
82
|
+
return this._mapContext && this._mapContext.getMap();
|
|
83
|
+
}
|
|
84
|
+
}, {
|
|
85
|
+
key: "getPosition",
|
|
86
|
+
value: function getPosition() {
|
|
87
|
+
var _this$_geoJson;
|
|
88
|
+
var coordinates = (_this$_geoJson = this._geoJson) === null || _this$_geoJson === void 0 || (_this$_geoJson = _this$_geoJson.geometry) === null || _this$_geoJson === void 0 ? void 0 : _this$_geoJson.coordinates;
|
|
89
|
+
return Array.isArray(coordinates) ? _toConsumableArray(coordinates) : coordinates;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// 是否能进行操作
|
|
93
|
+
}, {
|
|
94
|
+
key: "_canOperate",
|
|
95
|
+
value: function _canOperate() {
|
|
96
|
+
if (this.isDestroyed) {
|
|
97
|
+
utils.error('DragPoint实例已销毁');
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// 创建
|
|
104
|
+
}, {
|
|
105
|
+
key: "_create",
|
|
106
|
+
value: function _create() {
|
|
107
|
+
if (!this._canOperate()) return;
|
|
108
|
+
this.layer = this.getMap().addGraphicLayer(this._geoJson, {
|
|
109
|
+
type: 'point',
|
|
110
|
+
id: this.id,
|
|
111
|
+
style: _objectSpread(_objectSpread({}, this._style), {}, {
|
|
112
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
113
|
+
}),
|
|
114
|
+
positionProperty: new PositionProperty()
|
|
115
|
+
});
|
|
116
|
+
if (!this.isMiddlePoint) {
|
|
117
|
+
this._createLabel();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// 创建label
|
|
122
|
+
}, {
|
|
123
|
+
key: "_createLabel",
|
|
124
|
+
value: function _createLabel() {
|
|
125
|
+
this.labelLayer = this.getMap().addGraphicLayer(this._geoJson, {
|
|
126
|
+
type: 'label',
|
|
127
|
+
style: {
|
|
128
|
+
text: '',
|
|
129
|
+
font: 'bold 16px Arial',
|
|
130
|
+
style: Cesium.LabelStyle.FILL_AND_OUTLINE,
|
|
131
|
+
outlineWidth: 4,
|
|
132
|
+
eyeOffset: [-20, 0, 0],
|
|
133
|
+
horizontalOrigin: Cesium.HorizontalOrigin.RIGHT,
|
|
134
|
+
heightReference: Cesium.HeightReference.NONE,
|
|
135
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
136
|
+
show: false
|
|
137
|
+
},
|
|
138
|
+
positionProperty: new PositionProperty()
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// 开始编辑
|
|
143
|
+
}, {
|
|
144
|
+
key: "startEdit",
|
|
145
|
+
value: function startEdit() {
|
|
146
|
+
if (!this._canOperate()) return;
|
|
147
|
+
this.isEditing = true;
|
|
148
|
+
this.layer && this.layer.setStyle(this.isMiddlePoint ? TEMP_DRAG_POINT_STYLE : DRAG_POINT_STYLE);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// 开始鼠标拖拽
|
|
152
|
+
}, {
|
|
153
|
+
key: "mouseDragStart",
|
|
154
|
+
value: function mouseDragStart() {
|
|
155
|
+
if (this.isMiddlePoint) {
|
|
156
|
+
this.isMiddlePoint = false;
|
|
157
|
+
this.layer && this.layer.setStyle(DRAG_POINT_STYLE);
|
|
158
|
+
this._createLabel();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// 鼠标拖拽
|
|
163
|
+
}, {
|
|
164
|
+
key: "mouseDragChange",
|
|
165
|
+
value: function mouseDragChange(position) {
|
|
166
|
+
if (!this._canOperate()) return;
|
|
167
|
+
if (this.layer && position) {
|
|
168
|
+
var lng = position.lng,
|
|
169
|
+
lat = position.lat,
|
|
170
|
+
alt = position.alt;
|
|
171
|
+
this._geoJson.geometry.coordinates = [lng, lat, alt];
|
|
172
|
+
this.layer.setData(this._geoJson);
|
|
173
|
+
this.labelLayer && this.labelLayer.setData(this._geoJson);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// 结束编辑
|
|
178
|
+
}, {
|
|
179
|
+
key: "endEdit",
|
|
180
|
+
value: function endEdit() {
|
|
181
|
+
if (!this._canOperate()) return;
|
|
182
|
+
if (this.layer) {
|
|
183
|
+
this.isEditing = false;
|
|
184
|
+
this.layer.setStyle(this._style);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// 隐藏
|
|
189
|
+
}, {
|
|
190
|
+
key: "show",
|
|
191
|
+
value: function show(isShow) {
|
|
192
|
+
if (!this._canOperate()) return;
|
|
193
|
+
this.layer && this.layer.show(isShow);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// 销毁
|
|
197
|
+
}, {
|
|
198
|
+
key: "destroy",
|
|
199
|
+
value: function destroy() {
|
|
200
|
+
if (!this._canOperate()) return;
|
|
201
|
+
this.isDestroyed = true;
|
|
202
|
+
this.isEditing = false;
|
|
203
|
+
this.layer && this.layer.remove();
|
|
204
|
+
this.layer = null;
|
|
205
|
+
this.labelLayer && this.labelLayer.remove();
|
|
206
|
+
this.labelLayer = null;
|
|
207
|
+
}
|
|
208
|
+
}]);
|
|
209
|
+
return DragPoint;
|
|
210
|
+
}();
|
|
211
|
+
export default DragPoint;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import BaseShape from './BaseShape';
|
|
2
|
+
declare class Elliptic extends BaseShape {
|
|
3
|
+
readonly type: string;
|
|
4
|
+
shapePolylineLayer: any;
|
|
5
|
+
shapePolygonLayer: any;
|
|
6
|
+
private _segments;
|
|
7
|
+
private _centerPosition;
|
|
8
|
+
private _handlePosition;
|
|
9
|
+
constructor(drawContext: any, config: any);
|
|
10
|
+
private _normalizeSegments;
|
|
11
|
+
private _toPositionTuple;
|
|
12
|
+
private _getAltitudeBase;
|
|
13
|
+
private _getDrawPolylinePositions;
|
|
14
|
+
private _getDrawPolygonPositions;
|
|
15
|
+
private _destroyShapeLayers;
|
|
16
|
+
private _syncShapeLayers;
|
|
17
|
+
private _buildEllipticPositions;
|
|
18
|
+
private _getLocalHandleVector;
|
|
19
|
+
private _getPositionByLocalVector;
|
|
20
|
+
private _applyGeometry;
|
|
21
|
+
private _destroyEditHandles;
|
|
22
|
+
private _createEditHandle;
|
|
23
|
+
private _syncEditHandles;
|
|
24
|
+
private _emitMouseMoveChange;
|
|
25
|
+
private _emitPointsChange;
|
|
26
|
+
private _finishDraw;
|
|
27
|
+
transformData(_: any[], config?: any): boolean;
|
|
28
|
+
addPoint(position: any): void;
|
|
29
|
+
updateTempPosition(position: any): void;
|
|
30
|
+
endDraw(): void;
|
|
31
|
+
startEdit(): void;
|
|
32
|
+
mouseDragStart(position: any, dragLayer: any): void;
|
|
33
|
+
mouseDragChange(position: any): void;
|
|
34
|
+
mouseDragEnd(): void;
|
|
35
|
+
endEdit(layer: any, emitComplete?: boolean): void;
|
|
36
|
+
destroy(): void;
|
|
37
|
+
}
|
|
38
|
+
export default Elliptic;
|