@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
|
@@ -3,47 +3,46 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
exports.default = void 0;
|
|
7
7
|
var _ngraph = require("ngraph.path");
|
|
8
8
|
var _ngraph2 = _interopRequireDefault(require("ngraph.graph"));
|
|
9
9
|
var _helpers = require("@turf/helpers");
|
|
10
10
|
var turf = _interopRequireWildcard(require("@turf/turf"));
|
|
11
11
|
var _lodash = require("lodash");
|
|
12
|
-
var _interfaces = require("./interfaces");
|
|
13
|
-
var _mapObjectsHelper = require("./mapObjectsHelper");
|
|
14
|
-
var _routingHelpers = require("./routing-helpers");
|
|
15
|
-
var _utils = require("./utils");
|
|
16
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function
|
|
17
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /* eslint-disable guard-for-in */ /* eslint-disable no-restricted-syntax */ // import turfDistance from '@turf/distance';
|
|
12
|
+
var _interfaces = require("./interfaces.js");
|
|
13
|
+
var _mapObjectsHelper = require("./mapObjectsHelper.js");
|
|
14
|
+
var _routingHelpers = require("./routing-helpers.js");
|
|
15
|
+
var _utils = require("./utils.js");
|
|
16
|
+
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); }
|
|
17
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
|
+
/* eslint-disable guard-for-in */
|
|
19
|
+
/* eslint-disable no-restricted-syntax */
|
|
20
|
+
|
|
21
|
+
// import turfDistance from '@turf/distance';
|
|
22
|
+
|
|
24
23
|
/* eslint-disable @typescript-eslint/no-shadow */
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
const RoutingCore = function () {
|
|
26
|
+
let wheelChairAccessibleRouteOnly = true;
|
|
27
|
+
let startNode;
|
|
28
|
+
let endNode;
|
|
29
|
+
let changeZoneCheckEnabled = true;
|
|
30
|
+
let runIntersection = false;
|
|
31
|
+
let portalData = {
|
|
33
32
|
edgeData: {},
|
|
34
33
|
lines: []
|
|
35
34
|
};
|
|
36
35
|
function addVertex(graph, coords, mapObjectId, where, what, zone) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
let updateMapObjectId = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
37
|
+
const vertexName = `${coords.toString()},${where}`;
|
|
38
|
+
let vertex = graph.getNode(vertexName);
|
|
40
39
|
if (vertex === undefined) {
|
|
41
|
-
|
|
42
|
-
mapObjectId
|
|
43
|
-
coords
|
|
44
|
-
where
|
|
45
|
-
what
|
|
46
|
-
zone
|
|
40
|
+
const data = {
|
|
41
|
+
mapObjectId,
|
|
42
|
+
coords,
|
|
43
|
+
where,
|
|
44
|
+
what,
|
|
45
|
+
zone,
|
|
47
46
|
zoneUnionVertex: false
|
|
48
47
|
};
|
|
49
48
|
vertex = graph.addNode(vertexName, data);
|
|
@@ -57,38 +56,40 @@ var RoutingCore = function () {
|
|
|
57
56
|
return vertex;
|
|
58
57
|
}
|
|
59
58
|
function addLink(graph, vertex1, vertex2, data) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
const {
|
|
60
|
+
cost,
|
|
61
|
+
description
|
|
62
|
+
} = data;
|
|
63
|
+
const timeInSeconds = data.isPortal ? cost / _interfaces.WALK_SPEED : cost;
|
|
63
64
|
if (!wheelChairAccessibleRouteOnly || wheelChairAccessibleRouteOnly && data.wheelChairAccesible) {
|
|
64
65
|
graph.addLink(vertex1.id, vertex2.id, {
|
|
65
66
|
weight: timeInSeconds,
|
|
66
|
-
cost
|
|
67
|
-
description
|
|
67
|
+
cost,
|
|
68
|
+
description
|
|
68
69
|
});
|
|
69
70
|
}
|
|
70
71
|
}
|
|
71
72
|
function getDistance(coords1, coords2) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
const point1 = (0, _helpers.point)(coords1);
|
|
74
|
+
const point2 = (0, _helpers.point)(coords2);
|
|
75
|
+
const distance = turf.distance(point1, point2, {
|
|
75
76
|
units: 'meters'
|
|
76
77
|
});
|
|
77
78
|
return distance;
|
|
78
79
|
}
|
|
79
80
|
function addEdgeToGraph(graph, edge) {
|
|
80
|
-
|
|
81
|
+
const node = edge;
|
|
81
82
|
if (node) {
|
|
82
|
-
|
|
83
|
-
for (
|
|
84
|
-
|
|
83
|
+
const vertex = addVertex(graph, node.coords, node.id, node.where, node.what, node.zone, true);
|
|
84
|
+
for (let index = 0; index < node.lines.length; index += 1) {
|
|
85
|
+
const line = node.lines[index];
|
|
85
86
|
// add edges for coord pairs
|
|
86
|
-
|
|
87
|
-
for (
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
const coords = turf.getCoords(line);
|
|
88
|
+
for (let i = 0; i < coords.length - 1; i += 1) {
|
|
89
|
+
const vertex1 = addVertex(graph, coords[i], 'vertex', node.where, _interfaces.RouteDimension.Edge, line.properties.zone);
|
|
90
|
+
const vertex2 = addVertex(graph, coords[i + 1], 'vertex', node.where, _interfaces.RouteDimension.Edge, line.properties.zone);
|
|
90
91
|
if (vertex1.id !== vertex2.id) {
|
|
91
|
-
|
|
92
|
+
const distance = getDistance(coords[i], coords[i + 1]);
|
|
92
93
|
if (line.properties.direction === _interfaces.LineDirection.Forward || line.properties.direction === _interfaces.LineDirection.TwoWay) {
|
|
93
94
|
addLink(graph, vertex1, vertex2, {
|
|
94
95
|
wheelChairAccesible: line.properties.wheelchair,
|
|
@@ -113,21 +114,23 @@ var RoutingCore = function () {
|
|
|
113
114
|
return undefined;
|
|
114
115
|
}
|
|
115
116
|
function addNetworkToGraph(graph, networkFeatures) {
|
|
116
|
-
for (
|
|
117
|
-
|
|
117
|
+
for (let index = 0; index < networkFeatures.length; index += 1) {
|
|
118
|
+
const feature = networkFeatures[index];
|
|
118
119
|
if (feature.geometry.type === 'LineString') {
|
|
119
120
|
// get line
|
|
120
|
-
|
|
121
|
+
const lineCoords = turf.getCoords(feature);
|
|
121
122
|
if (feature.properties) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
const where = feature.properties.dimension_where;
|
|
124
|
+
const what = _interfaces.RouteDimension.Network; // feature.properties.dimension_what;
|
|
125
|
+
const {
|
|
126
|
+
zone
|
|
127
|
+
} = feature.properties;
|
|
125
128
|
// add edges for coord pairs
|
|
126
|
-
for (
|
|
127
|
-
|
|
128
|
-
|
|
129
|
+
for (let i = 0; i < lineCoords.length - 1; i += 1) {
|
|
130
|
+
const vertex1 = addVertex(graph, lineCoords[i], 'vertex', where, what, zone, true);
|
|
131
|
+
const vertex2 = addVertex(graph, lineCoords[i + 1], 'vertex', where, what, zone, true);
|
|
129
132
|
if (vertex1.id !== vertex2.id) {
|
|
130
|
-
|
|
133
|
+
const distance = getDistance(lineCoords[i], lineCoords[i + 1]);
|
|
131
134
|
if (feature.properties.direction === _interfaces.LineDirection.Forward || feature.properties.direction === _interfaces.LineDirection.TwoWay) {
|
|
132
135
|
addLink(graph, vertex1, vertex2, {
|
|
133
136
|
wheelChairAccesible: feature.properties.wheelchair,
|
|
@@ -151,41 +154,45 @@ var RoutingCore = function () {
|
|
|
151
154
|
}
|
|
152
155
|
}
|
|
153
156
|
function addVertexByEdge(graph, edge) {
|
|
154
|
-
|
|
157
|
+
const node = edge;
|
|
155
158
|
if (node === undefined) {
|
|
156
159
|
return undefined;
|
|
157
160
|
}
|
|
158
161
|
return addVertex(graph, node.coords, node.id, node.where, node.what, node.zone, true);
|
|
159
162
|
}
|
|
160
163
|
function addPortalLinksToGraph(graph, portalEdgeData) {
|
|
161
|
-
for (
|
|
162
|
-
|
|
163
|
-
for (
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
for (const mapObjectId1 in portalEdgeData) {
|
|
165
|
+
const portal = portalEdgeData[mapObjectId1];
|
|
166
|
+
for (let index = 0; index < portal.links.length; index += 1) {
|
|
167
|
+
const portalLink = portal.links[index];
|
|
168
|
+
let {
|
|
169
|
+
cost
|
|
170
|
+
} = portalLink;
|
|
166
171
|
cost = (0, _lodash.toInteger)(cost);
|
|
167
172
|
// if (cost <= 1) {
|
|
168
173
|
// cost = portalWeight;
|
|
169
174
|
// }
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
+
const {
|
|
176
|
+
direction,
|
|
177
|
+
wheelchair,
|
|
178
|
+
description
|
|
179
|
+
} = portalLink;
|
|
180
|
+
const portal1 = addVertexByEdge(graph, portal);
|
|
181
|
+
const portal2 = addVertexByEdge(graph, portalLink);
|
|
175
182
|
if (portal1 !== undefined && portal2 !== undefined && portal1.id !== portal2.id) {
|
|
176
183
|
if (direction === _interfaces.LineDirection.Forward || direction === _interfaces.LineDirection.TwoWay) {
|
|
177
184
|
addLink(graph, portal1, portal2, {
|
|
178
185
|
wheelChairAccesible: wheelchair,
|
|
179
|
-
cost
|
|
180
|
-
description
|
|
186
|
+
cost,
|
|
187
|
+
description,
|
|
181
188
|
isPortal: true
|
|
182
189
|
});
|
|
183
190
|
}
|
|
184
191
|
if (direction === _interfaces.LineDirection.Backward || direction === _interfaces.LineDirection.TwoWay) {
|
|
185
192
|
addLink(graph, portal2, portal1, {
|
|
186
193
|
wheelChairAccesible: wheelchair,
|
|
187
|
-
cost
|
|
188
|
-
description
|
|
194
|
+
cost,
|
|
195
|
+
description,
|
|
189
196
|
isPortal: true
|
|
190
197
|
});
|
|
191
198
|
}
|
|
@@ -214,44 +221,44 @@ var RoutingCore = function () {
|
|
|
214
221
|
return {};
|
|
215
222
|
} // if no path found
|
|
216
223
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
for (
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
224
|
+
const startNode = source;
|
|
225
|
+
const endNode = destination;
|
|
226
|
+
const segments = [];
|
|
227
|
+
let segmentStartVertexData = vertices[0].data;
|
|
228
|
+
const geojsonPaths = [initLineString(vertices[0])];
|
|
229
|
+
for (let i = 1; i < vertices.length; i += 1) {
|
|
230
|
+
const curVertex = vertices[i];
|
|
231
|
+
const prevVertex = vertices[i - 1];
|
|
232
|
+
const line = geojsonPaths[geojsonPaths.length - 1];
|
|
226
233
|
|
|
227
234
|
// if vertex is map object
|
|
228
235
|
if (curVertex.data.mapObjectId !== 'vertex' || curVertex.data.zoneUnionVertex) {
|
|
229
|
-
|
|
236
|
+
let segment;
|
|
230
237
|
if ((0, _routingHelpers.isPortalTaxonomy)(prevVertex.data.what) && (0, _routingHelpers.isPortalTaxonomy)(curVertex.data.what)) {
|
|
231
238
|
if (prevVertex.data.zone !== curVertex.data.zone) {
|
|
232
239
|
console.warn('A portal is triggering a change in zone');
|
|
233
240
|
}
|
|
234
241
|
|
|
235
242
|
// check if portal path is available to visualize
|
|
236
|
-
|
|
243
|
+
let portalPath;
|
|
237
244
|
if ((0, _routingHelpers.isMovingPortalTaxonomy)(prevVertex.data.what)) {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
245
|
+
const getPortalPath = function (portalEdgeData, curVertex, prevVertex) {
|
|
246
|
+
let invertStart = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
247
|
+
const prevVertexMapObjId = prevVertex.data.mapObjectId;
|
|
248
|
+
const set = new Set().add(prevVertexMapObjId);
|
|
249
|
+
const portalDataForSet = (0, _utils.filterPortalEdgeDataByList)(portalEdgeData, set);
|
|
243
250
|
if (portalDataForSet && portalDataForSet.edgeData[prevVertexMapObjId]) {
|
|
244
|
-
|
|
245
|
-
for (
|
|
246
|
-
|
|
247
|
-
if (
|
|
248
|
-
if (
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
251
|
+
const prevVertexPortalData = portalDataForSet.edgeData[prevVertexMapObjId];
|
|
252
|
+
for (let j = 0; j < prevVertexPortalData.links.length; j += 1) {
|
|
253
|
+
const link = prevVertexPortalData.links[j];
|
|
254
|
+
if (link.id === curVertex.data.mapObjectId) {
|
|
255
|
+
if (link.pathFeatures && link.pathFeatures.length > 0) {
|
|
256
|
+
const line = link.pathFeatures[0];
|
|
257
|
+
const start = invertStart === false ? prevVertex.data.coords : curVertex.data.coords;
|
|
258
|
+
const end = invertStart === false ? curVertex.data.coords : prevVertex.data.coords;
|
|
259
|
+
const distanceToStart = turf.distance(start, line.geometry.coordinates[0]);
|
|
260
|
+
const distanceToEnd = turf.distance(end, line.geometry.coordinates[0]);
|
|
261
|
+
const coordsToUse = distanceToStart < distanceToEnd ? line.geometry.coordinates : line.geometry.coordinates.slice().reverse();
|
|
255
262
|
return turf.lineString(coordsToUse);
|
|
256
263
|
}
|
|
257
264
|
}
|
|
@@ -264,9 +271,9 @@ var RoutingCore = function () {
|
|
|
264
271
|
}
|
|
265
272
|
|
|
266
273
|
// TODO: read description here
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
274
|
+
const link = graph.getLink(prevVertex.id, curVertex.id);
|
|
275
|
+
const cost = link ? link.data.cost ? link.data.cost : undefined : undefined;
|
|
276
|
+
const description = link ? link.data.description ? link.data.description : undefined : undefined;
|
|
270
277
|
segment = {
|
|
271
278
|
geojson: (0, _helpers.multiPoint)([prevVertex.data.coords, curVertex.data.coords], {
|
|
272
279
|
zone: curVertex.data.zone
|
|
@@ -275,15 +282,15 @@ var RoutingCore = function () {
|
|
|
275
282
|
startFloor: prevVertex.data.where,
|
|
276
283
|
endFloor: curVertex.data.where,
|
|
277
284
|
isPortal: true,
|
|
278
|
-
portalPath
|
|
279
|
-
cost
|
|
280
|
-
description
|
|
285
|
+
portalPath,
|
|
286
|
+
cost,
|
|
287
|
+
description
|
|
281
288
|
};
|
|
282
289
|
segments.push(segment);
|
|
283
290
|
segmentStartVertexData = curVertex.data;
|
|
284
291
|
} else {
|
|
285
|
-
|
|
286
|
-
if (curVertex.data.zoneUnionVertex && prevVertex && nextVertex &&
|
|
292
|
+
const nextVertex = i + 1 < vertices.length ? vertices[i + 1] : undefined;
|
|
293
|
+
if (curVertex.data.zoneUnionVertex && prevVertex && nextVertex && prevVertex?.data.zone === nextVertex?.data.zone) {
|
|
287
294
|
console.log('ignore zoneUnionVertex in segment');
|
|
288
295
|
} else {
|
|
289
296
|
segment = {
|
|
@@ -303,10 +310,10 @@ var RoutingCore = function () {
|
|
|
303
310
|
|
|
304
311
|
// same line
|
|
305
312
|
if (!((0, _routingHelpers.isPortalTaxonomy)(prevVertex.data.what) && (0, _routingHelpers.isPortalTaxonomy)(curVertex.data.what))) {
|
|
306
|
-
|
|
307
|
-
|
|
313
|
+
const link = graph.getLink(prevVertex.id, curVertex.id); // returns a link from 'hello' to 'world'
|
|
314
|
+
const cost = link ? link.data.cost ? link.data.cost : undefined : undefined;
|
|
308
315
|
line.geometry.coordinates.push(curVertex.data.coords);
|
|
309
|
-
line.properties.cost +=
|
|
316
|
+
line.properties.cost += cost;
|
|
310
317
|
} else {
|
|
311
318
|
// new line
|
|
312
319
|
if (line.geometry.coordinates.length < 2) {
|
|
@@ -317,24 +324,24 @@ var RoutingCore = function () {
|
|
|
317
324
|
|
|
318
325
|
// new line due to change in zone
|
|
319
326
|
if (curVertex.data.zoneUnionVertex) {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
if (
|
|
327
|
+
const prevVertex = i > 0 ? vertices[i - 1] : undefined;
|
|
328
|
+
const nextVertex = i + 1 < vertices.length ? vertices[i + 1] : undefined;
|
|
329
|
+
if (prevVertex && nextVertex && prevVertex?.data.zone === nextVertex?.data.zone) {
|
|
323
330
|
console.log('ignore zoneUnionVertex');
|
|
324
331
|
} else
|
|
325
332
|
// Use zone value of next vertex (when available) as current vertex is a common vertex and can have either of the zone values
|
|
326
|
-
if (
|
|
327
|
-
|
|
328
|
-
copyOfCurrentVertex.data.zone =
|
|
333
|
+
if (nextVertex) {
|
|
334
|
+
const copyOfCurrentVertex = (0, _lodash.cloneDeep)(curVertex);
|
|
335
|
+
copyOfCurrentVertex.data.zone = nextVertex.data.zone;
|
|
329
336
|
geojsonPaths.push(initLineString(copyOfCurrentVertex));
|
|
330
337
|
} else {
|
|
331
338
|
geojsonPaths.push(initLineString(curVertex));
|
|
332
339
|
}
|
|
333
340
|
}
|
|
334
341
|
}
|
|
335
|
-
|
|
336
|
-
startNode
|
|
337
|
-
endNode
|
|
342
|
+
const result = {
|
|
343
|
+
startNode,
|
|
344
|
+
endNode,
|
|
338
345
|
routes: segments,
|
|
339
346
|
distance: 0
|
|
340
347
|
};
|
|
@@ -342,18 +349,18 @@ var RoutingCore = function () {
|
|
|
342
349
|
}
|
|
343
350
|
function findPath(vertex1, vertex2, graph) {
|
|
344
351
|
// setup ngraph pathfinder
|
|
345
|
-
|
|
352
|
+
const pathFinder = (0, _ngraph.aStar)(graph, {
|
|
346
353
|
oriented: true,
|
|
347
|
-
distance
|
|
354
|
+
distance(fromNode, toNode, link) {
|
|
348
355
|
return link.data.weight;
|
|
349
356
|
},
|
|
350
|
-
blocked
|
|
357
|
+
blocked(fromNode, toNode, link) {
|
|
351
358
|
if (changeZoneCheckEnabled) {
|
|
352
|
-
|
|
359
|
+
const isZoneCrossing = fromNode?.data.zone !== toNode?.data.zone;
|
|
353
360
|
if (isZoneCrossing) {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
361
|
+
const parentWhereDimensionOfFromNode = (0, _utils.getParentDimension)(fromNode.data.where);
|
|
362
|
+
const parentWhereDimensionOfStartNode = (0, _utils.getParentDimension)(startNode.where);
|
|
363
|
+
const parentWhereDimensionOfToNode = (0, _utils.getParentDimension)(toNode.data.where);
|
|
357
364
|
if (parentWhereDimensionOfFromNode !== parentWhereDimensionOfStartNode && parentWhereDimensionOfToNode !== parentWhereDimensionOfStartNode) {
|
|
358
365
|
return true;
|
|
359
366
|
}
|
|
@@ -364,81 +371,84 @@ var RoutingCore = function () {
|
|
|
364
371
|
});
|
|
365
372
|
|
|
366
373
|
// get shortest path
|
|
367
|
-
|
|
374
|
+
const path = pathFinder.find(vertex1.id, vertex2.id).reverse();
|
|
368
375
|
return path;
|
|
369
376
|
}
|
|
370
377
|
function setupGraphAndFindPath(source, destination, portalEdgeData, networkData) {
|
|
371
378
|
// create ngraph graph
|
|
372
|
-
|
|
379
|
+
const graph = (0, _ngraph2.default)();
|
|
373
380
|
|
|
374
381
|
// add node & node lines to graph
|
|
375
|
-
|
|
376
|
-
|
|
382
|
+
const vertex1 = addEdgeToGraph(graph, source);
|
|
383
|
+
const vertex2 = addEdgeToGraph(graph, destination);
|
|
377
384
|
if (vertex1 && vertex2) {
|
|
378
385
|
// Add portal links
|
|
379
386
|
addPortalLinksToGraph(graph, portalEdgeData);
|
|
380
387
|
|
|
381
388
|
// add networks to graph
|
|
382
389
|
addNetworkToGraph(graph, networkData);
|
|
383
|
-
|
|
390
|
+
const path = findPath(vertex1, vertex2, graph);
|
|
384
391
|
// reconstruct path into geojson features
|
|
385
|
-
|
|
392
|
+
const geojsonPath = pathToFeatures(source, destination, path, graph);
|
|
386
393
|
return geojsonPath;
|
|
387
394
|
}
|
|
388
395
|
return {};
|
|
389
396
|
}
|
|
390
397
|
function getRouteWithAllPortals(source, destination) {
|
|
391
|
-
|
|
398
|
+
let start = performance.now();
|
|
392
399
|
|
|
393
400
|
// Load network data
|
|
394
|
-
|
|
401
|
+
const networkFeatures = (0, _mapObjectsHelper.getNetworkFeatures)(_utils.DEFAULT_DIMENSION);
|
|
395
402
|
console.log('time load: ', (performance.now() - start) / 1000);
|
|
396
403
|
start = performance.now();
|
|
397
|
-
|
|
398
|
-
|
|
404
|
+
const concatenatedEdgeFeatures = source.lines.concat(destination.lines, portalData.lines);
|
|
405
|
+
const concatenatedNetworkFeatures = networkFeatures;
|
|
399
406
|
if (runIntersection) (0, _utils.optimized)(concatenatedEdgeFeatures, concatenatedNetworkFeatures);
|
|
400
407
|
console.log('time network: ', (performance.now() - start) / 1000, networkFeatures.length);
|
|
401
408
|
return setupGraphAndFindPath(source, destination, portalData.edgeData, concatenatedNetworkFeatures);
|
|
402
409
|
}
|
|
403
410
|
function getRouteWithSpecificPortals(source, destination, routeWithAllAvailablePortals) {
|
|
404
|
-
|
|
405
|
-
for (
|
|
406
|
-
|
|
411
|
+
const portalsToUse = new Set();
|
|
412
|
+
for (let index = 0; routeWithAllAvailablePortals.routes && index < routeWithAllAvailablePortals.routes.length; index += 1) {
|
|
413
|
+
const segment = routeWithAllAvailablePortals.routes[index];
|
|
407
414
|
if (segment.isPortal) {
|
|
408
415
|
portalsToUse.add(segment.edges[0]);
|
|
409
416
|
portalsToUse.add(segment.edges[1]);
|
|
410
417
|
}
|
|
411
418
|
}
|
|
412
|
-
|
|
419
|
+
let start = performance.now();
|
|
413
420
|
// Load data
|
|
414
421
|
// Load network data
|
|
415
|
-
|
|
422
|
+
const networkFeatures = (0, _mapObjectsHelper.getNetworkFeatures)(_utils.DEFAULT_DIMENSION);
|
|
416
423
|
// Load portal data
|
|
417
|
-
|
|
424
|
+
const portalDataForList = (0, _utils.filterPortalEdgeDataByList)(portalData.edgeData, portalsToUse);
|
|
418
425
|
console.log('time load: ', (performance.now() - start) / 1000);
|
|
419
426
|
start = performance.now();
|
|
420
|
-
|
|
421
|
-
|
|
427
|
+
const concatenatedEdgeFeatures = source.lines.concat(destination.lines, portalDataForList.lines);
|
|
428
|
+
const concatenatedNetworkFeatures = networkFeatures;
|
|
422
429
|
if (runIntersection) (0, _utils.optimized)(concatenatedEdgeFeatures, concatenatedNetworkFeatures);
|
|
423
430
|
console.log('time network: ', (performance.now() - start) / 1000, networkFeatures.length);
|
|
424
431
|
return setupGraphAndFindPath(source, destination, portalDataForList.edgeData, concatenatedNetworkFeatures);
|
|
425
432
|
}
|
|
426
433
|
function getDirectRoute(source, destination) {
|
|
427
|
-
|
|
434
|
+
let start = performance.now();
|
|
428
435
|
// Load data
|
|
429
436
|
// Load network data
|
|
430
|
-
|
|
431
|
-
|
|
437
|
+
const networkFeaturesSourceNode = (0, _mapObjectsHelper.getNetworkFeatures)((0, _utils.getParentDimension)(source.where));
|
|
438
|
+
const networkFeaturesDestinationNode = (0, _mapObjectsHelper.getNetworkFeatures)((0, _utils.getParentDimension)(destination.where));
|
|
432
439
|
// Load portal data
|
|
433
|
-
|
|
434
|
-
|
|
440
|
+
const portalDataSourceNode = (0, _utils.filterPortalEdgeDataByWhere)(portalData.edgeData, (0, _utils.getParentDimension)(source.where));
|
|
441
|
+
const portalDataDestinationNode = (0, _utils.filterPortalEdgeDataByWhere)(portalData.edgeData, (0, _utils.getParentDimension)(destination.where));
|
|
435
442
|
console.log('time load: ', (performance.now() - start) / 1000);
|
|
436
443
|
start = performance.now();
|
|
437
|
-
|
|
438
|
-
|
|
444
|
+
const concatenatedEdgeFeatures = source.lines.concat(destination.lines, portalDataSourceNode.lines, portalDataDestinationNode.lines);
|
|
445
|
+
const concatenatedNetworkFeatures = networkFeaturesSourceNode.concat(networkFeaturesDestinationNode);
|
|
439
446
|
if (runIntersection) (0, _utils.optimized)(concatenatedEdgeFeatures, concatenatedNetworkFeatures);
|
|
440
447
|
console.log('time network: ', (performance.now() - start) / 1000, networkFeaturesSourceNode.length);
|
|
441
|
-
|
|
448
|
+
const portalEdgeData = {
|
|
449
|
+
...portalDataSourceNode.edgeData,
|
|
450
|
+
...portalDataDestinationNode.edgeData
|
|
451
|
+
};
|
|
442
452
|
return setupGraphAndFindPath(source, destination, portalEdgeData, concatenatedNetworkFeatures);
|
|
443
453
|
}
|
|
444
454
|
|
|
@@ -450,28 +460,28 @@ var RoutingCore = function () {
|
|
|
450
460
|
return {};
|
|
451
461
|
}
|
|
452
462
|
if (typeof mapObjectId1 !== 'string' || typeof mapObjectId2 !== 'string') runIntersection = true;
|
|
453
|
-
|
|
454
|
-
|
|
463
|
+
const node1 = (0, _mapObjectsHelper.getEdge)(mapObjectId1);
|
|
464
|
+
const node2 = (0, _mapObjectsHelper.getEdge)(mapObjectId2);
|
|
455
465
|
startNode = node1;
|
|
456
466
|
endNode = node2;
|
|
457
|
-
|
|
467
|
+
let start = performance.now();
|
|
458
468
|
portalData = (0, _mapObjectsHelper.getPortalDataForDimension)(_utils.DEFAULT_DIMENSION);
|
|
459
469
|
console.log('time portal load with extrapolation: ', (performance.now() - start) / 1000);
|
|
460
470
|
start = performance.now();
|
|
461
471
|
if (startNode && endNode) {
|
|
462
472
|
changeZoneCheckEnabled = true;
|
|
463
|
-
|
|
464
|
-
|
|
473
|
+
const runRouteIteration = () => {
|
|
474
|
+
const directRoute = getDirectRoute(startNode, endNode);
|
|
465
475
|
console.log('Direct route', directRoute);
|
|
466
476
|
if ((0, _lodash.isEmpty)(directRoute)) {
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
return
|
|
477
|
+
const routeWithAllPortals = getRouteWithAllPortals(startNode, endNode);
|
|
478
|
+
const finalRoute = getRouteWithSpecificPortals(startNode, endNode, routeWithAllPortals);
|
|
479
|
+
return finalRoute;
|
|
470
480
|
}
|
|
471
|
-
|
|
481
|
+
const finalRoute = getRouteWithSpecificPortals(startNode, endNode, directRoute);
|
|
472
482
|
return finalRoute;
|
|
473
483
|
};
|
|
474
|
-
|
|
484
|
+
let route = runRouteIteration();
|
|
475
485
|
if ((0, _lodash.isEmpty)(route)) {
|
|
476
486
|
changeZoneCheckEnabled = false;
|
|
477
487
|
route = runRouteIteration();
|
|
@@ -482,8 +492,8 @@ var RoutingCore = function () {
|
|
|
482
492
|
return {};
|
|
483
493
|
}
|
|
484
494
|
return {
|
|
485
|
-
getRoute
|
|
495
|
+
getRoute
|
|
486
496
|
};
|
|
487
497
|
}();
|
|
488
|
-
var _default = exports
|
|
498
|
+
var _default = exports.default = RoutingCore;
|
|
489
499
|
//# sourceMappingURL=index.js.map
|