Improve error handling for routing engines

This commit is contained in:
Tom Hughes 2015-09-30 21:56:57 +01:00
parent 3f93341506
commit 3c771a7844
5 changed files with 16 additions and 4 deletions

View file

@ -189,7 +189,7 @@ OSM.Directions = function (map) {
map.removeLayer(polyline);
if (!dragging) {
alert(I18n.t('javascripts.directions.errors.no_route'));
$('#sidebar_content').html('<p class="search_results_error">' + I18n.t('javascripts.directions.errors.no_route') + '</p>');
}
return;

View file

@ -58,12 +58,15 @@ function GraphHopperEngine(id, vehicleType) {
]); // TODO does graphhopper map instructions onto line indices?
}
callback(null, {
callback(false, {
line: line,
steps: steps,
distance: path.distance,
time: path.time / 1000
});
},
error: function () {
callback(true);
}
});
}

View file

@ -83,12 +83,15 @@ function MapQuestEngine(id, routeType) {
steps.push([L.latLng(s.startPoint.lat, s.startPoint.lng), d, s.narrative, s.distance * 1000, lineseg]);
}
callback(null, {
callback(false, {
line: line,
steps: steps,
distance: data.route.distance * 1000,
time: data.route.time
});
},
error: function () {
callback(true);
}
});
}

View file

@ -93,6 +93,9 @@ function MapzenEngine(id, costing) {
} else {
callback(true);
}
},
error: function () {
callback(true);
}
});
}

View file

@ -84,12 +84,15 @@ function OSRMEngine() {
steps.push([line[s[3]], s[0].split('-')[0], instText, s[2], line.slice(s[3], linesegend)]);
}
callback(null, {
callback(false, {
line: line,
steps: steps,
distance: data.route_summary.total_distance,
time: data.route_summary.total_time
});
},
error: function () {
callback(true);
}
});
}