]> git.openstreetmap.org Git - rails.git/commitdiff
Add Ascend/Descend when routing with GraphHopper
authorNicolas Cornu <ncornu@aldebaran.com>
Thu, 16 Feb 2017 18:35:27 +0000 (19:35 +0100)
committerNicolas Cornu <ncornu@aldebaran.com>
Thu, 16 Feb 2017 18:52:41 +0000 (19:52 +0100)
app/assets/javascripts/index/directions.js
app/assets/javascripts/index/directions/graphhopper.js
config/locales/en.yml

index 2a1e045dae4efc2bf61a5c5c75ce80ac54849f65..11601c5b2312819b752626b4738e48162d99dd86 100644 (file)
@@ -207,8 +207,13 @@ OSM.Directions = function (map) {
         '<span class="icon close"></span></a>' + I18n.t('javascripts.directions.directions') +
         '</h2><p id="routing_summary">' +
         I18n.t('javascripts.directions.distance') + ': ' + formatDistance(route.distance) + '. ' +
-        I18n.t('javascripts.directions.time') + ': ' + formatTime(route.time) + '.</p>' +
-        '<table id="turnbyturn" />';
+        I18n.t('javascripts.directions.time') + ': ' + formatTime(route.time) + '.';
+      if (typeof route.ascend !== 'undefined' && typeof route.descend !== 'undefined') {
+        html += '<br />' +
+          I18n.t('javascripts.directions.ascend') + ': ' + Math.round(route.ascend) + 'm. ' +
+          I18n.t('javascripts.directions.descend') + ': ' + Math.round(route.descend) +'m.';
+      }
+      html += '</p><table id="turnbyturn" />';
 
       $('#sidebar_content')
         .html(html);
index 88a9c15c1215b00ae19ba6a7373eb88dff1efd7c..71161c59132ca2370d7e543c0c91e21e4789a442 100644 (file)
@@ -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 () {
index 2414fcd1f0ef3c6a2c789f5e03110bc224a3f29b..4cc81750cd63598ea3cddc4f729475869239fa97 100644 (file)
@@ -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: