From cce38d001bc795c0ad29268b3cdf6c8eee833b7a Mon Sep 17 00:00:00 2001 From: Anatoliy Tomilov Date: Thu, 1 Oct 2020 20:39:46 +0500 Subject: [PATCH] [kml] Add BookmarkData::m_minZoom support to text kml serdes. MAPSME-14916 --- kml/kml_tests/serdes_tests.cpp | 3 ++- kml/serdes.cpp | 14 ++++++++++++++ kml/serdes.hpp | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/kml/kml_tests/serdes_tests.cpp b/kml/kml_tests/serdes_tests.cpp index 3d9417f51e..d17d76351b 100644 --- a/kml/kml_tests/serdes_tests.cpp +++ b/kml/kml_tests/serdes_tests.cpp @@ -84,6 +84,7 @@ kml::FileData GenerateKmlFileData() bookmarkData.m_boundTracks = {0}; bookmarkData.m_visible = false; bookmarkData.m_nearestToponym = "12345"; + bookmarkData.m_minZoom = 10; bookmarkData.m_properties = {{"bm_property1", "value1"}, {"bm_property2", "value2"}, {"score", "5"}}; @@ -419,6 +420,7 @@ R"( 0 12345 + 10 value1 value2 @@ -462,7 +464,6 @@ R"( value1 value2 - 5,6,7,8,9 diff --git a/kml/serdes.cpp b/kml/serdes.cpp index d82ac2b2ab..651b41befd 100644 --- a/kml/serdes.cpp +++ b/kml/serdes.cpp @@ -450,6 +450,12 @@ void SaveBookmarkExtendedData(KmlWriter::WriterWrapper & writer, BookmarkData co writer << "\n"; } + if (bookmarkData.m_minZoom > 1) + { + writer << kIndent6 << "" << strings::to_string(bookmarkData.m_minZoom) + << "\n"; + } + SaveStringsMap(writer, bookmarkData.m_properties, "properties", kIndent6); if (!bookmarkData.m_compilations.empty()) @@ -867,6 +873,7 @@ void KmlParser::Pop(std::string const & tag) data.m_boundTracks = std::move(m_boundTracks); data.m_visible = m_visible; data.m_nearestToponym = std::move(m_nearestToponym); + data.m_minZoom = m_minZoom; data.m_properties = std::move(m_properties); data.m_compilations = std::move(m_compilations); @@ -1160,6 +1167,13 @@ void KmlParser::CharData(std::string value) { m_nearestToponym = value; } + else if (currTag == "mwm:minZoom") + { + if (!strings::to_int(value, m_minZoom) || m_minZoom < 1) + m_minZoom = 1; + else if (m_minZoom > 19) + m_minZoom = 19; + } else if (currTag == "mwm:compilations") { m_compilations.clear(); diff --git a/kml/serdes.hpp b/kml/serdes.hpp index 0446e666e5..78b0a7ca97 100644 --- a/kml/serdes.hpp +++ b/kml/serdes.hpp @@ -129,6 +129,7 @@ private: bool m_visible; std::string m_nearestToponym; std::vector m_nearestToponyms; + int m_minZoom = 1; kml::Properties m_properties; std::vector m_compilations; double m_trackWidth;