@wemap/osm 3.1.3 → 3.1.5
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 +4 -4
- package/src/osrm/OsrmUtils.js +4 -4
- package/src/osrm/OsrmUtils.spec.js +49 -16
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"directory": "packages/osm"
|
|
12
12
|
},
|
|
13
13
|
"name": "@wemap/osm",
|
|
14
|
-
"version": "3.1.
|
|
14
|
+
"version": "3.1.5",
|
|
15
15
|
"bugs": {
|
|
16
16
|
"url": "https://github.com/wemap/wemap-modules-js/issues"
|
|
17
17
|
},
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
],
|
|
27
27
|
"license": "ISC",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@wemap/geo": "^3.
|
|
30
|
-
"@wemap/graph": "^3.
|
|
29
|
+
"@wemap/geo": "^3.1.4",
|
|
30
|
+
"@wemap/graph": "^3.1.4",
|
|
31
31
|
"@wemap/logger": "^3.0.0",
|
|
32
32
|
"lodash.isnumber": "^3.0.3",
|
|
33
33
|
"sax": "^1.2.4"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "3b3a9809debd83f27cdcf07152569ee64af7f867"
|
|
36
36
|
}
|
package/src/osrm/OsrmUtils.js
CHANGED
|
@@ -238,12 +238,12 @@ class OsrmUtils {
|
|
|
238
238
|
} = jsonStep.wemap.nextEdgeData;
|
|
239
239
|
if (type === 'node') {
|
|
240
240
|
firstEdge.data = new OsmNode(id, OsrmUtils.jsonToCoordinates(coords), tags);
|
|
241
|
-
} else
|
|
241
|
+
} else {
|
|
242
|
+
// if (type === 'way')
|
|
242
243
|
firstEdge.data = new OsmWay(id, tags);
|
|
243
244
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}
|
|
245
|
+
|
|
246
|
+
firstEdge.data.level = firstEdge.level;
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
249
|
|
|
@@ -12,6 +12,7 @@ import OsmRouter from '../network/OsmRouter';
|
|
|
12
12
|
import OsmNetwork from '../network/OsmNetwork';
|
|
13
13
|
import OsrmUtils from './OsrmUtils';
|
|
14
14
|
import OsmNode from '../model/OsmNode';
|
|
15
|
+
import OsmWay from '../model/OsmWay';
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
const load = fileName => {
|
|
@@ -26,7 +27,8 @@ const load = fileName => {
|
|
|
26
27
|
};
|
|
27
28
|
};
|
|
28
29
|
|
|
29
|
-
let
|
|
30
|
+
let wemapIndoorItinerary, wemapIndoorJsonItinerary, wemapIndoorStart, wemapIndoorEnd;
|
|
31
|
+
let wemapOutdoorItinerary, wemapOutdoorJsonItinerary, wemapOutdoorStart, wemapOutdoorEnd;
|
|
30
32
|
|
|
31
33
|
describe('OsrmUtils - itineraryToOsrmJson', () => {
|
|
32
34
|
|
|
@@ -36,13 +38,13 @@ describe('OsrmUtils - itineraryToOsrmJson', () => {
|
|
|
36
38
|
network, router
|
|
37
39
|
} = load('bureaux-wemap-montpellier-network.osm');
|
|
38
40
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const itinerary = router.getShortestPath(
|
|
42
|
-
|
|
41
|
+
wemapIndoorStart = new Coordinates(43.6092754, 3.8842306, null, new Level(2));
|
|
42
|
+
wemapIndoorEnd = new Coordinates(43.6092602, 3.8842669, null, new Level(1));
|
|
43
|
+
const itinerary = router.getShortestPath(wemapIndoorStart, wemapIndoorEnd);
|
|
44
|
+
wemapIndoorItinerary = itinerary;
|
|
43
45
|
|
|
44
46
|
const osrmJson = OsrmUtils.itineraryToOsrmJson(itinerary);
|
|
45
|
-
|
|
47
|
+
wemapIndoorJsonItinerary = osrmJson;
|
|
46
48
|
const itinerarySteps = itinerary.steps;
|
|
47
49
|
|
|
48
50
|
const {
|
|
@@ -133,8 +135,12 @@ describe('OsrmUtils - itineraryToOsrmJson', () => {
|
|
|
133
135
|
const end = network.getNodeByName('p3');
|
|
134
136
|
|
|
135
137
|
const itinerary = router.getShortestPath(start, end);
|
|
136
|
-
expect(() => OsrmUtils.itineraryToOsrmJson(itinerary)).not.throw(Error);
|
|
137
138
|
|
|
139
|
+
wemapOutdoorJsonItinerary = OsrmUtils.itineraryToOsrmJson(itinerary);
|
|
140
|
+
|
|
141
|
+
wemapOutdoorStart = start.coords;
|
|
142
|
+
wemapOutdoorEnd = end.coords;
|
|
143
|
+
wemapOutdoorItinerary = itinerary;
|
|
138
144
|
});
|
|
139
145
|
|
|
140
146
|
it('Itinerary with modifiers', () => {
|
|
@@ -235,6 +241,31 @@ describe('OsrmUtils - createItineraryFromJson', () => {
|
|
|
235
241
|
});
|
|
236
242
|
|
|
237
243
|
|
|
244
|
+
it('Without levels (from itineraryToOsrmJson)', () => {
|
|
245
|
+
|
|
246
|
+
const itinerary = OsrmUtils.createItineraryFromJson(wemapOutdoorJsonItinerary,
|
|
247
|
+
wemapOutdoorStart, wemapOutdoorEnd);
|
|
248
|
+
|
|
249
|
+
expect(itinerary.nodes.length).equal(wemapOutdoorItinerary.nodes.length);
|
|
250
|
+
for (let i = 0; i < itinerary.nodes.length; i++) {
|
|
251
|
+
const itineraryNode = itinerary.nodes[i];
|
|
252
|
+
const wemapItineraryNode = wemapOutdoorItinerary.nodes[i];
|
|
253
|
+
expect(itineraryNode.coords.equalsTo(wemapItineraryNode.coords)).true;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
expect(itinerary.edges.length).equal(wemapOutdoorItinerary.edges.length);
|
|
257
|
+
for (let i = 0; i < itinerary.edges.length; i++) {
|
|
258
|
+
const itineraryEdge = itinerary.edges[i];
|
|
259
|
+
const wemapItineraryEdge = wemapOutdoorItinerary.edges[i];
|
|
260
|
+
const firstNode = wemapItineraryEdge[wemapOutdoorItinerary._edgesDirectionReversed[i] ? 'node2' : 'node1'];
|
|
261
|
+
const secondNode = wemapItineraryEdge[wemapOutdoorItinerary._edgesDirectionReversed[i] ? 'node1' : 'node2'];
|
|
262
|
+
expect(itineraryEdge.node1.coords.equalsTo(firstNode.coords)).true;
|
|
263
|
+
expect(itineraryEdge.node2.coords.equalsTo(secondNode.coords)).true;
|
|
264
|
+
expect(Level.equalsTo(itineraryEdge.level, wemapItineraryEdge.level)).true;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
});
|
|
268
|
+
|
|
238
269
|
it('Without steps (Montpellier outdoor)', () => {
|
|
239
270
|
|
|
240
271
|
const filePath = path.resolve(__dirname,
|
|
@@ -259,22 +290,22 @@ describe('OsrmUtils - createItineraryFromJson', () => {
|
|
|
259
290
|
|
|
260
291
|
it('With levels (from itineraryToOsrmJson)', () => {
|
|
261
292
|
|
|
262
|
-
const itinerary = OsrmUtils.createItineraryFromJson(
|
|
263
|
-
|
|
293
|
+
const itinerary = OsrmUtils.createItineraryFromJson(wemapIndoorJsonItinerary,
|
|
294
|
+
wemapIndoorStart, wemapIndoorEnd);
|
|
264
295
|
|
|
265
|
-
expect(itinerary.nodes.length).equal(
|
|
296
|
+
expect(itinerary.nodes.length).equal(wemapIndoorItinerary.nodes.length);
|
|
266
297
|
for (let i = 0; i < itinerary.nodes.length; i++) {
|
|
267
298
|
const itineraryNode = itinerary.nodes[i];
|
|
268
|
-
const wemapItineraryNode =
|
|
299
|
+
const wemapItineraryNode = wemapIndoorItinerary.nodes[i];
|
|
269
300
|
expect(itineraryNode.coords.equalsTo(wemapItineraryNode.coords)).true;
|
|
270
301
|
}
|
|
271
302
|
|
|
272
|
-
expect(itinerary.edges.length).equal(
|
|
303
|
+
expect(itinerary.edges.length).equal(wemapIndoorItinerary.edges.length);
|
|
273
304
|
for (let i = 0; i < itinerary.edges.length; i++) {
|
|
274
305
|
const itineraryEdge = itinerary.edges[i];
|
|
275
|
-
const wemapItineraryEdge =
|
|
276
|
-
const firstNode = wemapItineraryEdge[
|
|
277
|
-
const secondNode = wemapItineraryEdge[
|
|
306
|
+
const wemapItineraryEdge = wemapIndoorItinerary.edges[i];
|
|
307
|
+
const firstNode = wemapItineraryEdge[wemapIndoorItinerary._edgesDirectionReversed[i] ? 'node2' : 'node1'];
|
|
308
|
+
const secondNode = wemapItineraryEdge[wemapIndoorItinerary._edgesDirectionReversed[i] ? 'node1' : 'node2'];
|
|
278
309
|
expect(itineraryEdge.node1.coords.equalsTo(firstNode.coords)).true;
|
|
279
310
|
expect(itineraryEdge.node2.coords.equalsTo(secondNode.coords)).true;
|
|
280
311
|
expect(Level.equalsTo(itineraryEdge.level, wemapItineraryEdge.level)).true;
|
|
@@ -298,7 +329,7 @@ describe('OsrmUtils - createItineraryFromJson', () => {
|
|
|
298
329
|
|
|
299
330
|
});
|
|
300
331
|
|
|
301
|
-
describe('OsrmUtils - itineraryToOsrmJson - createItineraryFromJson -
|
|
332
|
+
describe('OsrmUtils - itineraryToOsrmJson - createItineraryFromJson - way/node', () => {
|
|
302
333
|
|
|
303
334
|
it('With levels (Bureaux Wemap)', () => {
|
|
304
335
|
|
|
@@ -311,10 +342,12 @@ describe('OsrmUtils - itineraryToOsrmJson - createItineraryFromJson - elevator',
|
|
|
311
342
|
const osrmJson = OsrmUtils.itineraryToOsrmJson(itinerary);
|
|
312
343
|
const jsonSteps = osrmJson.routes[0].legs[0].steps;
|
|
313
344
|
|
|
345
|
+
expect(jsonSteps[0].wemap.nextEdgeData.type).equals('way');
|
|
314
346
|
expect(jsonSteps[4].wemap.nextEdgeData.type).equals('node');
|
|
315
347
|
|
|
316
348
|
const itineraryBis = OsrmUtils.createItineraryFromJson(osrmJson, start, end);
|
|
317
349
|
expect(itineraryBis.steps[4].edges[0].data).instanceOf(OsmNode);
|
|
350
|
+
expect(itineraryBis.steps[0].edges[0].data).instanceOf(OsmWay);
|
|
318
351
|
});
|
|
319
352
|
});
|
|
320
353
|
|