@twinmatrix/spatialverse-sdk-web 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +9 -9
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js +213 -294
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js +40 -41
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/3DMap/MainMap.js +170 -196
- package/lib/cjs/meta-atlas-sdk/3DMap/MainMap.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js +167 -215
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js +28 -30
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js +861 -1170
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js +166 -159
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/interfaces.js +6 -6
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/interfaces.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js +6 -6
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routeLayers.js +3 -3
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routeLayers.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js +523 -610
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js +149 -154
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/customStyles.js +2 -2
- package/lib/cjs/meta-atlas-sdk/customStyles.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/customerLayer.js +15 -29
- package/lib/cjs/meta-atlas-sdk/customerLayer.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/customerLayerVariant.js +5 -5
- package/lib/cjs/meta-atlas-sdk/customerLayerVariant.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js +809 -1033
- package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/helpers.js +32 -49
- package/lib/cjs/meta-atlas-sdk/utils/helpers.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/local-storage.js +21 -34
- package/lib/cjs/meta-atlas-sdk/utils/local-storage.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/mapobjects-store.js +6 -6
- package/lib/cjs/meta-atlas-sdk/utils/mapobjects-store.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/routing-store.js +6 -6
- package/lib/cjs/meta-atlas-sdk/utils/routing-store.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/routing-visualizer/index.js +363 -491
- package/lib/cjs/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
- package/lib/cjs/react/MetaAtlasMap.js +127 -0
- package/lib/cjs/react/MetaAtlasMap.js.map +1 -0
- package/lib/cjs/react/hooks/useDrawing/index.js +17 -18
- package/lib/cjs/react/hooks/useDrawing/index.js.map +1 -1
- package/lib/cjs/react/hooks/useFocus/index.js +48 -55
- package/lib/cjs/react/hooks/useFocus/index.js.map +1 -1
- package/lib/cjs/react/hooks/useMapEvents/index.js +40 -47
- package/lib/cjs/react/hooks/useMapEvents/index.js.map +1 -1
- package/lib/cjs/react/hooks/useMapOverlays/index.js +20 -21
- package/lib/cjs/react/hooks/useMapOverlays/index.js.map +1 -1
- package/lib/cjs/react/hooks/useMetaAtlas/index.js +77 -95
- package/lib/cjs/react/hooks/useMetaAtlas/index.js.map +1 -1
- package/lib/cjs/react/hooks/useMetaAtlas.js +78 -96
- package/lib/cjs/react/hooks/useMetaAtlas.js.map +1 -1
- package/lib/cjs/react/hooks/useRouting/index.js +21 -20
- package/lib/cjs/react/hooks/useRouting/index.js.map +1 -1
- package/lib/cjs/react/hooks/useSearch/index.js +35 -34
- package/lib/cjs/react/hooks/useSearch/index.js.map +1 -1
- package/lib/cjs/react/hooks/useStampRally/index.js +26 -23
- package/lib/cjs/react/hooks/useStampRally/index.js.map +1 -1
- package/lib/cjs/react/hooks/useStampRally/utils.js +2 -2
- package/lib/cjs/react/hooks/useStampRally/utils.js.map +1 -1
- package/lib/cjs/react/index.js +31 -31
- package/lib/cjs/react/index.js.map +1 -1
- package/lib/cjs/react/stores/useMapDataStore.js +47 -62
- package/lib/cjs/react/stores/useMapDataStore.js.map +1 -1
- package/lib/cjs/react/stores/useMetaAtlasStore.js +27 -40
- package/lib/cjs/react/stores/useMetaAtlasStore.js.map +1 -1
- package/lib/esm/index.js +3 -7
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js +4 -3
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js +14 -12
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/3DMap/MainMap.js +204 -200
- package/lib/esm/meta-atlas-sdk/3DMap/MainMap.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js +6 -6
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js +4 -3
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js +53 -42
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js +18 -16
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js +3 -3
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js +73 -79
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js +16 -15
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/customerLayer.js +4 -1
- package/lib/esm/meta-atlas-sdk/customerLayer.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js +148 -124
- package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/utils/helpers.js +4 -2
- package/lib/esm/meta-atlas-sdk/utils/helpers.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/utils/local-storage.js +6 -1
- package/lib/esm/meta-atlas-sdk/utils/local-storage.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js +115 -109
- package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
- package/lib/esm/react/MetaAtlasMap.js +120 -0
- package/lib/esm/react/MetaAtlasMap.js.map +1 -0
- package/lib/esm/react/hooks/useDrawing/index.js +2 -2
- package/lib/esm/react/hooks/useDrawing/index.js.map +1 -1
- package/lib/esm/react/hooks/useFocus/index.js +4 -3
- package/lib/esm/react/hooks/useFocus/index.js.map +1 -1
- package/lib/esm/react/hooks/useMapEvents/index.js +9 -6
- package/lib/esm/react/hooks/useMapEvents/index.js.map +1 -1
- package/lib/esm/react/hooks/useMapOverlays/index.js +2 -2
- package/lib/esm/react/hooks/useMapOverlays/index.js.map +1 -1
- package/lib/esm/react/hooks/useMetaAtlas/index.js +162 -60
- package/lib/esm/react/hooks/useMetaAtlas/index.js.map +1 -1
- package/lib/esm/react/hooks/useMetaAtlas.js +162 -60
- package/lib/esm/react/hooks/useMetaAtlas.js.map +1 -1
- package/lib/esm/react/hooks/useRouting/index.js +2 -2
- package/lib/esm/react/hooks/useRouting/index.js.map +1 -1
- package/lib/esm/react/hooks/useSearch/index.js +2 -2
- package/lib/esm/react/hooks/useSearch/index.js.map +1 -1
- package/lib/esm/react/hooks/useStampRally/index.js +15 -12
- package/lib/esm/react/hooks/useStampRally/index.js.map +1 -1
- package/lib/esm/react/hooks/useStampRally/utils.js +1 -1
- package/lib/esm/react/hooks/useStampRally/utils.js.map +1 -1
- package/lib/esm/react/index.js +11 -15
- package/lib/esm/react/index.js.map +1 -1
- package/lib/esm/react/stores/useMapDataStore.js +17 -21
- package/lib/esm/react/stores/useMapDataStore.js.map +1 -1
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.d.ts +30 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.d.ts.map +1 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.d.ts +5 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.d.ts.map +1 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.d.ts +21 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.d.ts.map +1 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.d.ts +27 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.d.ts.map +1 -0
- package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.d.ts +18 -0
- package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.d.ts.map +1 -0
- package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.d.ts +37 -0
- package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.d.ts.map +1 -0
- package/package.json +10 -7
|
@@ -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 : {
|
|
23
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function
|
|
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" ==
|
|
35
|
-
function _toPrimitive(t, r) { if ("object" !=
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
41
|
-
turf.coordEach(feature,
|
|
33
|
+
let matchIndex = -1;
|
|
34
|
+
turf.coordEach(feature, (currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) => {
|
|
42
35
|
if (matchIndex === -1) {
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
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,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
88
|
-
|
|
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 (
|
|
114
|
-
for (
|
|
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
|
-
|
|
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 (
|
|
125
|
-
|
|
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
|
-
|
|
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(
|
|
147
|
-
|
|
148
|
-
|
|
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(
|
|
151
|
-
|
|
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
|
-
|
|
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 (
|
|
161
|
-
|
|
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 (
|
|
173
|
-
|
|
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 (
|
|
182
|
-
|
|
183
|
-
|
|
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
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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
|
-
|
|
189
|
+
const DEFAULT_DIMENSION = exports.DEFAULT_DIMENSION = 'where.singapore';
|
|
197
190
|
function getPortalEdgeData(portalLinks) {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
cost
|
|
203
|
-
direction
|
|
204
|
-
wheelchair
|
|
205
|
-
description
|
|
206
|
-
|
|
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
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
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
|
|
211
|
+
allEdgeLines.push(...edge.lines);
|
|
220
212
|
}
|
|
221
213
|
};
|
|
222
|
-
|
|
223
|
-
|
|
214
|
+
const addNode = (mapObjectId, links) => {
|
|
215
|
+
const edge = (0, _mapObjectsHelper.getEdge)(mapObjectId);
|
|
224
216
|
if (edge && edge.lines) {
|
|
225
|
-
|
|
226
|
-
links
|
|
217
|
+
const portal = _objectSpread(_objectSpread({}, edge), {}, {
|
|
218
|
+
links
|
|
227
219
|
});
|
|
228
220
|
portalEdgeData[mapObjectId] = portal;
|
|
229
|
-
allEdgeLines.push
|
|
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
|
-
|
|
227
|
+
const escalatorGraph = new _graphlib.Graph();
|
|
236
228
|
if (!(0, _lodash.isEmpty)(portalLinks)) {
|
|
237
|
-
Object.keys(portalLinks).forEach(
|
|
238
|
-
|
|
239
|
-
type
|
|
240
|
-
links
|
|
229
|
+
Object.keys(portalLinks).forEach(anchorId => {
|
|
230
|
+
const {
|
|
231
|
+
type,
|
|
232
|
+
links
|
|
233
|
+
} = portalLinks[anchorId];
|
|
241
234
|
if (type !== _interfaces.PortalType.escalator) {
|
|
242
|
-
|
|
243
|
-
for (
|
|
244
|
-
|
|
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
|
-
|
|
249
|
-
for (
|
|
250
|
-
|
|
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
|
-
|
|
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 (
|
|
274
|
-
|
|
275
|
-
if (!escalatorGraph.hasNode(
|
|
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:
|
|
270
|
+
where: link.taxonomy1Path
|
|
278
271
|
});
|
|
279
272
|
}
|
|
280
|
-
if (!escalatorGraph.hasEdge(anchorId,
|
|
281
|
-
escalatorGraph.setEdge(anchorId,
|
|
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
|
-
|
|
290
|
-
|
|
291
|
-
components.forEach(
|
|
292
|
-
|
|
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 (
|
|
296
|
-
|
|
297
|
-
for (
|
|
298
|
-
|
|
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
|
-
|
|
293
|
+
let edgeData = {
|
|
301
294
|
cost: 120,
|
|
302
295
|
direction: 2,
|
|
303
296
|
wheelchair: true
|
|
304
297
|
};
|
|
305
|
-
|
|
306
|
-
|
|
298
|
+
const nodeEdges = graph.nodeEdges(node1);
|
|
299
|
+
let isParallelLink = false;
|
|
307
300
|
if (nodeEdges && nodeEdges.length > 0) {
|
|
308
|
-
for (
|
|
309
|
-
|
|
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
|
-
|
|
305
|
+
const nodeToUse = nodeEdge.v === node1 ? nodeEdge.w : nodeEdge.v;
|
|
313
306
|
if (graph.hasEdge(nodeToUse, node2)) {
|
|
314
|
-
|
|
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 (
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
for (
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
if ('isParallel' in
|
|
343
|
-
graph.removeEdge(
|
|
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
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
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
|
-
|
|
359
|
-
cost
|
|
360
|
-
direction
|
|
361
|
-
wheelchair
|
|
362
|
-
pathFeatures
|
|
363
|
-
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
|
|
361
|
+
allEdgeLines.push(...edge.lines);
|
|
367
362
|
}
|
|
368
363
|
};
|
|
369
|
-
|
|
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
|
-
|
|
375
|
-
for (
|
|
376
|
-
|
|
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
|
-
|
|
375
|
+
const portal = addNode(escalatorEdge.v, []);
|
|
381
376
|
if (portal) {
|
|
382
377
|
addLinkUsingGraph(portal, escalatorEdge);
|
|
383
378
|
}
|
|
384
379
|
} else {
|
|
385
|
-
|
|
386
|
-
addLinkUsingGraph(
|
|
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
|
-
|
|
397
|
-
|
|
391
|
+
const allEdgeLines = [];
|
|
392
|
+
const portalEdgeData = {};
|
|
398
393
|
|
|
399
394
|
// eslint-disable-next-line no-restricted-syntax
|
|
400
|
-
for (
|
|
395
|
+
for (const portalId in allPortalEdgeData) {
|
|
401
396
|
if (allPortalEdgeData[portalId].where.includes(whereDimension)) {
|
|
402
|
-
|
|
397
|
+
const portal = allPortalEdgeData[portalId];
|
|
403
398
|
portalEdgeData[portalId] = portal;
|
|
404
|
-
allEdgeLines.push
|
|
405
|
-
portal.links.forEach(
|
|
406
|
-
allEdgeLines.push
|
|
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
|
-
|
|
417
|
-
|
|
418
|
-
portalIdList.forEach(
|
|
411
|
+
const allEdgeLines = [];
|
|
412
|
+
const portalEdgeData = {};
|
|
413
|
+
portalIdList.forEach(portalId => {
|
|
419
414
|
if (portalId in allPortalEdgeData && portalIdList.has(allPortalEdgeData[portalId].id)) {
|
|
420
|
-
|
|
415
|
+
const portal = allPortalEdgeData[portalId];
|
|
421
416
|
portalEdgeData[portalId] = portal;
|
|
422
|
-
allEdgeLines.push
|
|
423
|
-
portal.links.forEach(
|
|
424
|
-
allEdgeLines.push
|
|
417
|
+
allEdgeLines.push(...portal.lines);
|
|
418
|
+
portal.links.forEach(link => {
|
|
419
|
+
allEdgeLines.push(...link.lines);
|
|
425
420
|
});
|
|
426
421
|
}
|
|
427
422
|
});
|