mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-02 02:53:44 +00:00
ADL for AlmostEqual* and use math:: instead of base:: (#9634)
* ADL for AlmostEqual* and use math:: instead of base:: Signed-off-by: Alexander Borsuk <me@alex.bio>
This commit is contained in:
committed by
Konstantin Pastbin
parent
82133c5743
commit
30718e106e
@@ -19,7 +19,7 @@ namespace
|
||||
{
|
||||
bool IsEqual(double d1, double d2)
|
||||
{
|
||||
return base::AlmostEqualAbs(d1, d2, kMwmPointAccuracy);
|
||||
return AlmostEqualAbs(d1, d2, kMwmPointAccuracy);
|
||||
}
|
||||
|
||||
bool IsEqual(m2::PointD const & p1, m2::PointD const & p2)
|
||||
|
||||
@@ -102,7 +102,7 @@ UNIT_TEST(PointDToPointU_WithLimitRect)
|
||||
auto const pt = m2::PointD(distX(rng), distY(rng));
|
||||
auto const pointU = PointDToPointU(pt, coordBits, limitRect);
|
||||
auto const pointD = PointUToPointD(pointU, coordBits, limitRect);
|
||||
TEST(base::AlmostEqualAbs(pt, pointD, kEps), (limitRect, pt, pointD, coordBits, kEps));
|
||||
TEST(AlmostEqualAbs(pt, pointD, kEps), (limitRect, pt, pointD, coordBits, kEps));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,10 +12,11 @@
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace coding
|
||||
namespace traffic_test
|
||||
{
|
||||
using coding::TrafficGPSEncoder;
|
||||
using std::vector;
|
||||
|
||||
double CalculateLength(vector<TrafficGPSEncoder::DataPoint> const & path)
|
||||
{
|
||||
double res = 0;
|
||||
@@ -30,7 +31,7 @@ double CalculateLength(vector<TrafficGPSEncoder::DataPoint> const & path)
|
||||
|
||||
void Test(vector<TrafficGPSEncoder::DataPoint> & points)
|
||||
{
|
||||
double const kEps = 1e-5;
|
||||
double constexpr kEps = 1e-5;
|
||||
|
||||
for (uint32_t version = 0; version <= TrafficGPSEncoder::kLatestVersion; ++version)
|
||||
{
|
||||
@@ -48,9 +49,9 @@ void Test(vector<TrafficGPSEncoder::DataPoint> & points)
|
||||
{
|
||||
TEST_EQUAL(points[i].m_timestamp, result[i].m_timestamp,
|
||||
(points[i].m_timestamp, result[i].m_timestamp));
|
||||
TEST(base::AlmostEqualAbsOrRel(points[i].m_latLon.m_lat, result[i].m_latLon.m_lat, kEps),
|
||||
TEST(AlmostEqualAbsOrRel(points[i].m_latLon.m_lat, result[i].m_latLon.m_lat, kEps),
|
||||
(points[i].m_latLon.m_lat, result[i].m_latLon.m_lat));
|
||||
TEST(base::AlmostEqualAbsOrRel(points[i].m_latLon.m_lon, result[i].m_latLon.m_lon, kEps),
|
||||
TEST(AlmostEqualAbsOrRel(points[i].m_latLon.m_lon, result[i].m_latLon.m_lon, kEps),
|
||||
(points[i].m_latLon.m_lon, result[i].m_latLon.m_lon));
|
||||
}
|
||||
|
||||
@@ -150,4 +151,4 @@ UNIT_TEST(Traffic_Serialization_ExtremeLatLon)
|
||||
};
|
||||
Test(path);
|
||||
}
|
||||
} // namespace coding
|
||||
} // namespace traffic_test
|
||||
|
||||
@@ -14,8 +14,8 @@ namespace
|
||||
inline m2::PointU ClampPoint(m2::PointD const & maxPoint, m2::PointD const & point)
|
||||
{
|
||||
using uvalue_t = m2::PointU::value_type;
|
||||
return { static_cast<uvalue_t>(base::Clamp(point.x, 0.0, maxPoint.x)),
|
||||
static_cast<uvalue_t>(base::Clamp(point.y, 0.0, maxPoint.y)) };
|
||||
return { static_cast<uvalue_t>(math::Clamp(point.x, 0.0, maxPoint.x)),
|
||||
static_cast<uvalue_t>(math::Clamp(point.y, 0.0, maxPoint.y)) };
|
||||
}
|
||||
|
||||
struct edge_less_p0
|
||||
|
||||
@@ -50,7 +50,7 @@ double Uint32ToDouble(uint32_t x, double min, double max, uint8_t coordBits)
|
||||
// It doesn't work because of possible floating errors.
|
||||
//ASSERT(d >= min && d <= max, (d, x, min, max, coordBits));
|
||||
|
||||
return base::Clamp(d, min, max);
|
||||
return math::Clamp(d, min, max);
|
||||
}
|
||||
|
||||
m2::PointU PointDToPointU(double x, double y, uint8_t coordBits)
|
||||
|
||||
@@ -13,7 +13,7 @@ uint8_t constexpr kFeatureSorterPointCoordBits = 27;
|
||||
// The absolute precision of the point encoding in the mwm files.
|
||||
// If both x and y coordinates of two points lie within |kMwmPointAccuracy| of one
|
||||
// another we consider the points equal. In other words, |kMwmPointAccuracy| may
|
||||
// be used as the eps value for both x and y in Point::EqualDxDy, base::AlmostEqualAbs and such.
|
||||
// be used as the eps value for both x and y in Point::EqualDxDy, AlmostEqualAbs and such.
|
||||
//
|
||||
// The constant is loosely tied to mercator::Bounds::kRangeX / (1 << kPointCoordBits):
|
||||
// The range of possible values for point coordinates
|
||||
|
||||
Reference in New Issue
Block a user