@wemap/osm 3.0.0 → 3.1.0
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/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"directory": "packages/osm"
|
|
12
12
|
},
|
|
13
13
|
"name": "@wemap/osm",
|
|
14
|
-
"version": "3.
|
|
14
|
+
"version": "3.1.0",
|
|
15
15
|
"bugs": {
|
|
16
16
|
"url": "https://github.com/wemap/wemap-modules-js/issues"
|
|
17
17
|
},
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"lodash.isnumber": "^3.0.3",
|
|
33
33
|
"sax": "^1.2.4"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "65aa989226647982201e95ecafae68e2e48e85ae"
|
|
36
36
|
}
|
|
@@ -87,8 +87,9 @@ describe('OsmRouter - Multi-level itinerary', () => {
|
|
|
87
87
|
it('do not use stairs', () => {
|
|
88
88
|
const itineraryWithoutStairs = router.getShortestPath(itineraryStart, itineraryEnd, { useStairs: false });
|
|
89
89
|
expect(itineraryWithoutStairs.nodes.length).equal(11);
|
|
90
|
-
expect(itineraryWithoutStairs.nodes[6].data.
|
|
91
|
-
expect(itineraryWithoutStairs.nodes[7].data.
|
|
90
|
+
expect(itineraryWithoutStairs.nodes[6].data.isElevator).is.true;
|
|
91
|
+
expect(itineraryWithoutStairs.nodes[7].data.isElevator).is.true;
|
|
92
|
+
expect(itineraryWithoutStairs.edges[6].data.isElevator).is.true;
|
|
92
93
|
});
|
|
93
94
|
|
|
94
95
|
});
|
package/src/osrm/OsrmUtils.js
CHANGED
|
@@ -25,7 +25,7 @@ class OsrmUtils {
|
|
|
25
25
|
|
|
26
26
|
const {
|
|
27
27
|
nodes, length, nextEdgeData, nextBearing, previousBearing, angle, node,
|
|
28
|
-
duration, levelChange
|
|
28
|
+
duration, levelChange, edges
|
|
29
29
|
} = itinerarySteps[i];
|
|
30
30
|
|
|
31
31
|
const edgeData = i !== lastStepId ? nextEdgeData : itinerary.edges[lastStepId];
|
|
@@ -66,10 +66,17 @@ class OsrmUtils {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
if (i !== lastStepId) {
|
|
69
|
-
osrmStep.wemap.
|
|
69
|
+
osrmStep.wemap.nextEdgeData = {
|
|
70
70
|
id: nextEdgeData.id,
|
|
71
71
|
tags: nextEdgeData.tags
|
|
72
72
|
};
|
|
73
|
+
if (edges[0].data instanceof OsmNode) {
|
|
74
|
+
osrmStep.wemap.nextEdgeData.type = 'node';
|
|
75
|
+
osrmStep.wemap.nextEdgeData.coords = OsrmUtils.coordinatesToJson(edges[0].data.coords);
|
|
76
|
+
}
|
|
77
|
+
if (edges[0].data instanceof OsmWay) {
|
|
78
|
+
osrmStep.wemap.nextEdgeData.type = 'way';
|
|
79
|
+
}
|
|
73
80
|
}
|
|
74
81
|
|
|
75
82
|
// The first modifier is not mandatory by OSRM.
|
|
@@ -225,12 +232,18 @@ class OsrmUtils {
|
|
|
225
232
|
}
|
|
226
233
|
|
|
227
234
|
const firstEdge = step.edges[0];
|
|
228
|
-
if (jsonStep.wemap.
|
|
235
|
+
if (jsonStep.wemap.nextEdgeData && firstEdge) {
|
|
229
236
|
const {
|
|
230
|
-
id, tags
|
|
231
|
-
} = jsonStep.wemap.
|
|
232
|
-
|
|
233
|
-
|
|
237
|
+
coords, id, tags, type
|
|
238
|
+
} = jsonStep.wemap.nextEdgeData;
|
|
239
|
+
if (type === 'node') {
|
|
240
|
+
firstEdge.data = new OsmNode(id, OsrmUtils.jsonToCoordinates(coords), tags);
|
|
241
|
+
} else if (type === 'way') {
|
|
242
|
+
firstEdge.data = new OsmWay(id, tags);
|
|
243
|
+
}
|
|
244
|
+
if (firstEdge.data) {
|
|
245
|
+
firstEdge.data.level = firstEdge.level;
|
|
246
|
+
}
|
|
234
247
|
}
|
|
235
248
|
}
|
|
236
249
|
|
|
@@ -11,6 +11,7 @@ import OsmParser from '../model/OsmParser';
|
|
|
11
11
|
import OsmRouter from '../network/OsmRouter';
|
|
12
12
|
import OsmNetwork from '../network/OsmNetwork';
|
|
13
13
|
import OsrmUtils from './OsrmUtils';
|
|
14
|
+
import OsmNode from '../model/OsmNode';
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
const load = fileName => {
|
|
@@ -297,6 +298,26 @@ describe('OsrmUtils - createItineraryFromJson', () => {
|
|
|
297
298
|
|
|
298
299
|
});
|
|
299
300
|
|
|
301
|
+
describe('OsrmUtils - itineraryToOsrmJson - createItineraryFromJson - elevator', () => {
|
|
302
|
+
|
|
303
|
+
it('With levels (Bureaux Wemap)', () => {
|
|
304
|
+
|
|
305
|
+
const { router } = load('bureaux-wemap-montpellier-network.osm');
|
|
306
|
+
|
|
307
|
+
const start = new Coordinates(43.6092754, 3.8842306, null, new Level(2));
|
|
308
|
+
const end = new Coordinates(43.60949854, 3.88452048, null, new Level(0));
|
|
309
|
+
const itinerary = router.getShortestPath(start, end);
|
|
310
|
+
|
|
311
|
+
const osrmJson = OsrmUtils.itineraryToOsrmJson(itinerary);
|
|
312
|
+
const jsonSteps = osrmJson.routes[0].legs[0].steps;
|
|
313
|
+
|
|
314
|
+
expect(jsonSteps[4].wemap.nextEdgeData.type).equals('node');
|
|
315
|
+
|
|
316
|
+
const itineraryBis = OsrmUtils.createItineraryFromJson(osrmJson, start, end);
|
|
317
|
+
expect(itineraryBis.steps[4].edges[0].data).instanceOf(OsmNode);
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
|
|
300
321
|
describe('OsrmUtils - Output JSON', () => {
|
|
301
322
|
|
|
302
323
|
it('noRouteFoundJson', () => {
|