deeptwins-engine-3d 0.1.75 → 0.1.76

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.
@@ -8,6 +8,7 @@ export declare class DeepTwinsEngine3D {
8
8
  static WmsLayer: any;
9
9
  static WmtsLayer: any;
10
10
  static ArcGisLayer: any;
11
+ static RoutePlanning: any;
11
12
  static BarrierLayer: any;
12
13
  static FactorLayer: any;
13
14
  static DeepTwins: any;
package/dist/esm/index.js CHANGED
@@ -22,6 +22,7 @@ import DeepTwins from "./deepTwins";
22
22
  import Drawer from "./drawer/index";
23
23
  import "./global.css";
24
24
  import BarrierLayer from "./lowAltitude/BarrierLayer";
25
+ import RoutePlanning from "./lowAltitude/RoutePlanning";
25
26
  import FactorLayer from "./lowAltitude/FactorLayer";
26
27
  import FlightPlanning from "./lowAltitude/FlightPlanning";
27
28
  import FlightRiskEvaluation from "./lowAltitude/FlightRiskEvaluation";
@@ -73,11 +74,11 @@ DEEP_TWINS_BASE_URL && (window.CESIUM_BASE_URL = DEEP_TWINS_BASE_URL);
73
74
  // 全局加载css
74
75
  loadCss(Cesium.buildModuleUrl('Widgets/widgets.css'));
75
76
  // 打印版本信息
76
- console.log('DeepTwinsEngine3D Version:', "0.1.75");
77
+ console.log('DeepTwinsEngine3D Version:', "0.1.76");
77
78
  export var DeepTwinsEngine3D = /*#__PURE__*/_createClass(function DeepTwinsEngine3D() {
78
79
  _classCallCheck(this, DeepTwinsEngine3D);
79
80
  });
80
- _defineProperty(DeepTwinsEngine3D, "Version", "0.1.75");
81
+ _defineProperty(DeepTwinsEngine3D, "Version", "0.1.76");
81
82
  _defineProperty(DeepTwinsEngine3D, "Map", Map);
82
83
  _defineProperty(DeepTwinsEngine3D, "GroundSkyBox", GroundSkyBox);
83
84
  _defineProperty(DeepTwinsEngine3D, "RasterLayer", RasterLayer);
@@ -85,6 +86,7 @@ _defineProperty(DeepTwinsEngine3D, "CustomRasterLayer", CustomRasterLayer);
85
86
  _defineProperty(DeepTwinsEngine3D, "WmsLayer", WmsLayer);
86
87
  _defineProperty(DeepTwinsEngine3D, "WmtsLayer", WmtsLayer);
87
88
  _defineProperty(DeepTwinsEngine3D, "ArcGisLayer", ArcGisLayer);
89
+ _defineProperty(DeepTwinsEngine3D, "RoutePlanning", RoutePlanning);
88
90
  _defineProperty(DeepTwinsEngine3D, "BarrierLayer", BarrierLayer);
89
91
  _defineProperty(DeepTwinsEngine3D, "FactorLayer", FactorLayer);
90
92
  _defineProperty(DeepTwinsEngine3D, "DeepTwins", DeepTwins);
@@ -0,0 +1,85 @@
1
+ export type RoutePlanningType = 'driving' | 'walking' | 'bicycling' | 'electrobike';
2
+ export type RouteCoordinate = string | [number, number] | {
3
+ lng?: number;
4
+ lon?: number;
5
+ longitude?: number;
6
+ lat?: number;
7
+ latitude?: number;
8
+ };
9
+ export interface RoutePlanningOptions {
10
+ key: string;
11
+ baseUrl?: string;
12
+ timeout?: number;
13
+ request?: RoutePlanningRequest;
14
+ }
15
+ export interface RoutePlanningRequestContext {
16
+ type: RoutePlanningType;
17
+ timeout: number;
18
+ }
19
+ export type RoutePlanningRequest = (url: string, params: Record<string, any>, context: RoutePlanningRequestContext) => Promise<RouteResponse>;
20
+ export interface RoutePlanningParams {
21
+ origin: RouteCoordinate;
22
+ destination: RouteCoordinate;
23
+ waypoints?: RouteCoordinate[];
24
+ show_fields?: string | string[];
25
+ [key: string]: any;
26
+ }
27
+ export interface RouteResponse {
28
+ status?: string;
29
+ info?: string;
30
+ infocode?: string;
31
+ count?: string;
32
+ route?: {
33
+ paths?: RoutePath[];
34
+ [key: string]: any;
35
+ };
36
+ [key: string]: any;
37
+ }
38
+ export interface RoutePath {
39
+ polyline?: string;
40
+ steps?: RouteStep[];
41
+ [key: string]: any;
42
+ }
43
+ export interface RouteStep {
44
+ polyline?: string;
45
+ [key: string]: any;
46
+ }
47
+ export interface RoutePoint {
48
+ lng: number;
49
+ lat: number;
50
+ }
51
+ export interface RouteNormalizedPath extends RoutePath {
52
+ points: RoutePoint[];
53
+ polylines: string[];
54
+ }
55
+ export interface RoutePlanningResult extends RouteResponse {
56
+ raw: RouteResponse;
57
+ paths: RouteNormalizedPath[];
58
+ points: RoutePoint[];
59
+ polylines: string[];
60
+ }
61
+ declare class RoutePlanning {
62
+ isDestroyed: boolean;
63
+ private readonly options;
64
+ constructor(options: RoutePlanningOptions);
65
+ plan(type: RoutePlanningType, params: RoutePlanningParams): Promise<RoutePlanningResult>;
66
+ driving(params: RoutePlanningParams): Promise<RoutePlanningResult>;
67
+ walking(params: RoutePlanningParams): Promise<RoutePlanningResult>;
68
+ bicycling(params: RoutePlanningParams): Promise<RoutePlanningResult>;
69
+ electrobike(params: RoutePlanningParams): Promise<RoutePlanningResult>;
70
+ destroy(): void;
71
+ private _request;
72
+ private _buildRequestParams;
73
+ private _formatCoordinate;
74
+ private _mergeShowFields;
75
+ private _normalizeResponse;
76
+ private _normalizePath;
77
+ private _parsePolyline;
78
+ private _dedupePoints;
79
+ private _assertSuccess;
80
+ private _assertUsable;
81
+ private _normalizeBaseUrl;
82
+ private _formatNumber;
83
+ private _isValidCoordinate;
84
+ }
85
+ export default RoutePlanning;
@@ -0,0 +1,318 @@
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 _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); }
6
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
7
+ 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."); }
8
+ 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); }
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 _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; } }
11
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
+ 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; }
13
+ 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; }
14
+ 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; }
15
+ 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); } }
16
+ 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); }); }; }
17
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18
+ 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); } }
19
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
20
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
22
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
23
+ import { get } from "../tool/fetch";
24
+ var DEFAULT_BASE_URL = 'https://restapi.amap.com';
25
+ var DEFAULT_TIMEOUT = 30000;
26
+ var DEFAULT_SHOW_FIELDS = ['polyline'];
27
+ var ENDPOINTS = {
28
+ driving: '/v5/direction/driving',
29
+ walking: '/v5/direction/walking',
30
+ bicycling: '/v5/direction/bicycling',
31
+ electrobike: '/v5/direction/electrobike'
32
+ };
33
+ var RoutePlanning = /*#__PURE__*/function () {
34
+ function RoutePlanning(options) {
35
+ _classCallCheck(this, RoutePlanning);
36
+ _defineProperty(this, "isDestroyed", false);
37
+ _defineProperty(this, "options", void 0);
38
+ if (!(options !== null && options !== void 0 && options.key)) {
39
+ throw new Error('请提供 Web 服务 key');
40
+ }
41
+ this.options = {
42
+ key: options.key,
43
+ baseUrl: this._normalizeBaseUrl(options.baseUrl || DEFAULT_BASE_URL),
44
+ timeout: options.timeout || DEFAULT_TIMEOUT,
45
+ request: options.request
46
+ };
47
+ }
48
+ _createClass(RoutePlanning, [{
49
+ key: "plan",
50
+ value: function () {
51
+ var _plan = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(type, params) {
52
+ var endpoint, url, requestParams, response;
53
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
54
+ while (1) switch (_context.prev = _context.next) {
55
+ case 0:
56
+ this._assertUsable();
57
+ endpoint = ENDPOINTS[type];
58
+ if (endpoint) {
59
+ _context.next = 4;
60
+ break;
61
+ }
62
+ throw new Error("\u4E0D\u652F\u6301\u7684\u8DEF\u5F84\u89C4\u5212\u7C7B\u578B\uFF1A".concat(type));
63
+ case 4:
64
+ url = "".concat(this.options.baseUrl).concat(endpoint);
65
+ requestParams = this._buildRequestParams(params);
66
+ _context.next = 8;
67
+ return this._request(type, url, requestParams);
68
+ case 8:
69
+ response = _context.sent;
70
+ this._assertSuccess(response);
71
+ return _context.abrupt("return", this._normalizeResponse(response));
72
+ case 11:
73
+ case "end":
74
+ return _context.stop();
75
+ }
76
+ }, _callee, this);
77
+ }));
78
+ function plan(_x, _x2) {
79
+ return _plan.apply(this, arguments);
80
+ }
81
+ return plan;
82
+ }()
83
+ }, {
84
+ key: "driving",
85
+ value: function driving(params) {
86
+ return this.plan('driving', params);
87
+ }
88
+ }, {
89
+ key: "walking",
90
+ value: function walking(params) {
91
+ return this.plan('walking', params);
92
+ }
93
+ }, {
94
+ key: "bicycling",
95
+ value: function bicycling(params) {
96
+ return this.plan('bicycling', params);
97
+ }
98
+ }, {
99
+ key: "electrobike",
100
+ value: function electrobike(params) {
101
+ return this.plan('electrobike', params);
102
+ }
103
+ }, {
104
+ key: "destroy",
105
+ value: function destroy() {
106
+ this.isDestroyed = true;
107
+ }
108
+ }, {
109
+ key: "_request",
110
+ value: function () {
111
+ var _request2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(type, url, params) {
112
+ var _yield$get, data;
113
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
114
+ while (1) switch (_context2.prev = _context2.next) {
115
+ case 0:
116
+ if (!this.options.request) {
117
+ _context2.next = 2;
118
+ break;
119
+ }
120
+ return _context2.abrupt("return", this.options.request(url, params, {
121
+ type: type,
122
+ timeout: this.options.timeout
123
+ }));
124
+ case 2:
125
+ _context2.next = 4;
126
+ return get(url, params, {
127
+ timeout: this.options.timeout
128
+ });
129
+ case 4:
130
+ _yield$get = _context2.sent;
131
+ data = _yield$get.data;
132
+ return _context2.abrupt("return", data);
133
+ case 7:
134
+ case "end":
135
+ return _context2.stop();
136
+ }
137
+ }, _callee2, this);
138
+ }));
139
+ function _request(_x3, _x4, _x5) {
140
+ return _request2.apply(this, arguments);
141
+ }
142
+ return _request;
143
+ }()
144
+ }, {
145
+ key: "_buildRequestParams",
146
+ value: function _buildRequestParams(params) {
147
+ var _this = this;
148
+ if (!params) {
149
+ throw new Error('请提供路径规划参数');
150
+ }
151
+ var origin = params.origin,
152
+ destination = params.destination,
153
+ waypoints = params.waypoints,
154
+ showFields = params.show_fields;
155
+ var requestParams = _objectSpread(_objectSpread({}, params), {}, {
156
+ key: this.options.key,
157
+ origin: this._formatCoordinate(origin, 'origin'),
158
+ destination: this._formatCoordinate(destination, 'destination'),
159
+ show_fields: this._mergeShowFields(showFields)
160
+ });
161
+ if (Array.isArray(waypoints) && waypoints.length > 0) {
162
+ requestParams.waypoints = waypoints.map(function (point, index) {
163
+ return _this._formatCoordinate(point, "waypoints[".concat(index, "]"));
164
+ }).join(';');
165
+ } else {
166
+ delete requestParams.waypoints;
167
+ }
168
+ return requestParams;
169
+ }
170
+ }, {
171
+ key: "_formatCoordinate",
172
+ value: function _formatCoordinate(coordinate, fieldName) {
173
+ var lng;
174
+ var lat;
175
+ if (typeof coordinate === 'string') {
176
+ var _coordinate$split = coordinate.split(','),
177
+ _coordinate$split2 = _slicedToArray(_coordinate$split, 2),
178
+ lngText = _coordinate$split2[0],
179
+ latText = _coordinate$split2[1];
180
+ lng = Number(lngText);
181
+ lat = Number(latText);
182
+ } else if (Array.isArray(coordinate)) {
183
+ lng = Number(coordinate[0]);
184
+ lat = Number(coordinate[1]);
185
+ } else if (coordinate && _typeof(coordinate) === 'object') {
186
+ var _ref, _coordinate$lng, _coordinate$lat;
187
+ lng = Number((_ref = (_coordinate$lng = coordinate.lng) !== null && _coordinate$lng !== void 0 ? _coordinate$lng : coordinate.lon) !== null && _ref !== void 0 ? _ref : coordinate.longitude);
188
+ lat = Number((_coordinate$lat = coordinate.lat) !== null && _coordinate$lat !== void 0 ? _coordinate$lat : coordinate.latitude);
189
+ }
190
+ if (!this._isValidCoordinate(lng, lat)) {
191
+ throw new Error("".concat(fieldName, " \u5750\u6807\u65E0\u6548"));
192
+ }
193
+ return "".concat(this._formatNumber(lng), ",").concat(this._formatNumber(lat));
194
+ }
195
+ }, {
196
+ key: "_mergeShowFields",
197
+ value: function _mergeShowFields(showFields) {
198
+ var fields = new Set(DEFAULT_SHOW_FIELDS);
199
+ var inputFields = Array.isArray(showFields) ? showFields : String(showFields || '').split(',').map(function (field) {
200
+ return field.trim();
201
+ });
202
+ inputFields.forEach(function (field) {
203
+ if (field) fields.add(field);
204
+ });
205
+ return Array.from(fields).join(',');
206
+ }
207
+ }, {
208
+ key: "_normalizeResponse",
209
+ value: function _normalizeResponse(response) {
210
+ var _response$route,
211
+ _this2 = this,
212
+ _paths$,
213
+ _paths$2;
214
+ var rawPaths = Array.isArray((_response$route = response.route) === null || _response$route === void 0 ? void 0 : _response$route.paths) ? response.route.paths : [];
215
+ var paths = rawPaths.map(function (path) {
216
+ return _this2._normalizePath(path);
217
+ });
218
+ return _objectSpread(_objectSpread({}, response), {}, {
219
+ raw: response,
220
+ paths: paths,
221
+ points: ((_paths$ = paths[0]) === null || _paths$ === void 0 ? void 0 : _paths$.points) || [],
222
+ polylines: ((_paths$2 = paths[0]) === null || _paths$2 === void 0 ? void 0 : _paths$2.polylines) || []
223
+ });
224
+ }
225
+ }, {
226
+ key: "_normalizePath",
227
+ value: function _normalizePath(path) {
228
+ var _this3 = this;
229
+ var steps = Array.isArray(path.steps) ? path.steps : [];
230
+ var stepPolylines = steps.map(function (step) {
231
+ return step.polyline;
232
+ }).filter(function (polyline) {
233
+ return typeof polyline === 'string' && polyline.length > 0;
234
+ });
235
+ var pathPolylines = typeof path.polyline === 'string' && path.polyline.length > 0 ? [path.polyline] : [];
236
+ var polylines = pathPolylines.length > 0 ? pathPolylines : stepPolylines;
237
+ var points = [];
238
+ polylines.forEach(function (polyline) {
239
+ points.push.apply(points, _toConsumableArray(_this3._parsePolyline(polyline)));
240
+ });
241
+ return _objectSpread(_objectSpread({}, path), {}, {
242
+ points: this._dedupePoints(points),
243
+ polylines: polylines
244
+ });
245
+ }
246
+ }, {
247
+ key: "_parsePolyline",
248
+ value: function _parsePolyline(polyline) {
249
+ var _this4 = this;
250
+ if (!polyline) return [];
251
+ return polyline.split(';').reduce(function (points, item) {
252
+ var _item$split = item.split(','),
253
+ _item$split2 = _slicedToArray(_item$split, 2),
254
+ lngText = _item$split2[0],
255
+ latText = _item$split2[1];
256
+ var lng = Number(lngText);
257
+ var lat = Number(latText);
258
+ if (_this4._isValidCoordinate(lng, lat)) {
259
+ points.push({
260
+ lng: lng,
261
+ lat: lat
262
+ });
263
+ }
264
+ return points;
265
+ }, []);
266
+ }
267
+ }, {
268
+ key: "_dedupePoints",
269
+ value: function _dedupePoints(points) {
270
+ var result = [];
271
+ points.forEach(function (point) {
272
+ var previous = result[result.length - 1];
273
+ if (!previous || previous.lng !== point.lng || previous.lat !== point.lat) {
274
+ result.push(point);
275
+ }
276
+ });
277
+ return result;
278
+ }
279
+ }, {
280
+ key: "_assertSuccess",
281
+ value: function _assertSuccess(response) {
282
+ if (!response || _typeof(response) !== 'object') {
283
+ throw new Error('路径规划接口返回为空');
284
+ }
285
+ if (String(response.status) !== '1') {
286
+ var error = new Error(response.info || '路径规划接口返回失败');
287
+ error.info = response.info;
288
+ error.infocode = response.infocode;
289
+ error.response = response;
290
+ throw error;
291
+ }
292
+ }
293
+ }, {
294
+ key: "_assertUsable",
295
+ value: function _assertUsable() {
296
+ if (this.isDestroyed) {
297
+ throw new Error('RoutePlanning实例已销毁');
298
+ }
299
+ }
300
+ }, {
301
+ key: "_normalizeBaseUrl",
302
+ value: function _normalizeBaseUrl(baseUrl) {
303
+ return baseUrl.replace(/\/+$/, '');
304
+ }
305
+ }, {
306
+ key: "_formatNumber",
307
+ value: function _formatNumber(value) {
308
+ return Number(value.toFixed(6)).toString();
309
+ }
310
+ }, {
311
+ key: "_isValidCoordinate",
312
+ value: function _isValidCoordinate(lng, lat) {
313
+ return Number.isFinite(lng) && Number.isFinite(lat) && Math.abs(lng) <= 180 && Math.abs(lat) <= 90;
314
+ }
315
+ }]);
316
+ return RoutePlanning;
317
+ }();
318
+ export default RoutePlanning;
@@ -467,6 +467,15 @@ var boundsIntersects = function boundsIntersects(left, right) {
467
467
  return left[0] <= right[2] && left[2] >= right[0] && left[1] <= right[3] && left[3] >= right[1];
468
468
  };
469
469
 
470
+ /** 计算两个 bbox 的有效交集范围;仅边界相切时不视为可飞行区域。 */
471
+ var intersectBounds = function intersectBounds(left, right) {
472
+ var bounds = normalizeBounds([Math.max(left[0], right[0]), Math.max(left[1], right[1]), Math.min(left[2], right[2]), Math.min(left[3], right[3])]);
473
+ if (!bounds || bounds[0] >= bounds[2] || bounds[1] >= bounds[3]) {
474
+ return undefined;
475
+ }
476
+ return bounds;
477
+ };
478
+
470
479
  /** 为裁剪面预计算 bbox,供瓦片级粗过滤使用。 */
471
480
  var createClipFeatureEntries = function createClipFeatureEntries(clipFeatures) {
472
481
  return clipFeatures.flatMap(function (feature) {
@@ -546,14 +555,15 @@ var CustomRasterLayer = /*#__PURE__*/function (_ImageryLayer) {
546
555
  sourceOptionsRest = _objectWithoutProperties(_options$source, _excluded);
547
556
  var tileBounds = options.bounds ? transformBounds(options.bounds, dataCrs, renderCrs) : undefined;
548
557
  var clipBounds = getClipFeatureBounds(effectiveClipFeatures);
549
- var renderBounds = clipBounds || tileBounds;
558
+ var boundsIntersection = tileBounds && clipBounds ? intersectBounds(tileBounds, clipBounds) : undefined;
559
+ var renderBounds = boundsIntersection || clipBounds || tileBounds;
550
560
  var sourceRectangleBounds = sourceOptionsRest.rectangle ? rectangleToBounds(sourceOptionsRest.rectangle) : undefined;
551
561
  validateRasterSchedulingRange({
552
562
  minimumLevel: sourceOptionsRest.minimumLevel,
553
563
  hasRenderBounds: !!renderBounds,
554
564
  hasSourceRectangle: !!sourceOptionsRest.rectangle
555
565
  });
556
- var fitBounds = clipBounds || tileBounds || sourceRectangleBounds;
566
+ var fitBounds = renderBounds || sourceRectangleBounds;
557
567
  var tilingScheme = createRenderTilingScheme(createSourceTilingScheme(sourceTilingSchemeOption), renderCrs);
558
568
  var sourceOptions = _objectSpread(_objectSpread({}, sourceOptionsRest), {}, {
559
569
  tilingScheme: tilingScheme