Removed SignedRound and replaced std::round with std::lround where needed

Also see https://clang.llvm.org/extra/clang-tidy/checks/bugprone/incorrect-roundings.html

Signed-off-by: Alexander Borsuk <me@alex.bio>
This commit is contained in:
Alexander Borsuk
2025-07-06 01:25:08 +02:00
committed by Konstantin Pastbin
parent ae349462c6
commit 76d7ef146c
22 changed files with 67 additions and 60 deletions

View File

@@ -4,6 +4,7 @@
#include "base/stl_helpers.hpp"
#include <algorithm>
#include <cmath>
namespace
{
@@ -42,8 +43,8 @@ CellsMerger::CellsMerger(std::vector<m2::RectD> && cells)
auto const sideSize = cells.front().SizeX();
for (auto const & cell : cells)
{
auto const xIdx = static_cast<int32_t>(std::round((cell.minX() - minX) / sideSize));
auto const yIdx = static_cast<int32_t>(std::round((cell.minY() - minY) / sideSize));
int32_t const xIdx = std::lround((cell.minX() - minX) / sideSize);
int32_t const yIdx = std::lround((cell.minY() - minY) / sideSize);
m_matrix.emplace(m2::PointI{xIdx, yIdx}, cell);
m_maxX = std::max(m_maxX, xIdx);
m_maxY = std::max(m_maxY, yIdx);

View File

@@ -24,6 +24,7 @@
#include "base/string_utils.hpp"
#include <algorithm>
#include <cmath>
#include <fstream>
#include <sstream>
#include <utility>

View File

@@ -8,6 +8,7 @@
#include "base/file_name_utils.hpp"
#include "base/logging.hpp"
#include <cmath>
#include <fstream>
#include <iomanip>
#include <sstream>
@@ -125,7 +126,7 @@ geometry::Altitude SrtmTile::GetHeight(ms::LatLon const & coord) const
auto const ll = GetCoordInSeconds(coord);
return GetHeightRC(static_cast<size_t>(std::round(ll.m_lat)), static_cast<size_t>(std::round(ll.m_lon)));
return GetHeightRC(std::lround(ll.m_lat), std::lround(ll.m_lon));
}
geometry::Altitude SrtmTile::GetHeightRC(size_t row, size_t col) const
@@ -142,7 +143,7 @@ double SrtmTile::GetTriangleHeight(ms::LatLon const & coord) const
auto const ll = GetCoordInSeconds(coord);
m2::Point<int> const p1(static_cast<int>(std::round(ll.m_lon)), static_cast<int>(std::round(ll.m_lat)));
m2::Point<int> const p1(std::lround(ll.m_lon), std::lround(ll.m_lat));
auto p2 = p1;
if (p2.x > ll.m_lon)