From 7e05661e00be1ce4c875c5afba1832533e6c69c7 Mon Sep 17 00:00:00 2001 From: ExMix Date: Wed, 19 Aug 2015 16:55:32 +0300 Subject: [PATCH] [drape] bugfix --- drape_frontend/tile_info.cpp | 15 ++++++--------- drape_frontend/tile_info.hpp | 1 - map/framework.cpp | 7 +++++-- map/user_mark.hpp | 10 ++++++++++ 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/drape_frontend/tile_info.cpp b/drape_frontend/tile_info.cpp index fb9bf034fb..33c6482e00 100644 --- a/drape_frontend/tile_info.cpp +++ b/drape_frontend/tile_info.cpp @@ -46,10 +46,13 @@ void TileInfo::ReadFeatures(MapDataProvider const & model, MemoryFeatureIndex & ReadFeatureIndex(model); - CheckCanceled(); vector featuresToRead; - featuresToRead.reserve(AverageFeaturesCount); - RequestFeatures(memIndex, featuresToRead); + { + lock_guard g(m_mutex); + CheckCanceled(); + featuresToRead.reserve(AverageFeaturesCount); + memIndex.ReadFeaturesRequest(m_featureInfo, featuresToRead); + } if (!featuresToRead.empty()) { @@ -84,12 +87,6 @@ bool TileInfo::DoNeedReadIndex() const return m_featureInfo.empty(); } -void TileInfo::RequestFeatures(MemoryFeatureIndex & memIndex, vector & featuresToRead) -{ - lock_guard lock(m_mutex); - memIndex.ReadFeaturesRequest(m_featureInfo, featuresToRead); -} - void TileInfo::CheckCanceled() const { if (m_isCanceled) diff --git a/drape_frontend/tile_info.hpp b/drape_frontend/tile_info.hpp index cdb21fb24f..2d1f1128b9 100644 --- a/drape_frontend/tile_info.hpp +++ b/drape_frontend/tile_info.hpp @@ -38,7 +38,6 @@ private: void ReadFeatureIndex(MapDataProvider const & model); void ProcessID(FeatureID const & id); void InitStylist(FeatureType const & f, Stylist & s); - void RequestFeatures(MemoryFeatureIndex & memIndex, vector & featuresToRead); void CheckCanceled() const; bool DoNeedReadIndex() const; diff --git a/map/framework.cpp b/map/framework.cpp index 8beba62489..97f597c6af 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -168,7 +168,7 @@ void Framework::SetMyPositionModeListener(location::TMyPositionModeChanged const void Framework::OnUserPositionChanged(m2::PointD const & position) { MyPositionMarkPoint * myPostition = UserMarkContainer::UserMarkForMyPostion(); - myPostition->SetPtOrg(position); + myPostition->SetUserPosition(position); if (IsRoutingActive()) m_routingSession.SetUserCurrentPosition(position); @@ -1005,9 +1005,12 @@ bool Framework::Search(search::SearchParams const & params) bool Framework::GetCurrentPosition(double & lat, double & lon) const { m2::PointD pos; - if (m_drapeEngine == nullptr || !m_drapeEngine->GetMyPosition(pos)) + MyPositionMarkPoint * myPosMark = UserMarkContainer::UserMarkForMyPostion(); + if (!myPosMark->HasPosition()) return false; + pos = myPosMark->GetPivot(); + lat = MercatorBounds::YToLat(pos.y); lon = MercatorBounds::XToLon(pos.x); return true; diff --git a/map/user_mark.hpp b/map/user_mark.hpp index 74f939da7c..ba6a0436e2 100644 --- a/map/user_mark.hpp +++ b/map/user_mark.hpp @@ -142,6 +142,16 @@ public: MyPositionMarkPoint(UserMarkContainer * container); UserMark::Type GetMarkType() const override; + + void SetUserPosition(m2::PointD const & pt) + { + SetPtOrg(pt); + m_hasPosition = true; + } + bool HasPosition() const { return m_hasPosition; } + +private: + bool m_hasPosition = false; }; class DebugMarkPoint : public UserMark