@wemap/osm 5.1.10 → 5.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.
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "directory": "packages/osm"
12
12
  },
13
13
  "name": "@wemap/osm",
14
- "version": "5.1.10",
14
+ "version": "5.1.12",
15
15
  "bugs": {
16
16
  "url": "https://github.com/wemap/wemap-modules-js/issues"
17
17
  },
@@ -31,5 +31,5 @@
31
31
  "@wemap/maths": "^5.1.1",
32
32
  "saxes": "^5.0.1"
33
33
  },
34
- "gitHead": "6e6153bf8dd922a647f37ed0b22034a80f1c2322"
34
+ "gitHead": "0d31164f7e74576225c6f03356498ff606bed7a2"
35
35
  }
@@ -164,7 +164,11 @@ function parseJsonSteps(jsonSteps, legCoords) {
164
164
  const step = new Step();
165
165
  step.coords = jsonToCoordinates(jsonStep.maneuver.location);
166
166
 
167
- const idStepCoordsInLeg = legCoords.findIndex(coords => step.coords.equalsTo(coords));
167
+ // Sometimes, OSRM step does not have the same coordinates than a point in legCoords.
168
+ // ex: first step of https://routing.getwemap.com/route/v1/walking/2.33222164147,48.87084765712;2.3320734,48.8730212?geometries=geojson&overview=full&steps=true
169
+ // That is why we look for the closest point.
170
+ const distances = legCoords.map(coords => coords.distanceTo(step.coords));
171
+ const idStepCoordsInLeg = distances.indexOf(Math.min(...distances));
168
172
  if (idStepCoordsInLeg < 0) {
169
173
  throw new Error('Osrm Parser: Cannot find step coords in leg coordinates');
170
174
  }
@@ -176,7 +180,7 @@ function parseJsonSteps(jsonSteps, legCoords) {
176
180
  step.distance = jsonStep.distance;
177
181
  step.duration = jsonStep.duration;
178
182
 
179
- if (step.extras.subwayEntrance) {
183
+ if (jsonStep.extras && jsonStep.extras.subwayEntrance) {
180
184
  step.extras.subwayEntrance = true;
181
185
  if (jsonStep.extras.subwayEntranceRef) {
182
186
  step.extras.subwayEntranceRef = jsonStep.extras.subwayEntranceRef;