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
package/dist/esm/drawer/utils.js
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
var _excluded = ["type", "featureTypeField", "featureConfigField", "config"];
|
|
2
|
+
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); }
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
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
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
9
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
10
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
11
|
+
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."); }
|
|
12
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
13
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
14
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
15
|
+
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."); }
|
|
16
|
+
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); }
|
|
17
|
+
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; }
|
|
18
|
+
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; } }
|
|
19
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
2
20
|
import { flattenEach } from '@turf/turf';
|
|
21
|
+
import * as Cesium from 'deeptwins-cesium';
|
|
22
|
+
import * as utils from "../tool/utils";
|
|
23
|
+
var DEFAULT_FEATURE_TYPE_FIELD = 'shapeType';
|
|
24
|
+
var DEFAULT_FEATURE_CONFIG_FIELD = 'shapeConfig';
|
|
25
|
+
var DRAWER_GEOMETRY_SHAPE_MAP = {
|
|
26
|
+
Point: 'point',
|
|
27
|
+
MultiPoint: 'point',
|
|
28
|
+
LineString: 'polyline',
|
|
29
|
+
MultiLineString: 'polyline',
|
|
30
|
+
Polygon: 'polygon',
|
|
31
|
+
MultiPolygon: 'polygon'
|
|
32
|
+
};
|
|
33
|
+
var DRAWER_POLYGON_BASED_SHAPES = new Set(['polygon', 'circle', 'regularPolygon', 'assemble', 'attackArrow', 'elliptic', 'pincerArrow', 'rightAngleArrow', 'sector', 'straightArrow', 'swallowtailArrow']);
|
|
34
|
+
var DRAWER_POLYLINE_BASED_SHAPES = new Set(['polyline', 'bow', 'curve', 'formation']);
|
|
35
|
+
|
|
36
|
+
// 获取对应类型的数据处理方法
|
|
3
37
|
export var HANDLE_FEATURE_DATA_TYPE_FUN = {
|
|
4
38
|
Point: handleFeaturePoint,
|
|
5
39
|
MultiPoint: handleFeatureMultiPoint,
|
|
@@ -9,6 +43,290 @@ export var HANDLE_FEATURE_DATA_TYPE_FUN = {
|
|
|
9
43
|
MultiPolygon: handleFeatureMultiPolygon
|
|
10
44
|
};
|
|
11
45
|
|
|
46
|
+
// 去掉 GeoJSON Polygon 首尾重复的闭合点,避免编辑时生成重复控制点。
|
|
47
|
+
export function normalizePolygonPositions() {
|
|
48
|
+
var positions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
49
|
+
if (!Array.isArray(positions)) {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
var normalizedPositions = positions.filter(function (position) {
|
|
53
|
+
return Array.isArray(position) && position.length >= 2;
|
|
54
|
+
}).map(function (position) {
|
|
55
|
+
var _position = _slicedToArray(position, 3),
|
|
56
|
+
lng = _position[0],
|
|
57
|
+
lat = _position[1],
|
|
58
|
+
_position$ = _position[2],
|
|
59
|
+
alt = _position$ === void 0 ? 0 : _position$;
|
|
60
|
+
return [lng, lat, alt];
|
|
61
|
+
});
|
|
62
|
+
if (normalizedPositions.length < 2) {
|
|
63
|
+
return normalizedPositions;
|
|
64
|
+
}
|
|
65
|
+
var first = normalizedPositions[0];
|
|
66
|
+
var last = normalizedPositions[normalizedPositions.length - 1];
|
|
67
|
+
var isClosedRing = first[0] === last[0] && first[1] === last[1] && first[2] === last[2];
|
|
68
|
+
return isClosedRing ? normalizedPositions.slice(0, normalizedPositions.length - 1) : normalizedPositions;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// 根据 polygon 顶点估算中心点,供 circle / regularPolygon 恢复双控制点模型。
|
|
72
|
+
export function getPolygonRestoreCenterPosition(positions) {
|
|
73
|
+
var normalizedPositions = normalizePolygonPositions(positions);
|
|
74
|
+
if (!normalizedPositions.length) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
var cartesianPositions = normalizedPositions.map(function (position) {
|
|
78
|
+
var _position2 = _slicedToArray(position, 3),
|
|
79
|
+
lng = _position2[0],
|
|
80
|
+
lat = _position2[1],
|
|
81
|
+
_position2$ = _position2[2],
|
|
82
|
+
alt = _position2$ === void 0 ? 0 : _position2$;
|
|
83
|
+
if (!Number.isFinite(lng) || !Number.isFinite(lat) || !Number.isFinite(alt)) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
return utils.lngLatAltToCartesian3(lng, lat, alt);
|
|
87
|
+
}).filter(function (position) {
|
|
88
|
+
return Boolean(position);
|
|
89
|
+
});
|
|
90
|
+
if (!cartesianPositions.length) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
var boundingSphere = Cesium.BoundingSphere.fromPoints(cartesianPositions);
|
|
94
|
+
var _utils$cartesian3ToLn = utils.cartesian3ToLngLatAlt(boundingSphere.center),
|
|
95
|
+
lng = _utils$cartesian3ToLn.lng,
|
|
96
|
+
lat = _utils$cartesian3ToLn.lat,
|
|
97
|
+
alt = _utils$cartesian3ToLn.alt;
|
|
98
|
+
return [lng, lat, alt];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// polygon 型特殊 shape 统一使用首个顶点作为半径/朝向控制点。
|
|
102
|
+
export function getPolygonRestoreHandlePosition(positions) {
|
|
103
|
+
var _normalizePolygonPosi = normalizePolygonPositions(positions),
|
|
104
|
+
_normalizePolygonPosi2 = _slicedToArray(_normalizePolygonPosi, 1),
|
|
105
|
+
firstPosition = _normalizePolygonPosi2[0];
|
|
106
|
+
if (!firstPosition) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
return _toConsumableArray(firstPosition);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// 检测恢复项
|
|
113
|
+
function isValidRestorePositionTuple(position) {
|
|
114
|
+
return Array.isArray(position) && position.length >= 3 && Number.isFinite(position[0]) && Number.isFinite(position[1]) && Number.isFinite(position[2]);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// 转换恢复项
|
|
118
|
+
function toCartesianRestorePositions(positions) {
|
|
119
|
+
var cartesianPositions = positions.map(function (position) {
|
|
120
|
+
var _position3 = _slicedToArray(position, 3),
|
|
121
|
+
lng = _position3[0],
|
|
122
|
+
lat = _position3[1],
|
|
123
|
+
_position3$ = _position3[2],
|
|
124
|
+
alt = _position3$ === void 0 ? 0 : _position3$;
|
|
125
|
+
if (!Number.isFinite(lng) || !Number.isFinite(lat) || !Number.isFinite(alt)) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
return utils.lngLatAltToCartesian3(lng, lat, alt);
|
|
129
|
+
}).filter(function (position) {
|
|
130
|
+
return Boolean(position);
|
|
131
|
+
});
|
|
132
|
+
return cartesianPositions.length === positions.length ? cartesianPositions : [];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// 获取中位值
|
|
136
|
+
function getMedianValue(values) {
|
|
137
|
+
var sortedValues = _toConsumableArray(values).sort(function (prev, next) {
|
|
138
|
+
return prev - next;
|
|
139
|
+
});
|
|
140
|
+
var middleIndex = Math.floor(sortedValues.length / 2);
|
|
141
|
+
if (sortedValues.length % 2 === 1) {
|
|
142
|
+
return sortedValues[middleIndex];
|
|
143
|
+
}
|
|
144
|
+
return (sortedValues[middleIndex - 1] + sortedValues[middleIndex]) / 2;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// 扇形的圆心到所有圆弧点距离基本一致,据此识别圆心顶点。
|
|
148
|
+
function getSectorRestoreCenterIndex(cartesianPositions) {
|
|
149
|
+
var bestIndex = -1;
|
|
150
|
+
var bestConsistency = -1;
|
|
151
|
+
var bestSpread = Number.POSITIVE_INFINITY;
|
|
152
|
+
var _loop = function _loop(index) {
|
|
153
|
+
var distances = cartesianPositions.map(function (position, currentIndex) {
|
|
154
|
+
if (currentIndex === index) {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
var distance = Cesium.Cartesian3.distance(cartesianPositions[index], position);
|
|
158
|
+
return Number.isFinite(distance) && distance > 0 ? distance : null;
|
|
159
|
+
}).filter(function (distance) {
|
|
160
|
+
return Number.isFinite(distance);
|
|
161
|
+
});
|
|
162
|
+
if (distances.length < 2) {
|
|
163
|
+
return 0; // continue
|
|
164
|
+
}
|
|
165
|
+
var medianDistance = getMedianValue(distances);
|
|
166
|
+
if (!Number.isFinite(medianDistance) || medianDistance <= 0) {
|
|
167
|
+
return 0; // continue
|
|
168
|
+
}
|
|
169
|
+
var tolerance = Math.max(medianDistance * 0.02, 0.5);
|
|
170
|
+
var consistentDistances = distances.filter(function (distance) {
|
|
171
|
+
return Math.abs(distance - medianDistance) <= tolerance;
|
|
172
|
+
});
|
|
173
|
+
if (consistentDistances.length < 2) {
|
|
174
|
+
return 0; // continue
|
|
175
|
+
}
|
|
176
|
+
var consistency = consistentDistances.length / distances.length;
|
|
177
|
+
var spread = consistentDistances.length > 1 ? (Math.max.apply(Math, _toConsumableArray(consistentDistances)) - Math.min.apply(Math, _toConsumableArray(consistentDistances))) / medianDistance : 0;
|
|
178
|
+
if (consistency > bestConsistency || consistency === bestConsistency && spread < bestSpread) {
|
|
179
|
+
bestIndex = index;
|
|
180
|
+
bestConsistency = consistency;
|
|
181
|
+
bestSpread = spread;
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
_ret;
|
|
185
|
+
for (var index = 0; index < cartesianPositions.length; index += 1) {
|
|
186
|
+
_ret = _loop(index);
|
|
187
|
+
if (_ret === 0) continue;
|
|
188
|
+
}
|
|
189
|
+
return bestConsistency >= 0.8 ? bestIndex : -1;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// 扇形恢复时先识别圆心,再取圆心前后两个相邻顶点作为两个转角。
|
|
193
|
+
export function getSectorRestoreAnchors(positions) {
|
|
194
|
+
var normalizedPositions = normalizePolygonPositions(positions);
|
|
195
|
+
if (normalizedPositions.length < 3) {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
var cartesianPositions = toCartesianRestorePositions(normalizedPositions);
|
|
199
|
+
if (cartesianPositions.length !== normalizedPositions.length) {
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
var centerIndex = getSectorRestoreCenterIndex(cartesianPositions);
|
|
203
|
+
if (centerIndex < 0) {
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
var previousIndex = (centerIndex - 1 + normalizedPositions.length) % normalizedPositions.length;
|
|
207
|
+
var nextIndex = (centerIndex + 1) % normalizedPositions.length;
|
|
208
|
+
var centerPosition = normalizedPositions[centerIndex];
|
|
209
|
+
var radiusPosition = normalizedPositions[nextIndex];
|
|
210
|
+
var anglePosition = normalizedPositions[previousIndex];
|
|
211
|
+
if (!isValidRestorePositionTuple(centerPosition) || !isValidRestorePositionTuple(radiusPosition) || !isValidRestorePositionTuple(anglePosition)) {
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
var radiusDistance = Cesium.Cartesian3.distance(cartesianPositions[centerIndex], cartesianPositions[nextIndex]);
|
|
215
|
+
var angleDistance = Cesium.Cartesian3.distance(cartesianPositions[centerIndex], cartesianPositions[previousIndex]);
|
|
216
|
+
var meanDistance = (radiusDistance + angleDistance) / 2;
|
|
217
|
+
if (!Number.isFinite(radiusDistance) || !Number.isFinite(angleDistance) || meanDistance <= 0 || Math.abs(radiusDistance - angleDistance) > Math.max(meanDistance * 0.05, 1)) {
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
return [_toConsumableArray(centerPosition), _toConsumableArray(radiusPosition), _toConsumableArray(anglePosition)];
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// 规范化数据转换绘制选项
|
|
224
|
+
export function normalizeDataTransformDrawOptions() {
|
|
225
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
226
|
+
var type = options.type,
|
|
227
|
+
featureTypeField = options.featureTypeField,
|
|
228
|
+
featureConfigField = options.featureConfigField,
|
|
229
|
+
config = options.config,
|
|
230
|
+
shapeOptions = _objectWithoutProperties(options, _excluded);
|
|
231
|
+
return {
|
|
232
|
+
type: type,
|
|
233
|
+
shapeOptions: _objectSpread(_objectSpread({}, config && _typeof(config) === 'object' ? config : {}), shapeOptions),
|
|
234
|
+
featureTypeField: featureTypeField || DEFAULT_FEATURE_TYPE_FIELD,
|
|
235
|
+
featureConfigField: featureConfigField || DEFAULT_FEATURE_CONFIG_FIELD
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// 获取默认绘制形状类型
|
|
240
|
+
export function getDefaultDrawerShapeType(geometryType) {
|
|
241
|
+
return DRAWER_GEOMETRY_SHAPE_MAP[geometryType];
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// 绘制形状类型是否与几何类型兼容
|
|
245
|
+
export function isShapeTypeCompatible(shapeType, geometryType) {
|
|
246
|
+
if (!shapeType || !geometryType) {
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
249
|
+
var defaultShapeType = getDefaultDrawerShapeType(geometryType);
|
|
250
|
+
if (!defaultShapeType) {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
if (DRAWER_POLYGON_BASED_SHAPES.has(shapeType)) {
|
|
254
|
+
return geometryType === 'Polygon' || geometryType === 'MultiPolygon';
|
|
255
|
+
}
|
|
256
|
+
if (DRAWER_POLYLINE_BASED_SHAPES.has(shapeType)) {
|
|
257
|
+
return geometryType === 'LineString' || geometryType === 'MultiLineString';
|
|
258
|
+
}
|
|
259
|
+
return shapeType === defaultShapeType;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// 获取绘制形状类型
|
|
263
|
+
function getDrawerFeatureShapeType(feature, geometryType, options) {
|
|
264
|
+
var _feature$properties;
|
|
265
|
+
var featureShapeType = feature === null || feature === void 0 || (_feature$properties = feature.properties) === null || _feature$properties === void 0 ? void 0 : _feature$properties[options.featureTypeField];
|
|
266
|
+
var shapeType = typeof options.type === 'string' ? options.type : featureShapeType;
|
|
267
|
+
if (typeof shapeType === 'string' && isShapeTypeCompatible(shapeType, geometryType)) {
|
|
268
|
+
return shapeType;
|
|
269
|
+
}
|
|
270
|
+
return getDefaultDrawerShapeType(geometryType);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// 获取绘制配置
|
|
274
|
+
function getDrawerFeatureConfig(feature, options) {
|
|
275
|
+
var _feature$properties2;
|
|
276
|
+
var featureConfig = feature === null || feature === void 0 || (_feature$properties2 = feature.properties) === null || _feature$properties2 === void 0 ? void 0 : _feature$properties2[options.featureConfigField];
|
|
277
|
+
if (!featureConfig || _typeof(featureConfig) !== 'object') {
|
|
278
|
+
return _objectSpread({}, options.shapeOptions);
|
|
279
|
+
}
|
|
280
|
+
return _objectSpread(_objectSpread({}, featureConfig), options.shapeOptions);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// 解析特征
|
|
284
|
+
function explodeFeature(feature) {
|
|
285
|
+
var _feature$geometry;
|
|
286
|
+
var geometryType = feature === null || feature === void 0 || (_feature$geometry = feature.geometry) === null || _feature$geometry === void 0 ? void 0 : _feature$geometry.type;
|
|
287
|
+
if (!geometryType) {
|
|
288
|
+
return [];
|
|
289
|
+
}
|
|
290
|
+
if (!geometryType.startsWith('Multi')) {
|
|
291
|
+
return [feature];
|
|
292
|
+
}
|
|
293
|
+
var features = [];
|
|
294
|
+
flattenEach(feature, function (currentFeature) {
|
|
295
|
+
features.push(_objectSpread(_objectSpread({}, currentFeature), {}, {
|
|
296
|
+
properties: _objectSpread(_objectSpread({}, (feature === null || feature === void 0 ? void 0 : feature.properties) || {}), (currentFeature === null || currentFeature === void 0 ? void 0 : currentFeature.properties) || {})
|
|
297
|
+
}));
|
|
298
|
+
});
|
|
299
|
+
return features;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// 获取恢复项
|
|
303
|
+
export function getDrawerRestoreItems(feature) {
|
|
304
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
305
|
+
var normalizedOptions = normalizeDataTransformDrawOptions(options);
|
|
306
|
+
return explodeFeature(feature).reduce(function (items, currentFeature) {
|
|
307
|
+
var _currentFeature$geome;
|
|
308
|
+
var geometryType = currentFeature === null || currentFeature === void 0 || (_currentFeature$geome = currentFeature.geometry) === null || _currentFeature$geome === void 0 ? void 0 : _currentFeature$geome.type;
|
|
309
|
+
if (!geometryType) {
|
|
310
|
+
return items;
|
|
311
|
+
}
|
|
312
|
+
var handle = HANDLE_FEATURE_DATA_TYPE_FUN[geometryType];
|
|
313
|
+
if (!handle) {
|
|
314
|
+
return items;
|
|
315
|
+
}
|
|
316
|
+
var handleFeature = handle(currentFeature);
|
|
317
|
+
if (!(handleFeature !== null && handleFeature !== void 0 && handleFeature.positions)) {
|
|
318
|
+
return items;
|
|
319
|
+
}
|
|
320
|
+
items.push({
|
|
321
|
+
shapeType: getDrawerFeatureShapeType(currentFeature, geometryType, normalizedOptions),
|
|
322
|
+
positions: handleFeature.positions,
|
|
323
|
+
config: getDrawerFeatureConfig(currentFeature, normalizedOptions),
|
|
324
|
+
geometryType: geometryType
|
|
325
|
+
});
|
|
326
|
+
return items;
|
|
327
|
+
}, []);
|
|
328
|
+
}
|
|
329
|
+
|
|
12
330
|
// 处理点
|
|
13
331
|
function handleFeaturePoint(feature) {
|
|
14
332
|
return {
|
|
@@ -45,7 +363,7 @@ function handleFeatureMultiLineString(feature) {
|
|
|
45
363
|
function handleFeaturePolygon(feature) {
|
|
46
364
|
return {
|
|
47
365
|
type: 'single',
|
|
48
|
-
positions: feature.geometry.coordinates[0]
|
|
366
|
+
positions: normalizePolygonPositions(feature.geometry.coordinates[0])
|
|
49
367
|
};
|
|
50
368
|
}
|
|
51
369
|
|
|
@@ -15,7 +15,7 @@ export default class BaseSource {
|
|
|
15
15
|
remove(): void;
|
|
16
16
|
setData(data: any): this | undefined;
|
|
17
17
|
_toDestroy(): void;
|
|
18
|
-
static analysisSourceType(data: any): "
|
|
18
|
+
static analysisSourceType(data: any): "clampedPolygonGrid" | "wkt" | "sourceId" | "sourceInstance" | "geoJson" | "other";
|
|
19
19
|
static wktToGeoJon(wkt: string): any;
|
|
20
20
|
static geoJsonToGeoCartesian3Array(geoJson: any): any[];
|
|
21
21
|
static handleFeaturePoint(feature: any): any;
|
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -20,9 +20,9 @@ import DeepTwins from "./deepTwins";
|
|
|
20
20
|
import Drawer from "./drawer/index";
|
|
21
21
|
import "./global.css";
|
|
22
22
|
import BarrierLayer from "./lowAltitude/BarrierLayer";
|
|
23
|
+
import FactorLayer from "./lowAltitude/FactorLayer";
|
|
23
24
|
import FlightPlanning from "./lowAltitude/FlightPlanning";
|
|
24
25
|
import FlightRiskEvaluation from "./lowAltitude/FlightRiskEvaluation";
|
|
25
|
-
import FactorLayer from "./lowAltitude/FactorLayer";
|
|
26
26
|
import GridDraw from "./lowAltitude/GridDraw";
|
|
27
27
|
import PoiLayer from "./lowAltitude/PoiLayer";
|
|
28
28
|
import VisitLayer from "./lowAltitude/VisitLayer";
|
|
@@ -40,6 +40,7 @@ import ImageMaterialAppearance from "./material/primitive/ImageMaterialAppearanc
|
|
|
40
40
|
import Measure from "./measure";
|
|
41
41
|
import PositionProperty from "./property/PositionProperty";
|
|
42
42
|
import ArcGisLayer from "./tileLayer/ArcGisLayer";
|
|
43
|
+
import MvtVectorLoad from "./tileLayer/MvtVectorLoad";
|
|
43
44
|
import RasterLayer from "./tileLayer/RasterLayer";
|
|
44
45
|
import WmsLayer from "./tileLayer/WmsLayer";
|
|
45
46
|
import WmtsLayer from "./tileLayer/WmtsLayer";
|
|
@@ -63,11 +64,11 @@ DEEP_TWINS_BASE_URL && (window.CESIUM_BASE_URL = DEEP_TWINS_BASE_URL);
|
|
|
63
64
|
// 全局加载css
|
|
64
65
|
loadCss(Cesium.buildModuleUrl('Widgets/widgets.css'));
|
|
65
66
|
// 打印版本信息
|
|
66
|
-
console.log('DeepTwinsEngine3D Version:', "0.1.
|
|
67
|
+
console.log('DeepTwinsEngine3D Version:', "0.1.65");
|
|
67
68
|
export var DeepTwinsEngine3D = /*#__PURE__*/_createClass(function DeepTwinsEngine3D() {
|
|
68
69
|
_classCallCheck(this, DeepTwinsEngine3D);
|
|
69
70
|
});
|
|
70
|
-
_defineProperty(DeepTwinsEngine3D, "Version", "0.1.
|
|
71
|
+
_defineProperty(DeepTwinsEngine3D, "Version", "0.1.65");
|
|
71
72
|
_defineProperty(DeepTwinsEngine3D, "Map", Map);
|
|
72
73
|
_defineProperty(DeepTwinsEngine3D, "GroundSkyBox", GroundSkyBox);
|
|
73
74
|
_defineProperty(DeepTwinsEngine3D, "RasterLayer", RasterLayer);
|
|
@@ -142,4 +143,5 @@ _defineProperty(DeepTwinsEngine3D, "BuildClampedPolygonGridUnified", BuildClampe
|
|
|
142
143
|
_defineProperty(DeepTwinsEngine3D, "ViewShedAnalyserLayer", ViewShedAnalyserLayer);
|
|
143
144
|
_defineProperty(DeepTwinsEngine3D, "VolumeClouds", VolumeClouds);
|
|
144
145
|
_defineProperty(DeepTwinsEngine3D, "ToolTip", ToolTip);
|
|
146
|
+
_defineProperty(DeepTwinsEngine3D, "MvtVectorLoad", MvtVectorLoad);
|
|
145
147
|
export default DeepTwinsEngine3D;
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import BaseDraw from './BaseDraw';
|
|
2
|
-
import { MeasureContext } from './
|
|
3
|
-
declare class Area extends BaseDraw {
|
|
4
|
-
private readonly _type;
|
|
2
|
+
import { AreaMeasureResult, MeasureContext, MeasureDrawConfig, MeasureLayer, MeasurePosition, MeasureShapeLayer } from './types';
|
|
3
|
+
declare class Area extends BaseDraw implements MeasureLayer {
|
|
5
4
|
private _config;
|
|
6
|
-
private
|
|
5
|
+
private readonly _shapeType;
|
|
6
|
+
_instance: MeasureShapeLayer | null;
|
|
7
7
|
private _area;
|
|
8
8
|
private _areaLayer;
|
|
9
|
-
constructor(measureContext: MeasureContext, config
|
|
9
|
+
constructor(measureContext: MeasureContext, config?: MeasureDrawConfig);
|
|
10
10
|
private _init;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
pointsChange(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
area: any;
|
|
19
|
-
} | undefined;
|
|
11
|
+
private _resolveShapeType;
|
|
12
|
+
private _getDrawerConfig;
|
|
13
|
+
drawing(positions: MeasurePosition[]): AreaMeasureResult | undefined;
|
|
14
|
+
pointsChange(_layer: MeasureShapeLayer, positions: MeasurePosition[]): AreaMeasureResult;
|
|
15
|
+
drawEnd(positions?: MeasurePosition[]): {
|
|
16
|
+
area: number;
|
|
17
|
+
};
|
|
20
18
|
startEdit(): void;
|
|
21
|
-
endEdit(positions
|
|
22
|
-
area:
|
|
23
|
-
}
|
|
19
|
+
endEdit(positions?: MeasurePosition[]): {
|
|
20
|
+
area: number;
|
|
21
|
+
};
|
|
24
22
|
private _calculateArea;
|
|
25
23
|
private _createAreaLabel;
|
|
26
24
|
private _destroyAreaLabel;
|
|
25
|
+
private _updateArea;
|
|
26
|
+
private _toPolygonPositions;
|
|
27
27
|
destroy(): void;
|
|
28
28
|
}
|
|
29
29
|
export default Area;
|