@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
@@ -17,31 +17,24 @@ var turf = _interopRequireWildcard(require("@turf/turf"));
17
17
  var _geojsonRbush = _interopRequireDefault(require("geojson-rbush"));
18
18
  var _graphlib = require("@dagrejs/graphlib");
19
19
  var _lodash = require("lodash");
20
- var _interfaces = require("./interfaces");
21
- var _mapObjectsHelper = require("./mapObjectsHelper");
22
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
23
- 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); }
24
- 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); }
25
- function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
26
- 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."); }
27
- 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; } }
28
- function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
29
- function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
30
- 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; }
20
+ var _interfaces = require("./interfaces.js");
21
+ var _mapObjectsHelper = require("./mapObjectsHelper.js");
22
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
23
+ 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); }
31
24
  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; }
32
25
  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; }
33
26
  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; }
34
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
35
- 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); }
36
- var debugMode = false;
37
- var minSnapDistance = exports.minSnapDistance = 1e-3; // meters
27
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
28
+ 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); }
29
+ const debugMode = false;
30
+ const minSnapDistance = exports.minSnapDistance = 1e-3; // meters
38
31
 
39
32
  function indexOfPointOnLine(feature, point) {
40
- var matchIndex = -1;
41
- turf.coordEach(feature, function (currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) {
33
+ let matchIndex = -1;
34
+ turf.coordEach(feature, (currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) => {
42
35
  if (matchIndex === -1) {
43
- var lineVertex = turf.point(currentCoord);
44
- var dist = turf.distance(point, lineVertex, {
36
+ const lineVertex = turf.point(currentCoord);
37
+ const dist = turf.distance(point, lineVertex, {
45
38
  units: 'meters'
46
39
  });
47
40
  if (debugMode) console.log('coordIndex: ', coordIndex, dist);
@@ -52,10 +45,10 @@ function indexOfPointOnLine(feature, point) {
52
45
  return matchIndex;
53
46
  }
54
47
  function addIntersectionToFeature(intersectedPoint, feature) {
55
- var doNearbyCheck = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
56
- var addToLine = function addToLine(point, line) {
57
- var cleanedFeature = turf.cleanCoords(line);
58
- var nearestPoint1 = turf.nearestPointOnLine(cleanedFeature, point);
48
+ let doNearbyCheck = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
49
+ const addToLine = (point, line) => {
50
+ const cleanedFeature = turf.cleanCoords(line);
51
+ const nearestPoint1 = turf.nearestPointOnLine(cleanedFeature, point);
59
52
  if (nearestPoint1.properties.index !== undefined) {
60
53
  feature.geometry.coordinates.splice(nearestPoint1.properties.index + 1, 0, intersectedPoint.geometry.coordinates);
61
54
  if (feature.properties) feature.properties.modified = 1;
@@ -63,7 +56,7 @@ function addIntersectionToFeature(intersectedPoint, feature) {
63
56
  } else if (debugMode) console.log('nearest point on line undefined');
64
57
  };
65
58
  if (doNearbyCheck) {
66
- var indexOnLine = indexOfPointOnLine(feature, intersectedPoint);
59
+ const indexOnLine = indexOfPointOnLine(feature, intersectedPoint);
67
60
  if (indexOnLine === -1) {
68
61
  addToLine(intersectedPoint.geometry.coordinates, feature);
69
62
  } else {
@@ -77,15 +70,15 @@ function addIntersectionToFeature(intersectedPoint, feature) {
77
70
  }
78
71
  function snap(a, b) {
79
72
  if (turf.getType(a) === 'LineString') {
80
- turf.coordEach(a, function (currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) {
81
- var currentPoint = turf.point(currentCoord);
82
- var cleanedFeature = turf.cleanCoords(b);
83
- var snappedPoint = turf.nearestPointOnLine(cleanedFeature, currentPoint, {
73
+ turf.coordEach(a, (currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) => {
74
+ const currentPoint = turf.point(currentCoord);
75
+ const cleanedFeature = turf.cleanCoords(b);
76
+ const snappedPoint = turf.nearestPointOnLine(cleanedFeature, currentPoint, {
84
77
  units: 'meters'
85
78
  });
86
79
  if (snappedPoint && snappedPoint.properties.dist !== undefined && snappedPoint.properties.index !== undefined) {
87
- var existingVertexOnLine = turf.point(b.geometry.coordinates[snappedPoint.properties.index]);
88
- var distToExistingVertexOnLine = turf.distance(currentPoint, existingVertexOnLine, {
80
+ const existingVertexOnLine = turf.point(b.geometry.coordinates[snappedPoint.properties.index]);
81
+ const distToExistingVertexOnLine = turf.distance(currentPoint, existingVertexOnLine, {
89
82
  units: 'meters'
90
83
  });
91
84
  // If the snappedPoint is close (< minSnapDistance) to a pre-existing vertex then use that vertex instead of adding new
@@ -110,19 +103,19 @@ function snap(a, b) {
110
103
 
111
104
  // b is a superset which also includes a
112
105
  function findIntersectionsWithSuperset(a, b) {
113
- for (var i = 0; i < a.length; i += 1) {
114
- for (var j = 0; j < b.length; j += 1) {
106
+ for (let i = 0; i < a.length; i += 1) {
107
+ for (let j = 0; j < b.length; j += 1) {
115
108
  if (a[i].id !== b[j].id) {
116
109
  // TODO: Optimize for two-way snapping in one call
117
110
  snap(a[i], b[j]);
118
111
  snap(b[j], a[i]);
119
- var intersections = turf.lineIntersect(a[i], b[j]);
112
+ const intersections = turf.lineIntersect(a[i], b[j]);
120
113
  if (debugMode) console.log('intersections for ', i, j, intersections);
121
114
 
122
115
  // Add intersection points to the respective LineStrings
123
116
  if (intersections.features.length > 0) {
124
- for (var index = 0; index < intersections.features.length; index += 1) {
125
- var intersectedFeature = intersections.features[index];
117
+ for (let index = 0; index < intersections.features.length; index += 1) {
118
+ const intersectedFeature = intersections.features[index];
126
119
  addIntersectionToFeature(intersectedFeature, a[i]);
127
120
  addIntersectionToFeature(intersectedFeature, b[j]);
128
121
  }
@@ -139,26 +132,26 @@ function findIntersectionsWithSuperset(a, b) {
139
132
  // It updates the given feature data inplace, make sure params are passed by reference.
140
133
  function optimized(a, b) {
141
134
  // Step 1: Build spatial index for the second set of LineStrings
142
- var tree = (0, _geojsonRbush["default"])();
135
+ const tree = (0, _geojsonRbush.default)();
143
136
  tree.load(b);
144
137
 
145
138
  // Step 2: Find potential intersecting pairs using bounding boxes
146
- a.forEach(function (line1) {
147
- var bbox1 = turf.bbox(line1);
148
- var possibleMatches = tree.search(bbox1);
139
+ a.forEach(line1 => {
140
+ const bbox1 = turf.bbox(line1);
141
+ const possibleMatches = tree.search(bbox1);
149
142
  if (debugMode) console.log('possible matches for ', line1.properties.title, possibleMatches);
150
- possibleMatches.features.forEach(function (match) {
151
- var line2 = match;
143
+ possibleMatches.features.forEach(match => {
144
+ const line2 = match;
152
145
  if (line1.properties && line1.properties.dimension_where && line2.properties && line2.properties.dimension_where && line1.properties.dimension_where === line2.properties.dimension_where) {
153
146
  // Step 3: Perform detailed intersection check
154
147
  snap(line1, line2);
155
- var intersections = turf.lineIntersect(line1, line2);
148
+ const intersections = turf.lineIntersect(line1, line2);
156
149
  if (debugMode) console.log('intersections', intersections);
157
150
 
158
151
  // Add intersection points to the respective LineStrings
159
152
  if (intersections.features.length > 0) {
160
- for (var j = 0; j < intersections.features.length; j += 1) {
161
- var intersectedFeature = intersections.features[j];
153
+ for (let j = 0; j < intersections.features.length; j += 1) {
154
+ const intersectedFeature = intersections.features[j];
162
155
  addIntersectionToFeature(intersectedFeature, line1, false);
163
156
  addIntersectionToFeature(intersectedFeature, line2, false);
164
157
  }
@@ -169,8 +162,8 @@ function optimized(a, b) {
169
162
  }
170
163
  function markAsModified(features, mapBoxDraw) {
171
164
  if (features) {
172
- for (var index = 0; index < features.length; index += 1) {
173
- var feature = features[index];
165
+ for (let index = 0; index < features.length; index += 1) {
166
+ const feature = features[index];
174
167
  // modified key is used to mark that a feature was updated by mapboxDraw or custom logic like intersection during the respective editing session
175
168
  feature.properties.modified = 1;
176
169
  mapBoxDraw.add(feature);
@@ -178,9 +171,9 @@ function markAsModified(features, mapBoxDraw) {
178
171
  }
179
172
  }
180
173
  function getFirstPointFeature(features) {
181
- for (var index = 0; index < features.length; index += 1) {
182
- var feature = features[index];
183
- var type = turf.getType(feature);
174
+ for (let index = 0; index < features.length; index += 1) {
175
+ const feature = features[index];
176
+ const type = turf.getType(feature);
184
177
  if (type === 'Point') {
185
178
  return feature;
186
179
  }
@@ -188,66 +181,66 @@ function getFirstPointFeature(features) {
188
181
  return undefined;
189
182
  }
190
183
  function getParentDimension(dimension) {
191
- var splitResult = dimension.split('.');
192
- var lastChildName = splitResult[splitResult.length - 1];
193
- var parentDimensionValueStrict = dimension.replace('.'.concat(lastChildName), '');
184
+ const splitResult = dimension.split('.');
185
+ const lastChildName = splitResult[splitResult.length - 1];
186
+ const parentDimensionValueStrict = dimension.replace('.'.concat(lastChildName), '');
194
187
  return parentDimensionValueStrict;
195
188
  }
196
- var DEFAULT_DIMENSION = exports.DEFAULT_DIMENSION = 'where.singapore';
189
+ const DEFAULT_DIMENSION = exports.DEFAULT_DIMENSION = 'where.singapore';
197
190
  function getPortalEdgeData(portalLinks) {
198
- var allEdgeLines = [];
199
- var portalEdgeData = {};
200
- var addLink = function addLink(link, container) {
201
- var _link$property_portal = link.property_portalLink,
202
- cost = _link$property_portal.cost,
203
- direction = _link$property_portal.direction,
204
- wheelchair = _link$property_portal.wheelchair,
205
- description = _link$property_portal.description;
206
- var edge = (0, _mapObjectsHelper.getEdge)(link.property_secondRelatedId);
191
+ const allEdgeLines = [];
192
+ const portalEdgeData = {};
193
+ const addLink = (link, container) => {
194
+ const {
195
+ cost,
196
+ direction,
197
+ wheelchair,
198
+ description
199
+ } = link.property_portalLink;
200
+ const edge = (0, _mapObjectsHelper.getEdge)(link.property_secondRelatedId);
207
201
  if (edge && edge.lines) {
208
- var pathFeatures = link.property_routeData && link.property_routeData.features ? link.property_routeData.features.filter(function (feature) {
209
- return feature.geometry !== undefined && turf.getType(feature) === 'LineString' && feature.geometry.coordinates.length > 0;
210
- }) : null;
211
- var portalEdge = _objectSpread(_objectSpread({}, edge), {}, {
212
- cost: cost,
213
- direction: direction,
214
- wheelchair: wheelchair,
215
- pathFeatures: pathFeatures,
216
- description: description
202
+ const pathFeatures = link.property_routeData && link.property_routeData.features ? link.property_routeData.features.filter(feature => feature.geometry !== undefined && turf.getType(feature) === 'LineString' && feature.geometry.coordinates.length > 0) : null;
203
+ const portalEdge = _objectSpread(_objectSpread({}, edge), {}, {
204
+ cost,
205
+ direction,
206
+ wheelchair,
207
+ pathFeatures,
208
+ description
217
209
  });
218
210
  container.push(portalEdge);
219
- allEdgeLines.push.apply(allEdgeLines, _toConsumableArray(edge.lines));
211
+ allEdgeLines.push(...edge.lines);
220
212
  }
221
213
  };
222
- var addNode = function addNode(mapObjectId, links) {
223
- var edge = (0, _mapObjectsHelper.getEdge)(mapObjectId);
214
+ const addNode = (mapObjectId, links) => {
215
+ const edge = (0, _mapObjectsHelper.getEdge)(mapObjectId);
224
216
  if (edge && edge.lines) {
225
- var portal = _objectSpread(_objectSpread({}, edge), {}, {
226
- links: links
217
+ const portal = _objectSpread(_objectSpread({}, edge), {}, {
218
+ links
227
219
  });
228
220
  portalEdgeData[mapObjectId] = portal;
229
- allEdgeLines.push.apply(allEdgeLines, _toConsumableArray(edge.lines));
221
+ allEdgeLines.push(...edge.lines);
230
222
  return portal;
231
223
  }
232
224
  return undefined;
233
225
  };
234
226
  console.log('portalData input', portalLinks);
235
- var escalatorGraph = new _graphlib.Graph();
227
+ const escalatorGraph = new _graphlib.Graph();
236
228
  if (!(0, _lodash.isEmpty)(portalLinks)) {
237
- Object.keys(portalLinks).forEach(function (anchorId) {
238
- var _portalLinks$anchorId = portalLinks[anchorId],
239
- type = _portalLinks$anchorId.type,
240
- links = _portalLinks$anchorId.links;
229
+ Object.keys(portalLinks).forEach(anchorId => {
230
+ const {
231
+ type,
232
+ links
233
+ } = portalLinks[anchorId];
241
234
  if (type !== _interfaces.PortalType.escalator) {
242
- var linksForAnchor = [];
243
- for (var j = 0; j < links.length; j += 1) {
244
- var link = links[j];
235
+ const linksForAnchor = [];
236
+ for (let j = 0; j < links.length; j += 1) {
237
+ const link = links[j];
245
238
  addLink(link, linksForAnchor);
246
239
  if (type === _interfaces.PortalType.lift) {
247
240
  // Extrapolate links for non-anchor lifts
248
- var linksForNonAnchor = [];
249
- for (var k = 0; k < links.length; k += 1) {
250
- var nestedLink = links[k];
241
+ const linksForNonAnchor = [];
242
+ for (let k = 0; k < links.length; k += 1) {
243
+ const nestedLink = links[k];
251
244
  if (nestedLink.property_secondRelatedId !== link.property_secondRelatedId) {
252
245
  addLink(nestedLink, linksForNonAnchor);
253
246
  }
@@ -263,22 +256,22 @@ function getPortalEdgeData(portalLinks) {
263
256
  addNode(anchorId, linksForAnchor);
264
257
  } else {
265
258
  if (!escalatorGraph.hasNode(anchorId)) {
266
- var edge = (0, _mapObjectsHelper.getEdge)(anchorId);
259
+ const edge = (0, _mapObjectsHelper.getEdge)(anchorId);
267
260
  if (edge) {
268
261
  escalatorGraph.setNode(anchorId, {
269
262
  where: edge.where
270
263
  });
271
264
  }
272
265
  }
273
- for (var _j = 0; _j < links.length; _j += 1) {
274
- var _link = links[_j];
275
- if (!escalatorGraph.hasNode(_link.property_secondRelatedId)) {
266
+ for (let j = 0; j < links.length; j += 1) {
267
+ const link = links[j];
268
+ if (!escalatorGraph.hasNode(link.property_secondRelatedId)) {
276
269
  escalatorGraph.setNode(anchorId, {
277
- where: _link.taxonomy1Path
270
+ where: link.taxonomy1Path
278
271
  });
279
272
  }
280
- if (!escalatorGraph.hasEdge(anchorId, _link.property_secondRelatedId)) {
281
- escalatorGraph.setEdge(anchorId, _link.property_secondRelatedId, _objectSpread({}, _link.property_portalLink));
273
+ if (!escalatorGraph.hasEdge(anchorId, link.property_secondRelatedId)) {
274
+ escalatorGraph.setEdge(anchorId, link.property_secondRelatedId, _objectSpread({}, link.property_portalLink));
282
275
  }
283
276
  }
284
277
  }
@@ -286,32 +279,32 @@ function getPortalEdgeData(portalLinks) {
286
279
  }
287
280
 
288
281
  // eslint-disable-next-line no-loop-func
289
- var extrapolateLinks = function extrapolateLinks(graph) {
290
- var components = _graphlib.alg.components(graph);
291
- components.forEach(function (component) {
292
- var reachableNodes = component;
282
+ const extrapolateLinks = graph => {
283
+ const components = _graphlib.alg.components(graph);
284
+ components.forEach(component => {
285
+ const reachableNodes = component;
293
286
 
294
287
  // Connect the node directly to each indirectly connected node
295
- for (var i = 0; i < reachableNodes.length; i += 1) {
296
- var node1 = reachableNodes[i];
297
- for (var j = i + 1; j < reachableNodes.length; j += 1) {
298
- var node2 = reachableNodes[j];
288
+ for (let i = 0; i < reachableNodes.length; i += 1) {
289
+ const node1 = reachableNodes[i];
290
+ for (let j = i + 1; j < reachableNodes.length; j += 1) {
291
+ const node2 = reachableNodes[j];
299
292
  if (node1 !== node2 && !graph.hasEdge(node1, node2)) {
300
- var edgeData = {
293
+ let edgeData = {
301
294
  cost: 120,
302
295
  direction: 2,
303
296
  wheelchair: true
304
297
  };
305
- var nodeEdges = graph.nodeEdges(node1);
306
- var isParallelLink = false;
298
+ const nodeEdges = graph.nodeEdges(node1);
299
+ let isParallelLink = false;
307
300
  if (nodeEdges && nodeEdges.length > 0) {
308
- for (var k = 0; !isParallelLink && k < nodeEdges.length; k += 1) {
309
- var nodeEdge = nodeEdges[k];
301
+ for (let k = 0; !isParallelLink && k < nodeEdges.length; k += 1) {
302
+ const nodeEdge = nodeEdges[k];
310
303
 
311
304
  // check sibling connection with node2
312
- var nodeToUse = nodeEdge.v === node1 ? nodeEdge.w : nodeEdge.v;
305
+ const nodeToUse = nodeEdge.v === node1 ? nodeEdge.w : nodeEdge.v;
313
306
  if (graph.hasEdge(nodeToUse, node2)) {
314
- var nodeEdgeData = graph.edgeAsObj(nodeToUse, node2);
307
+ const nodeEdgeData = graph.edgeAsObj(nodeToUse, node2);
315
308
  if ('isParallel' in nodeEdgeData && nodeEdgeData.isParallel) {
316
309
  isParallelLink = true;
317
310
  }
@@ -333,57 +326,59 @@ function getPortalEdgeData(portalLinks) {
333
326
  }
334
327
 
335
328
  // Delete all parallel links from graph
336
- for (var _i = 0; _i < reachableNodes.length; _i += 1) {
337
- var _node = reachableNodes[_i];
338
- var _nodeEdges = graph.nodeEdges(_node);
339
- for (var _k = 0; _nodeEdges && _k < _nodeEdges.length; _k += 1) {
340
- var _nodeEdge = _nodeEdges[_k];
341
- var _nodeEdgeData = graph.edgeAsObj(_nodeEdge);
342
- if ('isParallel' in _nodeEdgeData && _nodeEdgeData.isParallel) {
343
- graph.removeEdge(_nodeEdge.v, _nodeEdge.w);
329
+ for (let i = 0; i < reachableNodes.length; i += 1) {
330
+ const node1 = reachableNodes[i];
331
+ const nodeEdges = graph.nodeEdges(node1);
332
+ for (let k = 0; nodeEdges && k < nodeEdges.length; k += 1) {
333
+ const nodeEdge = nodeEdges[k];
334
+ const nodeEdgeData = graph.edgeAsObj(nodeEdge);
335
+ if ('isParallel' in nodeEdgeData && nodeEdgeData.isParallel) {
336
+ graph.removeEdge(nodeEdge.v, nodeEdge.w);
344
337
  }
345
338
  }
346
339
  }
347
340
  });
348
341
  };
349
- var addLinkUsingGraph = function addLinkUsingGraph(portal, escalatorEdge) {
350
- var nodeEdgeData = escalatorGraph.edge(escalatorEdge);
351
- var cost = nodeEdgeData.cost,
352
- direction = nodeEdgeData.direction,
353
- wheelchair = nodeEdgeData.wheelchair,
354
- pathFeatures = nodeEdgeData.pathFeatures,
355
- description = nodeEdgeData.description;
356
- var edge = (0, _mapObjectsHelper.getEdge)(escalatorEdge.w);
342
+ const addLinkUsingGraph = (portal, escalatorEdge) => {
343
+ const nodeEdgeData = escalatorGraph.edge(escalatorEdge);
344
+ const {
345
+ cost,
346
+ direction,
347
+ wheelchair,
348
+ pathFeatures,
349
+ description
350
+ } = nodeEdgeData;
351
+ const edge = (0, _mapObjectsHelper.getEdge)(escalatorEdge.w);
357
352
  if (edge && edge.lines) {
358
- var portalEdge = _objectSpread(_objectSpread({}, edge), {}, {
359
- cost: cost,
360
- direction: direction,
361
- wheelchair: wheelchair,
362
- pathFeatures: pathFeatures,
363
- description: description
353
+ const portalEdge = _objectSpread(_objectSpread({}, edge), {}, {
354
+ cost,
355
+ direction,
356
+ wheelchair,
357
+ pathFeatures,
358
+ description
364
359
  });
365
360
  portal.links.push(portalEdge);
366
- allEdgeLines.push.apply(allEdgeLines, _toConsumableArray(edge.lines));
361
+ allEdgeLines.push(...edge.lines);
367
362
  }
368
363
  };
369
- var start = performance.now();
364
+ const start = performance.now();
370
365
  extrapolateLinks(escalatorGraph);
371
366
  console.log('time extrapolation: ', (performance.now() - start) / 1000);
372
367
 
373
368
  // Add escaaltor links to portalEdgeData using the escalator graph
374
- var escalatorGraphEdges = escalatorGraph.edges();
375
- for (var i = 0; i < escalatorGraphEdges.length; i += 1) {
376
- var escalatorEdge = escalatorGraphEdges[i];
369
+ const escalatorGraphEdges = escalatorGraph.edges();
370
+ for (let i = 0; i < escalatorGraphEdges.length; i += 1) {
371
+ const escalatorEdge = escalatorGraphEdges[i];
377
372
  // eslint-disable-next-line no-prototype-builtins
378
373
  if (!portalEdgeData.hasOwnProperty(escalatorEdge.v)) {
379
374
  // Add node and then add link
380
- var portal = addNode(escalatorEdge.v, []);
375
+ const portal = addNode(escalatorEdge.v, []);
381
376
  if (portal) {
382
377
  addLinkUsingGraph(portal, escalatorEdge);
383
378
  }
384
379
  } else {
385
- var _portal = portalEdgeData[escalatorEdge.v];
386
- addLinkUsingGraph(_portal, escalatorEdge);
380
+ const portal = portalEdgeData[escalatorEdge.v];
381
+ addLinkUsingGraph(portal, escalatorEdge);
387
382
  }
388
383
  }
389
384
  console.log('portalEdgeData', portalEdgeData);
@@ -393,17 +388,17 @@ function getPortalEdgeData(portalLinks) {
393
388
  };
394
389
  }
395
390
  function filterPortalEdgeDataByWhere(allPortalEdgeData, whereDimension) {
396
- var allEdgeLines = [];
397
- var portalEdgeData = {};
391
+ const allEdgeLines = [];
392
+ const portalEdgeData = {};
398
393
 
399
394
  // eslint-disable-next-line no-restricted-syntax
400
- for (var portalId in allPortalEdgeData) {
395
+ for (const portalId in allPortalEdgeData) {
401
396
  if (allPortalEdgeData[portalId].where.includes(whereDimension)) {
402
- var portal = allPortalEdgeData[portalId];
397
+ const portal = allPortalEdgeData[portalId];
403
398
  portalEdgeData[portalId] = portal;
404
- allEdgeLines.push.apply(allEdgeLines, _toConsumableArray(portal.lines));
405
- portal.links.forEach(function (link) {
406
- allEdgeLines.push.apply(allEdgeLines, _toConsumableArray(link.lines));
399
+ allEdgeLines.push(...portal.lines);
400
+ portal.links.forEach(link => {
401
+ allEdgeLines.push(...link.lines);
407
402
  });
408
403
  }
409
404
  }
@@ -413,15 +408,15 @@ function filterPortalEdgeDataByWhere(allPortalEdgeData, whereDimension) {
413
408
  };
414
409
  }
415
410
  function filterPortalEdgeDataByList(allPortalEdgeData, portalIdList) {
416
- var allEdgeLines = [];
417
- var portalEdgeData = {};
418
- portalIdList.forEach(function (portalId) {
411
+ const allEdgeLines = [];
412
+ const portalEdgeData = {};
413
+ portalIdList.forEach(portalId => {
419
414
  if (portalId in allPortalEdgeData && portalIdList.has(allPortalEdgeData[portalId].id)) {
420
- var portal = allPortalEdgeData[portalId];
415
+ const portal = allPortalEdgeData[portalId];
421
416
  portalEdgeData[portalId] = portal;
422
- allEdgeLines.push.apply(allEdgeLines, _toConsumableArray(portal.lines));
423
- portal.links.forEach(function (link) {
424
- allEdgeLines.push.apply(allEdgeLines, _toConsumableArray(link.lines));
417
+ allEdgeLines.push(...portal.lines);
418
+ portal.links.forEach(link => {
419
+ allEdgeLines.push(...link.lines);
425
420
  });
426
421
  }
427
422
  });