@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.
Files changed (143) hide show
  1. package/lib/cjs/index.js +9 -9
  2. package/lib/cjs/index.js.map +1 -1
  3. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js +213 -294
  4. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js.map +1 -1
  5. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js +40 -41
  6. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js.map +1 -1
  7. package/lib/cjs/meta-atlas-sdk/3DMap/MainMap.js +170 -196
  8. package/lib/cjs/meta-atlas-sdk/3DMap/MainMap.js.map +1 -1
  9. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js +167 -215
  10. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js.map +1 -1
  11. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js +28 -30
  12. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js.map +1 -1
  13. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js +861 -1170
  14. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js.map +1 -1
  15. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js +166 -159
  16. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js.map +1 -1
  17. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/interfaces.js +6 -6
  18. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/interfaces.js.map +1 -1
  19. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js +6 -6
  20. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js.map +1 -1
  21. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routeLayers.js +3 -3
  22. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routeLayers.js.map +1 -1
  23. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js +523 -610
  24. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js.map +1 -1
  25. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js +149 -154
  26. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js.map +1 -1
  27. package/lib/cjs/meta-atlas-sdk/customStyles.js +2 -2
  28. package/lib/cjs/meta-atlas-sdk/customStyles.js.map +1 -1
  29. package/lib/cjs/meta-atlas-sdk/customerLayer.js +15 -29
  30. package/lib/cjs/meta-atlas-sdk/customerLayer.js.map +1 -1
  31. package/lib/cjs/meta-atlas-sdk/customerLayerVariant.js +5 -5
  32. package/lib/cjs/meta-atlas-sdk/customerLayerVariant.js.map +1 -1
  33. package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js +809 -1033
  34. package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
  35. package/lib/cjs/meta-atlas-sdk/utils/helpers.js +32 -49
  36. package/lib/cjs/meta-atlas-sdk/utils/helpers.js.map +1 -1
  37. package/lib/cjs/meta-atlas-sdk/utils/local-storage.js +21 -34
  38. package/lib/cjs/meta-atlas-sdk/utils/local-storage.js.map +1 -1
  39. package/lib/cjs/meta-atlas-sdk/utils/mapobjects-store.js +6 -6
  40. package/lib/cjs/meta-atlas-sdk/utils/mapobjects-store.js.map +1 -1
  41. package/lib/cjs/meta-atlas-sdk/utils/routing-store.js +6 -6
  42. package/lib/cjs/meta-atlas-sdk/utils/routing-store.js.map +1 -1
  43. package/lib/cjs/meta-atlas-sdk/utils/routing-visualizer/index.js +363 -491
  44. package/lib/cjs/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
  45. package/lib/cjs/react/MetaAtlasMap.js +127 -0
  46. package/lib/cjs/react/MetaAtlasMap.js.map +1 -0
  47. package/lib/cjs/react/hooks/useDrawing/index.js +17 -18
  48. package/lib/cjs/react/hooks/useDrawing/index.js.map +1 -1
  49. package/lib/cjs/react/hooks/useFocus/index.js +48 -55
  50. package/lib/cjs/react/hooks/useFocus/index.js.map +1 -1
  51. package/lib/cjs/react/hooks/useMapEvents/index.js +40 -47
  52. package/lib/cjs/react/hooks/useMapEvents/index.js.map +1 -1
  53. package/lib/cjs/react/hooks/useMapOverlays/index.js +20 -21
  54. package/lib/cjs/react/hooks/useMapOverlays/index.js.map +1 -1
  55. package/lib/cjs/react/hooks/useMetaAtlas/index.js +77 -95
  56. package/lib/cjs/react/hooks/useMetaAtlas/index.js.map +1 -1
  57. package/lib/cjs/react/hooks/useMetaAtlas.js +78 -96
  58. package/lib/cjs/react/hooks/useMetaAtlas.js.map +1 -1
  59. package/lib/cjs/react/hooks/useRouting/index.js +21 -20
  60. package/lib/cjs/react/hooks/useRouting/index.js.map +1 -1
  61. package/lib/cjs/react/hooks/useSearch/index.js +35 -34
  62. package/lib/cjs/react/hooks/useSearch/index.js.map +1 -1
  63. package/lib/cjs/react/hooks/useStampRally/index.js +26 -23
  64. package/lib/cjs/react/hooks/useStampRally/index.js.map +1 -1
  65. package/lib/cjs/react/hooks/useStampRally/utils.js +2 -2
  66. package/lib/cjs/react/hooks/useStampRally/utils.js.map +1 -1
  67. package/lib/cjs/react/index.js +31 -31
  68. package/lib/cjs/react/index.js.map +1 -1
  69. package/lib/cjs/react/stores/useMapDataStore.js +47 -62
  70. package/lib/cjs/react/stores/useMapDataStore.js.map +1 -1
  71. package/lib/cjs/react/stores/useMetaAtlasStore.js +27 -40
  72. package/lib/cjs/react/stores/useMetaAtlasStore.js.map +1 -1
  73. package/lib/esm/index.js +3 -7
  74. package/lib/esm/index.js.map +1 -1
  75. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js +4 -3
  76. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js.map +1 -1
  77. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js +14 -12
  78. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js.map +1 -1
  79. package/lib/esm/meta-atlas-sdk/3DMap/MainMap.js +204 -200
  80. package/lib/esm/meta-atlas-sdk/3DMap/MainMap.js.map +1 -1
  81. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js +6 -6
  82. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js.map +1 -1
  83. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js +4 -3
  84. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js.map +1 -1
  85. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js +53 -42
  86. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js.map +1 -1
  87. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js +18 -16
  88. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js.map +1 -1
  89. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js +3 -3
  90. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js.map +1 -1
  91. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js +73 -79
  92. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js.map +1 -1
  93. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js +16 -15
  94. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js.map +1 -1
  95. package/lib/esm/meta-atlas-sdk/customerLayer.js +4 -1
  96. package/lib/esm/meta-atlas-sdk/customerLayer.js.map +1 -1
  97. package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js +148 -124
  98. package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
  99. package/lib/esm/meta-atlas-sdk/utils/helpers.js +4 -2
  100. package/lib/esm/meta-atlas-sdk/utils/helpers.js.map +1 -1
  101. package/lib/esm/meta-atlas-sdk/utils/local-storage.js +6 -1
  102. package/lib/esm/meta-atlas-sdk/utils/local-storage.js.map +1 -1
  103. package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js +115 -109
  104. package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
  105. package/lib/esm/react/MetaAtlasMap.js +120 -0
  106. package/lib/esm/react/MetaAtlasMap.js.map +1 -0
  107. package/lib/esm/react/hooks/useDrawing/index.js +2 -2
  108. package/lib/esm/react/hooks/useDrawing/index.js.map +1 -1
  109. package/lib/esm/react/hooks/useFocus/index.js +4 -3
  110. package/lib/esm/react/hooks/useFocus/index.js.map +1 -1
  111. package/lib/esm/react/hooks/useMapEvents/index.js +9 -6
  112. package/lib/esm/react/hooks/useMapEvents/index.js.map +1 -1
  113. package/lib/esm/react/hooks/useMapOverlays/index.js +2 -2
  114. package/lib/esm/react/hooks/useMapOverlays/index.js.map +1 -1
  115. package/lib/esm/react/hooks/useMetaAtlas/index.js +162 -60
  116. package/lib/esm/react/hooks/useMetaAtlas/index.js.map +1 -1
  117. package/lib/esm/react/hooks/useMetaAtlas.js +162 -60
  118. package/lib/esm/react/hooks/useMetaAtlas.js.map +1 -1
  119. package/lib/esm/react/hooks/useRouting/index.js +2 -2
  120. package/lib/esm/react/hooks/useRouting/index.js.map +1 -1
  121. package/lib/esm/react/hooks/useSearch/index.js +2 -2
  122. package/lib/esm/react/hooks/useSearch/index.js.map +1 -1
  123. package/lib/esm/react/hooks/useStampRally/index.js +15 -12
  124. package/lib/esm/react/hooks/useStampRally/index.js.map +1 -1
  125. package/lib/esm/react/hooks/useStampRally/utils.js +1 -1
  126. package/lib/esm/react/hooks/useStampRally/utils.js.map +1 -1
  127. package/lib/esm/react/index.js +11 -15
  128. package/lib/esm/react/index.js.map +1 -1
  129. package/lib/esm/react/stores/useMapDataStore.js +17 -21
  130. package/lib/esm/react/stores/useMapDataStore.js.map +1 -1
  131. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.d.ts +30 -0
  132. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.d.ts.map +1 -0
  133. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.d.ts +5 -0
  134. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.d.ts.map +1 -0
  135. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.d.ts +21 -0
  136. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.d.ts.map +1 -0
  137. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.d.ts +27 -0
  138. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.d.ts.map +1 -0
  139. package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.d.ts +18 -0
  140. package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.d.ts.map +1 -0
  141. package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.d.ts +37 -0
  142. package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.d.ts.map +1 -0
  143. package/package.json +10 -7
@@ -12,35 +12,17 @@ var _nearestPointOnLine = require("@turf/nearest-point-on-line");
12
12
  var _turf = _interopRequireWildcard(require("@turf/turf"));
13
13
  var turf = _turf;
14
14
  var _transformTranslate = require("@turf/transform-translate");
15
- var _interfaces = require("../../MetaAtlasCore/routing-core/interfaces");
16
- var _routingHelpers = require("../../MetaAtlasCore/routing-core/routing-helpers");
17
- var _routeLayers = require("../../MetaAtlasCore/routing-core/routeLayers");
18
- var _routingStore = _interopRequireDefault(require("../routing-store"));
19
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
20
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
21
- 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); }
22
- function _regeneratorValues(e) { if (null != e) { var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"], r = 0; if (t) return t.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) return { next: function next() { return e && r >= e.length && (e = void 0), { value: e && e[r++], done: !e }; } }; } throw new TypeError(_typeof(e) + " is not iterable"); }
23
- 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 }; })(); }
24
- 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); }
25
- 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); }
26
- 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); }); }; }
27
- 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; } } }; }
28
- function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
29
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
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 _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
32
- function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
33
- 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; }
34
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
35
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
36
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
15
+ var _interfaces = require("../../MetaAtlasCore/routing-core/interfaces.js");
16
+ var _routingHelpers = require("../../MetaAtlasCore/routing-core/routing-helpers.js");
17
+ var _routeLayers = require("../../MetaAtlasCore/routing-core/routeLayers.js");
18
+ var _routingStore = _interopRequireDefault(require("../routing-store.js"));
19
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
20
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
37
21
  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); } // import { distance } from "@turf/distance";
40
- var RoutingVisualizer = exports.RoutingVisualizer = /*#__PURE__*/function () {
41
- function RoutingVisualizer(sdk) {
42
- var _this = this;
43
- _classCallCheck(this, RoutingVisualizer);
22
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
23
+ 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); } // import { distance } from "@turf/distance";
24
+ class RoutingVisualizer {
25
+ constructor(sdk) {
44
26
  // Routing
45
27
  _defineProperty(this, "routeSourceName", 'routeGeojson');
46
28
  _defineProperty(this, "patchFeatureCollection", {
@@ -61,15 +43,15 @@ var RoutingVisualizer = exports.RoutingVisualizer = /*#__PURE__*/function () {
61
43
  from: 0,
62
44
  to: 0
63
45
  });
64
- _defineProperty(this, "animateHighlightedRouteSegment", function () {
65
- var routeFeature = (0, _lodash.cloneDeep)(_this.animateRouteSegmentFeatureCollection.features[0]);
46
+ _defineProperty(this, "animateHighlightedRouteSegment", () => {
47
+ const routeFeature = (0, _lodash.cloneDeep)(this.animateRouteSegmentFeatureCollection.features[0]);
66
48
  if (routeFeature) {
67
- var currentTime = Date.now();
68
- var elapsed = currentTime - _this.animationStartTime;
69
- var writeToSource = function writeToSource(feature, coords) {
49
+ const currentTime = Date.now();
50
+ const elapsed = currentTime - this.animationStartTime;
51
+ const writeToSource = (feature, coords) => {
70
52
  //@ts-ignore
71
53
  feature.geometry.coordinates = coords;
72
- var routeSource = _this.map.getSource(_this.animateRouteSourceName);
54
+ const routeSource = this.map.getSource(this.animateRouteSourceName);
73
55
  if (routeSource) {
74
56
  //@ts-ignore
75
57
  routeSource.setData({
@@ -78,27 +60,29 @@ var RoutingVisualizer = exports.RoutingVisualizer = /*#__PURE__*/function () {
78
60
  });
79
61
  }
80
62
  };
81
- var animationDuration = 2000;
63
+ const animationDuration = 2000;
82
64
  if (elapsed < animationDuration) {
83
- var progress = 1 - elapsed / animationDuration;
65
+ const progress = 1 - elapsed / animationDuration;
84
66
 
85
67
  //@ts-ignore
86
- var fullRoute = routeFeature.geometry.coordinates;
87
- var end = _this.end;
88
- var currentEnd;
68
+ const fullRoute = routeFeature.geometry.coordinates;
69
+ const {
70
+ end
71
+ } = this;
72
+ let currentEnd;
89
73
  if (progress > 0.5) {
90
- var customProgress = 2 * (progress - 0.5); // map 0.5 - 1 to 0 - 1 range
74
+ const customProgress = 2 * (progress - 0.5); // map 0.5 - 1 to 0 - 1 range
91
75
  currentEnd = end.from * (1.0 - customProgress) + customProgress * end.to;
92
76
  } else {
93
- var _customProgress = progress * 2; // map 0 - 0.5 to 0 - 1 range
94
- currentEnd = end.from * (1.0 - _customProgress) + _customProgress * end.to;
77
+ const customProgress = progress * 2; // map 0 - 0.5 to 0 - 1 range
78
+ currentEnd = end.from * (1.0 - customProgress) + customProgress * end.to;
95
79
  }
96
80
 
97
81
  // calculate distance along the line using current animation percentage
98
82
  // percentage travels 1 - 0
99
- var prevsum = 0;
100
- var actsum = 0;
101
- var i = fullRoute.length - 1;
83
+ let prevsum = 0;
84
+ let actsum = 0;
85
+ let i = fullRoute.length - 1;
102
86
  while (actsum < currentEnd && i > 0) {
103
87
  prevsum = actsum;
104
88
  actsum += turf.distance((0, _helpers.point)(fullRoute[i]), (0, _helpers.point)(fullRoute[i - 1]));
@@ -114,27 +98,27 @@ var RoutingVisualizer = exports.RoutingVisualizer = /*#__PURE__*/function () {
114
98
  // }
115
99
 
116
100
  // Return coordinates from line start to current percentage point
117
- var r = (currentEnd - prevsum) / (actsum - prevsum);
118
- var or = 1.0 - r;
119
- var actRoute = [].concat(_toConsumableArray(fullRoute.slice(0, i + 1)), [[fullRoute[i][0] * r + fullRoute[i + 1][0] * or, fullRoute[i][1] * r + fullRoute[i + 1][1] * or]]);
101
+ const r = (currentEnd - prevsum) / (actsum - prevsum);
102
+ const or = 1.0 - r;
103
+ const actRoute = [...fullRoute.slice(0, i + 1), [fullRoute[i][0] * r + fullRoute[i + 1][0] * or, fullRoute[i][1] * r + fullRoute[i + 1][1] * or]];
120
104
  writeToSource(routeFeature, actRoute);
121
105
  } else {
122
106
  // Forward animation
123
107
  if (actsum <= currentEnd) {
124
108
  // Return last two points of the line as final result
125
- var _actRoute = _toConsumableArray(fullRoute.slice(fullRoute.length - 2, fullRoute.length));
126
- writeToSource(routeFeature, _actRoute);
109
+ const actRoute = [...fullRoute.slice(fullRoute.length - 2, fullRoute.length)];
110
+ writeToSource(routeFeature, actRoute);
127
111
  }
128
112
 
129
113
  // Return coordinates from line end to current percentage point
130
- var _r = (currentEnd - prevsum) / (actsum - prevsum);
131
- var _or = 1.0 - _r;
132
- var _actRoute2 = [[fullRoute[i][0] * _r + fullRoute[i + 1][0] * _or, fullRoute[i][1] * _r + fullRoute[i + 1][1] * _or]].concat(_toConsumableArray(fullRoute.slice(i + 1, fullRoute.length)));
133
- writeToSource(routeFeature, _actRoute2);
114
+ const r = (currentEnd - prevsum) / (actsum - prevsum);
115
+ const or = 1.0 - r;
116
+ const actRoute = [[fullRoute[i][0] * r + fullRoute[i + 1][0] * or, fullRoute[i][1] * r + fullRoute[i + 1][1] * or], ...fullRoute.slice(i + 1, fullRoute.length)];
117
+ writeToSource(routeFeature, actRoute);
134
118
  }
135
- _this.animationFrameID = requestAnimationFrame(_this.animateHighlightedRouteSegment);
119
+ this.animationFrameID = requestAnimationFrame(this.animateHighlightedRouteSegment);
136
120
  } else {
137
- _this.resetRouteSegmentAnimation();
121
+ this.resetRouteSegmentAnimation();
138
122
  }
139
123
  }
140
124
  });
@@ -143,476 +127,364 @@ var RoutingVisualizer = exports.RoutingVisualizer = /*#__PURE__*/function () {
143
127
 
144
128
  // MetaAtlasCore To Editor
145
129
  // eslint-disable-next-line class-methods-use-this
146
- return _createClass(RoutingVisualizer, [{
147
- key: "getCurrentFocus",
148
- value: function getCurrentFocus() {
149
- return this.main.getCurrentFocus();
130
+ getCurrentFocus() {
131
+ return this.main.getCurrentFocus();
132
+ }
133
+
134
+ // eslint-disable-next-line class-methods-use-this
135
+ filterWhereDimension(dimension) {
136
+ this.main.focusTo(dimension, false);
137
+ }
138
+
139
+ // Routing
140
+ setupRouting(map) {
141
+ this.map = map;
142
+ this.map.addSource(this.routeSourceName, {
143
+ type: 'geojson',
144
+ data: this.patchFeatureCollection
145
+ });
146
+ for (const layer of _routeLayers.routeLayers) {
147
+ layer.source = this.routeSourceName;
148
+ this.map.addLayer(layer);
150
149
  }
151
150
 
152
- // eslint-disable-next-line class-methods-use-this
153
- }, {
154
- key: "filterWhereDimension",
155
- value: function filterWhereDimension(dimension) {
156
- this.main.focusTo(dimension, false);
151
+ // Animation data
152
+ this.map.addSource(this.animateRouteSourceName, {
153
+ type: 'geojson',
154
+ data: this.animateRouteSegmentFeatureCollection
155
+ });
156
+ for (const layer of _routeLayers.routeAnimateLayers) {
157
+ layer.source = this.animateRouteSourceName;
158
+ this.map.addLayer(layer);
157
159
  }
160
+ }
158
161
 
159
- // Routing
160
- }, {
161
- key: "setupRouting",
162
- value: function setupRouting(map) {
163
- this.map = map;
164
- this.map.addSource(this.routeSourceName, {
165
- type: 'geojson',
166
- data: this.patchFeatureCollection
167
- });
168
- var _iterator = _createForOfIteratorHelper(_routeLayers.routeLayers),
169
- _step;
170
- try {
171
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
172
- var layer = _step.value;
173
- layer.source = this.routeSourceName;
174
- this.map.addLayer(layer);
175
- }
162
+ // eslint-disable-next-line class-methods-use-this
163
+ async computeRoute(startMapObjectId, endMapObjectId) {
164
+ let wheelChairAccessibleRouting = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
165
+ let shouldAddOverviewSegment = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
166
+ let indexOffset = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
167
+ this.currentPatchNumber = -1;
168
+ const generatedRoute = await (0, _routingHelpers.createRoute)(startMapObjectId, endMapObjectId, wheelChairAccessibleRouting, shouldAddOverviewSegment, indexOffset);
169
+ console.log('internal generated: ', generatedRoute);
176
170
 
177
- // Animation data
178
- } catch (err) {
179
- _iterator.e(err);
180
- } finally {
181
- _iterator.f();
182
- }
183
- this.map.addSource(this.animateRouteSourceName, {
184
- type: 'geojson',
185
- data: this.animateRouteSegmentFeatureCollection
186
- });
187
- var _iterator2 = _createForOfIteratorHelper(_routeLayers.routeAnimateLayers),
188
- _step2;
189
- try {
190
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
191
- var _layer = _step2.value;
192
- _layer.source = this.animateRouteSourceName;
193
- this.map.addLayer(_layer);
194
- }
195
- } catch (err) {
196
- _iterator2.e(err);
197
- } finally {
198
- _iterator2.f();
171
+ // Generate textual instructions
172
+ (0, _routingHelpers.generateInstructions)(generatedRoute);
173
+ console.log(generatedRoute.segments);
174
+ return generatedRoute;
175
+ }
176
+ handleAllRouteUpdate(allSegments, userPosition, segmentIndex) {
177
+ // Get the LineString Feature of the route
178
+ const featureLineStringToUpdate = allSegments[segmentIndex].features.filter(f => f.geometry.type === 'LineString')[0];
179
+
180
+ // Create a LineString with the coordinates of the route that would be updated accordingly
181
+ const lineStringToUpdate = (0, _turf.lineString)(featureLineStringToUpdate.geometry.coordinates.slice(1));
182
+
183
+ // Create a subset of LineString that contains the first two coords of the route which actually represent the route edge
184
+ const subLine = (0, _turf.lineString)([featureLineStringToUpdate.geometry.coordinates[0], featureLineStringToUpdate.geometry.coordinates[1]]);
185
+
186
+ // Find the nearest point to the user position on the sub line and update the LineString.
187
+ const nearestPoint = (0, _nearestPointOnLine.nearestPointOnLine)(subLine, userPosition.sourceCoords);
188
+ lineStringToUpdate.geometry.coordinates.unshift(userPosition.sourceCoords, nearestPoint.geometry.coordinates);
189
+ const coordsToUpdate = lineStringToUpdate.geometry.coordinates;
190
+ const index = nearestPoint.properties.index;
191
+ const coordsToKeep = coordsToUpdate.slice(index);
192
+ lineStringToUpdate.geometry.coordinates = coordsToKeep;
193
+ lineStringToUpdate.geometry.coordinates.unshift(userPosition.sourceCoords);
194
+ lineStringToUpdate.properties = featureLineStringToUpdate.properties;
195
+ let featureIndex = -1;
196
+ allSegments[segmentIndex].features.map((f, i) => {
197
+ if (f.geometry.type === 'LineString') {
198
+ featureIndex = i;
199
199
  }
200
+ });
201
+
202
+ // Update the new LineString in the route
203
+ allSegments[segmentIndex].features[featureIndex] = lineStringToUpdate;
204
+ allSegments[segmentIndex].coordinates = lineStringToUpdate.geometry.coordinates;
205
+ }
206
+ async computeRoutes(mapObjectIds) {
207
+ let wheelChairAccessibleRouteOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
208
+ if (mapObjectIds.length < 2) {
209
+ console.warn('Invalid array passed to computeRoutes');
210
+ return undefined;
200
211
  }
212
+ console.log('calling computeRoutes with mapObjectIds: ', mapObjectIds);
213
+ const mergedRoute = {
214
+ segments: [],
215
+ walkingDistance: 0,
216
+ transportDistance: 0,
217
+ walkingTime: 0,
218
+ transportTime: 0,
219
+ distanceUnit: _interfaces.DISTANCE_UNIT,
220
+ speed: _interfaces.WALK_SPEED
221
+ };
222
+
223
+ // Dummy segment for overview segment
224
+ const dummySegment = {};
225
+ mergedRoute.segments.push(dummySegment);
226
+ let indexOffset = 1; // Index set to 1, since overview segment will be added to 0th index
201
227
 
202
- // eslint-disable-next-line class-methods-use-this
203
- }, {
204
- key: "computeRoute",
205
- value: function () {
206
- var _computeRoute = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(startMapObjectId, endMapObjectId) {
207
- var wheelChairAccessibleRouting,
208
- shouldAddOverviewSegment,
209
- indexOffset,
210
- generatedRoute,
211
- _args = arguments;
212
- return _regenerator().w(function (_context) {
213
- while (1) switch (_context.n) {
214
- case 0:
215
- wheelChairAccessibleRouting = _args.length > 2 && _args[2] !== undefined ? _args[2] : false;
216
- shouldAddOverviewSegment = _args.length > 3 && _args[3] !== undefined ? _args[3] : true;
217
- indexOffset = _args.length > 4 && _args[4] !== undefined ? _args[4] : 0;
218
- this.currentPatchNumber = -1;
219
- _context.n = 1;
220
- return (0, _routingHelpers.createRoute)(startMapObjectId, endMapObjectId, wheelChairAccessibleRouting, shouldAddOverviewSegment, indexOffset);
221
- case 1:
222
- generatedRoute = _context.v;
223
- console.log('internal generated: ', generatedRoute);
228
+ for (let index = 0; index < mapObjectIds.length - 1; index += 1) {
229
+ let startMapObjectId = mapObjectIds[index];
230
+ const endMapObjectId = mapObjectIds[index + 1];
231
+ const shouldAddOverviewSegment = true; // include overview segment in first route
224
232
 
225
- // Generate textual instructions
226
- (0, _routingHelpers.generateInstructions)(generatedRoute);
227
- console.log(generatedRoute.segments);
228
- return _context.a(2, generatedRoute);
233
+ const id = mapObjectIds[0];
234
+ if (typeof mapObjectIds[0] !== 'string') {
235
+ // Run queryRenderedFeatures.
236
+ const routeData = _routingStore.default.getState().data;
237
+ const point = this.map.project([id.sourceCoords[0], id.sourceCoords[1]]);
238
+ const feats = this.map.queryRenderedFeatures(point);
239
+ feats.map(f => {
240
+ if (routeData[_interfaces.RouteDimension.Edge].hasOwnProperty(f.properties.mapObjectId)) {
241
+ const edgeData = routeData[_interfaces.RouteDimension.Edge][f.properties.mapObjectId];
242
+ if (edgeData.lines.length > 0) {
243
+ startMapObjectId = f.properties.mapObjectId;
244
+ }
229
245
  }
230
- }, _callee, this);
231
- }));
232
- function computeRoute(_x, _x2) {
233
- return _computeRoute.apply(this, arguments);
246
+ });
234
247
  }
235
- return computeRoute;
236
- }()
237
- }, {
238
- key: "handleAllRouteUpdate",
239
- value: function handleAllRouteUpdate(allSegments, userPosition, segmentIndex) {
240
- // Get the LineString Feature of the route
241
- var featureLineStringToUpdate = allSegments[segmentIndex].features.filter(function (f) {
242
- return f.geometry.type === 'LineString';
243
- })[0];
244
-
245
- // Create a LineString with the coordinates of the route that would be updated accordingly
246
- var lineStringToUpdate = (0, _turf.lineString)(featureLineStringToUpdate.geometry.coordinates.slice(1));
247
-
248
- // Create a subset of LineString that contains the first two coords of the route which actually represent the route edge
249
- var subLine = (0, _turf.lineString)([featureLineStringToUpdate.geometry.coordinates[0], featureLineStringToUpdate.geometry.coordinates[1]]);
250
248
 
251
- // Find the nearest point to the user position on the sub line and update the LineString.
252
- var nearestPoint = (0, _nearestPointOnLine.nearestPointOnLine)(subLine, userPosition.sourceCoords);
253
- lineStringToUpdate.geometry.coordinates.unshift(userPosition.sourceCoords, nearestPoint.geometry.coordinates);
254
- var coordsToUpdate = lineStringToUpdate.geometry.coordinates;
255
- var index = nearestPoint.properties.index;
256
- var coordsToKeep = coordsToUpdate.slice(index);
257
- lineStringToUpdate.geometry.coordinates = coordsToKeep;
258
- lineStringToUpdate.geometry.coordinates.unshift(userPosition.sourceCoords);
259
- lineStringToUpdate.properties = featureLineStringToUpdate.properties;
260
- var featureIndex = -1;
261
- allSegments[segmentIndex].features.map(function (f, i) {
262
- if (f.geometry.type === 'LineString') {
263
- featureIndex = i;
264
- }
265
- });
249
+ // eslint-disable-next-line no-await-in-loop
250
+ const generatedRoute = await this.computeRoute(startMapObjectId, endMapObjectId, wheelChairAccessibleRouteOnly, shouldAddOverviewSegment, indexOffset);
251
+ const allSegments = generatedRoute.segments;
252
+ // if (typeof mapObjectIds[index] !== 'string' && typeof startMapObjectId === 'string') {
253
+ // //Handle SectionOverview:
254
+ // this.handleAllRouteUpdate(allSegments, id as UserPosition, 0);
266
255
 
267
- // Update the new LineString in the route
268
- allSegments[segmentIndex].features[featureIndex] = lineStringToUpdate;
269
- allSegments[segmentIndex].coordinates = lineStringToUpdate.geometry.coordinates;
270
- }
271
- }, {
272
- key: "computeRoutes",
273
- value: function () {
274
- var _computeRoutes = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(mapObjectIds) {
275
- var _this2 = this;
276
- var wheelChairAccessibleRouteOnly,
277
- mergedRoute,
278
- dummySegment,
279
- indexOffset,
280
- _loop,
281
- index,
282
- overviewSegment,
283
- _args3 = arguments;
284
- return _regenerator().w(function (_context3) {
285
- while (1) switch (_context3.n) {
286
- case 0:
287
- wheelChairAccessibleRouteOnly = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : false;
288
- if (!(mapObjectIds.length < 2)) {
289
- _context3.n = 1;
290
- break;
291
- }
292
- console.warn('Invalid array passed to computeRoutes');
293
- return _context3.a(2, undefined);
294
- case 1:
295
- console.log('calling computeRoutes with mapObjectIds: ', mapObjectIds);
296
- mergedRoute = {
297
- segments: [],
298
- walkingDistance: 0,
299
- transportDistance: 0,
300
- walkingTime: 0,
301
- transportTime: 0,
302
- distanceUnit: _interfaces.DISTANCE_UNIT,
303
- speed: _interfaces.WALK_SPEED
304
- }; // Dummy segment for overview segment
305
- dummySegment = {};
306
- mergedRoute.segments.push(dummySegment);
307
- indexOffset = 1; // Index set to 1, since overview segment will be added to 0th index
308
- _loop = /*#__PURE__*/_regenerator().m(function _loop() {
309
- var startMapObjectId, endMapObjectId, shouldAddOverviewSegment, id, routeData, _point, feats, generatedRoute, allSegments, segmentOverview, j, segment;
310
- return _regenerator().w(function (_context2) {
311
- while (1) switch (_context2.n) {
312
- case 0:
313
- startMapObjectId = mapObjectIds[index];
314
- endMapObjectId = mapObjectIds[index + 1];
315
- shouldAddOverviewSegment = true; // include overview segment in first route
316
- id = mapObjectIds[0];
317
- if (typeof mapObjectIds[0] !== 'string') {
318
- // Run queryRenderedFeatures.
319
- routeData = _routingStore["default"].getState().data;
320
- _point = _this2.map.project([id.sourceCoords[0], id.sourceCoords[1]]);
321
- feats = _this2.map.queryRenderedFeatures(_point);
322
- feats.map(function (f) {
323
- if (routeData[_interfaces.RouteDimension.Edge].hasOwnProperty(f.properties.mapObjectId)) {
324
- var edgeData = routeData[_interfaces.RouteDimension.Edge][f.properties.mapObjectId];
325
- if (edgeData.lines.length > 0) {
326
- startMapObjectId = f.properties.mapObjectId;
327
- }
328
- }
329
- });
330
- }
256
+ // // Handle the second segment.
257
+ // const secondSegmentFeatures = generatedRoute.segments[1].features;
258
+ // if (secondSegmentFeatures.length < 3 && secondSegmentFeatures[0].geometry.type === 'Point') {
259
+ // secondSegmentFeatures[0].geometry.coordinates = id.sourceCoords;
260
+ // allSegments[1].coordinates = id.sourceCoords as any;
261
+ // } else {
262
+ // this.handleAllRouteUpdate(allSegments, id as UserPosition, 1);
263
+ // }
331
264
 
332
- // eslint-disable-next-line no-await-in-loop
333
- _context2.n = 1;
334
- return _this2.computeRoute(startMapObjectId, endMapObjectId, wheelChairAccessibleRouteOnly, shouldAddOverviewSegment, indexOffset);
335
- case 1:
336
- generatedRoute = _context2.v;
337
- allSegments = generatedRoute.segments; // if (typeof mapObjectIds[index] !== 'string' && typeof startMapObjectId === 'string') {
338
- // //Handle SectionOverview:
339
- // this.handleAllRouteUpdate(allSegments, id as UserPosition, 0);
340
- // // Handle the second segment.
341
- // const secondSegmentFeatures = generatedRoute.segments[1].features;
342
- // if (secondSegmentFeatures.length < 3 && secondSegmentFeatures[0].geometry.type === 'Point') {
343
- // secondSegmentFeatures[0].geometry.coordinates = id.sourceCoords;
344
- // allSegments[1].coordinates = id.sourceCoords as any;
345
- // } else {
346
- // this.handleAllRouteUpdate(allSegments, id as UserPosition, 1);
347
- // }
348
- // // Handle third segment
349
- // const thirdSegmentFeatures = generatedRoute.segments[2].features;
350
- // if (thirdSegmentFeatures.length < 3 && thirdSegmentFeatures.geometry.type === 'Point') {
351
- // allSegments[1].features[0].geometry.coordinates = id.sourceCoords;
352
- // allSegments[1].coordinates = id.sourceCoords as any;
353
- // } else {
354
- // this.handleAllRouteUpdate(allSegments, id as UserPosition, 2);
355
- // }
356
- // }
357
- if (generatedRoute.segments.length > 0) {
358
- segmentOverview = generatedRoute.segments[0];
359
- segmentOverview.maneuverType = _routingHelpers.ManeuverType.SectionOverview;
360
- segmentOverview.instructions = ["".concat(segmentOverview.startEdge.name, " to ").concat(segmentOverview.endEdge.name)];
361
- }
362
- for (j = 0; j < generatedRoute.segments.length; j += 1) {
363
- segment = generatedRoute.segments[j];
364
- mergedRoute.segments.push(segment);
365
- }
366
- mergedRoute.walkingDistance += generatedRoute.walkingDistance;
367
- mergedRoute.transportDistance += generatedRoute.transportDistance;
368
- mergedRoute.walkingTime += generatedRoute.walkingTime;
369
- mergedRoute.transportTime += generatedRoute.transportTime;
265
+ // // Handle third segment
266
+ // const thirdSegmentFeatures = generatedRoute.segments[2].features;
267
+ // if (thirdSegmentFeatures.length < 3 && thirdSegmentFeatures.geometry.type === 'Point') {
268
+ // allSegments[1].features[0].geometry.coordinates = id.sourceCoords;
269
+ // allSegments[1].coordinates = id.sourceCoords as any;
270
+ // } else {
271
+ // this.handleAllRouteUpdate(allSegments, id as UserPosition, 2);
272
+ // }
273
+ // }
370
274
 
371
- // Increment by segment count
372
- indexOffset += generatedRoute.segments.length;
373
- case 2:
374
- return _context2.a(2);
375
- }
376
- }, _loop);
377
- });
378
- index = 0;
379
- case 2:
380
- if (!(index < mapObjectIds.length - 1)) {
381
- _context3.n = 4;
382
- break;
383
- }
384
- return _context3.d(_regeneratorValues(_loop()), 3);
385
- case 3:
386
- index += 1;
387
- _context3.n = 2;
388
- break;
389
- case 4:
390
- if (mergedRoute.segments.length > 1) {
391
- // Use 1 here because 1 dummy segment will always be included
392
- overviewSegment = (0, _routingHelpers.generateOverviewSegment)(mergedRoute);
393
- mergedRoute.segments[0] = overviewSegment;
394
- } else {
395
- mergedRoute.segments.length = 0; // Remove dummy segment
396
- }
397
- console.log('merged route: ', mergedRoute);
398
- return _context3.a(2, mergedRoute);
399
- }
400
- }, _callee2);
401
- }));
402
- function computeRoutes(_x3) {
403
- return _computeRoutes.apply(this, arguments);
275
+ if (generatedRoute.segments.length > 0) {
276
+ const segmentOverview = generatedRoute.segments[0];
277
+ segmentOverview.maneuverType = _routingHelpers.ManeuverType.SectionOverview;
278
+ segmentOverview.instructions = ["".concat(segmentOverview.startEdge.name, " to ").concat(segmentOverview.endEdge.name)];
404
279
  }
405
- return computeRoutes;
406
- }()
407
- }, {
408
- key: "updateRouteSource",
409
- value: function updateRouteSource(updatedFeatureCollection) {
410
- if (!this.map) return false;
411
- this.patchFeatureCollection = updatedFeatureCollection;
412
- var routeSource = this.map.getSource(this.routeSourceName);
413
- if (routeSource) routeSource.setData(updatedFeatureCollection);
414
- return true;
415
- }
416
- }, {
417
- key: "updateAnimateRouteSource",
418
- value: function updateAnimateRouteSource(updatedFeatureCollection) {
419
- if (!this.map) return false;
420
- this.animateRouteSegmentFeatureCollection = updatedFeatureCollection;
421
- var routeSource = this.map.getSource(this.animateRouteSourceName);
422
- if (routeSource) routeSource.setData(updatedFeatureCollection);
423
- return true;
424
- }
425
- }, {
426
- key: "setActiveRoute",
427
- value: function setActiveRoute(route) {
428
- this.route = route;
280
+ for (let j = 0; j < generatedRoute.segments.length; j += 1) {
281
+ const segment = generatedRoute.segments[j];
282
+ mergedRoute.segments.push(segment);
283
+ }
284
+ mergedRoute.walkingDistance += generatedRoute.walkingDistance;
285
+ mergedRoute.transportDistance += generatedRoute.transportDistance;
286
+ mergedRoute.walkingTime += generatedRoute.walkingTime;
287
+ mergedRoute.transportTime += generatedRoute.transportTime;
288
+
289
+ // Increment by segment count
290
+ indexOffset += generatedRoute.segments.length;
429
291
  }
430
- }, {
431
- key: "getActiveRoute",
432
- value: function getActiveRoute() {
433
- return this.route;
292
+ if (mergedRoute.segments.length > 1) {
293
+ // Use 1 here because 1 dummy segment will always be included
294
+ const overviewSegment = (0, _routingHelpers.generateOverviewSegment)(mergedRoute);
295
+ mergedRoute.segments[0] = overviewSegment;
296
+ } else {
297
+ mergedRoute.segments.length = 0; // Remove dummy segment
434
298
  }
435
- }, {
436
- key: "resetRouteSegmentAnimation",
437
- value: function resetRouteSegmentAnimation() {
438
- this.animationStartTime = Date.now();
439
- cancelAnimationFrame(this.animationFrameID);
440
- if (this.animateRouteSegmentFeatureCollection.features.length > 0) {
441
- var routeFeature = this.animateRouteSegmentFeatureCollection.features[0];
442
- //@ts-ignore
443
- if (routeFeature.geometry.type === 'LineString') this.animateHighlightedRouteSegment();
444
- }
299
+ console.log('merged route: ', mergedRoute);
300
+ return mergedRoute;
301
+ }
302
+ updateRouteSource(updatedFeatureCollection) {
303
+ if (!this.map) return false;
304
+ this.patchFeatureCollection = updatedFeatureCollection;
305
+ const routeSource = this.map.getSource(this.routeSourceName);
306
+ if (routeSource) routeSource.setData(updatedFeatureCollection);
307
+ return true;
308
+ }
309
+ updateAnimateRouteSource(updatedFeatureCollection) {
310
+ if (!this.map) return false;
311
+ this.animateRouteSegmentFeatureCollection = updatedFeatureCollection;
312
+ const routeSource = this.map.getSource(this.animateRouteSourceName);
313
+ if (routeSource) routeSource.setData(updatedFeatureCollection);
314
+ return true;
315
+ }
316
+ setActiveRoute(route) {
317
+ this.route = route;
318
+ }
319
+ getActiveRoute() {
320
+ return this.route;
321
+ }
322
+ resetRouteSegmentAnimation() {
323
+ this.animationStartTime = Date.now();
324
+ cancelAnimationFrame(this.animationFrameID);
325
+ if (this.animateRouteSegmentFeatureCollection.features.length > 0) {
326
+ const routeFeature = this.animateRouteSegmentFeatureCollection.features[0];
327
+ //@ts-ignore
328
+ if (routeFeature.geometry.type === 'LineString') this.animateHighlightedRouteSegment();
445
329
  }
446
- }, {
447
- key: "updateFeaturesToAnimate",
448
- value: function updateFeaturesToAnimate(segmentNumber, whereDimensionForFeatures) {
449
- if (this.route && this.route.segments.length > segmentNumber) {
450
- var routeSegment = this.route.segments[segmentNumber];
451
- // set features for animated segment source
452
- if (routeSegment.features.length > 0) {
453
- var lineFeaturesOfSegment =
454
- // include where dimension here?
455
- (0, _routingHelpers.getLineStringFeaturesOfRouteSegment)(routeSegment, whereDimensionForFeatures);
456
- if (lineFeaturesOfSegment.length > 0) {
457
- this.updateAnimateRouteSource({
458
- type: 'FeatureCollection',
459
- features: lineFeaturesOfSegment
460
- });
461
- var ls = lineFeaturesOfSegment[0];
462
- //@ts-ignore
463
- var nearest = (0, _nearestPointOnLine.nearestPointOnLine)(ls, (0, _helpers.point)(lineFeaturesOfSegment[0].geometry.coordinates[0]));
464
- var toDist = (0, _length["default"])(ls) - nearest.properties.location;
465
- this.end = {
466
- from: 0,
467
- to: toDist
468
- };
469
- } else {
470
- this.updateAnimateRouteSource({
471
- type: 'FeatureCollection',
472
- features: []
473
- });
474
- }
475
- this.resetRouteSegmentAnimation();
330
+ }
331
+ updateFeaturesToAnimate(segmentNumber, whereDimensionForFeatures) {
332
+ if (this.route && this.route.segments.length > segmentNumber) {
333
+ const routeSegment = this.route.segments[segmentNumber];
334
+ // set features for animated segment source
335
+ if (routeSegment.features.length > 0) {
336
+ const lineFeaturesOfSegment =
337
+ // include where dimension here?
338
+ (0, _routingHelpers.getLineStringFeaturesOfRouteSegment)(routeSegment, whereDimensionForFeatures);
339
+ if (lineFeaturesOfSegment.length > 0) {
340
+ this.updateAnimateRouteSource({
341
+ type: 'FeatureCollection',
342
+ features: lineFeaturesOfSegment
343
+ });
344
+ const ls = lineFeaturesOfSegment[0];
345
+ //@ts-ignore
346
+ const nearest = (0, _nearestPointOnLine.nearestPointOnLine)(ls, (0, _helpers.point)(lineFeaturesOfSegment[0].geometry.coordinates[0]));
347
+ const toDist = (0, _length.default)(ls) - nearest.properties.location;
348
+ this.end = {
349
+ from: 0,
350
+ to: toDist
351
+ };
352
+ } else {
353
+ this.updateAnimateRouteSource({
354
+ type: 'FeatureCollection',
355
+ features: []
356
+ });
476
357
  }
358
+ this.resetRouteSegmentAnimation();
477
359
  }
478
360
  }
479
- }, {
480
- key: "highlightRouteSegment",
481
- value: function highlightRouteSegment(segmentNumberToHighlight) {
482
- var updateFilters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
483
- var route = this.route;
484
- if (route && route.segments.length > segmentNumberToHighlight) {
485
- if (route.segments[segmentNumberToHighlight].coordinates.length > 0) {
486
- this.highlightedSegmentNumber = segmentNumberToHighlight;
487
- var routeSegment = route.segments[segmentNumberToHighlight];
488
- var segmentWhereDimension = routeSegment.maneuverType === _routingHelpers.ManeuverType.ExitPortal || routeSegment.maneuverType === _routingHelpers.ManeuverType.Static ? routeSegment.endEdge.whereDimension : routeSegment.startEdge.whereDimension;
489
- var routeFeaturesToUse = this.patchFeatureCollection.features;
361
+ }
362
+ highlightRouteSegment(segmentNumberToHighlight) {
363
+ let updateFilters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
364
+ const {
365
+ route
366
+ } = this;
367
+ if (route && route.segments.length > segmentNumberToHighlight) {
368
+ if (route.segments[segmentNumberToHighlight].coordinates.length > 0) {
369
+ this.highlightedSegmentNumber = segmentNumberToHighlight;
370
+ const routeSegment = route.segments[segmentNumberToHighlight];
371
+ const segmentWhereDimension = routeSegment.maneuverType === _routingHelpers.ManeuverType.ExitPortal || routeSegment.maneuverType === _routingHelpers.ManeuverType.Static ? routeSegment.endEdge.whereDimension : routeSegment.startEdge.whereDimension;
372
+ let routeFeaturesToUse = this.patchFeatureCollection.features;
490
373
 
491
- // update visible route features if required
492
- var segmentPatchNumber = routeSegment.features[0].properties.patchNumber;
493
- if (this.currentPatchNumber !== segmentPatchNumber) {
494
- this.currentPatchNumber = segmentPatchNumber;
495
- var featureCollectionToDraw = {
496
- type: 'FeatureCollection',
497
- features: (0, _routingHelpers.getFeaturesForPatch)(route, segmentPatchNumber, {
498
- includeOverviewFeatures: (0, _routingHelpers.isOverviewSegment)(routeSegment),
499
- patchNumberForOverviewFeatures: segmentPatchNumber
500
- })
501
- };
502
- routeFeaturesToUse = featureCollectionToDraw.features;
503
- }
504
- if (segmentWhereDimension && segmentWhereDimension !== this.getCurrentFocus() && updateFilters) {
505
- this.filterWhereDimension(segmentWhereDimension);
506
- }
374
+ // update visible route features if required
375
+ const segmentPatchNumber = routeSegment.features[0].properties.patchNumber;
376
+ if (this.currentPatchNumber !== segmentPatchNumber) {
377
+ this.currentPatchNumber = segmentPatchNumber;
378
+ const featureCollectionToDraw = {
379
+ type: 'FeatureCollection',
380
+ features: (0, _routingHelpers.getFeaturesForPatch)(route, segmentPatchNumber, {
381
+ includeOverviewFeatures: (0, _routingHelpers.isOverviewSegment)(routeSegment),
382
+ patchNumberForOverviewFeatures: segmentPatchNumber
383
+ })
384
+ };
385
+ routeFeaturesToUse = featureCollectionToDraw.features;
386
+ }
387
+ if (segmentWhereDimension && segmentWhereDimension !== this.getCurrentFocus() && updateFilters) {
388
+ this.filterWhereDimension(segmentWhereDimension);
389
+ }
507
390
 
508
- // update highlighted route segment
509
- var updatedFeatures = (0, _routingHelpers.highlightRouteSegment)(routeFeaturesToUse, segmentNumberToHighlight);
510
- this.updateRouteSource({
391
+ // update highlighted route segment
392
+ const updatedFeatures = (0, _routingHelpers.highlightRouteSegment)(routeFeaturesToUse, segmentNumberToHighlight);
393
+ this.updateRouteSource({
394
+ type: 'FeatureCollection',
395
+ features: updatedFeatures
396
+ });
397
+ if (!(0, _routingHelpers.isOverviewSegment)(routeSegment)) {
398
+ this.updateFeaturesToAnimate(segmentNumberToHighlight, segmentWhereDimension);
399
+ } else {
400
+ // clear animation source
401
+ this.updateAnimateRouteSource({
511
402
  type: 'FeatureCollection',
512
- features: updatedFeatures
403
+ features: []
513
404
  });
514
- if (!(0, _routingHelpers.isOverviewSegment)(routeSegment)) {
515
- this.updateFeaturesToAnimate(segmentNumberToHighlight, segmentWhereDimension);
516
- } else {
517
- // clear animation source
518
- this.updateAnimateRouteSource({
519
- type: 'FeatureCollection',
520
- features: []
521
- });
522
- }
405
+ }
523
406
 
524
- // animate camera to segment
525
- if (routeSegment) {
526
- var getStartCoords = function getStartCoords(feature) {
407
+ // animate camera to segment
408
+ if (routeSegment) {
409
+ const getStartCoords = feature => {
410
+ //@ts-ignore
411
+ if (feature.geometry.type === 'Point') {
527
412
  //@ts-ignore
528
- if (feature.geometry.type === 'Point') {
529
- //@ts-ignore
530
- return feature.geometry.coordinates;
531
- }
413
+ return feature.geometry.coordinates;
414
+ }
532
415
 
533
- //@ts-ignore
534
- return feature.geometry.coordinates[0];
535
- };
536
- var canvas = this.map.getCanvas();
537
- var w = canvas.clientWidth;
538
- var h = canvas.clientHeight;
539
- var fitBoundsConfig = {
540
- padding: {
541
- top: h * 0.2,
542
- bottom: h * 0.2,
543
- left: w * 0.2,
544
- right: w * 0.2
545
- },
546
- duration: 1000,
547
- bearing: this.map.getBearing(),
548
- pitch: this.map.getPitch()
549
- };
550
- if (routeSegment.coordinates.length > 1) {
551
- var currentPatchFeatures = (0, _routingHelpers.getPatch)(route, routeSegment.patchNumber);
552
- var startCoords = getStartCoords(currentPatchFeatures[0]);
553
- // let index = 0;
554
- // for (index = 0; index < currentPatchFeatures.length; index++) {
555
- // const element = currentPatchFeatures[index];
556
- // if (element.properties.segmentNumber === segmentNumberToHighlight) {
557
- // startCoords = getStartCoords(element);
558
- // }
559
- // }
560
- var sw = new _maplibreGl["default"].LngLat(startCoords[0], startCoords[1]);
561
- var ne = new _maplibreGl["default"].LngLat(startCoords[0], startCoords[1]);
562
- var llb = new _maplibreGl["default"].LngLatBounds(sw, ne);
563
- for (var index = 0; index < currentPatchFeatures.length; index++) {
564
- var element = currentPatchFeatures[index];
565
- if (element.geometry.type === 'Point') {
566
- llb.extend(element.geometry.coordinates);
567
- } else {
568
- //@ts-ignore
569
- var _iterator3 = _createForOfIteratorHelper(element.geometry.coordinates),
570
- _step3;
571
- try {
572
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
573
- var coord = _step3.value;
574
- llb.extend(coord);
575
- }
576
- } catch (err) {
577
- _iterator3.e(err);
578
- } finally {
579
- _iterator3.f();
580
- }
416
+ //@ts-ignore
417
+ return feature.geometry.coordinates[0];
418
+ };
419
+ const canvas = this.map.getCanvas();
420
+ const w = canvas.clientWidth;
421
+ const h = canvas.clientHeight;
422
+ const fitBoundsConfig = {
423
+ padding: {
424
+ top: h * 0.2,
425
+ bottom: h * 0.2,
426
+ left: w * 0.2,
427
+ right: w * 0.2
428
+ },
429
+ duration: 1000,
430
+ bearing: this.map.getBearing(),
431
+ pitch: this.map.getPitch()
432
+ };
433
+ if (routeSegment.coordinates.length > 1) {
434
+ const currentPatchFeatures = (0, _routingHelpers.getPatch)(route, routeSegment.patchNumber);
435
+ const startCoords = getStartCoords(currentPatchFeatures[0]);
436
+ // let index = 0;
437
+ // for (index = 0; index < currentPatchFeatures.length; index++) {
438
+ // const element = currentPatchFeatures[index];
439
+ // if (element.properties.segmentNumber === segmentNumberToHighlight) {
440
+ // startCoords = getStartCoords(element);
441
+ // }
442
+ // }
443
+ const sw = new _maplibreGl.default.LngLat(startCoords[0], startCoords[1]);
444
+ const ne = new _maplibreGl.default.LngLat(startCoords[0], startCoords[1]);
445
+ const llb = new _maplibreGl.default.LngLatBounds(sw, ne);
446
+ for (let index = 0; index < currentPatchFeatures.length; index++) {
447
+ const element = currentPatchFeatures[index];
448
+ if (element.geometry.type === 'Point') {
449
+ llb.extend(element.geometry.coordinates);
450
+ } else {
451
+ //@ts-ignore
452
+ for (const coord of element.geometry.coordinates) {
453
+ llb.extend(coord);
581
454
  }
582
455
  }
583
- this.map.fitBounds(llb, fitBoundsConfig);
584
- } else {
585
- // Translate the point slightly to get another point which can used for the fitBounds function.
586
- var transformedFeatures = {
587
- type: 'FeatureCollection',
588
- features: [(0, _helpers.point)(routeSegment.coordinates[0])]
589
- };
590
- var forwardTransformed = (0, _transformTranslate.transformTranslate)(transformedFeatures, 0.025, 3).features[0].geometry.coordinates;
591
- var reverseTransformed = (0, _transformTranslate.transformTranslate)(transformedFeatures, -0.025, -3).features[0].geometry.coordinates;
592
- var bbox = [reverseTransformed, forwardTransformed];
593
- this.map.fitBounds(bbox, fitBoundsConfig);
594
456
  }
457
+ this.map.fitBounds(llb, fitBoundsConfig);
458
+ } else {
459
+ // Translate the point slightly to get another point which can used for the fitBounds function.
460
+ const transformedFeatures = {
461
+ type: 'FeatureCollection',
462
+ features: [(0, _helpers.point)(routeSegment.coordinates[0])]
463
+ };
464
+ const forwardTransformed = (0, _transformTranslate.transformTranslate)(transformedFeatures, 0.025, 3).features[0].geometry.coordinates;
465
+ const reverseTransformed = (0, _transformTranslate.transformTranslate)(transformedFeatures, -0.025, -3).features[0].geometry.coordinates;
466
+ const bbox = [reverseTransformed, forwardTransformed];
467
+ this.map.fitBounds(bbox, fitBoundsConfig);
595
468
  }
596
- } else {
597
- console.log('at vertical portal segment, ignoring!');
598
469
  }
599
- console.log(route.segments[segmentNumberToHighlight].instructions);
600
470
  } else {
601
- console.warn('Invalid segment number passed to highlightRouteSegment');
471
+ console.log('at vertical portal segment, ignoring!');
602
472
  }
473
+ console.log(route.segments[segmentNumberToHighlight].instructions);
474
+ } else {
475
+ console.warn('Invalid segment number passed to highlightRouteSegment');
603
476
  }
604
- }, {
605
- key: "clearRoute",
606
- value: function clearRoute() {
607
- var featureCollectionToDraw = {
608
- type: 'FeatureCollection',
609
- features: []
610
- };
611
- this.updateRouteSource(featureCollectionToDraw);
612
- this.updateAnimateRouteSource(featureCollectionToDraw);
613
- this.route = null;
614
- cancelAnimationFrame(this.animationFrameID);
615
- }
616
- }]);
617
- }();
477
+ }
478
+ clearRoute() {
479
+ const featureCollectionToDraw = {
480
+ type: 'FeatureCollection',
481
+ features: []
482
+ };
483
+ this.updateRouteSource(featureCollectionToDraw);
484
+ this.updateAnimateRouteSource(featureCollectionToDraw);
485
+ this.route = null;
486
+ cancelAnimationFrame(this.animationFrameID);
487
+ }
488
+ }
489
+ exports.RoutingVisualizer = RoutingVisualizer;
618
490
  //# sourceMappingURL=index.js.map