diff --git a/geometry/point_with_altitude.cpp b/geometry/point_with_altitude.cpp index 6df0c83b7f..49f4bd2653 100644 --- a/geometry/point_with_altitude.cpp +++ b/geometry/point_with_altitude.cpp @@ -23,6 +23,10 @@ std::string DebugPrint(PointWithAltitude const & r) << "}"; return ss.str(); } +bool AlmostEqualAbs(PointWithAltitude const & lhs, PointWithAltitude const & rhs, double eps) +{ + return lhs.GetPoint().EqualDxDy(rhs.GetPoint(), eps) && lhs.GetAltitude() == rhs.GetAltitude(); +} } // namespace geometry namespace std diff --git a/geometry/point_with_altitude.hpp b/geometry/point_with_altitude.hpp index 88e938771d..ab05a6bdee 100644 --- a/geometry/point_with_altitude.hpp +++ b/geometry/point_with_altitude.hpp @@ -15,8 +15,6 @@ using Altitudes = std::vector; Altitude constexpr kInvalidAltitude = std::numeric_limits::min(); Altitude constexpr kDefaultAltitudeMeters = 0; -double constexpr kPointsEqualEpsilon = 1e-6; - class PointWithAltitude { public: @@ -50,10 +48,7 @@ inline PointWithAltitude MakePointWithAltitudeForTesting(m2::PointD const & poin return PointWithAltitude(point, kDefaultAltitudeMeters); } -inline bool AlmostEqualAbs(PointWithAltitude const & lhs, PointWithAltitude const & rhs) -{ - return base::AlmostEqualAbs(lhs.GetPoint(), rhs.GetPoint(), kPointsEqualEpsilon); -} +bool AlmostEqualAbs(PointWithAltitude const & lhs, PointWithAltitude const & rhs, double eps); } // namespace geometry namespace std diff --git a/routing/features_road_graph.cpp b/routing/features_road_graph.cpp index 619f907148..f7b0826b39 100644 --- a/routing/features_road_graph.cpp +++ b/routing/features_road_graph.cpp @@ -11,6 +11,8 @@ #include "indexer/ftypes_matcher.hpp" #include "indexer/scales.hpp" +#include "coding/point_coding.hpp" + #include "geometry/distance_on_sphere.hpp" #include "base/logging.hpp" @@ -249,7 +251,7 @@ void FeaturesRoadGraph::GetJunctionTypes(geometry::PointWithAltitude const & jun if (ft.GetGeomType() != feature::GeomType::Point) return; - if (!base::AlmostEqualAbs(ft.GetCenter(), cross, geometry::kPointsEqualEpsilon)) + if (!base::AlmostEqualAbs(ft.GetCenter(), cross, kMwmPointAccuracy)) return; feature::TypesHolder typesHolder(ft); diff --git a/routing/road_graph.hpp b/routing/road_graph.hpp index 74f3612cf1..8479b5cff7 100644 --- a/routing/road_graph.hpp +++ b/routing/road_graph.hpp @@ -8,6 +8,8 @@ #include "indexer/feature_altitude.hpp" #include "indexer/feature_data.hpp" +#include "coding/point_coding.hpp" + #include "geometry/point2d.hpp" #include "geometry/point_with_altitude.hpp" #include "geometry/rect2d.hpp" @@ -210,8 +212,7 @@ public: { for (size_t i = 0; i < junctions.size(); ++i) { - if (!base::AlmostEqualAbs(m_cross.GetPoint(), junctions[i].GetPoint(), - geometry::kPointsEqualEpsilon)) + if (!base::AlmostEqualAbs(m_cross.GetPoint(), junctions[i].GetPoint(), kMwmPointAccuracy)) continue; if (i + 1 < junctions.size()) diff --git a/routing/routing_benchmarks/helpers.cpp b/routing/routing_benchmarks/helpers.cpp index 2826d85e45..6f8e8ceb34 100644 --- a/routing/routing_benchmarks/helpers.cpp +++ b/routing/routing_benchmarks/helpers.cpp @@ -15,6 +15,8 @@ #include "platform/local_country_file_utils.hpp" #include "platform/platform.hpp" +#include "coding/point_coding.hpp" + #include "geometry/mercator.hpp" #include "geometry/polyline2d.hpp" #include "geometry/point_with_altitude.hpp" @@ -160,8 +162,8 @@ void TestRouter(routing::IRouter & router, m2::PointD const & startPos, TEST(route.IsValid(), ()); m2::PolylineD const & poly = route.GetPoly(); TEST_GREATER(poly.GetSize(), 0, ()); - TEST(base::AlmostEqualAbs(poly.Front(), startPos, geometry::kPointsEqualEpsilon), ()); - TEST(base::AlmostEqualAbs(poly.Back(), finalPos, geometry::kPointsEqualEpsilon), ()); + TEST(base::AlmostEqualAbs(poly.Front(), startPos, kMwmPointAccuracy), ()); + TEST(base::AlmostEqualAbs(poly.Back(), finalPos, kMwmPointAccuracy), ()); LOG(LINFO, ("Route polyline size:", route.GetPoly().GetSize())); LOG(LINFO, ("Route distance, meters:", route.GetTotalDistanceMeters())); LOG(LINFO, ("Elapsed, seconds:", elapsedSec));