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:
authorVladiMihaylenko <vxmihaylenko@gmail.com>2016-10-05 13:42:17 +0300
committerVladiMihaylenko <vxmihaylenko@gmail.com>2016-10-17 17:16:47 +0300
commit3c0bac96e9e0b746bc2e156a81ea77e2bb660e9e (patch)
treecb7c0637b87bb48a7e4475ea746536dc49d9b616 /map
parent989154cb73d24f4ce44e38a64cffb438c4299778 (diff)
[map] Refactored work of bookmark
Diffstat (limited to 'map')
-rw-r--r--map/bookmark.hpp18
-rw-r--r--map/framework.cpp25
-rw-r--r--map/place_page_info.cpp10
-rw-r--r--map/place_page_info.hpp11
4 files changed, 44 insertions, 20 deletions
diff --git a/map/bookmark.hpp b/map/bookmark.hpp
index 60c9242eae..2fb0280e6b 100644
--- a/map/bookmark.hpp
+++ b/map/bookmark.hpp
@@ -180,14 +180,14 @@ protected:
UserMark * AllocateUserMark(m2::PointD const & ptOrg) override;
};
-/// <category index, bookmark index>
-typedef pair<int, int> BookmarkAndCategory;
-inline BookmarkAndCategory MakeEmptyBookmarkAndCategory()
+struct BookmarkAndCategory
{
- return BookmarkAndCategory(int(-1), int(-1));
-}
+ BookmarkAndCategory() = default;
+ BookmarkAndCategory(int bookmarkIndex, int categoryIndex) : m_bookmarkIndex(bookmarkIndex),
+ m_categoryIndex(categoryIndex) {}
-inline bool IsValid(BookmarkAndCategory const & bmc)
-{
- return (bmc.first >= 0 && bmc.second >= 0);
-}
+ bool IsValid() const { return m_bookmarkIndex >= 0 && m_categoryIndex >= 0; };
+
+ int m_bookmarkIndex = -1;
+ int m_categoryIndex = -1;
+};
diff --git a/map/framework.cpp b/map/framework.cpp
index 10e33394c7..c406e71808 100644
--- a/map/framework.cpp
+++ b/map/framework.cpp
@@ -683,8 +683,15 @@ bool Framework::DeleteBmCategory(size_t index)
void Framework::FillBookmarkInfo(Bookmark const & bmk, BookmarkAndCategory const & bac, place_page::Info & info) const
{
FillPointInfo(bmk.GetPivot(), string(), info);
+ info.m_countryId = m_infoGetter->GetRegionCountryId(info.GetMercator());
+
info.m_bac = bac;
- info.m_bookmarkCategoryName = GetBmCategory(bac.first)->GetName();
+ BookmarkCategory * cat = GetBmCategory(bac.m_categoryIndex);
+ info.m_bookmarkCategoryName = cat->GetName();
+ BookmarkData const & data = static_cast<Bookmark const *>(cat->GetUserMark(bac.m_bookmarkIndex))->GetData();
+ info.m_bookmarkTitle = data.GetName();
+ info.m_bookmarkColorName = data.GetType();
+ info.m_bookmarkDescription = data.GetDescription();
}
void Framework::FillFeatureInfo(FeatureID const & fid, place_page::Info & info) const
@@ -801,7 +808,7 @@ void Framework::ShowBookmark(BookmarkAndCategory const & bnc)
{
StopLocationFollow();
- Bookmark const * mark = static_cast<Bookmark const *>(GetBmCategory(bnc.first)->GetUserMark(bnc.second));
+ Bookmark const * mark = static_cast<Bookmark const *>(GetBmCategory(bnc.m_categoryIndex)->GetUserMark(bnc.m_bookmarkIndex));
double scale = mark->GetScale();
if (scale == -1.0)
@@ -1901,31 +1908,31 @@ bool Framework::GetFeatureByID(FeatureID const & fid, FeatureType & ft) const
BookmarkAndCategory Framework::FindBookmark(UserMark const * mark) const
{
- BookmarkAndCategory empty = MakeEmptyBookmarkAndCategory();
- BookmarkAndCategory result = empty;
+ BookmarkAndCategory empty;
+ BookmarkAndCategory result;
ASSERT_LESS_OR_EQUAL(GetBmCategoriesCount(), numeric_limits<int>::max(), ());
for (size_t i = 0; i < GetBmCategoriesCount(); ++i)
{
if (mark->GetContainer() == GetBmCategory(i))
{
- result.first = static_cast<int>(i);
+ result.m_categoryIndex = static_cast<int>(i);
break;
}
}
- ASSERT(result.first != empty.first, ());
- BookmarkCategory const * cat = GetBmCategory(result.first);
+ ASSERT(result.m_categoryIndex != empty.m_categoryIndex, ());
+ BookmarkCategory const * cat = GetBmCategory(result.m_categoryIndex);
ASSERT_LESS_OR_EQUAL(cat->GetUserMarkCount(), numeric_limits<int>::max(), ());
for (size_t i = 0; i < cat->GetUserMarkCount(); ++i)
{
if (mark == cat->GetUserMark(i))
{
- result.second = static_cast<int>(i);
+ result.m_bookmarkIndex = static_cast<int>(i);
break;
}
}
- ASSERT(result != empty, ());
+ ASSERT(result.IsValid(), ());
return result;
}
diff --git a/map/place_page_info.cpp b/map/place_page_info.cpp
index 7fbbe1c26a..20a5b97ba9 100644
--- a/map/place_page_info.cpp
+++ b/map/place_page_info.cpp
@@ -3,6 +3,8 @@
#include "indexer/feature_utils.hpp"
#include "indexer/osm_editor.hpp"
+#include "platform/measurement_utils.hpp"
+
namespace place_page
{
char const * const Info::kSubtitleSeparator = " • ";
@@ -12,7 +14,7 @@ char const * const Info::kEmptyRatingSymbol = "-";
char const * const Info::kPricingSymbol = "$";
bool Info::IsFeature() const { return m_featureID.IsValid(); }
-bool Info::IsBookmark() const { return m_bac != MakeEmptyBookmarkAndCategory(); }
+bool Info::IsBookmark() const { return m_bac.IsValid(); }
bool Info::IsMyPosition() const { return m_isMyPosition; }
bool Info::IsSponsoredHotel() const { return m_isSponsoredHotel; }
bool Info::IsHotel() const { return m_isHotel; }
@@ -103,6 +105,12 @@ string Info::FormatStars() const
return stars;
}
+string Info::GetFormattedCoordinate(bool isDMS) const
+{
+ auto const ll = GetLatLon();
+ return isDMS ? measurement_utils::FormatLatLon(ll.lat, ll.lon) : measurement_utils::FormatLatLonAsDMS(ll.lat, ll.lon, 2);
+}
+
string Info::GetCustomName() const { return m_customName; }
BookmarkAndCategory Info::GetBookmarkAndCategory() const { return m_bac; }
string Info::GetBookmarkCategoryName() const { return m_bookmarkCategoryName; }
diff --git a/map/place_page_info.hpp b/map/place_page_info.hpp
index ece891102e..2a150f4b43 100644
--- a/map/place_page_info.hpp
+++ b/map/place_page_info.hpp
@@ -54,6 +54,9 @@ public:
/// @returns empty string or GetStars() count of ★ symbol.
string FormatStars() const;
+ /// @returns coordinate in DMS format if isDMS is true
+ string GetFormattedCoordinate(bool isDMS) const;
+
string GetCustomName() const;
BookmarkAndCategory GetBookmarkAndCategory() const;
string GetBookmarkCategoryName() const;
@@ -72,9 +75,15 @@ public:
/// Comes from API, shared links etc.
string m_customName;
/// If not empty, bookmark is bound to this place page.
- BookmarkAndCategory m_bac = MakeEmptyBookmarkAndCategory();
+ BookmarkAndCategory m_bac;
/// Bookmark category name. Empty, if it's not bookmark;
string m_bookmarkCategoryName;
+ /// Bookmark title. Empty, if it's not bookmark;
+ string m_bookmarkTitle;
+ /// Bookmark color name. Empty, if it's not bookmark;
+ string m_bookmarkColorName;
+ /// Bookmark description. Empty, if it's not bookmark;
+ string m_bookmarkDescription;
/// Api ID passed for the selected object. It's automatically included in api url below.
string m_apiId;
/// [Deep] link to open when "Back" button is pressed in a Place Page.