@wemap/osm 4.0.3 → 4.0.4
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 +3 -3
- package/src/osrm/OsrmUtils.js +1 -29
- package/src/osrm/OsrmUtils.spec.js +4 -11
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"directory": "packages/osm"
|
|
12
12
|
},
|
|
13
13
|
"name": "@wemap/osm",
|
|
14
|
-
"version": "4.0.
|
|
14
|
+
"version": "4.0.4",
|
|
15
15
|
"bugs": {
|
|
16
16
|
"url": "https://github.com/wemap/wemap-modules-js/issues"
|
|
17
17
|
},
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
],
|
|
26
26
|
"license": "ISC",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@wemap/geo": "^4.0.
|
|
28
|
+
"@wemap/geo": "^4.0.4",
|
|
29
29
|
"@wemap/logger": "^4.0.0",
|
|
30
30
|
"@wemap/maths": "^4.0.3",
|
|
31
31
|
"sax": "^1.2.4"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "8cb2140ad039f1e12b9834effb7cef467ade7549"
|
|
34
34
|
}
|
package/src/osrm/OsrmUtils.js
CHANGED
|
@@ -102,26 +102,13 @@ export function itineraryToOsrmJson(itinerary) {
|
|
|
102
102
|
bearing_after: rad2deg(bearingAfter),
|
|
103
103
|
location: coordinatesToJson(node.coords),
|
|
104
104
|
type
|
|
105
|
-
}
|
|
106
|
-
wemap: {}
|
|
105
|
+
}
|
|
107
106
|
};
|
|
108
107
|
|
|
109
108
|
if (levelChange !== null) {
|
|
110
109
|
osrmStep.levelChange = levelChange;
|
|
111
110
|
}
|
|
112
111
|
|
|
113
|
-
const nodeProperties = node.extractProperties();
|
|
114
|
-
if (Object.keys(nodeProperties).length !== 0) {
|
|
115
|
-
osrmStep.wemap.nodeProperties = nodeProperties;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (i !== lastStepId && nextEdge) {
|
|
119
|
-
const nextEdgeProperties = nextEdge.extractProperties();
|
|
120
|
-
if (Object.keys(nextEdgeProperties).length !== 0) {
|
|
121
|
-
osrmStep.wemap.nextEdgeProperties = nextEdgeProperties;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
112
|
// The first modifier is not mandatory by OSRM.
|
|
126
113
|
// if (i !== 0) {
|
|
127
114
|
osrmStep.maneuver.modifier = getModifierFromAngle(angle);
|
|
@@ -220,21 +207,6 @@ function _parseSteps(itinerary, jsonSteps) {
|
|
|
220
207
|
step.name = jsonStep.name;
|
|
221
208
|
step.levelChange = jsonStep.levelChange ? jsonStep.levelChange : null;
|
|
222
209
|
|
|
223
|
-
/**
|
|
224
|
-
* Wemap fields
|
|
225
|
-
*/
|
|
226
|
-
if (jsonStep.wemap) {
|
|
227
|
-
const firstNode = step.nodes[0];
|
|
228
|
-
if (jsonStep.wemap.nodeProperties && firstNode) {
|
|
229
|
-
firstNode.applyProperties(jsonStep.wemap.nodeProperties);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
const firstEdge = step.edges[0];
|
|
233
|
-
if (jsonStep.wemap.nextEdgeProperties && firstEdge) {
|
|
234
|
-
firstEdge.applyProperties(jsonStep.wemap.nextEdgeProperties);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
210
|
itinerary._steps.push(step);
|
|
239
211
|
|
|
240
212
|
currentNodeIndex--;
|
|
@@ -117,7 +117,8 @@ describe('OsrmUtils - itineraryToOsrmJson', () => {
|
|
|
117
117
|
expect(steps[4].maneuver.bearing_after).be.closeTo(12.22, 0.01);
|
|
118
118
|
expect(steps[4].levelChange).is.not.null;
|
|
119
119
|
expect(steps[4].levelChange.direction).equals('down');
|
|
120
|
-
expect(steps[4].levelChange.
|
|
120
|
+
expect(steps[4].levelChange.difference).equals(-1);
|
|
121
|
+
expect(steps[4].levelChange.type).equals('stairs');
|
|
121
122
|
|
|
122
123
|
expect(steps[5].maneuver.modifier).equals('left');
|
|
123
124
|
expect(steps[5].distance).be.closeTo(4.23, 0.01);
|
|
@@ -358,17 +359,9 @@ describe('OsrmUtils - itineraryToOsrmJson - createItineraryFromJson - way/node',
|
|
|
358
359
|
const osrmJson = itineraryToOsrmJson(itinerary);
|
|
359
360
|
const jsonSteps = osrmJson.routes[0].legs[0].steps;
|
|
360
361
|
|
|
361
|
-
expect(jsonSteps[0].
|
|
362
|
-
expect(jsonSteps[
|
|
363
|
-
expect(jsonSteps[0].wemap.nodeProperties.name).equals('w2');
|
|
364
|
-
|
|
365
|
-
expect(jsonSteps[4].wemap.nextEdgeProperties.name).equals('p19');
|
|
366
|
-
expect(jsonSteps[4].wemap.nextEdgeProperties.level).equals('0;2');
|
|
367
|
-
expect(jsonSteps[4].wemap.nodeProperties.name).equals('p19');
|
|
368
|
-
|
|
362
|
+
expect(jsonSteps[0].name).equals('w2');
|
|
363
|
+
expect(jsonSteps[4].name).equals('p19');
|
|
369
364
|
expect(jsonSteps[6].name).equals('p21');
|
|
370
|
-
expect(jsonSteps[6].wemap.nextEdgeProperties).is.undefined;
|
|
371
|
-
expect(jsonSteps[6].wemap.nodeProperties.name).equals('p21');
|
|
372
365
|
|
|
373
366
|
const itineraryBis = createItineraryFromJson(osrmJson, start, end);
|
|
374
367
|
verifyCoherence(itineraryBis);
|