From a4718a235ea5e7e917ad307241c1753a3b0ea5c2 Mon Sep 17 00:00:00 2001 From: vng Date: Fri, 26 Dec 2014 11:36:33 +0300 Subject: [PATCH] Replace DistanceOnEarth fn call with more convenient one. --- map/ruler.cpp | 5 +---- routing/route.cpp | 6 +----- search/geometry_utils.cpp | 5 +---- search/house_detector.cpp | 4 +--- search/locality_finder.cpp | 9 +-------- 5 files changed, 5 insertions(+), 24 deletions(-) diff --git a/map/ruler.cpp b/map/ruler.cpp index 2bdeb9f21d..47fa36c6a1 100644 --- a/map/ruler.cpp +++ b/map/ruler.cpp @@ -17,7 +17,6 @@ #include "../indexer/mercator.hpp" -#include "../geometry/distance_on_sphere.hpp" #include "../geometry/transformations.hpp" #include "../base/string_utils.hpp" @@ -569,9 +568,7 @@ void Ruler::update() m2::PointD pt1 = screen.PtoG(pivot()); m2::PointD pt0 = screen.PtoG(pivot() - m2::PointD(minPxWidth, 0)); - double const distanceInMetres = ms::DistanceOnEarth( - MercatorBounds::YToLat(pt0.y), MercatorBounds::XToLon(pt0.x), - MercatorBounds::YToLat(pt1.y), MercatorBounds::XToLon(pt1.x)); + double const distanceInMetres = MercatorBounds::DistanceOnEarth(pt0, pt1); // convert metres to units for calculating m_metresDiff double metersDiff = CalcMetresDiff(distanceInMetres); diff --git a/routing/route.cpp b/routing/route.cpp index 6f23c5ec54..c65bfe4060 100644 --- a/routing/route.cpp +++ b/routing/route.cpp @@ -4,7 +4,6 @@ #include "../platform/location.hpp" -#include "../geometry/distance_on_sphere.hpp" #include "../geometry/angles.hpp" #include "../geometry/point2d.hpp" @@ -279,10 +278,7 @@ void Route::Update() m2::PointD const & p1 = m_poly.GetPoint(i); m2::PointD const & p2 = m_poly.GetPoint(i + 1); - dist += ms::DistanceOnEarth(MercatorBounds::YToLat(p1.y), - MercatorBounds::XToLon(p1.x), - MercatorBounds::YToLat(p2.y), - MercatorBounds::XToLon(p2.x)); + dist += MercatorBounds::DistanceOnEarth(p1, p2); m_segDistance[i] = dist; m_segProj[i].SetBounds(p1, p2); diff --git a/search/geometry_utils.cpp b/search/geometry_utils.cpp index 148dd289a9..51a2e0aabc 100644 --- a/search/geometry_utils.cpp +++ b/search/geometry_utils.cpp @@ -2,16 +2,13 @@ #include "../indexer/mercator.hpp" -#include "../geometry/distance_on_sphere.hpp" - namespace search { double PointDistance(m2::PointD const & a, m2::PointD const & b) { - return ms::DistanceOnEarth(MercatorBounds::YToLat(a.y), MercatorBounds::XToLon(a.x), - MercatorBounds::YToLat(b.y), MercatorBounds::XToLon(b.x)); + return MercatorBounds::DistanceOnEarth(a, b); } uint8_t ViewportDistance(m2::RectD const & viewport, m2::PointD const & p) diff --git a/search/house_detector.cpp b/search/house_detector.cpp index 6c116962c6..457a7dc4f8 100644 --- a/search/house_detector.cpp +++ b/search/house_detector.cpp @@ -6,7 +6,6 @@ #include "../indexer/classificator.hpp" #include "../geometry/distance.hpp" -#include "../geometry/distance_on_sphere.hpp" #include "../geometry/angles.hpp" #include "../base/logging.hpp" @@ -267,8 +266,7 @@ bool LessStreetDistance(HouseProjection const & p1, HouseProjection const & p2) double GetDistanceMeters(m2::PointD const & p1, m2::PointD const & p2) { - return ms::DistanceOnEarth(MercatorBounds::YToLat(p1.y), MercatorBounds::XToLon(p1.x), - MercatorBounds::YToLat(p2.y), MercatorBounds::XToLon(p2.x)); + return MercatorBounds::DistanceOnEarth(p1, p2); } pair GetConnectionAngleAndDistance(bool & isBeg, Street const * s1, Street const * s2) diff --git a/search/locality_finder.cpp b/search/locality_finder.cpp index d64c2fa97b..8f2321b9b0 100644 --- a/search/locality_finder.cpp +++ b/search/locality_finder.cpp @@ -3,8 +3,6 @@ #include "../indexer/ftypes_matcher.hpp" #include "../indexer/features_vector.hpp" -#include "../geometry/distance_on_sphere.hpp" - namespace search { @@ -77,12 +75,7 @@ public: void operator() (LocalityItem const & item) { - m2::PointD const c = item.m_rect.Center(); - double const d = ms::DistanceOnEarth(MercatorBounds::YToLat(c.y), - MercatorBounds::XToLon(c.x), - MercatorBounds::YToLat(m_point.y), - MercatorBounds::XToLon(m_point.x)); - + double const d = MercatorBounds::DistanceOnEarth(item.m_rect.Center(), m_point); double const value = ftypes::GetPopulationByRadius(d) / static_cast(item.m_population); if (value < m_bestValue) {