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/kml
diff options
context:
space:
mode:
authorAnatoliy Tomilov <tomilovanatoliy@gmail.com>2020-10-01 18:04:13 +0300
committermpimenov <mpimenov@users.noreply.github.com>2020-10-17 02:12:48 +0300
commit10450c31832886b8fa710372b524ea369d5b7f05 (patch)
tree7ddcb42e03152db7efe408f92c01f546610e46aa /kml
parent9c10d61bca3c165c9b1d96e247ca6ad2df0ecda8 (diff)
[kml] [kmb] Bump kmb version to V8. Add Bookmark::m_minZoom. MAPSME-14916
Diffstat (limited to 'kml')
-rw-r--r--kml/CMakeLists.txt1
-rw-r--r--kml/header_binary.hpp3
-rw-r--r--kml/kml_tests/tests_data.hpp25
-rw-r--r--kml/serdes_binary.hpp12
-rw-r--r--kml/types.hpp4
-rw-r--r--kml/types_v8.hpp152
-rw-r--r--kml/types_v9.hpp11
7 files changed, 189 insertions, 19 deletions
diff --git a/kml/CMakeLists.txt b/kml/CMakeLists.txt
index 3d893a610b..43d34482fc 100644
--- a/kml/CMakeLists.txt
+++ b/kml/CMakeLists.txt
@@ -14,6 +14,7 @@ set(
types_v6.hpp
types_v7.hpp
types_v8.hpp
+ types_v9.hpp
visitors.hpp
)
diff --git a/kml/header_binary.hpp b/kml/header_binary.hpp
index 12e0503592..fd17f7021d 100644
--- a/kml/header_binary.hpp
+++ b/kml/header_binary.hpp
@@ -24,7 +24,8 @@ enum class Version : uint8_t
V7 = 7, // 13th February 2020: track points are replaced by points with altitude.
V8 = 8, // 24 September 2020: add compilations to types and corresponding section to kmb and
// tags to kml
- Latest = V8
+ V9 = 9, // 01 October 2020: add minZoom to bookmarks
+ Latest = V9
};
struct Header
diff --git a/kml/kml_tests/tests_data.hpp b/kml/kml_tests/tests_data.hpp
index e289f2ca93..c8ac4742c4 100644
--- a/kml/kml_tests/tests_data.hpp
+++ b/kml/kml_tests/tests_data.hpp
@@ -1364,23 +1364,24 @@ std::vector<uint8_t> const kBinKmlV4 = {
};
std::vector<uint8_t> const kBinKml = {
- 0x08, 0x00, 0x00, 0x1E, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5E, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x16, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x01, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x18, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8A, 0x02, 0x00, 0x00,
+ 0x09, 0x00, 0x00, 0x1E, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5E, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x26, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x27, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x28, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9A, 0x02, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x01,
0x00, 0x01, 0x00, 0x01, 0x00, 0x02, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x0D, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x8D, 0xB7, 0xF5, 0x71, 0xFC, 0x8C, 0xFC, 0xC0, 0x02, 0x00, 0x01,
- 0x00, 0x05, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF3, 0xC2,
- 0xFB, 0xF9, 0x01, 0xE3, 0xB9, 0xBB, 0x8E, 0x01, 0xC3, 0xC5, 0xD2, 0xBB, 0x02, 0x00, 0x01, 0x00,
- 0x05, 0x01, 0x00, 0x05, 0x01, 0x00, 0x06, 0x01, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB8,
- 0xBC, 0xED, 0xA7, 0x03, 0x97, 0xB0, 0x9A, 0xA7, 0x02, 0xA4, 0xD6, 0xAE, 0xDB, 0x02, 0x00, 0x01,
- 0x00, 0x05, 0x01, 0x00, 0x08, 0x00, 0x01, 0x00, 0x09, 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9C,
- 0xCD, 0x97, 0xA7, 0x02, 0xFD, 0xC1, 0xAC, 0xDB, 0x02, 0x00, 0x01, 0x00, 0x05, 0x01, 0x00, 0x0A,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x05, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, 0x01, 0x00, 0x00,
+ 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xF3, 0xC2, 0xFB, 0xF9, 0x01, 0xE3, 0xB9, 0xBB, 0x8E, 0x01, 0xC3, 0xC5, 0xD2, 0xBB,
+ 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x05, 0x01, 0x00, 0x05, 0x01, 0x00, 0x06, 0x01,
+ 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x02,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB8, 0xBC, 0xED, 0xA7, 0x03, 0x97, 0xB0, 0x9A, 0xA7,
+ 0x02, 0xA4, 0xD6, 0xAE, 0xDB, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x05, 0x01, 0x00,
+ 0x08, 0x00, 0x01, 0x00, 0x09, 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9C, 0xCD, 0x97, 0xA7, 0x02,
+ 0xFD, 0xC1, 0xAC, 0xDB, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x05, 0x01, 0x00, 0x0A,
0x01, 0x00, 0x0B, 0x01, 0x00, 0x0C, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0E, 0x08, 0x08, 0x1B, 0x1A, 0x1B, 0x41, 0x41, 0x0C, 0x11,
0x0C, 0x37, 0x3E, 0x00, 0x01, 0x00, 0x01, 0x06, 0x01, 0x03, 0x09, 0x03, 0x05, 0x05, 0x07, 0x07,
diff --git a/kml/serdes_binary.hpp b/kml/serdes_binary.hpp
index a272b6e406..c5568793db 100644
--- a/kml/serdes_binary.hpp
+++ b/kml/serdes_binary.hpp
@@ -155,7 +155,7 @@ public:
if (m_header.m_version != Version::V2 && m_header.m_version != Version::V3 &&
m_header.m_version != Version::V4 && m_header.m_version != Version::V5 &&
m_header.m_version != Version::V6 && m_header.m_version != Version::V7 &&
- m_header.m_version != Version::V8)
+ m_header.m_version != Version::V8 && m_header.m_version != Version::V9)
{
MYTHROW(DeserializeException, ("Incorrect file version."));
}
@@ -174,6 +174,16 @@ public:
DeserializeFileData(subReader, m_data);
break;
}
+ case Version::V8:
+ {
+ FileDataV8 dataV8;
+ dataV8.m_deviceId = m_data.m_deviceId;
+ dataV8.m_serverId = m_data.m_serverId;
+ DeserializeFileData(subReader, dataV8);
+
+ m_data = dataV8.ConvertToLatestVersion();
+ break;
+ }
case Version::V7:
{
FileDataV7 dataV7;
diff --git a/kml/types.hpp b/kml/types.hpp
index d9dcfe1eca..f37f4fbcba 100644
--- a/kml/types.hpp
+++ b/kml/types.hpp
@@ -228,6 +228,7 @@ struct BookmarkData
visitor(m_boundTracks, "boundTracks"),
visitor(m_visible, "visible"),
visitor(m_nearestToponym, "nearestToponym"),
+ visitor(m_minZoom, "minZoom"),
visitor(m_compilations, "compilations"),
visitor(m_properties, "properties"),
VISITOR_COLLECTABLE)
@@ -248,6 +249,7 @@ struct BookmarkData
m_boundTracks == data.m_boundTracks &&
m_visible == data.m_visible &&
m_nearestToponym == data.m_nearestToponym &&
+ m_minZoom == data.m_minZoom &&
m_compilations == data.m_compilations &&
m_properties == data.m_properties;
}
@@ -281,6 +283,8 @@ struct BookmarkData
bool m_visible = true;
// Nearest toponym.
std::string m_nearestToponym;
+ // Minimal zoom when bookmark is visible.
+ int m_minZoom = 1;
// List of compilationIds.
std::vector<CompilationId> m_compilations;
// Key-value properties.
diff --git a/kml/types_v8.hpp b/kml/types_v8.hpp
index 0879f3f019..b27d149ebb 100644
--- a/kml/types_v8.hpp
+++ b/kml/types_v8.hpp
@@ -1,11 +1,153 @@
#pragma once
-#include "kml/types.hpp"
+#include "kml/types_v9.hpp"
namespace kml
{
-using BookmarkDataV8 = BookmarkData;
-using TrackDataV8 = TrackData;
-using CategoryDataV8 = CategoryData;
-using FileDataV8 = FileData;
+
+struct BookmarkDataV8
+{
+ DECLARE_VISITOR_AND_DEBUG_PRINT(BookmarkDataV8, visitor(m_id, "id"),
+ visitor(m_name, "name"),
+ visitor(m_description, "description"),
+ visitor(m_featureTypes, "featureTypes"),
+ visitor(m_customName, "customName"),
+ visitor(m_color, "color"),
+ visitor(m_icon, "icon"),
+ visitor(m_viewportScale, "viewportScale"),
+ visitor(m_timestamp, "timestamp"),
+ visitor(m_point, "point"),
+ visitor(m_boundTracks, "boundTracks"),
+ visitor(m_visible, "visible"),
+ visitor(m_nearestToponym, "nearestToponym"),
+ visitor(m_properties, "properties"),
+ visitor(m_compilations, "compilations"),
+ VISITOR_COLLECTABLE)
+
+ DECLARE_COLLECTABLE(LocalizableStringIndex, m_name, m_description, m_customName,
+ m_nearestToponym, m_properties)
+
+ bool operator==(BookmarkDataV8 const & data) const
+ {
+ return m_id == data.m_id && m_name == data.m_name &&
+ m_description == data.m_description &&
+ m_color == data.m_color && m_icon == data.m_icon &&
+ m_viewportScale == data.m_viewportScale &&
+ IsEqual(m_timestamp, data.m_timestamp) &&
+ m_point.EqualDxDy(data.m_point, kMwmPointAccuracy) &&
+ m_featureTypes == data.m_featureTypes &&
+ m_customName == data.m_customName &&
+ m_boundTracks == data.m_boundTracks &&
+ m_visible == data.m_visible &&
+ m_nearestToponym == data.m_nearestToponym &&
+ m_properties == data.m_properties &&
+ m_compilations == data.m_compilations;
+ }
+
+ BookmarkData ConvertToLatestVersion()
+ {
+ BookmarkData data;
+ data.m_id = m_id;
+ data.m_name = m_name;
+ data.m_description = m_description;
+ data.m_featureTypes = m_featureTypes;
+ data.m_customName = m_customName;
+ data.m_color = m_color;
+ data.m_icon = m_icon;
+ data.m_viewportScale = m_viewportScale;
+ data.m_timestamp = m_timestamp;
+ data.m_point = m_point;
+ data.m_boundTracks = m_boundTracks;
+ data.m_visible = m_visible;
+ data.m_nearestToponym = m_nearestToponym;
+ data.m_properties = m_properties;
+ data.m_compilations = m_compilations;
+ return data;
+ }
+
+ bool operator!=(BookmarkDataV8 const & data) const { return !operator==(data); }
+
+ // Unique id (it will not be serialized in text files).
+ MarkId m_id = kInvalidMarkId;
+ // Bookmark's name.
+ LocalizableString m_name;
+ // Bookmark's description.
+ LocalizableString m_description;
+ // Bound feature's types: type indices sorted by importance, the most
+ // important one goes first.
+ std::vector<uint32_t> m_featureTypes;
+ // Custom bookmark's name.
+ LocalizableString m_customName;
+ // Bookmark's color.
+ ColorData m_color;
+ // Bookmark's icon.
+ BookmarkIcon m_icon = BookmarkIcon::None;
+ // Viewport scale. 0 is a default value (no scale set).
+ uint8_t m_viewportScale = 0;
+ // Creation timestamp.
+ Timestamp m_timestamp = {};
+ // Coordinates in mercator.
+ m2::PointD m_point;
+ // Bound tracks (vector contains local track ids).
+ std::vector<LocalId> m_boundTracks;
+ // Visibility.
+ bool m_visible = true;
+ // Nearest toponym.
+ std::string m_nearestToponym;
+ // Key-value properties.
+ Properties m_properties;
+ // List of compilationIds.
+ std::vector<CompilationId> m_compilations;
+};
+
+using TrackDataV8 = TrackDataV9;
+using CategoryDataV8 = CategoryDataV9;
+
+struct FileDataV8
+{
+ DECLARE_VISITOR_AND_DEBUG_PRINT(FileDataV8, visitor(m_serverId, "serverId"),
+ visitor(m_categoryData, "category"),
+ visitor(m_bookmarksData, "bookmarks"),
+ visitor(m_tracksData, "tracks"),
+ visitor(m_compilationData, "compilations"))
+
+ bool operator==(FileDataV8 const & data) const
+ {
+ return m_serverId == data.m_serverId && m_categoryData == data.m_categoryData &&
+ m_bookmarksData == data.m_bookmarksData && m_tracksData == data.m_tracksData &&
+ m_compilationData == data.m_compilationData;
+ }
+
+ bool operator!=(FileDataV8 const & data) const { return !operator==(data); }
+
+ FileData ConvertToLatestVersion()
+ {
+ FileData data;
+ data.m_deviceId = m_deviceId;
+ data.m_serverId = m_serverId;
+
+ data.m_categoryData = m_categoryData;
+
+ data.m_bookmarksData.reserve(m_bookmarksData.size());
+ for (auto & d : m_bookmarksData)
+ data.m_bookmarksData.emplace_back(d.ConvertToLatestVersion());
+
+ data.m_tracksData = m_tracksData;
+
+ return data;
+ }
+
+ // Device id (it will not be serialized in text files).
+ std::string m_deviceId;
+ // Server id.
+ std::string m_serverId;
+ // Category's data.
+ CategoryDataV8 m_categoryData;
+ // Bookmarks collection.
+ std::vector<BookmarkDataV8> m_bookmarksData;
+ // Tracks collection.
+ std::vector<TrackDataV8> m_tracksData;
+ // Compilation collection.
+ std::vector<CategoryDataV8> m_compilationData;
+};
} // namespace kml
diff --git a/kml/types_v9.hpp b/kml/types_v9.hpp
new file mode 100644
index 0000000000..00aa6bfff3
--- /dev/null
+++ b/kml/types_v9.hpp
@@ -0,0 +1,11 @@
+#pragma once
+
+#include "kml/types.hpp"
+
+namespace kml
+{
+using BookmarkDataV9 = BookmarkData;
+using TrackDataV9 = TrackData;
+using CategoryDataV9 = CategoryData;
+using FileDataV9 = FileData;
+} // namespace kml