From 21503a6752c1e0acc2419eca76815af19818c1fd Mon Sep 17 00:00:00 2001 From: vng Date: Fri, 19 Oct 2012 02:40:40 +0300 Subject: [PATCH] Minor changes to support (as desired) test kml file. --- map/bookmark.cpp | 65 ++++++++++++++++++++++++++++++++++-------------- map/bookmark.hpp | 2 +- 2 files changed, 47 insertions(+), 20 deletions(-) diff --git a/map/bookmark.cpp b/map/bookmark.cpp index 89f721a086..092804049d 100644 --- a/map/bookmark.cpp +++ b/map/bookmark.cpp @@ -99,27 +99,27 @@ int BookmarkCategory::GetBookmark(m2::PointD const org, double const squareDista namespace bookmark_impl { - // Fixes icons which are not supported by MapsWithMe - static string GetSupportedBMType(string const & s) - { - static char const * icons[] = { - "placemark-red", "placemark-blue", "placemark-purple", - "placemark-pink", "placemark-brown", "placemark-green", "placemark-orange" - }; - - // Remove leading '#' symbol - string const result = s.substr(1); - for (size_t i = 0; i < ARRAY_SIZE(icons); ++i) - if (result == icons[i]) - return result; - - // Not recognized symbols are replaced with default one - LOG(LWARNING, ("Bookmark icon is not supported:", result)); - return icons[0]; - } - class KMLParser { + // Fixes icons which are not supported by MapsWithMe + string GetSupportedBMType(string const & s) const + { + static char const * icons[] = { + "placemark-red", "placemark-blue", "placemark-purple", + "placemark-pink", "placemark-brown", "placemark-green", "placemark-orange" + }; + + // Remove leading '#' symbol + string const result = s.substr(1); + for (size_t i = 0; i < ARRAY_SIZE(icons); ++i) + if (result == icons[i]) + return result; + + // Not recognized symbols are replaced with default one + LOG(LWARNING, ("Icon", result, "for bookmark", m_name, "is not supported")); + return icons[0]; + } + BookmarkCategory & m_category; vector m_tags; @@ -163,6 +163,31 @@ namespace bookmark_impl MercatorBounds::ValidX(m_org.x) && MercatorBounds::ValidY(m_org.y)); } + /* + void TryResolveName(string const & s) + { + if (m_name.empty()) + { + // "CosmosVDC" has only description in placemark. + size_t i1 = s.find("", i1); + if (i1 != string::npos) + { + ++i1; + size_t const i2 = s.find("", i1); + if (i2 != string::npos) + { + m_name = s.substr(i1, i2-i1); + strings::Trim(m_name); + } + } + } + } + } + */ + public: KMLParser(BookmarkCategory & cat) : m_category(cat) { @@ -210,6 +235,8 @@ namespace bookmark_impl { if (currTag == "name") m_name = value; + //else if (currTag == "description") + // TryResolveName(value); else if (currTag == "styleUrl") m_type = GetSupportedBMType(value); } diff --git a/map/bookmark.hpp b/map/bookmark.hpp index 594ea20570..9938c10bb1 100644 --- a/map/bookmark.hpp +++ b/map/bookmark.hpp @@ -24,7 +24,7 @@ public: { } - m2::PointD GetOrg() const { return m_org; } + m2::PointD const & GetOrg() const { return m_org; } string const & GetName() const { return m_name; } /// @return Now its a bookmark color. string const & GetType() const { return m_type; }