From 94fa7d216cffdffe1fbfd58923fe2e6f13523b3a Mon Sep 17 00:00:00 2001 From: vng Date: Fri, 21 Sep 2012 02:22:22 +0300 Subject: [PATCH] Add MercatorBounds::FullRect(). --- generator/polygonizer.hpp | 4 +--- indexer/mercator.hpp | 2 ++ map/feature_vec_model.cpp | 5 +---- map/framework.cpp | 3 +-- map/map_tests/multithread_map_test.cpp | 3 +-- map/navigator.cpp | 8 +++----- 6 files changed, 9 insertions(+), 16 deletions(-) diff --git a/generator/polygonizer.hpp b/generator/polygonizer.hpp index 2a921cf543..3602224562 100644 --- a/generator/polygonizer.hpp +++ b/generator/polygonizer.hpp @@ -70,9 +70,7 @@ namespace feature { // Insert fake country polygon equal to whole world to // create only one output file which contains all features - m_countries.Add(borders::CountryPolygons(), - m2::RectD(MercatorBounds::minX, MercatorBounds::minY, - MercatorBounds::maxX, MercatorBounds::maxY)); + m_countries.Add(borders::CountryPolygons(), MercatorBounds::FullRect()); } } ~Polygonizer() diff --git a/indexer/mercator.hpp b/indexer/mercator.hpp index b976fb2509..261931c141 100644 --- a/indexer/mercator.hpp +++ b/indexer/mercator.hpp @@ -12,6 +12,8 @@ struct MercatorBounds static double minY; static double maxY; + inline static m2::RectD FullRect() { return m2::RectD(minX, minY, maxX, maxY); } + inline static bool ValidLon(double d) { return my::between_s(-180.0, 180.0, d); diff --git a/map/feature_vec_model.cpp b/map/feature_vec_model.cpp index 28fab68fd3..537117641d 100644 --- a/map/feature_vec_model.cpp +++ b/map/feature_vec_model.cpp @@ -107,10 +107,7 @@ m2::RectD FeaturesFetcher::GetWorldRect() const { // rect is empty when now countries are loaded // return max global rect - return m2::RectD(MercatorBounds::minX, - MercatorBounds::minY, - MercatorBounds::maxX, - MercatorBounds::maxY); + return MercatorBounds::FullRect(); } return m_rect; } diff --git a/map/framework.cpp b/map/framework.cpp index 209672d0ca..83b30687cc 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -437,8 +437,7 @@ void Framework::SetNeedRedraw(bool flag) void Framework::Invalidate(bool doForceUpdate) { - InvalidateRect(m2::RectD(MercatorBounds::minX, MercatorBounds::minY, - MercatorBounds::maxX, MercatorBounds::maxY), doForceUpdate); + InvalidateRect(MercatorBounds::FullRect(), doForceUpdate); } void Framework::InvalidateRect(m2::RectD const & rect, bool doForceUpdate) diff --git a/map/map_tests/multithread_map_test.cpp b/map/map_tests/multithread_map_test.cpp index 6367602f14..ff7feb3d4a 100644 --- a/map/map_tests/multithread_map_test.cpp +++ b/map/map_tests/multithread_map_test.cpp @@ -66,8 +66,7 @@ namespace m2::RectD const r = src.GetWorldRect(); TEST ( r.IsValid(), () ); - m2::RectD world(MercatorBounds::minX, MercatorBounds::minY, - MercatorBounds::maxX, MercatorBounds::maxY); + m2::RectD world(MercatorBounds::FullRect()); world.Inflate(-10.0, -10.0); TEST ( world.IsRectInside(r), () ); diff --git a/map/navigator.cpp b/map/navigator.cpp index 50ddca16f1..a64e004b69 100644 --- a/map/navigator.cpp +++ b/map/navigator.cpp @@ -27,14 +27,14 @@ namespace } Navigator::Navigator() - : m_worldRect(MercatorBounds::minX, MercatorBounds::minY, MercatorBounds::maxX, MercatorBounds::maxY), + : m_worldRect(MercatorBounds::FullRect()), m_InAction(false), m_DoSupportRotation(false) { } Navigator::Navigator(ScreenBase const & screen) - : m_worldRect(MercatorBounds::minX, MercatorBounds::minY, MercatorBounds::maxX, MercatorBounds::maxY), + : m_worldRect(MercatorBounds::FullRect()), m_StartScreen(screen), m_Screen(screen), m_InAction(false), @@ -99,9 +99,7 @@ bool Navigator::LoadState() return false; // additional check for valid rect - m2::RectD const r = rect.GetGlobalRect(); - if (r.minX() < MercatorBounds::minX || r.minY() < MercatorBounds::minY - || r.maxX() > MercatorBounds::maxX || r.maxY() > MercatorBounds::maxY) + if (!MercatorBounds::FullRect().IsRectInside(rect.GetGlobalRect())) return false; SetFromRect(rect);