+ function _processDirections(tripLegs) {
+ let line = [];
+ let steps = [];
+ let distance = 0;
+ let time = 0;
+
+ for (const leg of tripLegs) {
+ const legLine = L.PolylineUtil.decode(leg.shape, {
+ precision: 6
+ });
+
+ const legSteps = leg.maneuvers.map(function (manoeuvre, idx) {
+ const num = `<b>${idx + 1}.</b> `;
+ const lineseg = legLine
+ .slice(manoeuvre.begin_shape_index, manoeuvre.end_shape_index + 1)
+ .map(([lat, lng]) => ({ lat, lng }));
+ return [
+ lineseg[0],
+ INSTR_MAP[manoeuvre.type],
+ num + manoeuvre.instruction,
+ manoeuvre.length * 1000,
+ lineseg
+ ];
+ });
+
+ line = line.concat(legLine);
+ steps = steps.concat(legSteps);
+ distance += leg.summary.length;
+ time += leg.summary.time;
+ }
+
+ return {
+ line: line,
+ steps: steps,
+ distance: distance * 1000,
+ time: time
+ };
+ }
+