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