From 036c71dfb2e80e11daeccd1911d70a28a4e8579b Mon Sep 17 00:00:00 2001 From: vng Date: Thu, 23 May 2013 13:35:33 +0300 Subject: [PATCH] Fix location zoom level with new tile scale coverage logic. --- map/framework.cpp | 19 +++---------------- map/framework.hpp | 3 --- map/location_state.cpp | 11 ++++++++--- 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/map/framework.cpp b/map/framework.cpp index f84c20d323..64c94681f5 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -270,7 +270,7 @@ double Framework::GetVisualScale() const int Framework::GetScaleEtalonSize() const { - return (m_renderPolicy ? m_renderPolicy->ScaleEtalonSize() : 512 + 256); + return (m_renderPolicy ? m_renderPolicy->ScaleEtalonSize() : 512); } void Framework::DeleteCountry(TIndex const & index) @@ -927,21 +927,8 @@ void Framework::ShowRectFixed(m2::AnyRectD const & r) m2::AnyRectD rect(r); CheckMinGlobalRect(rect); - /* - if (!m_renderPolicy) - { - m_pendingFixedRect = rect; - m_hasPendingShowRectFixed = true; - return; - } - */ - - //size_t const sz = m_renderPolicy->ScaleEtalonSize(); - - /// @todo Get stored value instead of m_renderPolicy call because of invalid render policy here. - int const etalonSize = GetScaleEtalonSize(); - m2::RectD etalonRect(0, 0, etalonSize, etalonSize); - etalonRect.Offset(-etalonSize / 2, -etalonSize); + double const halfSize = GetScaleEtalonSize() / 2.0; + m2::RectD etalonRect(-halfSize, -halfSize, halfSize, halfSize); m2::PointD const pxCenter = m_navigator.Screen().PixelRect().Center(); etalonRect.Offset(pxCenter); diff --git a/map/framework.hpp b/map/framework.hpp index c2f152d3a3..79a669d08f 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -86,11 +86,8 @@ protected: double m_StartForegroundTime; - //bool m_hasPendingInvalidate, m_doForceUpdate, m_queryMaxScaleMode, m_drawPlacemark, m_hasPendingShowRectFixed; bool m_queryMaxScaleMode, m_drawPlacemark; - //m2::RectD m_pendingFixedRect; - //m2::AnyRectD m_invalidRect; m2::PointD m_placemark; double const m_metresMinWidth; diff --git a/map/location_state.cpp b/map/location_state.cpp index 653a58f52a..c02434ee25 100644 --- a/map/location_state.cpp +++ b/map/location_state.cpp @@ -152,20 +152,25 @@ namespace location int const rectScale = scales::GetScaleLevel(rect); int setScale = -1; - // correct rect scale if country isn't downloaded + // Correct rect scale if country isn't downloaded. int const upperScale = scales::GetUpperWorldScale(); if (rectScale > upperScale && !m_framework->IsCountryLoaded(center)) setScale = upperScale; else { - // correct rect scale for best user experience + // Correct scale if it's too small. int const bestScale = scales::GetUpperScale() - 1; if (rectScale > bestScale) setScale = bestScale; } if (setScale != -1) - rect = scales::GetRectForLevel(setScale, center, 1.0); + { + /// @todo Correct rect scale for best user experience. + /// The logic of GetRectForLevel differs from tile scale calculating logic + /// (@see initial_level in scales.cpp). + rect = scales::GetRectForLevel(setScale + 0.51, center, 1.0); + } m_framework->ShowRectEx(rect);