@twinmatrix/spatialverse-sdk-web 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) 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 +43 -45
  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 +241 -271
  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 +876 -1188
  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 +173 -163
  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 +546 -620
  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 +155 -160
  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 +832 -1060
  34. package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
  35. package/lib/cjs/meta-atlas-sdk/utils/helpers.js +33 -50
  36. package/lib/cjs/meta-atlas-sdk/utils/helpers.js.map +1 -1
  37. package/lib/cjs/meta-atlas-sdk/utils/local-storage.js +18 -36
  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 +428 -556
  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 -50
  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 +30 -29
  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 +53 -64
  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 +2 -1
  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 +10 -9
  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 +2 -2
  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 +3 -3
  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 +22 -14
  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 +8 -8
  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 +18 -11
  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 +4 -3
  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 +80 -61
  98. package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
  99. package/lib/esm/meta-atlas-sdk/utils/helpers.js +3 -1
  100. package/lib/esm/meta-atlas-sdk/utils/helpers.js.map +1 -1
  101. package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js +19 -15
  102. package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
  103. package/lib/esm/react/MetaAtlasMap.js +120 -0
  104. package/lib/esm/react/MetaAtlasMap.js.map +1 -0
  105. package/lib/esm/react/hooks/useDrawing/index.js +2 -2
  106. package/lib/esm/react/hooks/useDrawing/index.js.map +1 -1
  107. package/lib/esm/react/hooks/useFocus/index.js +4 -3
  108. package/lib/esm/react/hooks/useFocus/index.js.map +1 -1
  109. package/lib/esm/react/hooks/useMapEvents/index.js +3 -3
  110. package/lib/esm/react/hooks/useMapEvents/index.js.map +1 -1
  111. package/lib/esm/react/hooks/useMapOverlays/index.js +2 -2
  112. package/lib/esm/react/hooks/useMapOverlays/index.js.map +1 -1
  113. package/lib/esm/react/hooks/useMetaAtlas/index.js +162 -60
  114. package/lib/esm/react/hooks/useMetaAtlas/index.js.map +1 -1
  115. package/lib/esm/react/hooks/useMetaAtlas.js +162 -60
  116. package/lib/esm/react/hooks/useMetaAtlas.js.map +1 -1
  117. package/lib/esm/react/hooks/useRouting/index.js +2 -2
  118. package/lib/esm/react/hooks/useRouting/index.js.map +1 -1
  119. package/lib/esm/react/hooks/useSearch/index.js +2 -2
  120. package/lib/esm/react/hooks/useSearch/index.js.map +1 -1
  121. package/lib/esm/react/hooks/useStampRally/index.js +8 -7
  122. package/lib/esm/react/hooks/useStampRally/index.js.map +1 -1
  123. package/lib/esm/react/index.js +11 -15
  124. package/lib/esm/react/index.js.map +1 -1
  125. package/package.json +9 -6
@@ -17,31 +17,19 @@ 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; }
31
- 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
- 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
- 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
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); }
24
+ const debugMode = false;
25
+ const minSnapDistance = exports.minSnapDistance = 1e-3; // meters
38
26
 
39
27
  function indexOfPointOnLine(feature, point) {
40
- var matchIndex = -1;
41
- turf.coordEach(feature, function (currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) {
28
+ let matchIndex = -1;
29
+ turf.coordEach(feature, (currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) => {
42
30
  if (matchIndex === -1) {
43
- var lineVertex = turf.point(currentCoord);
44
- var dist = turf.distance(point, lineVertex, {
31
+ const lineVertex = turf.point(currentCoord);
32
+ const dist = turf.distance(point, lineVertex, {
45
33
  units: 'meters'
46
34
  });
47
35
  if (debugMode) console.log('coordIndex: ', coordIndex, dist);
@@ -52,10 +40,10 @@ function indexOfPointOnLine(feature, point) {
52
40
  return matchIndex;
53
41
  }
54
42
  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);
43
+ let doNearbyCheck = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
44
+ const addToLine = (point, line) => {
45
+ const cleanedFeature = turf.cleanCoords(line);
46
+ const nearestPoint1 = turf.nearestPointOnLine(cleanedFeature, point);
59
47
  if (nearestPoint1.properties.index !== undefined) {
60
48
  feature.geometry.coordinates.splice(nearestPoint1.properties.index + 1, 0, intersectedPoint.geometry.coordinates);
61
49
  if (feature.properties) feature.properties.modified = 1;
@@ -63,7 +51,7 @@ function addIntersectionToFeature(intersectedPoint, feature) {
63
51
  } else if (debugMode) console.log('nearest point on line undefined');
64
52
  };
65
53
  if (doNearbyCheck) {
66
- var indexOnLine = indexOfPointOnLine(feature, intersectedPoint);
54
+ const indexOnLine = indexOfPointOnLine(feature, intersectedPoint);
67
55
  if (indexOnLine === -1) {
68
56
  addToLine(intersectedPoint.geometry.coordinates, feature);
69
57
  } else {
@@ -77,15 +65,15 @@ function addIntersectionToFeature(intersectedPoint, feature) {
77
65
  }
78
66
  function snap(a, b) {
79
67
  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, {
68
+ turf.coordEach(a, (currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) => {
69
+ const currentPoint = turf.point(currentCoord);
70
+ const cleanedFeature = turf.cleanCoords(b);
71
+ const snappedPoint = turf.nearestPointOnLine(cleanedFeature, currentPoint, {
84
72
  units: 'meters'
85
73
  });
86
74
  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, {
75
+ const existingVertexOnLine = turf.point(b.geometry.coordinates[snappedPoint.properties.index]);
76
+ const distToExistingVertexOnLine = turf.distance(currentPoint, existingVertexOnLine, {
89
77
  units: 'meters'
90
78
  });
91
79
  // If the snappedPoint is close (< minSnapDistance) to a pre-existing vertex then use that vertex instead of adding new
@@ -110,19 +98,19 @@ function snap(a, b) {
110
98
 
111
99
  // b is a superset which also includes a
112
100
  function findIntersectionsWithSuperset(a, b) {
113
- for (var i = 0; i < a.length; i += 1) {
114
- for (var j = 0; j < b.length; j += 1) {
101
+ for (let i = 0; i < a.length; i += 1) {
102
+ for (let j = 0; j < b.length; j += 1) {
115
103
  if (a[i].id !== b[j].id) {
116
104
  // TODO: Optimize for two-way snapping in one call
117
105
  snap(a[i], b[j]);
118
106
  snap(b[j], a[i]);
119
- var intersections = turf.lineIntersect(a[i], b[j]);
107
+ const intersections = turf.lineIntersect(a[i], b[j]);
120
108
  if (debugMode) console.log('intersections for ', i, j, intersections);
121
109
 
122
110
  // Add intersection points to the respective LineStrings
123
111
  if (intersections.features.length > 0) {
124
- for (var index = 0; index < intersections.features.length; index += 1) {
125
- var intersectedFeature = intersections.features[index];
112
+ for (let index = 0; index < intersections.features.length; index += 1) {
113
+ const intersectedFeature = intersections.features[index];
126
114
  addIntersectionToFeature(intersectedFeature, a[i]);
127
115
  addIntersectionToFeature(intersectedFeature, b[j]);
128
116
  }
@@ -139,26 +127,26 @@ function findIntersectionsWithSuperset(a, b) {
139
127
  // It updates the given feature data inplace, make sure params are passed by reference.
140
128
  function optimized(a, b) {
141
129
  // Step 1: Build spatial index for the second set of LineStrings
142
- var tree = (0, _geojsonRbush["default"])();
130
+ const tree = (0, _geojsonRbush.default)();
143
131
  tree.load(b);
144
132
 
145
133
  // 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);
134
+ a.forEach(line1 => {
135
+ const bbox1 = turf.bbox(line1);
136
+ const possibleMatches = tree.search(bbox1);
149
137
  if (debugMode) console.log('possible matches for ', line1.properties.title, possibleMatches);
150
- possibleMatches.features.forEach(function (match) {
151
- var line2 = match;
138
+ possibleMatches.features.forEach(match => {
139
+ const line2 = match;
152
140
  if (line1.properties && line1.properties.dimension_where && line2.properties && line2.properties.dimension_where && line1.properties.dimension_where === line2.properties.dimension_where) {
153
141
  // Step 3: Perform detailed intersection check
154
142
  snap(line1, line2);
155
- var intersections = turf.lineIntersect(line1, line2);
143
+ const intersections = turf.lineIntersect(line1, line2);
156
144
  if (debugMode) console.log('intersections', intersections);
157
145
 
158
146
  // Add intersection points to the respective LineStrings
159
147
  if (intersections.features.length > 0) {
160
- for (var j = 0; j < intersections.features.length; j += 1) {
161
- var intersectedFeature = intersections.features[j];
148
+ for (let j = 0; j < intersections.features.length; j += 1) {
149
+ const intersectedFeature = intersections.features[j];
162
150
  addIntersectionToFeature(intersectedFeature, line1, false);
163
151
  addIntersectionToFeature(intersectedFeature, line2, false);
164
152
  }
@@ -169,8 +157,8 @@ function optimized(a, b) {
169
157
  }
170
158
  function markAsModified(features, mapBoxDraw) {
171
159
  if (features) {
172
- for (var index = 0; index < features.length; index += 1) {
173
- var feature = features[index];
160
+ for (let index = 0; index < features.length; index += 1) {
161
+ const feature = features[index];
174
162
  // modified key is used to mark that a feature was updated by mapboxDraw or custom logic like intersection during the respective editing session
175
163
  feature.properties.modified = 1;
176
164
  mapBoxDraw.add(feature);
@@ -178,9 +166,9 @@ function markAsModified(features, mapBoxDraw) {
178
166
  }
179
167
  }
180
168
  function getFirstPointFeature(features) {
181
- for (var index = 0; index < features.length; index += 1) {
182
- var feature = features[index];
183
- var type = turf.getType(feature);
169
+ for (let index = 0; index < features.length; index += 1) {
170
+ const feature = features[index];
171
+ const type = turf.getType(feature);
184
172
  if (type === 'Point') {
185
173
  return feature;
186
174
  }
@@ -188,66 +176,68 @@ function getFirstPointFeature(features) {
188
176
  return undefined;
189
177
  }
190
178
  function getParentDimension(dimension) {
191
- var splitResult = dimension.split('.');
192
- var lastChildName = splitResult[splitResult.length - 1];
193
- var parentDimensionValueStrict = dimension.replace('.'.concat(lastChildName), '');
179
+ const splitResult = dimension.split('.');
180
+ const lastChildName = splitResult[splitResult.length - 1];
181
+ const parentDimensionValueStrict = dimension.replace('.'.concat(lastChildName), '');
194
182
  return parentDimensionValueStrict;
195
183
  }
196
- var DEFAULT_DIMENSION = exports.DEFAULT_DIMENSION = 'where.singapore';
184
+ const DEFAULT_DIMENSION = exports.DEFAULT_DIMENSION = 'where.singapore';
197
185
  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);
186
+ const allEdgeLines = [];
187
+ const portalEdgeData = {};
188
+ const addLink = (link, container) => {
189
+ const {
190
+ cost,
191
+ direction,
192
+ wheelchair,
193
+ description
194
+ } = link.property_portalLink;
195
+ const edge = (0, _mapObjectsHelper.getEdge)(link.property_secondRelatedId);
207
196
  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
217
- });
197
+ 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;
198
+ const portalEdge = {
199
+ ...edge,
200
+ cost,
201
+ direction,
202
+ wheelchair,
203
+ pathFeatures,
204
+ description
205
+ };
218
206
  container.push(portalEdge);
219
- allEdgeLines.push.apply(allEdgeLines, _toConsumableArray(edge.lines));
207
+ allEdgeLines.push(...edge.lines);
220
208
  }
221
209
  };
222
- var addNode = function addNode(mapObjectId, links) {
223
- var edge = (0, _mapObjectsHelper.getEdge)(mapObjectId);
210
+ const addNode = (mapObjectId, links) => {
211
+ const edge = (0, _mapObjectsHelper.getEdge)(mapObjectId);
224
212
  if (edge && edge.lines) {
225
- var portal = _objectSpread(_objectSpread({}, edge), {}, {
226
- links: links
227
- });
213
+ const portal = {
214
+ ...edge,
215
+ links
216
+ };
228
217
  portalEdgeData[mapObjectId] = portal;
229
- allEdgeLines.push.apply(allEdgeLines, _toConsumableArray(edge.lines));
218
+ allEdgeLines.push(...edge.lines);
230
219
  return portal;
231
220
  }
232
221
  return undefined;
233
222
  };
234
223
  console.log('portalData input', portalLinks);
235
- var escalatorGraph = new _graphlib.Graph();
224
+ const escalatorGraph = new _graphlib.Graph();
236
225
  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;
226
+ Object.keys(portalLinks).forEach(anchorId => {
227
+ const {
228
+ type,
229
+ links
230
+ } = portalLinks[anchorId];
241
231
  if (type !== _interfaces.PortalType.escalator) {
242
- var linksForAnchor = [];
243
- for (var j = 0; j < links.length; j += 1) {
244
- var link = links[j];
232
+ const linksForAnchor = [];
233
+ for (let j = 0; j < links.length; j += 1) {
234
+ const link = links[j];
245
235
  addLink(link, linksForAnchor);
246
236
  if (type === _interfaces.PortalType.lift) {
247
237
  // Extrapolate links for non-anchor lifts
248
- var linksForNonAnchor = [];
249
- for (var k = 0; k < links.length; k += 1) {
250
- var nestedLink = links[k];
238
+ const linksForNonAnchor = [];
239
+ for (let k = 0; k < links.length; k += 1) {
240
+ const nestedLink = links[k];
251
241
  if (nestedLink.property_secondRelatedId !== link.property_secondRelatedId) {
252
242
  addLink(nestedLink, linksForNonAnchor);
253
243
  }
@@ -263,22 +253,24 @@ function getPortalEdgeData(portalLinks) {
263
253
  addNode(anchorId, linksForAnchor);
264
254
  } else {
265
255
  if (!escalatorGraph.hasNode(anchorId)) {
266
- var edge = (0, _mapObjectsHelper.getEdge)(anchorId);
256
+ const edge = (0, _mapObjectsHelper.getEdge)(anchorId);
267
257
  if (edge) {
268
258
  escalatorGraph.setNode(anchorId, {
269
259
  where: edge.where
270
260
  });
271
261
  }
272
262
  }
273
- for (var _j = 0; _j < links.length; _j += 1) {
274
- var _link = links[_j];
275
- if (!escalatorGraph.hasNode(_link.property_secondRelatedId)) {
263
+ for (let j = 0; j < links.length; j += 1) {
264
+ const link = links[j];
265
+ if (!escalatorGraph.hasNode(link.property_secondRelatedId)) {
276
266
  escalatorGraph.setNode(anchorId, {
277
- where: _link.taxonomy1Path
267
+ where: link.taxonomy1Path
278
268
  });
279
269
  }
280
- if (!escalatorGraph.hasEdge(anchorId, _link.property_secondRelatedId)) {
281
- escalatorGraph.setEdge(anchorId, _link.property_secondRelatedId, _objectSpread({}, _link.property_portalLink));
270
+ if (!escalatorGraph.hasEdge(anchorId, link.property_secondRelatedId)) {
271
+ escalatorGraph.setEdge(anchorId, link.property_secondRelatedId, {
272
+ ...link.property_portalLink
273
+ });
282
274
  }
283
275
  }
284
276
  }
@@ -286,32 +278,32 @@ function getPortalEdgeData(portalLinks) {
286
278
  }
287
279
 
288
280
  // 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;
281
+ const extrapolateLinks = graph => {
282
+ const components = _graphlib.alg.components(graph);
283
+ components.forEach(component => {
284
+ const reachableNodes = component;
293
285
 
294
286
  // 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];
287
+ for (let i = 0; i < reachableNodes.length; i += 1) {
288
+ const node1 = reachableNodes[i];
289
+ for (let j = i + 1; j < reachableNodes.length; j += 1) {
290
+ const node2 = reachableNodes[j];
299
291
  if (node1 !== node2 && !graph.hasEdge(node1, node2)) {
300
- var edgeData = {
292
+ let edgeData = {
301
293
  cost: 120,
302
294
  direction: 2,
303
295
  wheelchair: true
304
296
  };
305
- var nodeEdges = graph.nodeEdges(node1);
306
- var isParallelLink = false;
297
+ const nodeEdges = graph.nodeEdges(node1);
298
+ let isParallelLink = false;
307
299
  if (nodeEdges && nodeEdges.length > 0) {
308
- for (var k = 0; !isParallelLink && k < nodeEdges.length; k += 1) {
309
- var nodeEdge = nodeEdges[k];
300
+ for (let k = 0; !isParallelLink && k < nodeEdges.length; k += 1) {
301
+ const nodeEdge = nodeEdges[k];
310
302
 
311
303
  // check sibling connection with node2
312
- var nodeToUse = nodeEdge.v === node1 ? nodeEdge.w : nodeEdge.v;
304
+ const nodeToUse = nodeEdge.v === node1 ? nodeEdge.w : nodeEdge.v;
313
305
  if (graph.hasEdge(nodeToUse, node2)) {
314
- var nodeEdgeData = graph.edgeAsObj(nodeToUse, node2);
306
+ const nodeEdgeData = graph.edgeAsObj(nodeToUse, node2);
315
307
  if ('isParallel' in nodeEdgeData && nodeEdgeData.isParallel) {
316
308
  isParallelLink = true;
317
309
  }
@@ -333,57 +325,60 @@ function getPortalEdgeData(portalLinks) {
333
325
  }
334
326
 
335
327
  // 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);
328
+ for (let i = 0; i < reachableNodes.length; i += 1) {
329
+ const node1 = reachableNodes[i];
330
+ const nodeEdges = graph.nodeEdges(node1);
331
+ for (let k = 0; nodeEdges && k < nodeEdges.length; k += 1) {
332
+ const nodeEdge = nodeEdges[k];
333
+ const nodeEdgeData = graph.edgeAsObj(nodeEdge);
334
+ if ('isParallel' in nodeEdgeData && nodeEdgeData.isParallel) {
335
+ graph.removeEdge(nodeEdge.v, nodeEdge.w);
344
336
  }
345
337
  }
346
338
  }
347
339
  });
348
340
  };
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);
341
+ const addLinkUsingGraph = (portal, escalatorEdge) => {
342
+ const nodeEdgeData = escalatorGraph.edge(escalatorEdge);
343
+ const {
344
+ cost,
345
+ direction,
346
+ wheelchair,
347
+ pathFeatures,
348
+ description
349
+ } = nodeEdgeData;
350
+ const edge = (0, _mapObjectsHelper.getEdge)(escalatorEdge.w);
357
351
  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
364
- });
352
+ const portalEdge = {
353
+ ...edge,
354
+ cost,
355
+ direction,
356
+ wheelchair,
357
+ pathFeatures,
358
+ description
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
  });