@wemap/osm 3.1.10 → 3.1.12

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.
@@ -0,0 +1,110 @@
1
+ {
2
+ "code": "Ok",
3
+ "routes": [
4
+ {
5
+ "geometry": {
6
+ "coordinates": [
7
+ [
8
+ 4.931728,
9
+ 44.799761
10
+ ],
11
+ [
12
+ 4.927543,
13
+ 44.799052
14
+ ],
15
+ [
16
+ 4.927543,
17
+ 44.799052
18
+ ],
19
+ [
20
+ 4.927385,
21
+ 44.799037
22
+ ],
23
+ [
24
+ 4.923283,
25
+ 44.798721
26
+ ]
27
+ ],
28
+ "type": "LineString"
29
+ },
30
+ "legs": [
31
+ {
32
+ "steps": [
33
+ {
34
+ "driving_side": "right",
35
+ "geometry": {
36
+ "coordinates": [
37
+ [
38
+ 4.931728,
39
+ 44.799761
40
+ ],
41
+ [
42
+ 4.927543,
43
+ 44.799052
44
+ ],
45
+ [
46
+ 4.927543,
47
+ 44.799052
48
+ ],
49
+ [
50
+ 4.927385,
51
+ 44.799037
52
+ ],
53
+ [
54
+ 4.923283,
55
+ 44.798721
56
+ ]
57
+ ],
58
+ "type": "LineString"
59
+ },
60
+ "mode": "walking",
61
+ "duration": 496.9,
62
+ "maneuver": {
63
+ "bearing_after": 264,
64
+ "type": "end of road",
65
+ "modifier": "left",
66
+ "bearing_before": 338,
67
+ "location": [
68
+ 4.931728,
69
+ 44.799761
70
+ ]
71
+ },
72
+ "weight": 496.9,
73
+ "distance": 689.7,
74
+ "name": "Route d'Ambonil"
75
+ },
76
+ {
77
+ "driving_side": "right",
78
+ "geometry": {
79
+ "coordinates": [
80
+ [
81
+ 4.931728,
82
+ 44.799761
83
+ ],
84
+ [
85
+ 4.931728,
86
+ 44.799761
87
+ ]
88
+ ]
89
+ },
90
+ "maneuver": {
91
+ "bearing_after": 0,
92
+ "type": "arrive",
93
+ "modifier": "left",
94
+ "bearing_before": 291,
95
+ "location": [
96
+ 4.556421,
97
+ 44.302754
98
+ ]
99
+ }
100
+ }
101
+ ]
102
+ }
103
+ ],
104
+ "distance": 75006.7,
105
+ "duration": 54016.6,
106
+ "weight_name": "duration",
107
+ "weight": 54016.6
108
+ }
109
+ ]
110
+ }
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "directory": "packages/osm"
12
12
  },
13
13
  "name": "@wemap/osm",
14
- "version": "3.1.10",
14
+ "version": "3.1.12",
15
15
  "bugs": {
16
16
  "url": "https://github.com/wemap/wemap-modules-js/issues"
17
17
  },
@@ -26,11 +26,12 @@
26
26
  ],
27
27
  "license": "ISC",
28
28
  "dependencies": {
29
- "@wemap/geo": "^3.1.9",
30
- "@wemap/graph": "^3.1.10",
29
+ "@wemap/geo": "^3.1.11",
30
+ "@wemap/graph": "^3.1.11",
31
31
  "@wemap/logger": "^3.0.0",
32
+ "@wemap/maths": "^3.1.11",
32
33
  "lodash.isnumber": "^3.0.3",
33
34
  "sax": "^1.2.4"
34
35
  },
35
- "gitHead": "2bba01343dd4507adc51cff378450d5369d124ea"
36
+ "gitHead": "a00b7441f2ee41da9b095f646aa2beaf1acef35f"
36
37
  }
@@ -159,6 +159,8 @@ class OsrmUtils {
159
159
  itinerary._steps = [];
160
160
  itinerary._nextStepsIndexes = [];
161
161
 
162
+ let currentNodeIndex = 0;
163
+
162
164
  for (let i = 0; i < jsonSteps.length; i++) {
163
165
  const jsonStep = jsonSteps[i];
164
166
 
@@ -181,13 +183,10 @@ class OsrmUtils {
181
183
  if (step.lastStep) {
182
184
  coordinates = [coordinates[0]];
183
185
  }
184
- coordinates.forEach(coords => {
185
- const wgs84 = OsrmUtils.jsonToCoordinates(coords);
186
- const node = itinerary.getNodeByCoords(wgs84);
187
- if (!node) {
188
- throw new Error('Cannot parse these step coordinates, '
189
- + 'they are not found in main itinerary: ' + wgs84.toString());
190
- }
186
+
187
+ for (const coords of coordinates) {
188
+
189
+ const node = itinerary.nodes[currentNodeIndex];
191
190
  step.nodes.push(node);
192
191
 
193
192
  const isFirstNode = coordinates[0] === coords;
@@ -204,7 +203,8 @@ class OsrmUtils {
204
203
  }
205
204
 
206
205
  previousNode = node;
207
- });
206
+ currentNodeIndex++;
207
+ }
208
208
 
209
209
  /**
210
210
  * Add common fields
@@ -248,6 +248,8 @@ class OsrmUtils {
248
248
  }
249
249
 
250
250
  itinerary._steps.push(step);
251
+
252
+ currentNodeIndex--;
251
253
  }
252
254
  }
253
255
 
@@ -6,6 +6,7 @@ import path from 'path';
6
6
  import {
7
7
  Level, Coordinates
8
8
  } from '@wemap/geo';
9
+ import { Edge } from '@wemap/graph';
9
10
 
10
11
  import OsmParser from '../model/OsmParser';
11
12
  import OsmRouter from '../network/OsmRouter';
@@ -316,15 +317,23 @@ describe('OsrmUtils - createItineraryFromJson', () => {
316
317
  it('Errored (Montpellier outdoor)', () => {
317
318
 
318
319
  const filePath = path.resolve(__dirname,
319
- '../../assets/itinerary-montpellier-outdoor-errored.json');
320
+ '../../assets/itinerary-with-duplicate-nodes.json');
320
321
  const fileString = fs.readFileSync(filePath, 'utf8');
321
322
 
322
323
  const json = JSON.parse(fileString);
323
324
 
324
- const start = new Coordinates(43.6007871, 3.8757218000000004);
325
- const end = new Coordinates(43.598877, 3.873866);
325
+ const start = new Coordinates(44.810569099999995, 4.9503924999999995);
326
+ const end = new Coordinates(44.302673, 4.556377);
326
327
 
327
- expect(() => OsrmUtils.createItineraryFromJson(json, start, end)).throw(Error);
328
+ const itinerary = OsrmUtils.createItineraryFromJson(json, start, end);
329
+ itinerary.edges.forEach(edge => {
330
+ expect(edge).instanceOf(Edge);
331
+ });
332
+ itinerary.steps.forEach(step => {
333
+ step.edges.forEach(edge => {
334
+ expect(edge).instanceOf(Edge);
335
+ });
336
+ });
328
337
  });
329
338
 
330
339
  });
@@ -1 +0,0 @@
1
- {"code":"Ok","routes":[{"geometry":{"coordinates":[[3.875607,43.600777],[3.875723,43.600109],[3.875766,43.600086],[3.876247,43.599974],[3.876341,43.599956],[3.876396,43.599881],[3.876234,43.599853],[3.875869,43.599787],[3.875829,43.599781],[3.875671,43.599759],[3.875643,43.599755],[3.875606,43.599749],[3.875578,43.599746],[3.875498,43.599734],[3.87536,43.599707],[3.875169,43.599674],[3.874655,43.599577],[3.874623,43.599063],[3.873865,43.59906]],"type":"LineString"},"legs":[{"steps":[{"intersections":[{"out":0,"entry":[true],"bearings":[173],"location":[3.875607,43.600777]}],"driving_side":"right","geometry":{"coordinates":[[3.875607,43.600777],[3.875723,43.600109],[3.875766,43.600086],[3.876247,43.599974],[3.876341,43.599956],[3.876396,43.599881]],"type":"LineString"},"mode":"walking","duration":98.7,"maneuver":{"bearing_after":173,"type":"depart","modifier":"left","bearing_before":0,"location":[3.875607,43.600777]},"weight":98.7,"distance":137.2,"name":""},{"intersections":[{"out":1,"location":[3.876396,43.599881],"bearings":[75,255,330],"entry":[true,true,false],"in":2},{"out":2,"location":[3.876234,43.599853],"bearings":[75,180,255],"entry":[false,true,true],"in":0},{"out":2,"location":[3.875829,43.599781],"bearings":[75,195,255],"entry":[false,true,true],"in":0},{"out":2,"location":[3.875643,43.599755],"bearings":[75,135,255],"entry":[false,true,true],"in":0},{"out":2,"location":[3.875498,43.599734],"bearings":[75,165,255,345],"entry":[false,true,true,true],"in":0},{"out":2,"location":[3.875169,43.599674],"bearings":[75,180,255],"entry":[false,true,true],"in":0}],"driving_side":"right","geometry":{"coordinates":[[3.876396,43.599881],[3.876234,43.599853],[3.875869,43.599787],[3.875829,43.599781],[3.875671,43.599759],[4.875643,43.599755],[3.875606,43.599749],[3.875578,43.599746],[3.875498,43.599734],[3.87536,43.599707],[3.875169,43.599674],[3.874655,43.599577]],"type":"LineString"},"mode":"walking","duration":103.9,"maneuver":{"bearing_after":255,"type":"turn","modifier":"right","bearing_before":149,"location":[3.876396,43.599881]},"weight":103.9,"distance":144.3,"name":"Boulevard Vieussens"},{"intersections":[{"out":1,"location":[3.874655,43.599577],"bearings":[75,180,255],"entry":[false,true,true],"in":0}],"driving_side":"right","geometry":{"coordinates":[[3.874655,43.599577],[3.874623,43.599063]],"type":"LineString"},"mode":"walking","duration":41.2,"maneuver":{"bearing_after":181,"type":"turn","modifier":"left","bearing_before":254,"location":[3.874655,43.599577]},"weight":41.2,"distance":57.2,"name":"Impasse Bizeray"},{"intersections":[{"out":2,"location":[3.874623,43.599063],"bearings":[0,90,270],"entry":[false,true,true],"in":0}],"driving_side":"right","geometry":{"coordinates":[[3.874623,43.599063],[3.873865,43.59906]],"type":"LineString"},"mode":"walking","duration":44,"maneuver":{"bearing_after":268,"type":"turn","modifier":"right","bearing_before":181,"location":[3.874623,43.599063]},"weight":44,"distance":61.1,"name":"Rue du Docteur Louis Perrier"},{"intersections":[{"in":0,"entry":[true],"bearings":[90],"location":[3.873865,43.59906]}],"driving_side":"right","geometry":{"coordinates":[[3.873865,43.59906],[3.873865,43.59906]],"type":"LineString"},"mode":"walking","duration":0,"maneuver":{"bearing_after":0,"type":"arrive","modifier":"left","bearing_before":270,"location":[3.873865,43.59906]},"weight":0,"distance":0,"name":"Rue du Docteur Louis Perrier"}],"distance":399.7,"duration":287.8,"summary":"Boulevard Vieussens, Boulevard Berthelot","weight":287.8}],"distance":399.7,"duration":287.8,"weight_name":"duration","weight":287.8}],"waypoints":[{"hint":"d89TgaHPU4GmAQAAGwIAAB0AAADAAQAApgEAABsCAAAdAAAAwAEAAAIAAAAXIzsAiUuZAoojOwCTS5kCAQDPCg61bn8=","name":"","location":[3.875607,43.600777]},{"hint":"dNRTgZbUU4FHAAAAuAEAAIMAAAAAAAAARwAAALgBAACDAAAAAAAAAAIAAABJHDsA1ESZAkocOwAdRJkCAwCfBQ61bn8=","name":"Rue du Docteur Louis Perrier","location":[3.873865,43.59906]}]}