Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/map
diff options
context:
space:
mode:
authorvng <viktor.govako@gmail.com>2012-12-13 15:34:35 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:48:00 +0300
commit15e39284a050b4f26722c30758201cb061364bbc (patch)
treec4a6dde6ec62e17d2ddf122b42e3c4dc495c4214 /map
parent0280b0b1294ed25bcb7a45249f427a88a14dae3d (diff)
Handle storage::TIndex to get downloaded country instead of country name.
Diffstat (limited to 'map')
-rw-r--r--map/basic_tiling_render_policy.cpp6
-rw-r--r--map/basic_tiling_render_policy.hpp10
-rw-r--r--map/country_status_display.cpp10
-rw-r--r--map/country_status_display.hpp4
-rw-r--r--map/coverage_generator.cpp8
-rw-r--r--map/coverage_generator.hpp6
-rw-r--r--map/framework.cpp10
-rw-r--r--map/framework.hpp3
-rw-r--r--map/information_display.cpp4
-rw-r--r--map/information_display.hpp10
-rw-r--r--map/render_policy.cpp9
-rw-r--r--map/render_policy.hpp14
-rw-r--r--map/screen_coverage.cpp12
-rw-r--r--map/screen_coverage.hpp4
-rw-r--r--map/tiling_render_policy_mt.cpp2
-rw-r--r--map/tiling_render_policy_st.cpp2
16 files changed, 63 insertions, 51 deletions
diff --git a/map/basic_tiling_render_policy.cpp b/map/basic_tiling_render_policy.cpp
index 8ef7914f1a..f3c448089a 100644
--- a/map/basic_tiling_render_policy.cpp
+++ b/map/basic_tiling_render_policy.cpp
@@ -128,7 +128,7 @@ void BasicTilingRenderPolicy::DrawFrame(shared_ptr<PaintEvent> const & e, Screen
{
m_IsEmptyModel = curCvg->IsEmptyDrawingCoverage() && curCvg->IsEmptyModelAtCoverageCenter();
if (m_IsEmptyModel)
- m_CountryName = curCvg->GetCountryNameAtCoverageCenter();
+ m_countryIndex = curCvg->GetCountryIndexAtCoverageCenter();
}
}
@@ -229,9 +229,9 @@ bool BasicTilingRenderPolicy::IsEmptyModel() const
return m_IsEmptyModel;
}
-string const BasicTilingRenderPolicy::GetCountryName() const
+storage::TIndex BasicTilingRenderPolicy::GetCountryIndex() const
{
- return m_CountryName;
+ return m_countryIndex;
}
bool BasicTilingRenderPolicy::NeedRedraw() const
diff --git a/map/basic_tiling_render_policy.hpp b/map/basic_tiling_render_policy.hpp
index ef25199e7e..c447a71630 100644
--- a/map/basic_tiling_render_policy.hpp
+++ b/map/basic_tiling_render_policy.hpp
@@ -2,10 +2,12 @@
#include "render_policy.hpp"
+#include "../graphics/overlay.hpp"
+
#include "../geometry/screenbase.hpp"
#include "../std/shared_ptr.hpp"
-#include "../graphics/overlay.hpp"
+
class TileRenderer;
class CoverageGenerator;
@@ -34,7 +36,7 @@ protected:
ScreenBase m_CurrentScreen;
int m_DrawScale;
bool m_IsEmptyModel;
- string m_CountryName;
+ storage::TIndex m_countryIndex;
bool m_DoRecreateCoverage;
bool m_IsNavigating;
bool m_WasAnimatingLastFrame;
@@ -72,8 +74,8 @@ public:
bool NeedRedraw() const;
bool IsTiling() const;
bool IsEmptyModel() const;
- string const GetCountryName() const;
- int GetDrawScale(ScreenBase const & s) const;
+ storage::TIndex GetCountryIndex() const;
+ int GetDrawScale(ScreenBase const & s) const;
size_t ScaleEtalonSize() const;
size_t TileSize() const;
diff --git a/map/country_status_display.cpp b/map/country_status_display.cpp
index 4c9b2fe350..9fc840fb91 100644
--- a/map/country_status_display.cpp
+++ b/map/country_status_display.cpp
@@ -217,17 +217,17 @@ void CountryStatusDisplay::UpdateStatusAndProgress()
}
}
-void CountryStatusDisplay::setCountryName(string const & name)
+void CountryStatusDisplay::setCountryIndex(storage::TIndex const & idx)
{
- if (m_fullName != name)
+ if (m_countryIdx != idx)
{
- storage::CountryInfo::FullName2GroupAndMap(name, m_mapGroupName, m_mapName);
+ m_countryIdx = idx;
+
+ m_storage->GetGroupAndCountry(idx, m_mapGroupName, m_mapName);
LOG(LDEBUG, (m_mapName, m_mapGroupName));
- m_countryIdx = m_storage->FindIndexByName(m_mapName);
UpdateStatusAndProgress();
- m_fullName = name;
m_notEnoughSpace = false;
setIsDirtyDrawing(true);
diff --git a/map/country_status_display.hpp b/map/country_status_display.hpp
index 6a6bc3b7f9..32877fdac6 100644
--- a/map/country_status_display.hpp
+++ b/map/country_status_display.hpp
@@ -32,8 +32,6 @@ private:
shared_ptr<gui::Button> m_downloadButton;
/// country status message
shared_ptr<gui::TextView> m_statusMsg;
- /// full name, could be in the form "Country, Province"
- string m_fullName;
/// current map name, "Province" part of the fullName
string m_mapName;
/// current map group name, "Country" part of the fullName
@@ -73,7 +71,7 @@ public:
/// set download button listener
void setDownloadListener(gui::Button::TOnClickListener const & l);
/// set current country name
- void setCountryName(string const & name);
+ void setCountryIndex(storage::TIndex const & idx);
/// reposition element
void setPivot(m2::PointD const & pv);
/// attach element to controller.
diff --git a/map/coverage_generator.cpp b/map/coverage_generator.cpp
index fe73664a56..b205451c09 100644
--- a/map/coverage_generator.cpp
+++ b/map/coverage_generator.cpp
@@ -21,12 +21,12 @@ CoverageGenerator::CoverageGenerator(
shared_ptr<graphics::RenderContext> const & primaryRC,
shared_ptr<graphics::ResourceManager> const & rm,
graphics::PacketsQueue * glQueue,
- RenderPolicy::TCountryNameFn countryNameFn)
+ RenderPolicy::TCountryIndexFn const & countryIndexFn)
: m_queue(1),
m_tileRenderer(tileRenderer),
m_sequenceID(0),
m_windowHandle(windowHandle),
- m_countryNameFn(countryNameFn),
+ m_countryIndexFn(countryIndexFn),
m_glQueue(glQueue),
m_skinName(skinName),
m_fenceManager(2),
@@ -321,9 +321,9 @@ shared_ptr<graphics::ResourceManager> const & CoverageGenerator::resourceManager
return m_resourceManager;
}
-string CoverageGenerator::GetCountryName(m2::PointD const & pt) const
+storage::TIndex CoverageGenerator::GetCountryIndex(m2::PointD const & pt) const
{
- return m_countryNameFn(pt);
+ return m_countryIndexFn(pt);
}
void CoverageGenerator::CancelCommands()
diff --git a/map/coverage_generator.hpp b/map/coverage_generator.hpp
index 21caa4bd24..e16c2ade30 100644
--- a/map/coverage_generator.hpp
+++ b/map/coverage_generator.hpp
@@ -58,7 +58,7 @@ private:
threads::Mutex m_mutex;
- RenderPolicy::TCountryNameFn m_countryNameFn;
+ RenderPolicy::TCountryIndexFn m_countryIndexFn;
graphics::PacketsQueue * m_glQueue;
string m_skinName;
@@ -79,7 +79,7 @@ public:
shared_ptr<graphics::RenderContext> const & primaryRC,
shared_ptr<graphics::ResourceManager> const & rm,
graphics::PacketsQueue * glQueue,
- RenderPolicy::TCountryNameFn countryNameFn);
+ RenderPolicy::TCountryIndexFn const & countryIndexFn);
~CoverageGenerator();
@@ -112,7 +112,7 @@ public:
void WaitForEmptyAndFinished();
- string GetCountryName(m2::PointD const & pt) const;
+ storage::TIndex GetCountryIndex(m2::PointD const & pt) const;
ScreenCoverage * CurrentCoverage();
diff --git a/map/framework.cpp b/map/framework.cpp
index f9b53e3065..7edaf2b81a 100644
--- a/map/framework.cpp
+++ b/map/framework.cpp
@@ -711,7 +711,7 @@ void Framework::DrawAdditionalInfo(shared_ptr<PaintEvent> const & e)
bool const isEmptyModel = m_renderPolicy->IsEmptyModel();
if (isEmptyModel)
- m_informationDisplay.setEmptyCountryName(m_renderPolicy->GetCountryName());
+ m_informationDisplay.setEmptyCountryIndex(m_renderPolicy->GetCountryIndex());
m_informationDisplay.enableCountryStatusDisplay(isEmptyModel);
m_informationDisplay.enableCompassArrow(m_navigator.Screen().GetAngle() != 0);
@@ -1163,6 +1163,11 @@ search::Engine * Framework::GetSearchEngine() const
return m_pSearchEngine.get();
}
+storage::TIndex Framework::GetCountryIndex(m2::PointD const & pt) const
+{
+ return m_storage.FindIndexByFile(GetSearchEngine()->GetCountryFile(pt));
+}
+
string Framework::GetCountryName(m2::PointD const & pt) const
{
return GetSearchEngine()->GetCountryName(pt);
@@ -1281,8 +1286,7 @@ void Framework::SetRenderPolicy(RenderPolicy * renderPolicy)
m_guiController->SetRenderParams(rp);
- string (Framework::*pFn)(m2::PointD const &) const = &Framework::GetCountryName;
- m_renderPolicy->SetCountryNameFn(bind(pFn, this, _1));
+ m_renderPolicy->SetCountryIndexFn(bind(&Framework::GetCountryIndex, this, _1));
m_renderPolicy->SetRenderFn(DrawModelFn());
diff --git a/map/framework.hpp b/map/framework.hpp
index c4eaa65dd6..1d3fc661d7 100644
--- a/map/framework.hpp
+++ b/map/framework.hpp
@@ -271,6 +271,9 @@ public:
double lat, double lon, double north,
string & distance, double & azimut);
+private:
+ storage::TIndex GetCountryIndex(m2::PointD const & pt) const;
+public:
string GetCountryName(m2::PointD const & pt) const;
/// @param[in] id Country file name without an extension.
string GetCountryName(string const & id) const;
diff --git a/map/information_display.cpp b/map/information_display.cpp
index eeca55f888..b8c52ef207 100644
--- a/map/information_display.cpp
+++ b/map/information_display.cpp
@@ -393,9 +393,9 @@ void InformationDisplay::enableCountryStatusDisplay(bool doEnable)
m_countryStatusDisplay->setIsVisible(doEnable);
}
-void InformationDisplay::setEmptyCountryName(string const & country)
+void InformationDisplay::setEmptyCountryIndex(storage::TIndex const & idx)
{
- m_countryStatusDisplay->setCountryName(country);
+ m_countryStatusDisplay->setCountryIndex(idx);
}
void InformationDisplay::setDownloadListener(gui::Button::TOnClickListener l)
diff --git a/map/information_display.hpp b/map/information_display.hpp
index 906cd9515f..9e7c0e8b38 100644
--- a/map/information_display.hpp
+++ b/map/information_display.hpp
@@ -2,12 +2,18 @@
#include "window_handle.hpp"
#include "ruler.hpp"
+
+#include "../storage/index.hpp"
+
+#include "../gui/button.hpp"
+
#include "../geometry/point2d.hpp"
#include "../geometry/rect2d.hpp"
#include "../geometry/screenbase.hpp"
+
#include "../base/timer.hpp"
#include "../base/logging.hpp"
-#include "../gui/button.hpp"
+
namespace location
{
@@ -135,7 +141,7 @@ public:
void enableCountryStatusDisplay(bool doEnable);
void setDownloadListener(gui::Button::TOnClickListener l);
- void setEmptyCountryName(string const & country);
+ void setEmptyCountryIndex(storage::TIndex const & idx);
shared_ptr<CountryStatusDisplay> const & countryStatusDisplay() const;
diff --git a/map/render_policy.cpp b/map/render_policy.cpp
index 6509f986a6..043952ee1e 100644
--- a/map/render_policy.cpp
+++ b/map/render_policy.cpp
@@ -169,9 +169,9 @@ void RenderPolicy::SetRenderFn(TRenderFn renderFn)
m_renderFn = renderFn;
}
-void RenderPolicy::SetCountryNameFn(TCountryNameFn countryNameFn)
+void RenderPolicy::SetCountryIndexFn(TCountryIndexFn const & fn)
{
- m_countryNameFn = countryNameFn;
+ m_countryIndexFn = fn;
}
bool RenderPolicy::DoForceUpdate() const
@@ -199,11 +199,6 @@ bool RenderPolicy::IsEmptyModel() const
return false;
}
-string const RenderPolicy::GetCountryName() const
-{
- return string();
-}
-
int RenderPolicy::GetDrawScale(ScreenBase const & s) const
{
m2::PointD textureCenter(s.PixelRect().Center());
diff --git a/map/render_policy.hpp b/map/render_policy.hpp
index 0c4908967e..bfd95e3c71 100644
--- a/map/render_policy.hpp
+++ b/map/render_policy.hpp
@@ -2,12 +2,15 @@
#include "drawer.hpp"
+#include "../storage/index.hpp"
+
#include "../graphics/color.hpp"
+#include "../geometry/rect2d.hpp"
+
#include "../std/function.hpp"
#include "../std/shared_ptr.hpp"
-#include "../geometry/rect2d.hpp"
class PaintEvent;
class ScreenBase;
@@ -47,7 +50,7 @@ public:
bool)> TRenderFn;
typedef function<bool (m2::PointD const &)> TEmptyModelFn;
- typedef function<string (m2::PointD const &)> TCountryNameFn;
+ typedef function<storage::TIndex (m2::PointD const &)> TCountryIndexFn;
protected:
@@ -59,7 +62,7 @@ protected:
shared_ptr<WindowHandle> m_windowHandle;
shared_ptr<Drawer> m_drawer;
TRenderFn m_renderFn;
- TCountryNameFn m_countryNameFn;
+ TCountryIndexFn m_countryIndexFn;
bool m_doSupportRotation;
bool m_doForceUpdate;
m2::AnyRectD m_invalidRect;
@@ -117,7 +120,8 @@ public:
/// the start point of rendering in renderpolicy.
virtual void SetRenderFn(TRenderFn renderFn);
- virtual void SetCountryNameFn(TCountryNameFn countryNameFn);
+
+ void SetCountryIndexFn(TCountryIndexFn const & fn);
void SetAnimController(anim::Controller * controller);
bool DoSupportRotation() const;
@@ -125,7 +129,7 @@ public:
virtual bool NeedRedraw() const;
virtual bool IsEmptyModel() const;
- virtual string const GetCountryName() const;
+ virtual storage::TIndex GetCountryIndex() const { return storage::TIndex(); }
virtual int GetDrawScale(ScreenBase const & s) const;
bool DoForceUpdate() const;
diff --git a/map/screen_coverage.cpp b/map/screen_coverage.cpp
index 5d4a7fdeb4..f96b93c84a 100644
--- a/map/screen_coverage.cpp
+++ b/map/screen_coverage.cpp
@@ -54,7 +54,7 @@ void ScreenCoverage::CopyInto(ScreenCoverage & cvg)
cvg.m_isEmptyDrawingCoverage = m_isEmptyDrawingCoverage;
cvg.m_isEmptyModelAtCoverageCenter = m_isEmptyModelAtCoverageCenter;
cvg.m_leafTilesToRender = m_leafTilesToRender;
- cvg.m_countryNameAtCoverageCenter = m_countryNameAtCoverageCenter;
+ cvg.m_countryIndexAtCoverageCenter = m_countryIndexAtCoverageCenter;
TileCache * tileCache = &m_tileRenderer->GetTileCache();
@@ -452,18 +452,18 @@ void ScreenCoverage::ResetEmptyModelAtCoverageCenter()
m_isEmptyModelAtCoverageCenter = false;
}
-string ScreenCoverage::GetCountryNameAtCoverageCenter() const
+storage::TIndex ScreenCoverage::GetCountryIndexAtCoverageCenter() const
{
- return m_countryNameAtCoverageCenter;
+ return m_countryIndexAtCoverageCenter;
}
void ScreenCoverage::CheckEmptyModelAtCoverageCenter()
{
if (!IsPartialCoverage() && IsEmptyDrawingCoverage())
{
- m2::PointD centerPt = m_screen.GlobalRect().GetGlobalRect().Center();
- m_countryNameAtCoverageCenter = m_coverageGenerator->GetCountryName(centerPt);
- m_isEmptyModelAtCoverageCenter = !m_countryNameAtCoverageCenter.empty();
+ m2::PointD const centerPt = m_screen.GlobalRect().GetGlobalRect().Center();
+ m_countryIndexAtCoverageCenter = m_coverageGenerator->GetCountryIndex(centerPt);
+ m_isEmptyModelAtCoverageCenter = m_countryIndexAtCoverageCenter.IsValid();
}
}
diff --git a/map/screen_coverage.hpp b/map/screen_coverage.hpp
index 8c058ce678..66431c7837 100644
--- a/map/screen_coverage.hpp
+++ b/map/screen_coverage.hpp
@@ -62,7 +62,7 @@ private:
bool m_isEmptyModelAtCoverageCenter;
/// Which country this coverage points to at its center?
/// It's valid only if m_isEmptyModelAtCoverageCenter is true
- string m_countryNameAtCoverageCenter;
+ storage::TIndex m_countryIndexAtCoverageCenter;
/// How many "leaf" tiles we should render to cover the screen.
/// This is efficiently the size of newLeafTileRects and is cached for
/// quick check.
@@ -110,7 +110,7 @@ public:
void ResetEmptyModelAtCoverageCenter();
/// What country is at this coverage center.
/// @warning check this flag only if IsEmptyModelAtCoverageCenter is true
- string GetCountryNameAtCoverageCenter() const;
+ storage::TIndex GetCountryIndexAtCoverageCenter() const;
/// Check, whether the model is empty at the center of the coverage.
void CheckEmptyModelAtCoverageCenter();
/// Getter for Overlay
diff --git a/map/tiling_render_policy_mt.cpp b/map/tiling_render_policy_mt.cpp
index ee3b539013..aa64d91a8e 100644
--- a/map/tiling_render_policy_mt.cpp
+++ b/map/tiling_render_policy_mt.cpp
@@ -181,5 +181,5 @@ void TilingRenderPolicyMT::SetRenderFn(TRenderFn renderFn)
m_primaryRC,
m_resourceManager,
0,
- m_countryNameFn));
+ m_countryIndexFn));
}
diff --git a/map/tiling_render_policy_st.cpp b/map/tiling_render_policy_st.cpp
index 04038d74a3..21f6974b50 100644
--- a/map/tiling_render_policy_st.cpp
+++ b/map/tiling_render_policy_st.cpp
@@ -210,5 +210,5 @@ void TilingRenderPolicyST::SetRenderFn(TRenderFn renderFn)
m_primaryRC,
m_resourceManager,
m_QueuedRenderer->GetPacketsQueue(cpuCores),
- m_countryNameFn));
+ m_countryIndexFn));
}