@twinmatrix/spatialverse-sdk-web 0.0.2 → 0.0.4
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/lib/cjs/index.js +9 -9
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js +213 -294
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js +40 -41
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/3DMap/MainMap.js +170 -196
- package/lib/cjs/meta-atlas-sdk/3DMap/MainMap.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js +167 -215
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js +28 -30
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js +861 -1170
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js +166 -159
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/interfaces.js +6 -6
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/interfaces.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js +6 -6
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routeLayers.js +3 -3
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routeLayers.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js +523 -610
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js +149 -154
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/customStyles.js +2 -2
- package/lib/cjs/meta-atlas-sdk/customStyles.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/customerLayer.js +15 -29
- package/lib/cjs/meta-atlas-sdk/customerLayer.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/customerLayerVariant.js +5 -5
- package/lib/cjs/meta-atlas-sdk/customerLayerVariant.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js +809 -1033
- package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/helpers.js +32 -49
- package/lib/cjs/meta-atlas-sdk/utils/helpers.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/local-storage.js +21 -34
- package/lib/cjs/meta-atlas-sdk/utils/local-storage.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/mapobjects-store.js +6 -6
- package/lib/cjs/meta-atlas-sdk/utils/mapobjects-store.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/routing-store.js +6 -6
- package/lib/cjs/meta-atlas-sdk/utils/routing-store.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/routing-visualizer/index.js +363 -491
- package/lib/cjs/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
- package/lib/cjs/react/MetaAtlasMap.js +127 -0
- package/lib/cjs/react/MetaAtlasMap.js.map +1 -0
- package/lib/cjs/react/hooks/useDrawing/index.js +17 -18
- package/lib/cjs/react/hooks/useDrawing/index.js.map +1 -1
- package/lib/cjs/react/hooks/useFocus/index.js +48 -55
- package/lib/cjs/react/hooks/useFocus/index.js.map +1 -1
- package/lib/cjs/react/hooks/useMapEvents/index.js +40 -47
- package/lib/cjs/react/hooks/useMapEvents/index.js.map +1 -1
- package/lib/cjs/react/hooks/useMapOverlays/index.js +20 -21
- package/lib/cjs/react/hooks/useMapOverlays/index.js.map +1 -1
- package/lib/cjs/react/hooks/useMetaAtlas/index.js +77 -95
- package/lib/cjs/react/hooks/useMetaAtlas/index.js.map +1 -1
- package/lib/cjs/react/hooks/useMetaAtlas.js +78 -96
- package/lib/cjs/react/hooks/useMetaAtlas.js.map +1 -1
- package/lib/cjs/react/hooks/useRouting/index.js +21 -20
- package/lib/cjs/react/hooks/useRouting/index.js.map +1 -1
- package/lib/cjs/react/hooks/useSearch/index.js +35 -34
- package/lib/cjs/react/hooks/useSearch/index.js.map +1 -1
- package/lib/cjs/react/hooks/useStampRally/index.js +26 -23
- package/lib/cjs/react/hooks/useStampRally/index.js.map +1 -1
- package/lib/cjs/react/hooks/useStampRally/utils.js +2 -2
- package/lib/cjs/react/hooks/useStampRally/utils.js.map +1 -1
- package/lib/cjs/react/index.js +31 -31
- package/lib/cjs/react/index.js.map +1 -1
- package/lib/cjs/react/stores/useMapDataStore.js +47 -62
- package/lib/cjs/react/stores/useMapDataStore.js.map +1 -1
- package/lib/cjs/react/stores/useMetaAtlasStore.js +27 -40
- package/lib/cjs/react/stores/useMetaAtlasStore.js.map +1 -1
- package/lib/esm/index.js +3 -7
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js +4 -3
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js +14 -12
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/3DMap/MainMap.js +204 -200
- package/lib/esm/meta-atlas-sdk/3DMap/MainMap.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js +6 -6
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js +4 -3
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js +53 -42
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js +18 -16
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js +3 -3
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js +73 -79
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js +16 -15
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/customerLayer.js +4 -1
- package/lib/esm/meta-atlas-sdk/customerLayer.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js +148 -124
- package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/utils/helpers.js +4 -2
- package/lib/esm/meta-atlas-sdk/utils/helpers.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/utils/local-storage.js +6 -1
- package/lib/esm/meta-atlas-sdk/utils/local-storage.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js +115 -109
- package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
- package/lib/esm/react/MetaAtlasMap.js +120 -0
- package/lib/esm/react/MetaAtlasMap.js.map +1 -0
- package/lib/esm/react/hooks/useDrawing/index.js +2 -2
- package/lib/esm/react/hooks/useDrawing/index.js.map +1 -1
- package/lib/esm/react/hooks/useFocus/index.js +4 -3
- package/lib/esm/react/hooks/useFocus/index.js.map +1 -1
- package/lib/esm/react/hooks/useMapEvents/index.js +9 -6
- package/lib/esm/react/hooks/useMapEvents/index.js.map +1 -1
- package/lib/esm/react/hooks/useMapOverlays/index.js +2 -2
- package/lib/esm/react/hooks/useMapOverlays/index.js.map +1 -1
- package/lib/esm/react/hooks/useMetaAtlas/index.js +162 -60
- package/lib/esm/react/hooks/useMetaAtlas/index.js.map +1 -1
- package/lib/esm/react/hooks/useMetaAtlas.js +162 -60
- package/lib/esm/react/hooks/useMetaAtlas.js.map +1 -1
- package/lib/esm/react/hooks/useRouting/index.js +2 -2
- package/lib/esm/react/hooks/useRouting/index.js.map +1 -1
- package/lib/esm/react/hooks/useSearch/index.js +2 -2
- package/lib/esm/react/hooks/useSearch/index.js.map +1 -1
- package/lib/esm/react/hooks/useStampRally/index.js +15 -12
- package/lib/esm/react/hooks/useStampRally/index.js.map +1 -1
- package/lib/esm/react/hooks/useStampRally/utils.js +1 -1
- package/lib/esm/react/hooks/useStampRally/utils.js.map +1 -1
- package/lib/esm/react/index.js +11 -15
- package/lib/esm/react/index.js.map +1 -1
- package/lib/esm/react/stores/useMapDataStore.js +17 -21
- package/lib/esm/react/stores/useMapDataStore.js.map +1 -1
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.d.ts +30 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.d.ts.map +1 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.d.ts +5 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.d.ts.map +1 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.d.ts +21 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.d.ts.map +1 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.d.ts +27 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.d.ts.map +1 -0
- package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.d.ts +18 -0
- package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.d.ts.map +1 -0
- package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.d.ts +37 -0
- package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.d.ts.map +1 -0
- package/package.json +10 -7
|
@@ -20,24 +20,16 @@ var _helpers = require("@turf/helpers");
|
|
|
20
20
|
var _length = _interopRequireDefault(require("@turf/length"));
|
|
21
21
|
var _turf = require("@turf/turf");
|
|
22
22
|
var _lodash = require("lodash");
|
|
23
|
-
var _interfaces = require("./interfaces");
|
|
24
|
-
var
|
|
25
|
-
var _mapObjectsHelper = require("./mapObjectsHelper");
|
|
26
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : {
|
|
27
|
-
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
28
|
-
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
29
|
-
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
30
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
31
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
32
|
-
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); }
|
|
33
|
-
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
34
|
-
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
23
|
+
var _interfaces = require("./interfaces.js");
|
|
24
|
+
var _index = _interopRequireDefault(require("./index.js"));
|
|
25
|
+
var _mapObjectsHelper = require("./mapObjectsHelper.js");
|
|
26
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
35
27
|
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; }
|
|
36
28
|
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; }
|
|
37
29
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
38
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" ==
|
|
39
|
-
function _toPrimitive(t, r) { if ("object" !=
|
|
40
|
-
|
|
30
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
31
|
+
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); }
|
|
32
|
+
let ManeuverType = exports.ManeuverType = /*#__PURE__*/function (ManeuverType) {
|
|
41
33
|
ManeuverType["RouteOverview"] = "Route Overview";
|
|
42
34
|
ManeuverType["SectionOverview"] = "Section Overview";
|
|
43
35
|
ManeuverType["LeftHairPinTurn"] = "Left hairpin turn";
|
|
@@ -54,9 +46,9 @@ var ManeuverType = exports.ManeuverType = /*#__PURE__*/function (ManeuverType) {
|
|
|
54
46
|
return ManeuverType;
|
|
55
47
|
}({});
|
|
56
48
|
function createDefaultSegment(pathSegment) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
49
|
+
const startMapObj = (0, _mapObjectsHelper.getEdge)(pathSegment.edges[0]);
|
|
50
|
+
const endMapObj = (0, _mapObjectsHelper.getEdge)(pathSegment.edges[1]);
|
|
51
|
+
const segment = {
|
|
60
52
|
maneuverType: ManeuverType.Static,
|
|
61
53
|
coordinates: [],
|
|
62
54
|
distance: 0,
|
|
@@ -88,8 +80,8 @@ function isOverviewSegment(segment) {
|
|
|
88
80
|
return segment.maneuverType === ManeuverType.RouteOverview || segment.maneuverType === ManeuverType.SectionOverview;
|
|
89
81
|
}
|
|
90
82
|
function updateFeatureHighlightState(features, isHighlighted) {
|
|
91
|
-
for (
|
|
92
|
-
|
|
83
|
+
for (let index = 0; index < features.length; index += 1) {
|
|
84
|
+
const feature = features[index];
|
|
93
85
|
if (isHighlighted) {
|
|
94
86
|
feature.properties.highlight = true;
|
|
95
87
|
} else {
|
|
@@ -99,9 +91,9 @@ function updateFeatureHighlightState(features, isHighlighted) {
|
|
|
99
91
|
return features;
|
|
100
92
|
}
|
|
101
93
|
function highlightRouteSegment(pathFeatures, segmentToHighlight) {
|
|
102
|
-
|
|
103
|
-
for (
|
|
104
|
-
|
|
94
|
+
let highlightNodeOnly = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
95
|
+
for (let index = 0; index < pathFeatures.length; index += 1) {
|
|
96
|
+
const segment = pathFeatures[index];
|
|
105
97
|
if (segment.properties.segmentNumber === segmentToHighlight) {
|
|
106
98
|
if (highlightNodeOnly) {
|
|
107
99
|
if (segment.properties.startPoint === true) {
|
|
@@ -117,53 +109,53 @@ function highlightRouteSegment(pathFeatures, segmentToHighlight) {
|
|
|
117
109
|
return pathFeatures;
|
|
118
110
|
}
|
|
119
111
|
function getRouteNode(coordinates, segmentNumber, isHighlighted, patchNumber) {
|
|
120
|
-
|
|
112
|
+
let whereDimension = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : '';
|
|
121
113
|
if (coordinates.length === 0) {
|
|
122
114
|
return [];
|
|
123
115
|
}
|
|
124
|
-
|
|
125
|
-
segmentNumber
|
|
116
|
+
const properties = {
|
|
117
|
+
segmentNumber,
|
|
126
118
|
dimension_where: whereDimension,
|
|
127
|
-
patchNumber
|
|
119
|
+
patchNumber,
|
|
128
120
|
isNode: true
|
|
129
121
|
};
|
|
130
|
-
|
|
131
|
-
|
|
122
|
+
const node = (0, _helpers.point)(coordinates, properties);
|
|
123
|
+
const features = [node];
|
|
132
124
|
updateFeatureHighlightState(features, isHighlighted);
|
|
133
125
|
return features;
|
|
134
126
|
}
|
|
135
127
|
function getRouteLine(coordinates, segmentNumber, isHighlighted, patchNumber, zone) {
|
|
136
|
-
|
|
128
|
+
let whereDimension = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : '';
|
|
137
129
|
if (coordinates.length === 0) {
|
|
138
130
|
return [];
|
|
139
131
|
}
|
|
140
|
-
|
|
141
|
-
segmentNumber
|
|
132
|
+
const properties = {
|
|
133
|
+
segmentNumber,
|
|
142
134
|
dimension_where: whereDimension,
|
|
143
|
-
patchNumber
|
|
135
|
+
patchNumber,
|
|
144
136
|
isNode: false,
|
|
145
|
-
zone
|
|
137
|
+
zone
|
|
146
138
|
};
|
|
147
139
|
// const curved = smooth(coordinates, {iteration: 1});
|
|
148
|
-
|
|
140
|
+
const line = (0, _helpers.lineString)(coordinates, _objectSpread(_objectSpread({}, properties), {}, {
|
|
149
141
|
featureBelongsToLineString: true
|
|
150
142
|
}));
|
|
151
|
-
|
|
143
|
+
const startPoint = (0, _helpers.point)(coordinates[0], _objectSpread(_objectSpread({}, properties), {}, {
|
|
152
144
|
featureBelongsToLineString: false
|
|
153
145
|
}));
|
|
154
|
-
|
|
146
|
+
const endPoint = (0, _helpers.point)(coordinates[coordinates.length - 1], _objectSpread(_objectSpread({}, properties), {}, {
|
|
155
147
|
featureBelongsToLineString: false
|
|
156
148
|
}));
|
|
157
|
-
|
|
149
|
+
const features = [];
|
|
158
150
|
features.push(startPoint, line, endPoint);
|
|
159
151
|
updateFeatureHighlightState(features, isHighlighted);
|
|
160
152
|
return features;
|
|
161
153
|
}
|
|
162
154
|
function getLineStringFeaturesOfRouteSegment(routeSegment) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
for (
|
|
166
|
-
|
|
155
|
+
let whereDimension = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
156
|
+
const lineFeatures = [];
|
|
157
|
+
for (let index = 0; index < routeSegment.features.length; index += 1) {
|
|
158
|
+
const feature = routeSegment.features[index];
|
|
167
159
|
if (feature.properties.featureBelongsToLineString) {
|
|
168
160
|
if (whereDimension !== '') {
|
|
169
161
|
if (feature.properties.dimension_where && feature.properties.dimension_where === whereDimension) {
|
|
@@ -177,9 +169,9 @@ function getLineStringFeaturesOfRouteSegment(routeSegment) {
|
|
|
177
169
|
return lineFeatures;
|
|
178
170
|
}
|
|
179
171
|
function generateOverviewSegment(route) {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
172
|
+
let indexOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
173
|
+
const overviewSegment = (0, _lodash.cloneDeep)(route.segments[1]);
|
|
174
|
+
const initialWhereDimension = route.segments.length > 1 ? route.segments[1].startEdge.whereDimension : '';
|
|
183
175
|
overviewSegment.coordinates = [];
|
|
184
176
|
overviewSegment.features = [];
|
|
185
177
|
overviewSegment.time = 0;
|
|
@@ -188,14 +180,14 @@ function generateOverviewSegment(route) {
|
|
|
188
180
|
overviewSegment.maneuverType = ManeuverType.RouteOverview;
|
|
189
181
|
overviewSegment.patchNumber = indexOffset;
|
|
190
182
|
overviewSegment.instructions = ['Overview'];
|
|
191
|
-
for (
|
|
183
|
+
for (let index = 1; index < route.segments.length; index += 1) {
|
|
192
184
|
if (route.segments[index].maneuverType !== ManeuverType.SectionOverview) {
|
|
193
|
-
for (
|
|
194
|
-
|
|
185
|
+
for (let j = 0; j < route.segments[index].coordinates.length; j += 1) {
|
|
186
|
+
const coord = route.segments[index].coordinates[j];
|
|
195
187
|
overviewSegment.coordinates.push(coord);
|
|
196
188
|
}
|
|
197
|
-
for (
|
|
198
|
-
|
|
189
|
+
for (let j = 0; j < route.segments[index].features.length; j += 1) {
|
|
190
|
+
const feature = (0, _lodash.cloneDeep)(route.segments[index].features[j]);
|
|
199
191
|
if (feature.properties && !feature.properties.isNode) {
|
|
200
192
|
// isNonHighlightedOverview is used in layer styling to decide the color of lines
|
|
201
193
|
// features which are not on initialWhereDimension should be colored accordingly
|
|
@@ -213,551 +205,472 @@ function generateOverviewSegment(route) {
|
|
|
213
205
|
overviewSegment.distance = route.walkingDistance + route.transportDistance;
|
|
214
206
|
return overviewSegment;
|
|
215
207
|
}
|
|
216
|
-
function createRoute(
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
_path,
|
|
231
|
-
lastManeuverType,
|
|
232
|
-
firstSegment,
|
|
233
|
-
prevPathSegment,
|
|
234
|
-
prevZone,
|
|
235
|
-
prevPath,
|
|
236
|
-
pathPoint,
|
|
237
|
-
index,
|
|
238
|
-
startPoint,
|
|
239
|
-
midPoint,
|
|
240
|
-
endPoint,
|
|
241
|
-
currentManeuverType,
|
|
242
|
-
_pathPoint,
|
|
243
|
-
_pathPoint2,
|
|
244
|
-
removeExtraChangeZoneSegment,
|
|
245
|
-
lastSegmentAdded,
|
|
246
|
-
immigrationPolygonFeatures,
|
|
247
|
-
line,
|
|
248
|
-
_index,
|
|
249
|
-
immigrationPolygonFeature,
|
|
250
|
-
intersects,
|
|
251
|
-
lineBeforeImmigration,
|
|
252
|
-
lengthOfLineBeforeImmigration,
|
|
253
|
-
segmentBeforeImmigration,
|
|
254
|
-
coordsOfLastSegment,
|
|
255
|
-
secondLastSegmentAdded,
|
|
256
|
-
immigrationLine,
|
|
257
|
-
immigrationSegment,
|
|
258
|
-
lineCoords,
|
|
259
|
-
lineAfterImmigration,
|
|
260
|
-
segmentAfterImmigration,
|
|
261
|
-
startPointWithinPolygon,
|
|
262
|
-
_immigrationLine,
|
|
263
|
-
_immigrationSegment,
|
|
264
|
-
changeZoneSegment,
|
|
265
|
-
_secondLastSegmentAdded,
|
|
266
|
-
_lineCoords,
|
|
267
|
-
_lineAfterImmigration,
|
|
268
|
-
_segmentAfterImmigration,
|
|
269
|
-
previousLine,
|
|
270
|
-
_lineCoords2,
|
|
271
|
-
_lineAfterImmigration2,
|
|
272
|
-
_segmentAfterImmigration2,
|
|
273
|
-
enterPortalSegment,
|
|
274
|
-
exitPortalSegment,
|
|
275
|
-
_lastSegmentAdded2,
|
|
276
|
-
travelPortalSegment,
|
|
277
|
-
route,
|
|
278
|
-
addOverviewSegment,
|
|
279
|
-
initialIndex,
|
|
280
|
-
dummySegment,
|
|
281
|
-
patchNumber,
|
|
282
|
-
whereDimension,
|
|
283
|
-
_index2,
|
|
284
|
-
highlight,
|
|
285
|
-
segment,
|
|
286
|
-
segmentNumber,
|
|
287
|
-
routeSegmentCoords,
|
|
288
|
-
segmentDistance,
|
|
289
|
-
startEdgeFeatures,
|
|
290
|
-
features,
|
|
291
|
-
_iterator,
|
|
292
|
-
_step,
|
|
293
|
-
feature,
|
|
294
|
-
_nextRouteSegment,
|
|
295
|
-
portalCost,
|
|
296
|
-
_portalCost,
|
|
297
|
-
_segmentDistance,
|
|
298
|
-
nextRouteSegment,
|
|
299
|
-
overviewSegment,
|
|
300
|
-
_args = arguments;
|
|
301
|
-
return _regenerator().w(function (_context) {
|
|
302
|
-
while (1) switch (_context.n) {
|
|
303
|
-
case 0:
|
|
304
|
-
shouldAddOverviewSegment = _args.length > 3 && _args[3] !== undefined ? _args[3] : true;
|
|
305
|
-
indexOffset = _args.length > 4 && _args[4] !== undefined ? _args[4] : 0;
|
|
306
|
-
path = _["default"].getRoute(startMapObjectId, endMapObjectId, wheelChairAccessibleRouteOnly);
|
|
307
|
-
pathSegments = path.routes; // Find optimized path (i.e. combine straight segments) & maneuvers list
|
|
308
|
-
optimizedPath = [];
|
|
309
|
-
for (segmentIndex = 0; pathSegments && segmentIndex < pathSegments.length; segmentIndex += 1) {
|
|
310
|
-
pathSegment = pathSegments[segmentIndex];
|
|
311
|
-
currentZone = pathSegment.geojson.properties.zone;
|
|
312
|
-
if (!pathSegment.isPortal) {
|
|
313
|
-
_path = pathSegment.geojson.geometry.coordinates; // Reset state for each segment of the path
|
|
314
|
-
lastManeuverType = ManeuverType.Static; // Only add the starting static node for the very first node of route
|
|
315
|
-
if (optimizedPath.length === 0) {
|
|
316
|
-
firstSegment = _objectSpread(_objectSpread({}, createDefaultSegment(pathSegment)), {}, {
|
|
317
|
-
maneuverType: ManeuverType.Static,
|
|
318
|
-
coordinates: [_path[0]]
|
|
319
|
-
});
|
|
320
|
-
optimizedPath.push(firstSegment);
|
|
321
|
-
}
|
|
322
|
-
if (segmentIndex > 0 && optimizedPath.length > 0) {
|
|
323
|
-
prevPathSegment = pathSegments[segmentIndex - 1];
|
|
324
|
-
prevZone = prevPathSegment.geojson.properties.zone;
|
|
325
|
-
if (currentZone !== prevZone) {
|
|
326
|
-
prevPath = prevPathSegment.geojson.geometry.coordinates;
|
|
327
|
-
pathPoint = _objectSpread(_objectSpread({}, createDefaultSegment(prevPathSegment)), {}, {
|
|
328
|
-
maneuverType: ManeuverType.ChangeZone,
|
|
329
|
-
zone: currentZone,
|
|
330
|
-
coordinates: [prevPath[prevPath.length - 1]]
|
|
331
|
-
});
|
|
332
|
-
optimizedPath.push(pathPoint);
|
|
333
|
-
lastManeuverType = ManeuverType.ChangeZone;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
if (_path.length > 2) {
|
|
337
|
-
for (index = 0; index < _path.length - 2; index += 1) {
|
|
338
|
-
startPoint = _path[index];
|
|
339
|
-
midPoint = _path[index + 1];
|
|
340
|
-
endPoint = _path[index + 2]; // Keep updating endSegment on each iteration
|
|
341
|
-
endSegment = _objectSpread(_objectSpread({}, createDefaultSegment(pathSegment)), {}, {
|
|
342
|
-
maneuverType: ManeuverType.Static,
|
|
343
|
-
coordinates: [endPoint],
|
|
344
|
-
zone: currentZone
|
|
345
|
-
});
|
|
208
|
+
async function createRoute(startMapObjectId, endMapObjectId, wheelChairAccessibleRouteOnly) {
|
|
209
|
+
let shouldAddOverviewSegment = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
210
|
+
let indexOffset = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
211
|
+
const path = _index.default.getRoute(startMapObjectId, endMapObjectId, wheelChairAccessibleRouteOnly);
|
|
212
|
+
const pathSegments = path.routes;
|
|
213
|
+
|
|
214
|
+
// Find optimized path (i.e. combine straight segments) & maneuvers list
|
|
215
|
+
const optimizedPath = [];
|
|
216
|
+
let endSegment;
|
|
217
|
+
for (let segmentIndex = 0; pathSegments && segmentIndex < pathSegments.length; segmentIndex += 1) {
|
|
218
|
+
const pathSegment = pathSegments[segmentIndex];
|
|
219
|
+
const currentZone = pathSegment.geojson.properties.zone;
|
|
220
|
+
if (!pathSegment.isPortal) {
|
|
221
|
+
const path = pathSegment.geojson.geometry.coordinates;
|
|
346
222
|
|
|
347
|
-
|
|
348
|
-
|
|
223
|
+
// Reset state for each segment of the path
|
|
224
|
+
let lastManeuverType = ManeuverType.Static;
|
|
349
225
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
226
|
+
// Only add the starting static node for the very first node of route
|
|
227
|
+
if (optimizedPath.length === 0) {
|
|
228
|
+
const firstSegment = _objectSpread(_objectSpread({}, createDefaultSegment(pathSegment)), {}, {
|
|
229
|
+
maneuverType: ManeuverType.Static,
|
|
230
|
+
coordinates: [path[0]]
|
|
231
|
+
});
|
|
232
|
+
optimizedPath.push(firstSegment);
|
|
233
|
+
}
|
|
234
|
+
if (segmentIndex > 0 && optimizedPath.length > 0) {
|
|
235
|
+
const prevPathSegment = pathSegments[segmentIndex - 1];
|
|
236
|
+
const prevZone = prevPathSegment.geojson.properties.zone;
|
|
237
|
+
if (currentZone !== prevZone) {
|
|
238
|
+
const prevPath = prevPathSegment.geojson.geometry.coordinates;
|
|
239
|
+
const pathPoint = _objectSpread(_objectSpread({}, createDefaultSegment(prevPathSegment)), {}, {
|
|
240
|
+
maneuverType: ManeuverType.ChangeZone,
|
|
241
|
+
zone: currentZone,
|
|
242
|
+
coordinates: [prevPath[prevPath.length - 1]]
|
|
243
|
+
});
|
|
244
|
+
optimizedPath.push(pathPoint);
|
|
245
|
+
lastManeuverType = ManeuverType.ChangeZone;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
if (path.length > 2) {
|
|
249
|
+
for (let index = 0; index < path.length - 2; index += 1) {
|
|
250
|
+
const startPoint = path[index];
|
|
251
|
+
const midPoint = path[index + 1];
|
|
252
|
+
const endPoint = path[index + 2];
|
|
360
253
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
// }
|
|
254
|
+
// Keep updating endSegment on each iteration
|
|
255
|
+
endSegment = _objectSpread(_objectSpread({}, createDefaultSegment(pathSegment)), {}, {
|
|
256
|
+
maneuverType: ManeuverType.Static,
|
|
257
|
+
coordinates: [endPoint],
|
|
258
|
+
zone: currentZone
|
|
259
|
+
});
|
|
368
260
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
// } else if (angle > 140) {
|
|
372
|
-
// currentManeuverType = ManeuverType.RightHairPinTurn;
|
|
373
|
-
// } else if (angle < -50) {
|
|
374
|
-
// currentManeuverType = ManeuverType.LeftTurn;
|
|
375
|
-
// } else if (angle > 50) {
|
|
376
|
-
// currentManeuverType = ManeuverType.RightTurn;
|
|
377
|
-
// // } else if (angle < -10) {
|
|
378
|
-
// // currentManeuverType = 'Veer left';
|
|
379
|
-
// // } else if (angle > 10) {
|
|
380
|
-
// // currentManeuverType = 'Veer right';
|
|
381
|
-
// } else {
|
|
382
|
-
// currentManeuverType = ManeuverType.ContinueStraight;
|
|
383
|
-
// }
|
|
384
|
-
// }
|
|
385
|
-
_pathPoint = _objectSpread(_objectSpread({}, createDefaultSegment(pathSegment)), {}, {
|
|
386
|
-
maneuverType: currentManeuverType,
|
|
387
|
-
zone: currentZone
|
|
388
|
-
});
|
|
389
|
-
if (lastManeuverType === ManeuverType.ContinueStraight) {
|
|
390
|
-
// If last iteration of loop then use the end point as segment end else use mid point
|
|
391
|
-
// Use index + 3 because last two points are skipped by loop
|
|
392
|
-
if (index + 3 === _path.length) {
|
|
393
|
-
optimizedPath[optimizedPath.length - 1].coordinates.push(midPoint, endPoint);
|
|
394
|
-
} else {
|
|
395
|
-
optimizedPath[optimizedPath.length - 1].coordinates.push(midPoint);
|
|
396
|
-
}
|
|
397
|
-
optimizedPath[optimizedPath.length - 1].maneuverType = currentManeuverType;
|
|
398
|
-
} else {
|
|
399
|
-
_pathPoint.coordinates.push(startPoint, midPoint);
|
|
400
|
-
optimizedPath.push(_pathPoint);
|
|
261
|
+
// const line = lineString([startPoint, midPoint]);
|
|
262
|
+
// const segmentDistance = length(line, { units: DISTANCE_UNIT });
|
|
401
263
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
264
|
+
// Determine the maneuver type based on the angle of the turn
|
|
265
|
+
let currentManeuverType;
|
|
266
|
+
currentManeuverType = ManeuverType.ContinueStraight;
|
|
267
|
+
// if ((index === 0 || index === path.length - 3) && segmentDistance < 3) {
|
|
268
|
+
// currentManeuverType = ManeuverType.ContinueStraight;
|
|
269
|
+
// }
|
|
270
|
+
// else {
|
|
271
|
+
// // Calculate the bearings between the points
|
|
272
|
+
// const bearing1 = bearing(startPoint, midPoint);
|
|
273
|
+
// const bearing2 = bearing(midPoint, endPoint);
|
|
274
|
+
|
|
275
|
+
// // Calculate the angle between the bearings
|
|
276
|
+
// let angle = bearing2 - bearing1;
|
|
277
|
+
// if (angle < -180) {
|
|
278
|
+
// angle += 360;
|
|
279
|
+
// } else if (angle > 180) {
|
|
280
|
+
// angle -= 360;
|
|
281
|
+
// }
|
|
282
|
+
|
|
283
|
+
// if (angle < -140) {
|
|
284
|
+
// currentManeuverType = ManeuverType.LeftHairPinTurn;
|
|
285
|
+
// } else if (angle > 140) {
|
|
286
|
+
// currentManeuverType = ManeuverType.RightHairPinTurn;
|
|
287
|
+
// } else if (angle < -50) {
|
|
288
|
+
// currentManeuverType = ManeuverType.LeftTurn;
|
|
289
|
+
// } else if (angle > 50) {
|
|
290
|
+
// currentManeuverType = ManeuverType.RightTurn;
|
|
291
|
+
// // } else if (angle < -10) {
|
|
292
|
+
// // currentManeuverType = 'Veer left';
|
|
293
|
+
// // } else if (angle > 10) {
|
|
294
|
+
// // currentManeuverType = 'Veer right';
|
|
295
|
+
// } else {
|
|
296
|
+
// currentManeuverType = ManeuverType.ContinueStraight;
|
|
297
|
+
// }
|
|
298
|
+
// }
|
|
299
|
+
|
|
300
|
+
const pathPoint = _objectSpread(_objectSpread({}, createDefaultSegment(pathSegment)), {}, {
|
|
301
|
+
maneuverType: currentManeuverType,
|
|
302
|
+
zone: currentZone
|
|
303
|
+
});
|
|
304
|
+
if (lastManeuverType === ManeuverType.ContinueStraight) {
|
|
305
|
+
// If last iteration of loop then use the end point as segment end else use mid point
|
|
306
|
+
// Use index + 3 because last two points are skipped by loop
|
|
307
|
+
if (index + 3 === path.length) {
|
|
308
|
+
optimizedPath[optimizedPath.length - 1].coordinates.push(midPoint, endPoint);
|
|
309
|
+
} else {
|
|
310
|
+
optimizedPath[optimizedPath.length - 1].coordinates.push(midPoint);
|
|
311
|
+
}
|
|
312
|
+
optimizedPath[optimizedPath.length - 1].maneuverType = currentManeuverType;
|
|
313
|
+
} else {
|
|
314
|
+
pathPoint.coordinates.push(startPoint, midPoint);
|
|
315
|
+
optimizedPath.push(pathPoint);
|
|
316
|
+
|
|
317
|
+
// If reached end of path then add a ContinueStraight segment at end of path
|
|
318
|
+
// Use index + 3 because last two points are skipped by loop
|
|
319
|
+
if (index + 3 === path.length) {
|
|
320
|
+
// if a ContinueStraight segment was just added then extend that, else add a new ContinueStraight segment at end
|
|
321
|
+
if (currentManeuverType === ManeuverType.ContinueStraight) {
|
|
322
|
+
optimizedPath[optimizedPath.length - 1].coordinates.push(endPoint);
|
|
419
323
|
} else {
|
|
420
|
-
|
|
324
|
+
optimizedPath.push(_objectSpread(_objectSpread({}, createDefaultSegment(pathSegment)), {}, {
|
|
421
325
|
maneuverType: ManeuverType.ContinueStraight,
|
|
422
|
-
coordinates:
|
|
326
|
+
coordinates: [midPoint, endPoint],
|
|
423
327
|
zone: currentZone
|
|
424
|
-
});
|
|
425
|
-
optimizedPath.push(_pathPoint2);
|
|
328
|
+
}));
|
|
426
329
|
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
lastManeuverType = currentManeuverType;
|
|
333
|
+
}
|
|
334
|
+
} else {
|
|
335
|
+
const pathPoint = _objectSpread(_objectSpread({}, createDefaultSegment(pathSegment)), {}, {
|
|
336
|
+
maneuverType: ManeuverType.ContinueStraight,
|
|
337
|
+
coordinates: path,
|
|
338
|
+
zone: currentZone
|
|
339
|
+
});
|
|
340
|
+
optimizedPath.push(pathPoint);
|
|
341
|
+
}
|
|
342
|
+
const removeExtraChangeZoneSegment = () => {
|
|
343
|
+
// When going from public to transit, hide the ChangeZone instruction, if the next step is PassThroughImmigration.
|
|
344
|
+
if (optimizedPath.length > 0) {
|
|
345
|
+
const lastSegmentAdded = optimizedPath[optimizedPath.length - 1];
|
|
346
|
+
if (lastSegmentAdded.maneuverType === ManeuverType.ChangeZone) {
|
|
347
|
+
if (lastSegmentAdded.zone === _interfaces.Zone.Transit) optimizedPath.pop();
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
// Check if there are immigration crossings
|
|
352
|
+
let lastSegmentAdded = optimizedPath.length > 0 ? optimizedPath[optimizedPath.length - 1] : undefined;
|
|
353
|
+
if (lastSegmentAdded && lastSegmentAdded.maneuverType === ManeuverType.ContinueStraight) {
|
|
354
|
+
// Will add new segment, search for immigration crossings on the current non-vertical segment
|
|
355
|
+
const immigrationPolygonFeatures = (0, _mapObjectsHelper.getImmigrationPolygonFeaturesForWhereTaxonomy)(lastSegmentAdded.startEdge.whereDimension);
|
|
356
|
+
const line = (0, _helpers.lineString)(lastSegmentAdded.coordinates);
|
|
357
|
+
for (let index = 0; index < immigrationPolygonFeatures.length; index += 1) {
|
|
358
|
+
const immigrationPolygonFeature = immigrationPolygonFeatures[index];
|
|
359
|
+
if (!(0, _turf.booleanDisjoint)(line, immigrationPolygonFeature)) {
|
|
360
|
+
const intersects = (0, _turf.lineIntersect)(line, immigrationPolygonFeature);
|
|
361
|
+
if (intersects.features.length > 1) {
|
|
362
|
+
optimizedPath.pop();
|
|
363
|
+
const lineBeforeImmigration = (0, _turf.lineSlice)((0, _turf.getCoords)(line)[0], (0, _turf.getCoord)(intersects.features[0]), line);
|
|
364
|
+
const lengthOfLineBeforeImmigration = (0, _length.default)(lineBeforeImmigration, {
|
|
365
|
+
units: 'meters'
|
|
366
|
+
});
|
|
367
|
+
// Only add if length greater then min limit
|
|
368
|
+
if (lengthOfLineBeforeImmigration >= 10) {
|
|
369
|
+
const segmentBeforeImmigration = _objectSpread(_objectSpread({}, createDefaultSegment(pathSegment)), {}, {
|
|
370
|
+
maneuverType: ManeuverType.ContinueStraight,
|
|
371
|
+
zone: currentZone,
|
|
372
|
+
coordinates: (0, _turf.getCoords)(lineBeforeImmigration)
|
|
373
|
+
});
|
|
374
|
+
optimizedPath.push(segmentBeforeImmigration);
|
|
375
|
+
} else if (optimizedPath.length > 0) {
|
|
376
|
+
lastSegmentAdded = optimizedPath[optimizedPath.length - 1];
|
|
377
|
+
// If lastSegmentAdded is a change zone segment then move both lastSegmentAdded and also the second last segment
|
|
378
|
+
if (lastSegmentAdded.maneuverType === ManeuverType.ChangeZone) {
|
|
379
|
+
const coordsOfLastSegment = (0, _turf.getCoords)(lineBeforeImmigration);
|
|
380
|
+
lastSegmentAdded.coordinates = [coordsOfLastSegment[coordsOfLastSegment.length - 1]];
|
|
381
|
+
if (optimizedPath.length > 1) {
|
|
382
|
+
const secondLastSegmentAdded = optimizedPath[optimizedPath.length - 2];
|
|
383
|
+
secondLastSegmentAdded.coordinates = secondLastSegmentAdded.coordinates.concat((0, _turf.getCoords)(lineBeforeImmigration));
|
|
433
384
|
}
|
|
385
|
+
} else {
|
|
386
|
+
lastSegmentAdded.coordinates.concat((0, _turf.getCoords)(lineBeforeImmigration));
|
|
434
387
|
}
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
lineBeforeImmigration = (0, _turf.lineSlice)((0, _turf.getCoords)(line)[0], (0, _turf.getCoord)(intersects.features[0]), line);
|
|
448
|
-
lengthOfLineBeforeImmigration = (0, _length["default"])(lineBeforeImmigration, {
|
|
449
|
-
units: 'meters'
|
|
450
|
-
}); // Only add if length greater then min limit
|
|
451
|
-
if (lengthOfLineBeforeImmigration >= 10) {
|
|
452
|
-
segmentBeforeImmigration = _objectSpread(_objectSpread({}, createDefaultSegment(pathSegment)), {}, {
|
|
453
|
-
maneuverType: ManeuverType.ContinueStraight,
|
|
454
|
-
zone: currentZone,
|
|
455
|
-
coordinates: (0, _turf.getCoords)(lineBeforeImmigration)
|
|
456
|
-
});
|
|
457
|
-
optimizedPath.push(segmentBeforeImmigration);
|
|
458
|
-
} else if (optimizedPath.length > 0) {
|
|
459
|
-
lastSegmentAdded = optimizedPath[optimizedPath.length - 1];
|
|
460
|
-
// If lastSegmentAdded is a change zone segment then move both lastSegmentAdded and also the second last segment
|
|
461
|
-
if (lastSegmentAdded.maneuverType === ManeuverType.ChangeZone) {
|
|
462
|
-
coordsOfLastSegment = (0, _turf.getCoords)(lineBeforeImmigration);
|
|
463
|
-
lastSegmentAdded.coordinates = [coordsOfLastSegment[coordsOfLastSegment.length - 1]];
|
|
464
|
-
if (optimizedPath.length > 1) {
|
|
465
|
-
secondLastSegmentAdded = optimizedPath[optimizedPath.length - 2];
|
|
466
|
-
secondLastSegmentAdded.coordinates = secondLastSegmentAdded.coordinates.concat((0, _turf.getCoords)(lineBeforeImmigration));
|
|
467
|
-
}
|
|
468
|
-
} else {
|
|
469
|
-
lastSegmentAdded.coordinates.concat((0, _turf.getCoords)(lineBeforeImmigration));
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
immigrationLine = (0, _turf.lineSlice)((0, _turf.getCoord)(intersects.features[0]), (0, _turf.getCoord)(intersects.features[1]), line);
|
|
473
|
-
immigrationSegment = _objectSpread(_objectSpread({}, createDefaultSegment(pathSegment)), {}, {
|
|
474
|
-
maneuverType: ManeuverType.PassThroughImmigration,
|
|
475
|
-
zone: currentZone,
|
|
476
|
-
coordinates: (0, _turf.getCoords)(immigrationLine)
|
|
477
|
-
}); // The lineBeforeImmigration might not have been added due to length limit
|
|
478
|
-
// And if lineBeforeImmigration was supposed to be the the first segment then prepend this segment with coordinates of lineBeforeImmigration
|
|
479
|
-
if (optimizedPath.length === 0) {
|
|
480
|
-
immigrationSegment.coordinates = lineBeforeImmigration.geometry.coordinates.concat(immigrationSegment.coordinates);
|
|
481
|
-
}
|
|
388
|
+
}
|
|
389
|
+
const immigrationLine = (0, _turf.lineSlice)((0, _turf.getCoord)(intersects.features[0]), (0, _turf.getCoord)(intersects.features[1]), line);
|
|
390
|
+
const immigrationSegment = _objectSpread(_objectSpread({}, createDefaultSegment(pathSegment)), {}, {
|
|
391
|
+
maneuverType: ManeuverType.PassThroughImmigration,
|
|
392
|
+
zone: currentZone,
|
|
393
|
+
coordinates: (0, _turf.getCoords)(immigrationLine)
|
|
394
|
+
});
|
|
395
|
+
// The lineBeforeImmigration might not have been added due to length limit
|
|
396
|
+
// And if lineBeforeImmigration was supposed to be the the first segment then prepend this segment with coordinates of lineBeforeImmigration
|
|
397
|
+
if (optimizedPath.length === 0) {
|
|
398
|
+
immigrationSegment.coordinates = lineBeforeImmigration.geometry.coordinates.concat(immigrationSegment.coordinates);
|
|
399
|
+
}
|
|
482
400
|
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
401
|
+
// When going from public to transit, hide the ChangeZone instruction, if the next step is PassThroughImmigration.
|
|
402
|
+
removeExtraChangeZoneSegment();
|
|
403
|
+
optimizedPath.push(immigrationSegment);
|
|
404
|
+
const lineCoords = (0, _turf.getCoords)(line);
|
|
405
|
+
const lineAfterImmigration = (0, _turf.lineSlice)((0, _turf.getCoord)(intersects.features[1]), lineCoords[lineCoords.length - 1], line);
|
|
406
|
+
const segmentAfterImmigration = _objectSpread(_objectSpread({}, createDefaultSegment(pathSegment)), {}, {
|
|
407
|
+
maneuverType: ManeuverType.ContinueStraight,
|
|
408
|
+
zone: currentZone,
|
|
409
|
+
coordinates: (0, _turf.getCoords)(lineAfterImmigration)
|
|
410
|
+
});
|
|
411
|
+
optimizedPath.push(segmentAfterImmigration);
|
|
412
|
+
// line = segmentAfterImmigration;
|
|
413
|
+
} else if (intersects.features.length > 0) {
|
|
414
|
+
// check if start point outside polygon then end inside polygon - valid
|
|
415
|
+
const startPointWithinPolygon = (0, _turf.booleanPointInPolygon)((0, _turf.getCoords)(line)[0], immigrationPolygonFeature);
|
|
416
|
+
if (startPointWithinPolygon) {
|
|
417
|
+
optimizedPath.pop();
|
|
500
418
|
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
419
|
+
// One intersection point and start point is within polygon
|
|
420
|
+
// Means line start inside and exits the polygon
|
|
421
|
+
const immigrationLine = (0, _turf.lineSlice)((0, _turf.getCoords)(line)[0], (0, _turf.getCoord)(intersects.features[0]), line);
|
|
422
|
+
const immigrationSegment = _objectSpread(_objectSpread({}, createDefaultSegment(pathSegment)), {}, {
|
|
423
|
+
maneuverType: ManeuverType.PassThroughImmigration,
|
|
424
|
+
zone: currentZone,
|
|
425
|
+
coordinates: (0, _turf.getCoords)(immigrationLine)
|
|
426
|
+
});
|
|
427
|
+
lastSegmentAdded = optimizedPath.length > 0 ? optimizedPath[optimizedPath.length - 1] : undefined;
|
|
428
|
+
if (lastSegmentAdded && lastSegmentAdded.maneuverType === ManeuverType.ChangeZone) {
|
|
429
|
+
// Remove change zone segment
|
|
430
|
+
const changeZoneSegment = optimizedPath.pop();
|
|
431
|
+
if (optimizedPath.length > 1) {
|
|
432
|
+
const secondLastSegmentAdded = optimizedPath[optimizedPath.length - 1];
|
|
433
|
+
if (secondLastSegmentAdded.maneuverType === ManeuverType.PassThroughImmigration) {
|
|
434
|
+
optimizedPath.pop();
|
|
517
435
|
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
// When going from public to transit, hide the ChangeZone instruction, if the next step is PassThroughImmigration.
|
|
526
|
-
removeExtraChangeZoneSegment();
|
|
527
|
-
optimizedPath.push(_immigrationSegment);
|
|
528
|
-
_lineCoords = (0, _turf.getCoords)(line);
|
|
529
|
-
_lineAfterImmigration = (0, _turf.lineSlice)((0, _turf.getCoord)(intersects.features[0]), _lineCoords[_lineCoords.length - 1], line);
|
|
530
|
-
_segmentAfterImmigration = _objectSpread(_objectSpread({}, createDefaultSegment(pathSegment)), {}, {
|
|
531
|
-
maneuverType: ManeuverType.ContinueStraight,
|
|
532
|
-
zone: currentZone,
|
|
533
|
-
coordinates: (0, _turf.getCoords)(_lineAfterImmigration)
|
|
534
|
-
});
|
|
535
|
-
optimizedPath.push(_segmentAfterImmigration);
|
|
536
|
-
} else {
|
|
537
|
-
// line starts outside immigration and ends inside immigration
|
|
538
|
-
// this is not a valid case but lines are still divided into segments as the segments are used
|
|
539
|
-
// by the logic under case 2(startPointWithinPolygon)
|
|
540
|
-
previousLine = (0, _turf.lineSlice)((0, _turf.getCoords)(line)[0], (0, _turf.getCoord)(intersects.features[0]), line);
|
|
541
|
-
lastSegmentAdded.coordinates = (0, _turf.getCoords)(previousLine);
|
|
542
|
-
_lineCoords2 = (0, _turf.getCoords)(line);
|
|
543
|
-
_lineAfterImmigration2 = (0, _turf.lineSlice)((0, _turf.getCoord)(intersects.features[0]), _lineCoords2[_lineCoords2.length - 1], line);
|
|
544
|
-
_segmentAfterImmigration2 = _objectSpread(_objectSpread({}, createDefaultSegment(pathSegment)), {}, {
|
|
545
|
-
maneuverType: ManeuverType.PassThroughImmigration,
|
|
546
|
-
zone: currentZone,
|
|
547
|
-
coordinates: (0, _turf.getCoords)(_lineAfterImmigration2)
|
|
548
|
-
});
|
|
549
|
-
optimizedPath.push(_segmentAfterImmigration2);
|
|
550
|
-
// line = segmentAfterImmigration;
|
|
551
|
-
}
|
|
436
|
+
// Re add the change zone segment with updated coordinates
|
|
437
|
+
changeZoneSegment.coordinates = [secondLastSegmentAdded.coordinates[0]];
|
|
438
|
+
optimizedPath.push(changeZoneSegment);
|
|
439
|
+
immigrationSegment.coordinates = secondLastSegmentAdded.coordinates.concat(immigrationSegment.coordinates);
|
|
552
440
|
}
|
|
553
441
|
}
|
|
554
442
|
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
// // Only add this ExitPortal segment if previously same what dimension portal is not being continued
|
|
582
|
-
// // This is done to ensure Take Lift at A, Exit Lift at B, Take lift at B, Exit Lift at C is generated only as Take lift at A, Exit lift at C
|
|
583
|
-
// if (lastSegmentAdded && lastSegmentAdded.maneuverType !== ManeuverType.ExitPortal) {
|
|
584
|
-
// if (pathSegment.portalPath) {
|
|
585
|
-
// const travelPortalSegment: RouteSegment = {
|
|
586
|
-
// ...createDefaultSegment(pathSegment),
|
|
587
|
-
// maneuverType: ManeuverType.TravelPortal,
|
|
588
|
-
// coordinates: pathSegment.portalPath.geometry.coordinates,
|
|
589
|
-
// zone: currentZone,
|
|
590
|
-
// };
|
|
591
|
-
// optimizedPath.push(travelPortalSegment);
|
|
592
|
-
// }
|
|
593
|
-
// optimizedPath.push(exitPortalSegment);
|
|
594
|
-
// } else
|
|
595
|
-
optimizedPath.push(exitPortalSegment);
|
|
596
|
-
_lastSegmentAdded2 = optimizedPath.length > 0 ? optimizedPath[optimizedPath.length - 1] : undefined;
|
|
597
|
-
if (_lastSegmentAdded2 && _lastSegmentAdded2.maneuverType === ManeuverType.ExitPortal) {
|
|
598
|
-
optimizedPath.pop();
|
|
599
|
-
if (pathSegment.portalPath) {
|
|
600
|
-
travelPortalSegment = _objectSpread(_objectSpread({}, createDefaultSegment(pathSegment)), {}, {
|
|
601
|
-
maneuverType: ManeuverType.TravelPortal,
|
|
602
|
-
coordinates: pathSegment.portalPath.geometry.coordinates,
|
|
603
|
-
zone: currentZone
|
|
604
|
-
});
|
|
605
|
-
optimizedPath.push(travelPortalSegment);
|
|
606
|
-
}
|
|
607
|
-
optimizedPath.push(exitPortalSegment);
|
|
443
|
+
// When going from public to transit, hide the ChangeZone instruction, if the next step is PassThroughImmigration.
|
|
444
|
+
removeExtraChangeZoneSegment();
|
|
445
|
+
optimizedPath.push(immigrationSegment);
|
|
446
|
+
const lineCoords = (0, _turf.getCoords)(line);
|
|
447
|
+
const lineAfterImmigration = (0, _turf.lineSlice)((0, _turf.getCoord)(intersects.features[0]), lineCoords[lineCoords.length - 1], line);
|
|
448
|
+
const segmentAfterImmigration = _objectSpread(_objectSpread({}, createDefaultSegment(pathSegment)), {}, {
|
|
449
|
+
maneuverType: ManeuverType.ContinueStraight,
|
|
450
|
+
zone: currentZone,
|
|
451
|
+
coordinates: (0, _turf.getCoords)(lineAfterImmigration)
|
|
452
|
+
});
|
|
453
|
+
optimizedPath.push(segmentAfterImmigration);
|
|
454
|
+
} else {
|
|
455
|
+
// line starts outside immigration and ends inside immigration
|
|
456
|
+
// this is not a valid case but lines are still divided into segments as the segments are used
|
|
457
|
+
// by the logic under case 2(startPointWithinPolygon)
|
|
458
|
+
const previousLine = (0, _turf.lineSlice)((0, _turf.getCoords)(line)[0], (0, _turf.getCoord)(intersects.features[0]), line);
|
|
459
|
+
lastSegmentAdded.coordinates = (0, _turf.getCoords)(previousLine);
|
|
460
|
+
const lineCoords = (0, _turf.getCoords)(line);
|
|
461
|
+
const lineAfterImmigration = (0, _turf.lineSlice)((0, _turf.getCoord)(intersects.features[0]), lineCoords[lineCoords.length - 1], line);
|
|
462
|
+
const segmentAfterImmigration = _objectSpread(_objectSpread({}, createDefaultSegment(pathSegment)), {}, {
|
|
463
|
+
maneuverType: ManeuverType.PassThroughImmigration,
|
|
464
|
+
zone: currentZone,
|
|
465
|
+
coordinates: (0, _turf.getCoords)(lineAfterImmigration)
|
|
466
|
+
});
|
|
467
|
+
optimizedPath.push(segmentAfterImmigration);
|
|
468
|
+
// line = segmentAfterImmigration;
|
|
608
469
|
}
|
|
609
470
|
}
|
|
610
471
|
}
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
} else {
|
|
475
|
+
// Keep updating endSegment on each iteration
|
|
476
|
+
endSegment = _objectSpread(_objectSpread({}, createDefaultSegment(pathSegment)), {}, {
|
|
477
|
+
maneuverType: ManeuverType.Static,
|
|
478
|
+
coordinates: [pathSegment.geojson.geometry.coordinates[1]],
|
|
479
|
+
zone: currentZone,
|
|
480
|
+
isPortal: false
|
|
481
|
+
});
|
|
482
|
+
const enterPortalSegment = _objectSpread(_objectSpread({}, createDefaultSegment(pathSegment)), {}, {
|
|
483
|
+
maneuverType: ManeuverType.EnterPortal,
|
|
484
|
+
coordinates: [pathSegment.geojson.geometry.coordinates[0]]
|
|
485
|
+
});
|
|
486
|
+
// // Only add this EnterPortal segment if previously same what dimension portal is not being continued
|
|
487
|
+
// // This is done to ensure Take Lift at A, Exit Lift at B, Take lift at B, Exit Lift at C is generated only as Take lift at A, Exit lift at C
|
|
488
|
+
// let lastSegmentAdded = (optimizedPath.length > 0) ? optimizedPath[optimizedPath.length - 1] : undefined;
|
|
489
|
+
// if (!lastSegmentAdded
|
|
490
|
+
// || (lastSegmentAdded && lastSegmentAdded.maneuverType !== ManeuverType.ExitPortal)
|
|
491
|
+
// || (lastSegmentAdded && lastSegmentAdded.maneuverType === ManeuverType.ExitPortal && lastSegmentAdded.startEdge.whatDimension !== enterPortalSegment.startEdge.whatDimension)) {
|
|
492
|
+
// optimizedPath.push(enterPortalSegment);
|
|
493
|
+
// lastSegmentAdded = enterPortalSegment;
|
|
494
|
+
// }
|
|
631
495
|
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
routeSegmentCoords = segment.coordinates;
|
|
651
|
-
segmentDistance = void 0;
|
|
652
|
-
if (routeSegmentCoords.length > 1) {
|
|
653
|
-
segmentDistance = (0, _length["default"])((0, _helpers.lineString)(routeSegmentCoords), {
|
|
654
|
-
units: route.distanceUnit
|
|
655
|
-
});
|
|
656
|
-
} else {
|
|
657
|
-
segmentDistance = 0;
|
|
658
|
-
}
|
|
659
|
-
segment.distance = segmentDistance;
|
|
660
|
-
if (segment.maneuverType !== ManeuverType.PassThroughImmigration) {
|
|
661
|
-
segment.time = segment.distance / route.speed;
|
|
662
|
-
} else {
|
|
663
|
-
segment.time = 0;
|
|
664
|
-
}
|
|
665
|
-
} else {
|
|
666
|
-
// if (
|
|
667
|
-
// segment.maneuverType !== ManeuverType.EnterPortal
|
|
668
|
-
// && segment.maneuverType !== ManeuverType.ExitPortal
|
|
669
|
-
// ) {
|
|
670
|
-
// console.warn('unexpected state in createRoute');
|
|
671
|
-
// }
|
|
496
|
+
optimizedPath.push(enterPortalSegment);
|
|
497
|
+
const exitPortalSegment = _objectSpread(_objectSpread({}, createDefaultSegment(pathSegment)), {}, {
|
|
498
|
+
maneuverType: ManeuverType.ExitPortal,
|
|
499
|
+
coordinates: [pathSegment.geojson.geometry.coordinates[1]]
|
|
500
|
+
});
|
|
501
|
+
// // This logic is tied to the above similar logic for EnterPortal
|
|
502
|
+
// // Only add this ExitPortal segment if previously same what dimension portal is not being continued
|
|
503
|
+
// // This is done to ensure Take Lift at A, Exit Lift at B, Take lift at B, Exit Lift at C is generated only as Take lift at A, Exit lift at C
|
|
504
|
+
// if (lastSegmentAdded && lastSegmentAdded.maneuverType !== ManeuverType.ExitPortal) {
|
|
505
|
+
// if (pathSegment.portalPath) {
|
|
506
|
+
// const travelPortalSegment: RouteSegment = {
|
|
507
|
+
// ...createDefaultSegment(pathSegment),
|
|
508
|
+
// maneuverType: ManeuverType.TravelPortal,
|
|
509
|
+
// coordinates: pathSegment.portalPath.geometry.coordinates,
|
|
510
|
+
// zone: currentZone,
|
|
511
|
+
// };
|
|
512
|
+
// optimizedPath.push(travelPortalSegment);
|
|
513
|
+
// }
|
|
672
514
|
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
515
|
+
// optimizedPath.push(exitPortalSegment);
|
|
516
|
+
// } else
|
|
517
|
+
optimizedPath.push(exitPortalSegment);
|
|
518
|
+
const lastSegmentAdded = optimizedPath.length > 0 ? optimizedPath[optimizedPath.length - 1] : undefined;
|
|
519
|
+
if (lastSegmentAdded && lastSegmentAdded.maneuverType === ManeuverType.ExitPortal) {
|
|
520
|
+
optimizedPath.pop();
|
|
521
|
+
if (pathSegment.portalPath) {
|
|
522
|
+
const travelPortalSegment = _objectSpread(_objectSpread({}, createDefaultSegment(pathSegment)), {}, {
|
|
523
|
+
maneuverType: ManeuverType.TravelPortal,
|
|
524
|
+
coordinates: pathSegment.portalPath.geometry.coordinates,
|
|
525
|
+
zone: currentZone
|
|
526
|
+
});
|
|
527
|
+
optimizedPath.push(travelPortalSegment);
|
|
528
|
+
}
|
|
529
|
+
optimizedPath.push(exitPortalSegment);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
if (endSegment) optimizedPath.push(endSegment);
|
|
534
|
+
const route = {
|
|
535
|
+
segments: optimizedPath,
|
|
536
|
+
walkingDistance: 0,
|
|
537
|
+
transportDistance: 0,
|
|
538
|
+
walkingTime: 0,
|
|
539
|
+
transportTime: 0,
|
|
540
|
+
distanceUnit: _interfaces.DISTANCE_UNIT,
|
|
541
|
+
speed: _interfaces.WALK_SPEED
|
|
542
|
+
};
|
|
690
543
|
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
segment.features = getRouteLine(segment.coordinates, segmentNumber, highlight, patchNumber, segment.zone, segment.startEdge.whereDimension);
|
|
703
|
-
segment.patchNumber = patchNumber;
|
|
704
|
-
segment.whereDimension = whereDimension;
|
|
705
|
-
_portalCost = segment.cost;
|
|
706
|
-
segment.time = _portalCost || 0;
|
|
707
|
-
_segmentDistance = void 0;
|
|
708
|
-
if (segment.coordinates.length > 1) {
|
|
709
|
-
_segmentDistance = (0, _length["default"])((0, _helpers.lineString)(segment.coordinates), {
|
|
710
|
-
units: route.distanceUnit
|
|
711
|
-
});
|
|
712
|
-
} else {
|
|
713
|
-
_segmentDistance = 0;
|
|
714
|
-
}
|
|
715
|
-
segment.distance = _segmentDistance;
|
|
544
|
+
// A patch denotes the segments which are directly connected to each other i.e. no portal in between, portal enter/exit can be part of the patch
|
|
545
|
+
if (route.segments.length > 0) {
|
|
546
|
+
const addOverviewSegment = shouldAddOverviewSegment;
|
|
547
|
+
let initialIndex = 0;
|
|
548
|
+
if (addOverviewSegment) {
|
|
549
|
+
// Dummy overview segment at start of route
|
|
550
|
+
const dummySegment = (0, _lodash.cloneDeep)(route.segments[0]);
|
|
551
|
+
dummySegment.maneuverType = ManeuverType.RouteOverview;
|
|
552
|
+
route.segments.unshift(dummySegment);
|
|
553
|
+
initialIndex = 1; // Because overview segment will be at 0th index of route
|
|
554
|
+
}
|
|
716
555
|
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
556
|
+
// A patch denotes the segments which are directly connected to each other i.e. no portal in between, portal enter/exit can be part of the patch
|
|
557
|
+
let patchNumber = indexOffset + initialIndex;
|
|
558
|
+
let whereDimension = route.segments.length > initialIndex ? route.segments[initialIndex].startEdge.whereDimension : '';
|
|
559
|
+
for (let index = initialIndex; index < route.segments.length; index += 1) {
|
|
560
|
+
const highlight = false;
|
|
561
|
+
const segment = route.segments[index];
|
|
562
|
+
const segmentNumber = indexOffset + index;
|
|
563
|
+
if (!segment.isPortal) {
|
|
564
|
+
// point feature if ManeuverType.Static else line feature
|
|
565
|
+
if (segment.maneuverType === ManeuverType.Static || segment.maneuverType === ManeuverType.ChangeZone) {
|
|
566
|
+
segment.features = getRouteNode(segment.coordinates[0], segmentNumber, highlight, patchNumber, segment.endEdge.whereDimension);
|
|
567
|
+
segment.patchNumber = patchNumber;
|
|
568
|
+
segment.whereDimension = whereDimension;
|
|
569
|
+
} else {
|
|
570
|
+
segment.features = getRouteLine(segment.coordinates, segmentNumber, highlight, patchNumber, segment.zone, segment.startEdge.whereDimension);
|
|
571
|
+
segment.patchNumber = patchNumber;
|
|
572
|
+
segment.whereDimension = whereDimension;
|
|
573
|
+
}
|
|
574
|
+
const routeSegmentCoords = segment.coordinates;
|
|
575
|
+
let segmentDistance;
|
|
576
|
+
if (routeSegmentCoords.length > 1) {
|
|
577
|
+
segmentDistance = (0, _length.default)((0, _helpers.lineString)(routeSegmentCoords), {
|
|
578
|
+
units: route.distanceUnit
|
|
579
|
+
});
|
|
580
|
+
} else {
|
|
581
|
+
segmentDistance = 0;
|
|
582
|
+
}
|
|
583
|
+
segment.distance = segmentDistance;
|
|
584
|
+
if (segment.maneuverType !== ManeuverType.PassThroughImmigration) {
|
|
585
|
+
segment.time = segment.distance / route.speed;
|
|
586
|
+
} else {
|
|
587
|
+
segment.time = 0;
|
|
588
|
+
}
|
|
589
|
+
} else {
|
|
590
|
+
// if (
|
|
591
|
+
// segment.maneuverType !== ManeuverType.EnterPortal
|
|
592
|
+
// && segment.maneuverType !== ManeuverType.ExitPortal
|
|
593
|
+
// ) {
|
|
594
|
+
// console.warn('unexpected state in createRoute');
|
|
595
|
+
// }
|
|
724
596
|
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
597
|
+
if (segment.maneuverType === ManeuverType.EnterPortal) {
|
|
598
|
+
const startEdgeFeatures = getRouteNode(segment.coordinates[0], segmentNumber, highlight, patchNumber, segment.startEdge.whereDimension);
|
|
599
|
+
const features = [];
|
|
600
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
601
|
+
for (const feature of startEdgeFeatures) {
|
|
602
|
+
features.push(feature);
|
|
603
|
+
}
|
|
604
|
+
segment.features = features;
|
|
605
|
+
segment.patchNumber = patchNumber;
|
|
606
|
+
segment.whereDimension = whereDimension;
|
|
729
607
|
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
route.transportDistance += segment.distance;
|
|
738
|
-
route.transportTime += segment.time;
|
|
739
|
-
} else {
|
|
740
|
-
route.walkingDistance += segment.distance;
|
|
741
|
-
route.walkingTime += segment.time;
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
if (addOverviewSegment) {
|
|
745
|
-
// Generate and add actual overview segment
|
|
746
|
-
overviewSegment = generateOverviewSegment(route, indexOffset);
|
|
747
|
-
route.segments[0] = overviewSegment;
|
|
748
|
-
}
|
|
608
|
+
// read next segment, if next segment is TravelPortal then do not include time of this enter portal segment
|
|
609
|
+
const nextRouteSegment = route.segments.length >= index + 2 ? route.segments[index + 1] : undefined;
|
|
610
|
+
if (nextRouteSegment && nextRouteSegment.maneuverType !== ManeuverType.TravelPortal) {
|
|
611
|
+
const portalCost = segment.cost;
|
|
612
|
+
segment.time = portalCost || 0;
|
|
613
|
+
} else {
|
|
614
|
+
segment.time = 0;
|
|
749
615
|
}
|
|
750
|
-
|
|
616
|
+
segment.distance = 0;
|
|
617
|
+
}
|
|
618
|
+
if (segment.maneuverType === ManeuverType.TravelPortal) {
|
|
619
|
+
segment.features = getRouteLine(segment.coordinates, segmentNumber, highlight, patchNumber, segment.zone, segment.startEdge.whereDimension);
|
|
620
|
+
segment.patchNumber = patchNumber;
|
|
621
|
+
segment.whereDimension = whereDimension;
|
|
622
|
+
const portalCost = segment.cost;
|
|
623
|
+
segment.time = portalCost || 0;
|
|
624
|
+
let segmentDistance;
|
|
625
|
+
if (segment.coordinates.length > 1) {
|
|
626
|
+
segmentDistance = (0, _length.default)((0, _helpers.lineString)(segment.coordinates), {
|
|
627
|
+
units: route.distanceUnit
|
|
628
|
+
});
|
|
629
|
+
} else {
|
|
630
|
+
segmentDistance = 0;
|
|
631
|
+
}
|
|
632
|
+
segment.distance = segmentDistance;
|
|
633
|
+
|
|
634
|
+
// Set time of previous enter portal instruction to zero, so that time in not shown in UI
|
|
635
|
+
if (index > 0) route.segments[index - 1].time = 0;
|
|
636
|
+
}
|
|
637
|
+
if (segment.maneuverType === ManeuverType.ExitPortal) {
|
|
638
|
+
// increment patch number to next value
|
|
639
|
+
patchNumber += 1;
|
|
640
|
+
whereDimension = segment.endEdge.whereDimension;
|
|
641
|
+
|
|
642
|
+
// Remove ExitPortal segment from route, because its only used to calculate patch information since ATOMS-207
|
|
643
|
+
route.segments.splice(index, 1);
|
|
644
|
+
index -= 1;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
// read next segment
|
|
648
|
+
const nextRouteSegment = route.segments.length >= index + 2 ? route.segments[index + 1] : undefined;
|
|
649
|
+
if (nextRouteSegment && nextRouteSegment.maneuverType === ManeuverType.TravelPortal) {
|
|
650
|
+
patchNumber += 1;
|
|
651
|
+
}
|
|
751
652
|
}
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
653
|
+
if (segment.maneuverType === ManeuverType.TravelPortal) {
|
|
654
|
+
route.transportDistance += segment.distance;
|
|
655
|
+
route.transportTime += segment.time;
|
|
656
|
+
} else {
|
|
657
|
+
route.walkingDistance += segment.distance;
|
|
658
|
+
route.walkingTime += segment.time;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
if (addOverviewSegment) {
|
|
662
|
+
// Generate and add actual overview segment
|
|
663
|
+
const overviewSegment = generateOverviewSegment(route, indexOffset);
|
|
664
|
+
route.segments[0] = overviewSegment;
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
return route;
|
|
755
668
|
}
|
|
756
669
|
function getPatch(route) {
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
for (
|
|
760
|
-
|
|
670
|
+
let patchNumber = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
671
|
+
let routefeatures = [];
|
|
672
|
+
for (let index = 0; index < route.segments.length; index += 1) {
|
|
673
|
+
const routeSegment = route.segments[index];
|
|
761
674
|
if (routeSegment.patchNumber === patchNumber) {
|
|
762
675
|
routefeatures = routefeatures.concat(routeSegment.features);
|
|
763
676
|
}
|
|
@@ -765,17 +678,17 @@ function getPatch(route) {
|
|
|
765
678
|
return routefeatures;
|
|
766
679
|
}
|
|
767
680
|
function getFeaturesForPatch(route, patchNumber, overviewSegmentInfo) {
|
|
768
|
-
|
|
769
|
-
for (
|
|
770
|
-
|
|
681
|
+
let routefeatures = [];
|
|
682
|
+
for (let index = 0; index < route.segments.length; index += 1) {
|
|
683
|
+
const routeSegment = route.segments[index];
|
|
771
684
|
if (overviewSegmentInfo.includeOverviewFeatures) {
|
|
772
685
|
// Return all features in default case
|
|
773
686
|
if (isOverviewSegment(routeSegment)) {
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
for (
|
|
687
|
+
const nonHighlightedOverviewFeatures = [];
|
|
688
|
+
const highlightedOverviewFeatures = [];
|
|
689
|
+
for (let j = 0; j < routeSegment.features.length; j++) {
|
|
777
690
|
var _feature$properties;
|
|
778
|
-
|
|
691
|
+
const feature = routeSegment.features[j];
|
|
779
692
|
if (((_feature$properties = feature.properties) === null || _feature$properties === void 0 ? void 0 : _feature$properties.patchNumber) !== undefined && feature.properties.patchNumber === overviewSegmentInfo.patchNumberForOverviewFeatures) {
|
|
780
693
|
if (feature.properties.isNonHighlightedOverview !== undefined) {
|
|
781
694
|
if (feature.properties.isNonHighlightedOverview === '1') {
|
|
@@ -788,7 +701,7 @@ function getFeaturesForPatch(route, patchNumber, overviewSegmentInfo) {
|
|
|
788
701
|
}
|
|
789
702
|
// Sort the features such that non hihglighted features come first in the array
|
|
790
703
|
// because on map they should be sorted below highlighted features in z dimension
|
|
791
|
-
|
|
704
|
+
const overviewSegmentFeatures = nonHighlightedOverviewFeatures.concat(highlightedOverviewFeatures);
|
|
792
705
|
routefeatures = routefeatures.concat(overviewSegmentFeatures);
|
|
793
706
|
}
|
|
794
707
|
} else if (routeSegment.patchNumber === patchNumber) {
|
|
@@ -845,12 +758,12 @@ function getPortalName(whatDimension) {
|
|
|
845
758
|
}
|
|
846
759
|
}
|
|
847
760
|
function getTerminalAndLevelName(whereDimension) {
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
761
|
+
const regex = /^(T\d+|JEWEL)([A-Za-z]\d+[A-Za-z]?)$/;
|
|
762
|
+
const subDimension = whereDimension.split('.').slice(-2).join('').toUpperCase();
|
|
763
|
+
const match = subDimension.match(regex);
|
|
851
764
|
if (match) {
|
|
852
|
-
|
|
853
|
-
|
|
765
|
+
const terminalIndicator = match[1][0];
|
|
766
|
+
let terminalName;
|
|
854
767
|
switch (terminalIndicator) {
|
|
855
768
|
case 'T':
|
|
856
769
|
terminalName = 'Terminal';
|
|
@@ -862,9 +775,9 @@ function getTerminalAndLevelName(whereDimension) {
|
|
|
862
775
|
terminalName = 'Level';
|
|
863
776
|
break;
|
|
864
777
|
}
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
778
|
+
const terminal = terminalName === 'Terminal' ? "".concat(terminalName, " ").concat(match[1][1]) : "".concat(terminalName);
|
|
779
|
+
const levelIdentifier = match[2][0];
|
|
780
|
+
let levelName;
|
|
868
781
|
switch (levelIdentifier) {
|
|
869
782
|
case 'L':
|
|
870
783
|
levelName = 'Level';
|
|
@@ -876,7 +789,7 @@ function getTerminalAndLevelName(whereDimension) {
|
|
|
876
789
|
levelName = 'Level';
|
|
877
790
|
break;
|
|
878
791
|
}
|
|
879
|
-
|
|
792
|
+
const level = "".concat(levelName, " ").concat(match[2].substring(1));
|
|
880
793
|
return {
|
|
881
794
|
Terminal: terminal,
|
|
882
795
|
Level: level
|
|
@@ -885,7 +798,7 @@ function getTerminalAndLevelName(whereDimension) {
|
|
|
885
798
|
return null; // Return null if the input doesn't match the expected format
|
|
886
799
|
}
|
|
887
800
|
function getWhereDimensionNameForPortal(portalDimension, whereDimension) {
|
|
888
|
-
|
|
801
|
+
const terminalAndLevelName = getTerminalAndLevelName(whereDimension);
|
|
889
802
|
if (terminalAndLevelName) {
|
|
890
803
|
if (isCrossTerminalPortal(portalDimension)) {
|
|
891
804
|
return terminalAndLevelName.Terminal;
|
|
@@ -901,10 +814,10 @@ function getWhereDimensionNameForPortal(portalDimension, whereDimension) {
|
|
|
901
814
|
}
|
|
902
815
|
function convertSecondsToMinutes(timeInSeconds) {
|
|
903
816
|
// Calculate minutes
|
|
904
|
-
|
|
817
|
+
let minutes = Math.floor(timeInSeconds / 60);
|
|
905
818
|
|
|
906
819
|
// Check for remaining seconds
|
|
907
|
-
|
|
820
|
+
const remainingSeconds = timeInSeconds % 60;
|
|
908
821
|
|
|
909
822
|
// If there are remaining seconds and they are greater than 30, increment minutes
|
|
910
823
|
if (remainingSeconds > 30) {
|
|
@@ -917,34 +830,34 @@ function formatTime(value) {
|
|
|
917
830
|
return "~".concat(convertSecondsToMinutes(value), " ").concat(convertSecondsToMinutes(value) > 1 ? 'minutes' : 'minute');
|
|
918
831
|
}
|
|
919
832
|
function generateInstructions(route) {
|
|
920
|
-
|
|
833
|
+
const isFirstSegment = index => {
|
|
921
834
|
if (index === 0 || index === 1 && route.segments[index - 1].maneuverType === ManeuverType.RouteOverview) return true;
|
|
922
835
|
return false;
|
|
923
836
|
};
|
|
924
|
-
|
|
837
|
+
const getImmigrationInstruction = segment => {
|
|
925
838
|
if (segment.startEdge.whereDimension.toLowerCase().includes('l1')) {
|
|
926
839
|
return 'Clear Arrival Immigration';
|
|
927
840
|
}
|
|
928
841
|
return 'Clear Departure Immigration';
|
|
929
842
|
};
|
|
930
|
-
for (
|
|
931
|
-
|
|
843
|
+
for (let index = 0; index < route.segments.length; index += 1) {
|
|
844
|
+
const rotueSegment = route.segments[index];
|
|
932
845
|
rotueSegment.instructions = []; // clear instructions array
|
|
933
846
|
|
|
934
847
|
if (rotueSegment.maneuverType === ManeuverType.RouteOverview) {
|
|
935
|
-
|
|
848
|
+
const instruction = 'Overview';
|
|
936
849
|
rotueSegment.instructions.push(instruction);
|
|
937
850
|
}
|
|
938
851
|
if (index > 0 && rotueSegment.maneuverType === ManeuverType.ChangeZone) {
|
|
939
|
-
|
|
852
|
+
let instruction = '';
|
|
940
853
|
if (route.segments[index - 1].zone === _interfaces.Zone.Public && rotueSegment.zone === _interfaces.Zone.Transit) {
|
|
941
|
-
|
|
854
|
+
instruction = getImmigrationInstruction(rotueSegment);
|
|
942
855
|
} else if (route.segments[index - 1].zone === _interfaces.Zone.Transit && rotueSegment.zone === _interfaces.Zone.Public) {
|
|
943
|
-
|
|
856
|
+
instruction = 'Exit Baggage Claim Hall';
|
|
944
857
|
}
|
|
945
|
-
rotueSegment.instructions.push(
|
|
858
|
+
rotueSegment.instructions.push(instruction);
|
|
946
859
|
} else if (rotueSegment.maneuverType === ManeuverType.ContinueStraight || rotueSegment.maneuverType === ManeuverType.PassThroughImmigration) {
|
|
947
|
-
|
|
860
|
+
const postfix = rotueSegment.maneuverType === ManeuverType.ContinueStraight ? "Walk for ".concat(Math.ceil(rotueSegment.distance), " ").concat(route.distanceUnit) : getImmigrationInstruction(rotueSegment);
|
|
948
861
|
|
|
949
862
|
// 0th index if overview segment was not included, else 1st index
|
|
950
863
|
// if (index === 0
|
|
@@ -957,9 +870,9 @@ function generateInstructions(route) {
|
|
|
957
870
|
// } \n& ${postfix}`,
|
|
958
871
|
// );
|
|
959
872
|
// } else {
|
|
960
|
-
|
|
873
|
+
let instruction;
|
|
961
874
|
if (route.segments[index - 1].maneuverType === ManeuverType.ChangeZone || route.segments[index - 1].maneuverType === ManeuverType.PassThroughImmigration) {
|
|
962
|
-
|
|
875
|
+
instruction = postfix;
|
|
963
876
|
// eslint-disable-next-line brace-style
|
|
964
877
|
}
|
|
965
878
|
// else if (route.segments[index - 1].maneuverType === ManeuverType.EnterPortal || route.segments[index - 1].maneuverType === ManeuverType.TravelPortal) {
|
|
@@ -994,9 +907,9 @@ function generateInstructions(route) {
|
|
|
994
907
|
// // }
|
|
995
908
|
// }
|
|
996
909
|
else {
|
|
997
|
-
|
|
910
|
+
instruction = postfix;
|
|
998
911
|
}
|
|
999
|
-
rotueSegment.instructions.push(
|
|
912
|
+
rotueSegment.instructions.push(instruction);
|
|
1000
913
|
// }
|
|
1001
914
|
} else if (rotueSegment.maneuverType === ManeuverType.Static) {
|
|
1002
915
|
if (isFirstSegment(index)) {
|
|
@@ -1006,24 +919,24 @@ function generateInstructions(route) {
|
|
|
1006
919
|
rotueSegment.instructions.push("Arrive at ".concat(rotueSegment.endEdge.name));
|
|
1007
920
|
}
|
|
1008
921
|
} else if (rotueSegment.maneuverType === ManeuverType.EnterPortal) {
|
|
1009
|
-
|
|
922
|
+
let instruction = "Enter ".concat(rotueSegment.startEdge.name, " at ").concat(rotueSegment.startEdge.whereDimension.split('.').slice(-2).join(' ').toUpperCase());
|
|
1010
923
|
if (isNonMovingPortalTaxonomy(rotueSegment.startEdge.whatDimension)) {
|
|
1011
|
-
|
|
1012
|
-
rotueSegment.instructions.push(
|
|
924
|
+
instruction = "Continue to ".concat(getWhereDimensionNameForPortal(rotueSegment.startEdge.whatDimension, rotueSegment.endEdge.whereDimension));
|
|
925
|
+
rotueSegment.instructions.push(instruction);
|
|
1013
926
|
} else if (isMovingPortalTaxonomy(rotueSegment.startEdge.whatDimension)) {
|
|
1014
|
-
|
|
927
|
+
const nextRouteSegment = index + 1 <= route.segments.length - 1 ? route.segments[index + 1] : undefined;
|
|
1015
928
|
if (nextRouteSegment && nextRouteSegment.maneuverType === ManeuverType.TravelPortal) {
|
|
1016
929
|
// push the current enter portal instruction and increment index, since we want to skip the iteration on TravelPortal segment
|
|
1017
|
-
rotueSegment.instructions.push(
|
|
930
|
+
rotueSegment.instructions.push(instruction);
|
|
1018
931
|
index += 1;
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
nextRouteSegment.instructions.push(
|
|
932
|
+
const name = getPortalName(nextRouteSegment.startEdge.whatDimension);
|
|
933
|
+
instruction = "Take ".concat(name, " to ").concat(getWhereDimensionNameForPortal(rotueSegment.startEdge.whatDimension, rotueSegment.endEdge.whereDimension));
|
|
934
|
+
nextRouteSegment.instructions.push(instruction);
|
|
1022
935
|
if (rotueSegment.description) nextRouteSegment.instructions.push(rotueSegment.description);
|
|
1023
936
|
} else {
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
rotueSegment.instructions.push(
|
|
937
|
+
const name = getPortalName(rotueSegment.startEdge.whatDimension);
|
|
938
|
+
instruction = "Take ".concat(name, " to ").concat(getWhereDimensionNameForPortal(rotueSegment.startEdge.whatDimension, rotueSegment.endEdge.whereDimension));
|
|
939
|
+
rotueSegment.instructions.push(instruction);
|
|
1027
940
|
}
|
|
1028
941
|
}
|
|
1029
942
|
}
|