@twinmatrix/spatialverse-sdk-web 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +9 -9
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js +213 -294
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js +43 -45
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/3DMap/MainMap.js +241 -271
- package/lib/cjs/meta-atlas-sdk/3DMap/MainMap.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js +167 -215
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js +28 -30
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js +876 -1188
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js +173 -163
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/interfaces.js +6 -6
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/interfaces.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js +6 -6
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routeLayers.js +3 -3
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routeLayers.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js +546 -620
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js +155 -160
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/customStyles.js +2 -2
- package/lib/cjs/meta-atlas-sdk/customStyles.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/customerLayer.js +15 -29
- package/lib/cjs/meta-atlas-sdk/customerLayer.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/customerLayerVariant.js +5 -5
- package/lib/cjs/meta-atlas-sdk/customerLayerVariant.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js +832 -1060
- package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/helpers.js +33 -50
- package/lib/cjs/meta-atlas-sdk/utils/helpers.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/local-storage.js +18 -36
- package/lib/cjs/meta-atlas-sdk/utils/local-storage.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/mapobjects-store.js +6 -6
- package/lib/cjs/meta-atlas-sdk/utils/mapobjects-store.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/routing-store.js +6 -6
- package/lib/cjs/meta-atlas-sdk/utils/routing-store.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/routing-visualizer/index.js +428 -556
- package/lib/cjs/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
- package/lib/cjs/react/MetaAtlasMap.js +127 -0
- package/lib/cjs/react/MetaAtlasMap.js.map +1 -0
- package/lib/cjs/react/hooks/useDrawing/index.js +17 -18
- package/lib/cjs/react/hooks/useDrawing/index.js.map +1 -1
- package/lib/cjs/react/hooks/useFocus/index.js +48 -55
- package/lib/cjs/react/hooks/useFocus/index.js.map +1 -1
- package/lib/cjs/react/hooks/useMapEvents/index.js +40 -50
- package/lib/cjs/react/hooks/useMapEvents/index.js.map +1 -1
- package/lib/cjs/react/hooks/useMapOverlays/index.js +20 -21
- package/lib/cjs/react/hooks/useMapOverlays/index.js.map +1 -1
- package/lib/cjs/react/hooks/useMetaAtlas/index.js +77 -95
- package/lib/cjs/react/hooks/useMetaAtlas/index.js.map +1 -1
- package/lib/cjs/react/hooks/useMetaAtlas.js +78 -96
- package/lib/cjs/react/hooks/useMetaAtlas.js.map +1 -1
- package/lib/cjs/react/hooks/useRouting/index.js +21 -20
- package/lib/cjs/react/hooks/useRouting/index.js.map +1 -1
- package/lib/cjs/react/hooks/useSearch/index.js +35 -34
- package/lib/cjs/react/hooks/useSearch/index.js.map +1 -1
- package/lib/cjs/react/hooks/useStampRally/index.js +30 -29
- package/lib/cjs/react/hooks/useStampRally/index.js.map +1 -1
- package/lib/cjs/react/hooks/useStampRally/utils.js +2 -2
- package/lib/cjs/react/hooks/useStampRally/utils.js.map +1 -1
- package/lib/cjs/react/index.js +31 -31
- package/lib/cjs/react/index.js.map +1 -1
- package/lib/cjs/react/stores/useMapDataStore.js +53 -64
- package/lib/cjs/react/stores/useMapDataStore.js.map +1 -1
- package/lib/cjs/react/stores/useMetaAtlasStore.js +27 -40
- package/lib/cjs/react/stores/useMetaAtlasStore.js.map +1 -1
- package/lib/esm/index.js +3 -7
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js +2 -1
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js +10 -9
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/3DMap/MainMap.js +2 -2
- package/lib/esm/meta-atlas-sdk/3DMap/MainMap.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js +3 -3
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js +4 -3
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js +22 -14
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js +8 -8
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js +3 -3
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js +18 -11
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js +4 -3
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/customerLayer.js +4 -1
- package/lib/esm/meta-atlas-sdk/customerLayer.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js +80 -61
- package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/utils/helpers.js +3 -1
- package/lib/esm/meta-atlas-sdk/utils/helpers.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js +19 -15
- package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
- package/lib/esm/react/MetaAtlasMap.js +120 -0
- package/lib/esm/react/MetaAtlasMap.js.map +1 -0
- package/lib/esm/react/hooks/useDrawing/index.js +2 -2
- package/lib/esm/react/hooks/useDrawing/index.js.map +1 -1
- package/lib/esm/react/hooks/useFocus/index.js +4 -3
- package/lib/esm/react/hooks/useFocus/index.js.map +1 -1
- package/lib/esm/react/hooks/useMapEvents/index.js +3 -3
- package/lib/esm/react/hooks/useMapEvents/index.js.map +1 -1
- package/lib/esm/react/hooks/useMapOverlays/index.js +2 -2
- package/lib/esm/react/hooks/useMapOverlays/index.js.map +1 -1
- package/lib/esm/react/hooks/useMetaAtlas/index.js +162 -60
- package/lib/esm/react/hooks/useMetaAtlas/index.js.map +1 -1
- package/lib/esm/react/hooks/useMetaAtlas.js +162 -60
- package/lib/esm/react/hooks/useMetaAtlas.js.map +1 -1
- package/lib/esm/react/hooks/useRouting/index.js +2 -2
- package/lib/esm/react/hooks/useRouting/index.js.map +1 -1
- package/lib/esm/react/hooks/useSearch/index.js +2 -2
- package/lib/esm/react/hooks/useSearch/index.js.map +1 -1
- package/lib/esm/react/hooks/useStampRally/index.js +8 -7
- package/lib/esm/react/hooks/useStampRally/index.js.map +1 -1
- package/lib/esm/react/index.js +11 -15
- package/lib/esm/react/index.js.map +1 -1
- package/package.json +9 -6
|
@@ -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 : {
|
|
23
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
41
|
-
turf.coordEach(feature,
|
|
28
|
+
let matchIndex = -1;
|
|
29
|
+
turf.coordEach(feature, (currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) => {
|
|
42
30
|
if (matchIndex === -1) {
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
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,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
88
|
-
|
|
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 (
|
|
114
|
-
for (
|
|
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
|
-
|
|
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 (
|
|
125
|
-
|
|
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
|
-
|
|
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(
|
|
147
|
-
|
|
148
|
-
|
|
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(
|
|
151
|
-
|
|
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
|
-
|
|
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 (
|
|
161
|
-
|
|
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 (
|
|
173
|
-
|
|
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 (
|
|
182
|
-
|
|
183
|
-
|
|
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
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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
|
-
|
|
184
|
+
const DEFAULT_DIMENSION = exports.DEFAULT_DIMENSION = 'where.singapore';
|
|
197
185
|
function getPortalEdgeData(portalLinks) {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
cost
|
|
203
|
-
direction
|
|
204
|
-
wheelchair
|
|
205
|
-
description
|
|
206
|
-
|
|
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
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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
|
|
207
|
+
allEdgeLines.push(...edge.lines);
|
|
220
208
|
}
|
|
221
209
|
};
|
|
222
|
-
|
|
223
|
-
|
|
210
|
+
const addNode = (mapObjectId, links) => {
|
|
211
|
+
const edge = (0, _mapObjectsHelper.getEdge)(mapObjectId);
|
|
224
212
|
if (edge && edge.lines) {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
213
|
+
const portal = {
|
|
214
|
+
...edge,
|
|
215
|
+
links
|
|
216
|
+
};
|
|
228
217
|
portalEdgeData[mapObjectId] = portal;
|
|
229
|
-
allEdgeLines.push
|
|
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
|
-
|
|
224
|
+
const escalatorGraph = new _graphlib.Graph();
|
|
236
225
|
if (!(0, _lodash.isEmpty)(portalLinks)) {
|
|
237
|
-
Object.keys(portalLinks).forEach(
|
|
238
|
-
|
|
239
|
-
type
|
|
240
|
-
links
|
|
226
|
+
Object.keys(portalLinks).forEach(anchorId => {
|
|
227
|
+
const {
|
|
228
|
+
type,
|
|
229
|
+
links
|
|
230
|
+
} = portalLinks[anchorId];
|
|
241
231
|
if (type !== _interfaces.PortalType.escalator) {
|
|
242
|
-
|
|
243
|
-
for (
|
|
244
|
-
|
|
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
|
-
|
|
249
|
-
for (
|
|
250
|
-
|
|
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
|
-
|
|
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 (
|
|
274
|
-
|
|
275
|
-
if (!escalatorGraph.hasNode(
|
|
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:
|
|
267
|
+
where: link.taxonomy1Path
|
|
278
268
|
});
|
|
279
269
|
}
|
|
280
|
-
if (!escalatorGraph.hasEdge(anchorId,
|
|
281
|
-
escalatorGraph.setEdge(anchorId,
|
|
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
|
-
|
|
290
|
-
|
|
291
|
-
components.forEach(
|
|
292
|
-
|
|
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 (
|
|
296
|
-
|
|
297
|
-
for (
|
|
298
|
-
|
|
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
|
-
|
|
292
|
+
let edgeData = {
|
|
301
293
|
cost: 120,
|
|
302
294
|
direction: 2,
|
|
303
295
|
wheelchair: true
|
|
304
296
|
};
|
|
305
|
-
|
|
306
|
-
|
|
297
|
+
const nodeEdges = graph.nodeEdges(node1);
|
|
298
|
+
let isParallelLink = false;
|
|
307
299
|
if (nodeEdges && nodeEdges.length > 0) {
|
|
308
|
-
for (
|
|
309
|
-
|
|
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
|
-
|
|
304
|
+
const nodeToUse = nodeEdge.v === node1 ? nodeEdge.w : nodeEdge.v;
|
|
313
305
|
if (graph.hasEdge(nodeToUse, node2)) {
|
|
314
|
-
|
|
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 (
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
for (
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
if ('isParallel' in
|
|
343
|
-
graph.removeEdge(
|
|
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
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
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
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
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
|
|
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
|
});
|