From f476e68dc61898cc0285975d2b674a59a40de46a Mon Sep 17 00:00:00 2001 From: Alexander Borsuk Date: Thu, 26 Aug 2021 00:01:38 +0200 Subject: [PATCH] Fixed rounding error in the height chart Signed-off-by: Alexander Borsuk --- map/chart_generator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/map/chart_generator.cpp b/map/chart_generator.cpp index e892ba47fd..bbbd9898f9 100644 --- a/map/chart_generator.cpp +++ b/map/chart_generator.cpp @@ -188,8 +188,8 @@ bool GenerateYAxisChartData(uint32_t height, double minMetersPerPxl, LOG(LERROR, ("metersPerPxl == 0.0")); return false; } - - double const deltaAltPxl = deltaAltM / metersPerPxl; + // int avoids double errors which make freeHeightSpacePxl slightly less than zero. + int const deltaAltPxl = deltaAltM / metersPerPxl; double const freeHeightSpacePxl = drawHeightPxl - deltaAltPxl; if (freeHeightSpacePxl < 0 || freeHeightSpacePxl > drawHeightPxl) {