From 5401055ce16a7bd74dd0dc2a0caf2dbc66e0d986 Mon Sep 17 00:00:00 2001 From: Nicolas Cornu Date: Thu, 16 Feb 2017 19:35:27 +0100 Subject: [PATCH] Add Ascend/Descend when routing with GraphHopper --- app/assets/javascripts/index/directions.js | 9 +++++++-- app/assets/javascripts/index/directions/graphhopper.js | 4 +++- config/locales/en.yml | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/index/directions.js b/app/assets/javascripts/index/directions.js index 2a1e045da..11601c5b2 100644 --- a/app/assets/javascripts/index/directions.js +++ b/app/assets/javascripts/index/directions.js @@ -207,8 +207,13 @@ OSM.Directions = function (map) { '' + I18n.t('javascripts.directions.directions') + '

' + I18n.t('javascripts.directions.distance') + ': ' + formatDistance(route.distance) + '. ' + - I18n.t('javascripts.directions.time') + ': ' + formatTime(route.time) + '.

' + - ''; + I18n.t('javascripts.directions.time') + ': ' + formatTime(route.time) + '.'; + if (typeof route.ascend !== 'undefined' && typeof route.descend !== 'undefined') { + html += '
' + + I18n.t('javascripts.directions.ascend') + ': ' + Math.round(route.ascend) + 'm. ' + + I18n.t('javascripts.directions.descend') + ': ' + Math.round(route.descend) +'m.'; + } + html += '

'; $('#sidebar_content') .html(html); diff --git a/app/assets/javascripts/index/directions/graphhopper.js b/app/assets/javascripts/index/directions/graphhopper.js index 88a9c15c1..71161c591 100644 --- a/app/assets/javascripts/index/directions/graphhopper.js +++ b/app/assets/javascripts/index/directions/graphhopper.js @@ -62,7 +62,9 @@ function GraphHopperEngine(id, vehicleType) { line: line, steps: steps, distance: path.distance, - time: path.time / 1000 + time: path.time / 1000, + ascend: path.ascend, + descend: path.descend }); }, error: function () { diff --git a/config/locales/en.yml b/config/locales/en.yml index 2414fcd1f..4cc81750c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2246,6 +2246,7 @@ en: comment: Comment edit_help: Move the map and zoom in on a location you want to edit, then click here. directions: + ascend: "Ascend" engines: graphhopper_bicycle: "Bicycle (GraphHopper)" graphhopper_foot: "Foot (GraphHopper)" @@ -2256,6 +2257,7 @@ en: mapzen_bicycle: "Bicycle (Mapzen)" mapzen_car: "Car (Mapzen)" mapzen_foot: "Foot (Mapzen)" + descend: "Descend" directions: "Directions" distance: "Distance" errors: -- 2.43.2