function FOSSGISOSRMEngine(modeId, vehicleType) {
let cachedHints = [];
- function getInstructionText(step, maneuver_id) {
+ function getInstructionText(step) {
const INSTRUCTION_TEMPLATE = {
"continue": "continue",
"merge right": "merge_right",
}
const instrPrefix = "javascripts.directions.instructions.";
- let template = instrPrefix + INSTRUCTION_TEMPLATE[maneuver_id];
+ let template = instrPrefix + INSTRUCTION_TEMPLATE[step.maneuverId];
const destinations = "<b>" + step.destinations + "</b>";
let namedRoad = true;
"arrive": "destination"
};
- const steps = leg.steps.map(function (step) {
- const maneuver_id = getManeuverId(step.maneuver);
- const step_geometry = L.PolylineUtil.decode(step.geometry, { precision: 5 });
- const instText = getInstructionText(step, maneuver_id);
- return [
- ICON_MAP[maneuver_id],
- instText,
- step.distance,
- step_geometry
- ];
- });
+ for (const step of leg.steps) step.maneuverId = getManeuverId(step.maneuver);
+
+ const steps = leg.steps.map(step => [
+ ICON_MAP[step.maneuverId],
+ getInstructionText(step),
+ step.distance,
+ L.PolylineUtil.decode(step.geometry, { precision: 5 })
+ ]);
return {
line: steps.flatMap(step => step[3]),
function _processDirections(leg) {
const line = L.PolylineUtil.decode(leg.shape, { precision: 6 });
- const steps = leg.maneuvers.map(manoeuvre => {
- const lineseg = line
- .slice(manoeuvre.begin_shape_index, manoeuvre.end_shape_index + 1);
- return [
- INSTR_MAP[manoeuvre.type],
- manoeuvre.instruction,
- manoeuvre.length * 1000,
- lineseg
- ];
- });
+ const steps = leg.maneuvers.map(manoeuvre => [
+ INSTR_MAP[manoeuvre.type],
+ manoeuvre.instruction,
+ manoeuvre.length * 1000,
+ line.slice(manoeuvre.begin_shape_index, manoeuvre.end_shape_index + 1)
+ ]);
return {
line: line,
function _processDirections(path) {
const line = L.PolylineUtil.decode(path.points);
- const steps = path.instructions.map(function (instr) {
- const lineseg = line
- .slice(instr.interval[0], instr.interval[1] + 1);
- return [
- GH_INSTR_MAP[instr.sign],
- instr.text,
- instr.distance,
- lineseg
- ];
- });
+ const steps = path.instructions.map(instr => [
+ GH_INSTR_MAP[instr.sign],
+ instr.text,
+ instr.distance,
+ line.slice(instr.interval[0], instr.interval[1] + 1)
+ ]);
steps.at(-1)[0] = "destination";
return {