From a61b1a36230a8be86dae67671e1f5f179609f45f Mon Sep 17 00:00:00 2001 From: karenzshea Date: Mon, 13 Feb 2017 11:06:38 +0100 Subject: [PATCH] round speed to 1 decimal place --- features/testbot/weight.feature | 10 +++++----- include/engine/api/route_api.hpp | 2 +- unit_tests/library/route.cpp | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/features/testbot/weight.feature b/features/testbot/weight.feature index 0663bb413..8306d45f9 100644 --- a/features/testbot/weight.feature +++ b/features/testbot/weight.feature @@ -53,11 +53,11 @@ Feature: Weight tests | abc | When I route I should get - | waypoints | route | distances | weights | times | a:distance | a:duration | a:weight | a:speed | - | s,t | abc,abc | 20m,0m | 2.1,0 | 2.1s,0s | 20.017685 | 3 | 3 | 6.672562 | - | t,s | abc,abc | 20m,0m | 2.1,0 | 2.1s,0s | 20.017685 | 3.1 | 3.1 | 6.457318 | - | s,e | abc,abc | 40m,0m | 4.1,0 | 4.1s,0s | 30.026527:10.008842 | 3.1:1 | 3.1:1 | 9.685976:10.008842 | - | e,s | abc,abc | 40m,0m | 4.1,0 | 4.1s,0s | 10.008842:30.026527 | 1:3.1 | 1:3.1 | 10.008842:9.685976 | + | waypoints | route | distances | weights | times | a:distance | a:duration | a:weight | a:speed | + | s,t | abc,abc | 20m,0m | 2.1,0 | 2.1s,0s | 20.017685 | 3 | 3 | 6.7 | + | t,s | abc,abc | 20m,0m | 2.1,0 | 2.1s,0s | 20.017685 | 3.1 | 3.1 | 6.5 | + | s,e | abc,abc | 40m,0m | 4.1,0 | 4.1s,0s | 30.026527:10.008842 | 3.1:1 | 3.1:1 | 9.7:10 | + | e,s | abc,abc | 40m,0m | 4.1,0 | 4.1s,0s | 10.008842:30.026527 | 1:3.1 | 1:3.1 | 10:9.7 | Scenario: Step weights -- way_function: fail if no weight or weight_per_meter property diff --git a/include/engine/api/route_api.hpp b/include/engine/api/route_api.hpp index d43ea50d1..32549bf1e 100644 --- a/include/engine/api/route_api.hpp +++ b/include/engine/api/route_api.hpp @@ -239,7 +239,7 @@ class RouteAPI : public BaseAPI { annotation.values["speed"] = GetAnnotations( leg_geometry, [](const guidance::LegGeometry::Annotation &anno) { - return anno.distance / anno.duration; + return std::round(anno.distance / anno.duration * 10.) / 10.; }); } diff --git a/unit_tests/library/route.cpp b/unit_tests/library/route.cpp index 37ec5a1ae..574a6e0e4 100644 --- a/unit_tests/library/route.cpp +++ b/unit_tests/library/route.cpp @@ -418,7 +418,7 @@ BOOST_AUTO_TEST_CASE(speed_annotation_matches_duration_and_distance) auto speed = speeds[i].get().value; auto duration = durations[i].get().value; auto distance = distances[i].get().value; - BOOST_CHECK_EQUAL(speed, distance / duration); + BOOST_CHECK_EQUAL(speed, std::round(distance / duration * 10.) / 10.); } }