deeptwins-engine-3d 0.1.42 → 0.1.44

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 (35) hide show
  1. package/dist/esm/analyze/ViewshedAnalysis.d.ts +8 -8
  2. package/dist/esm/analyze/ViewshedAnalysis.js +76 -90
  3. package/dist/esm/constant.d.ts +44 -6
  4. package/dist/esm/constant.js +86 -7
  5. package/dist/esm/deepTwins/index.js +2 -1
  6. package/dist/esm/drawer/index.d.ts +1 -1
  7. package/dist/esm/index.d.ts +4 -1
  8. package/dist/esm/index.js +12 -5
  9. package/dist/esm/lowAltitude/BarrierLayer.d.ts +29 -0
  10. package/dist/esm/{tileLayer → lowAltitude}/BarrierLayer.js +39 -165
  11. package/dist/esm/lowAltitude/BaseGridMvtLayer.d.ts +34 -0
  12. package/dist/esm/lowAltitude/BaseGridMvtLayer.js +122 -0
  13. package/dist/esm/lowAltitude/FlightPlanning.d.ts +27 -0
  14. package/dist/esm/lowAltitude/FlightPlanning.js +411 -0
  15. package/dist/esm/lowAltitude/FlightRiskEvaluation.d.ts +0 -0
  16. package/dist/esm/lowAltitude/FlightRiskEvaluation.js +383 -0
  17. package/dist/esm/{visualization/Airspace.d.ts → lowAltitude/GridDraw.d.ts} +2 -1
  18. package/dist/esm/{visualization/Airspace.js → lowAltitude/GridDraw.js} +9 -9
  19. package/dist/esm/lowAltitude/PoiLayer.d.ts +13 -0
  20. package/dist/esm/lowAltitude/PoiLayer.js +74 -0
  21. package/dist/esm/lowAltitude/VisitLayer.d.ts +26 -0
  22. package/dist/esm/lowAltitude/VisitLayer.js +180 -0
  23. package/dist/esm/map/Map.js +3 -3
  24. package/dist/esm/tool/common.d.ts +2 -1
  25. package/dist/esm/tool/common.js +14 -2
  26. package/dist/esm/tool/fetch.d.ts +51 -0
  27. package/dist/esm/tool/fetch.js +222 -0
  28. package/dist/esm/videoFusion/BaseVideo.d.ts +1 -1
  29. package/dist/esm/videoFusion/BaseVideo.js +47 -2
  30. package/dist/esm/videoFusion/VideoProject.js +3 -0
  31. package/dist/esm/videoFusion/VideoTexture.js +3 -0
  32. package/dist/esm/visualization/FrustumWithCamera.js +10 -8
  33. package/dist/umd/deeptwins-engine-3d.min.js +1 -1
  34. package/package.json +2 -2
  35. package/dist/esm/tileLayer/BarrierLayer.d.ts +0 -76
@@ -0,0 +1,411 @@
1
+ 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; }
2
+ 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; }
3
+ 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); }
4
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
5
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
6
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
7
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
+ 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); } }
9
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
10
+ 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; }
11
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
+ 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); }
13
+ import { lineString } from '@turf/turf';
14
+ import * as Cesium from 'deeptwins-cesium';
15
+ import { merge } from 'lodash';
16
+ import { DEFAULT_FLIGHT_PLANNING_OPTIONS } from "../constant";
17
+ import { ShapeSection } from "../tool/common";
18
+ import fetch from "../tool/fetch";
19
+ import * as utils from "../tool/utils";
20
+ import GridDraw from "./GridDraw";
21
+ var FlightPlanning = /*#__PURE__*/function () {
22
+ function FlightPlanning(map, options) {
23
+ _classCallCheck(this, FlightPlanning);
24
+ _defineProperty(this, "_mapContext", void 0);
25
+ _defineProperty(this, "isDestroyed", false);
26
+ _defineProperty(this, "options", {});
27
+ _defineProperty(this, "currentRoute", null);
28
+ // 路线网格
29
+ _defineProperty(this, "routeGrid", null);
30
+ // 规划管道
31
+ _defineProperty(this, "pipelinePlanningLayer", null);
32
+ // 路线点位
33
+ _defineProperty(this, "routePointsLayer", null);
34
+ // 路线点位文字
35
+ _defineProperty(this, "routePointsLabelLayer", null);
36
+ this._mapContext = map._mapContext;
37
+ this.options = merge(DEFAULT_FLIGHT_PLANNING_OPTIONS(), options);
38
+ }
39
+
40
+ // 是否能进行操作
41
+ _createClass(FlightPlanning, [{
42
+ key: "_canOperate",
43
+ value: function _canOperate() {
44
+ if (this.isDestroyed) {
45
+ utils.error('SubmergenceAnalysis实例已销毁');
46
+ return false;
47
+ }
48
+ return true;
49
+ }
50
+ }, {
51
+ key: "getMap",
52
+ value: function getMap() {
53
+ return this._mapContext && this._mapContext.getMap();
54
+ }
55
+
56
+ // 生成计划
57
+ }, {
58
+ key: "createPlan",
59
+ value: function () {
60
+ var _createPlan = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(value) {
61
+ var payload, _yield$fetch$post, result, normalized, hasPoints;
62
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
63
+ while (1) switch (_context.prev = _context.next) {
64
+ case 0:
65
+ payload = this._buildPayload(value);
66
+ _context.next = 3;
67
+ return fetch.post(this.options.API_URL, payload);
68
+ case 3:
69
+ _yield$fetch$post = _context.sent;
70
+ result = _yield$fetch$post.data;
71
+ if (!(result.code !== 0)) {
72
+ _context.next = 8;
73
+ break;
74
+ }
75
+ utils.error(result.message || '规划接口返回失败');
76
+ return _context.abrupt("return");
77
+ case 8:
78
+ if (result.data) {
79
+ _context.next = 11;
80
+ break;
81
+ }
82
+ utils.error('规划结果为空');
83
+ return _context.abrupt("return");
84
+ case 11:
85
+ normalized = this._normalizeRouteData(result.data);
86
+ if (this.options.isDraw) {
87
+ hasPoints = normalized && Array.isArray(normalized.points) && normalized.points.length > 0;
88
+ this.currentRoute = normalized;
89
+ this._clearRouteGrids();
90
+ if (hasPoints) {
91
+ this._createRoute();
92
+ // 渲染路线网格
93
+ if (this.currentRoute.grids && Array.isArray(this.currentRoute.grids) && this.currentRoute.grids.length > 0) {
94
+ this._renderRouteGrids();
95
+ }
96
+ }
97
+ }
98
+ return _context.abrupt("return", normalized);
99
+ case 14:
100
+ case "end":
101
+ return _context.stop();
102
+ }
103
+ }, _callee, this);
104
+ }));
105
+ function createPlan(_x) {
106
+ return _createPlan.apply(this, arguments);
107
+ }
108
+ return createPlan;
109
+ }()
110
+ }, {
111
+ key: "_buildPayload",
112
+ value: function _buildPayload(values) {
113
+ var toCoord = function toCoord(_ref) {
114
+ var lng = _ref.lng,
115
+ lat = _ref.lat,
116
+ alt = _ref.alt;
117
+ return [lng, lat, alt];
118
+ };
119
+ return {
120
+ source_target: {
121
+ source: {
122
+ coord: toCoord(values.source)
123
+ },
124
+ way_points: values.waypoints.map(function (item) {
125
+ return {
126
+ coord: toCoord(item)
127
+ };
128
+ }),
129
+ target: {
130
+ coord: toCoord(values.target)
131
+ }
132
+ },
133
+ metric: values.metric
134
+ };
135
+ }
136
+
137
+ // 规划接口响应归一化:
138
+ // - 新版:result.data.paths[0].points 为航迹点数组(可能是二维数组,分段点数组)
139
+ // - 兼容老版:result.data.points 为航迹点数组
140
+ }, {
141
+ key: "_normalizeRouteData",
142
+ value: function _normalizeRouteData(data) {
143
+ if (!data || _typeof(data) !== 'object') return null;
144
+ var points = [];
145
+ var statistic = data.statistic;
146
+ var grids = data.grids;
147
+ var gridLevel = data.gridLevel;
148
+ var pushPoint = function pushPoint(p) {
149
+ if (!p || _typeof(p) !== 'object') return;
150
+ var lng = Number(p.lng);
151
+ var lat = Number(p.lat);
152
+ var alt = p.alt != null ? Number(p.alt) : 0;
153
+ var type = p.type;
154
+ if (!Number.isFinite(lng) || !Number.isFinite(lat)) return;
155
+ points.push({
156
+ lng: lng,
157
+ lat: lat,
158
+ alt: Number.isFinite(alt) ? alt : 0,
159
+ type: type
160
+ });
161
+ };
162
+ if (Array.isArray(data.paths) && data.paths.length) {
163
+ var path = data.paths[0] || {};
164
+ statistic = path.statistic || statistic;
165
+ grids = path.grids || grids;
166
+ gridLevel = path.gridLevel != null ? path.gridLevel : gridLevel;
167
+ var rawPoints = Array.isArray(path.points) ? path.points : [];
168
+ rawPoints.forEach(function (item) {
169
+ // 兼容二维数组 [ [point, point], [point, ...] ]
170
+ if (Array.isArray(item)) {
171
+ item.forEach(pushPoint);
172
+ } else {
173
+ pushPoint(item);
174
+ }
175
+ });
176
+ } else if (Array.isArray(data.points)) {
177
+ data.points.forEach(pushPoint);
178
+ }
179
+ return _objectSpread(_objectSpread({}, data), {}, {
180
+ points: points,
181
+ statistic: statistic,
182
+ grids: grids,
183
+ gridLevel: gridLevel
184
+ });
185
+ }
186
+
187
+ // 绘制路线
188
+ }, {
189
+ key: "_createRoute",
190
+ value: function _createRoute() {
191
+ var _this = this;
192
+ if (!this.currentRoute || !Array.isArray(this.currentRoute.points) || !this.currentRoute.points.length) {
193
+ return;
194
+ }
195
+
196
+ // 规划管道
197
+ this.pipelinePlanningLayer = this.getMap().addGraphicLayer(lineString(this.currentRoute.points.map(function (point) {
198
+ return [point.lng, point.lat, point.alt];
199
+ })), {
200
+ type: 'polylineVolumeP',
201
+ style: {
202
+ // 圆截面
203
+ shapePositions: ShapeSection.circleSection(7.66 / 2, 48),
204
+ cornerType: Cesium.CornerType.ROUNDED,
205
+ color: 'rgba(0,255,255,0.85)'
206
+ }
207
+ });
208
+ var pointGeoJson = {
209
+ type: 'FeatureCollection',
210
+ features: this.currentRoute.points.map(function (point) {
211
+ return {
212
+ type: 'Feature',
213
+ geometry: {
214
+ type: 'Point',
215
+ coordinates: [point.lng, point.lat, point.alt]
216
+ },
217
+ properties: _objectSpread({}, point)
218
+ };
219
+ })
220
+ };
221
+
222
+ // 路线点位
223
+ this.routePointsLayer = this.getMap().addGraphicLayer(pointGeoJson, {
224
+ type: 'pointP',
225
+ style: {
226
+ pixelSize: 14,
227
+ color: function color(p) {
228
+ var typeKey = (p.type || '').toUpperCase();
229
+ return _this.options.TYPE_COLOR_MAP[typeKey] || '#38bdf8';
230
+ },
231
+ outlineColor: '#ffffff',
232
+ outlineWidth: 2,
233
+ disableDepthTestDistance: Number.POSITIVE_INFINITY
234
+ }
235
+ });
236
+
237
+ // 路线点位标签
238
+ this.routePointsLabelLayer = this.getMap().addGraphicLayer(pointGeoJson, {
239
+ type: 'labelP',
240
+ style: {
241
+ text: function text(p) {
242
+ var _p$alt$toFixed, _p$alt;
243
+ var typeKey = (p.type || '').toUpperCase();
244
+ var displayType = _this.options.TYPE_LABEL_MAP[typeKey] || typeKey || 'POINT';
245
+ return "".concat(displayType, "\n ").concat((_p$alt$toFixed = (_p$alt = p.alt) === null || _p$alt === void 0 ? void 0 : _p$alt.toFixed(1)) !== null && _p$alt$toFixed !== void 0 ? _p$alt$toFixed : '-', " m");
246
+ },
247
+ font: '14px "Helvetica Neue", Arial, sans-serif',
248
+ fillColor: '#ffffff',
249
+ showBackground: true,
250
+ backgroundColor: 'rgba(0,0,0,0.55)',
251
+ pixelOffset: [0, -24],
252
+ verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
253
+ disableDepthTestDistance: Number.POSITIVE_INFINITY
254
+ }
255
+ });
256
+ this.pipelinePlanningLayer.flyTo();
257
+ }
258
+
259
+ // 清除路线
260
+ }, {
261
+ key: "_clearRoute",
262
+ value: function _clearRoute() {
263
+ if (!this._canOperate) return;
264
+ this.pipelinePlanningLayer && this.pipelinePlanningLayer.remove();
265
+ this.pipelinePlanningLayer = null;
266
+ this.routePointsLayer && this.routePointsLayer.remove();
267
+ this.routePointsLayer = null;
268
+ this.routePointsLabelLayer && this.routePointsLabelLayer.remove();
269
+ this.routePointsLabelLayer = null;
270
+ }
271
+
272
+ // 渲染路线网格
273
+ }, {
274
+ key: "_renderRouteGrids",
275
+ value: function _renderRouteGrids() {
276
+ var _this2 = this;
277
+ if (!this._canOperate) return;
278
+
279
+ // 清除之前的路线网格
280
+ this._clearRouteGrids();
281
+ if (!this.currentRoute || !Array.isArray(this.currentRoute.grids) || this.currentRoute.grids.length === 0) {
282
+ return;
283
+ }
284
+ var gridLevel = this.currentRoute.gridLevel || this.options.DEFAULT_GRID_LEVEL;
285
+
286
+ // 使用第一个网格的纬度来计算网格大小(如果网格数组为空,使用默认纬度)
287
+ var firstGrid = this.currentRoute.grids[0];
288
+ var latitude = firstGrid && typeof firstGrid.lat === 'number' ? firstGrid.lat : this.options.DEFAULT_LATITUDE;
289
+ var gridSize = this._getGridSizeByLevel(gridLevel, latitude);
290
+ var gridGeoJson = {
291
+ type: 'FeatureCollection',
292
+ features: this.currentRoute.grids.map(function (grid) {
293
+ var layerHeight = grid.alt || 0;
294
+ var centerHeight = _this2._calculateGridCenterHeight(layerHeight);
295
+ return {
296
+ type: 'Feature',
297
+ geometry: {
298
+ type: 'Point',
299
+ coordinates: [grid.lng, grid.lat, centerHeight],
300
+ properties: {
301
+ color: Cesium.Color.fromCssColorString(_this2._getColorByLayerHeight(layerHeight)).withAlpha(_this2.options.GRID_ALPHA)
302
+ }
303
+ }
304
+ };
305
+ })
306
+ };
307
+ this.routeGrid = new GridDraw(this.getMap(), gridGeoJson, {
308
+ dimensions: [gridSize, gridSize, this.options.GRID_HEIGHT_PER_LAYER],
309
+ translucent: true
310
+ });
311
+ }
312
+
313
+ // 清除路线网格
314
+ }, {
315
+ key: "_clearRouteGrids",
316
+ value: function _clearRouteGrids() {
317
+ if (this.routeGrid) {
318
+ this.routeGrid.destroy();
319
+ this.routeGrid = null;
320
+ }
321
+ }
322
+
323
+ // 根据层高获取颜色
324
+ }, {
325
+ key: "_getColorByLayerHeight",
326
+ value: function _getColorByLayerHeight(layerHeight) {
327
+ var colorIndex = Math.min(Math.floor(layerHeight / this.options.COLOR_GROUP_SIZE), this.options.HEIGHT_COLORS.length - 1);
328
+ return this.options.HEIGHT_COLORS[colorIndex] || this.options.DEFAULT_GRID_COLOR;
329
+ }
330
+
331
+ // 计算网格中心高度
332
+ }, {
333
+ key: "_calculateGridCenterHeight",
334
+ value: function _calculateGridCenterHeight(layerHeight) {
335
+ var bottomHeight = layerHeight * this.options.GRID_HEIGHT_PER_LAYER;
336
+ var topHeight = (layerHeight + 1) * this.options.GRID_HEIGHT_PER_LAYER;
337
+ return (bottomHeight + topHeight) / 2;
338
+ }
339
+
340
+ // 根据网格级别和纬度计算网格大小
341
+ }, {
342
+ key: "_getGridSizeByLevel",
343
+ value: function _getGridSizeByLevel(gridLevel) {
344
+ var latitude = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.options.DEFAULT_LATITUDE;
345
+ if (gridLevel < 0 || gridLevel >= this.options.GRID_SIZES.length) {
346
+ console.warn("\u7F51\u683C\u7EA7\u522B ".concat(gridLevel, " \u8D85\u51FA\u8303\u56F4\uFF0C\u4F7F\u7528\u9ED8\u8BA4\u5927\u5C0F"));
347
+ return 100;
348
+ }
349
+ var gridSizeInSeconds = this.options.GRID_SIZES[gridLevel];
350
+ if (!gridSizeInSeconds || gridSizeInSeconds[0] === 0) {
351
+ console.warn("\u7F51\u683C\u7EA7\u522B ".concat(gridLevel, " \u65E0\u6548\uFF0C\u4F7F\u7528\u9ED8\u8BA4\u5927\u5C0F"));
352
+ return 100;
353
+ }
354
+
355
+ // 将秒转换为度
356
+ var lonPerCell = gridSizeInSeconds[0] / 3600;
357
+ var latPerCell = gridSizeInSeconds[1] / 3600;
358
+
359
+ // 计算经度和纬度方向的网格大小(米)
360
+ var lonSize = this._calculateSphericalDistance(latitude, lonPerCell, 0);
361
+ var latSize = this._calculateSphericalDistance(latitude, 0, latPerCell);
362
+ return (lonSize + latSize) / 2;
363
+ }
364
+
365
+ // 计算球面地理长度(米)
366
+ }, {
367
+ key: "_calculateSphericalDistance",
368
+ value: function _calculateSphericalDistance(centerLat) {
369
+ var deltaLongitude = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
370
+ var deltaLatitude = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
371
+ var earthRadius = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 6371008.8;
372
+ var latRad = centerLat * Math.PI / 180;
373
+ var deltaLonRad = deltaLongitude * Math.PI / 180;
374
+ var deltaLatRad = deltaLatitude * Math.PI / 180;
375
+ if (deltaLongitude === 0 && deltaLatitude !== 0) {
376
+ return Math.abs(deltaLatRad * earthRadius);
377
+ }
378
+ if (deltaLongitude !== 0 && deltaLatitude === 0) {
379
+ var latitudeCircleRadius = earthRadius * Math.cos(latRad);
380
+ return Math.abs(deltaLonRad * latitudeCircleRadius);
381
+ }
382
+ var endLatRad = latRad + deltaLatRad;
383
+ var dLat = deltaLatRad;
384
+ var dLon = deltaLonRad;
385
+ var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(latRad) * Math.cos(endLatRad) * Math.sin(dLon / 2) * Math.sin(dLon / 2);
386
+ var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
387
+ return earthRadius * c;
388
+ }
389
+
390
+ // 清除
391
+ }, {
392
+ key: "clear",
393
+ value: function clear() {
394
+ if (!this._canOperate()) return;
395
+ this.currentRoute = null;
396
+ this._clearRoute();
397
+ this._clearRouteGrids();
398
+ }
399
+
400
+ // 销毁
401
+ }, {
402
+ key: "destroy",
403
+ value: function destroy() {
404
+ if (!this._canOperate()) return;
405
+ this.isDestroyed = true;
406
+ this.clear();
407
+ }
408
+ }]);
409
+ return FlightPlanning;
410
+ }();
411
+ export default FlightPlanning;
File without changes