[bookmarks] Extended bookmarks icons.

This commit is contained in:
Daria Volvenkova 2019-12-04 14:28:13 +03:00 committed by Arsentiy Milchakov
parent c796a1342f
commit 9691cc75ef
7 changed files with 110 additions and 29 deletions

View file

@ -1364,7 +1364,7 @@ std::vector<uint8_t> const kBinKmlV4 = {
};
std::vector<uint8_t> const kBinKml = {
0x05, 0x00, 0x00, 0x1E, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4D, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x1E, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4D, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x74, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x01, 0x00,

View file

@ -300,6 +300,14 @@ std::string PredefinedColorToString(PredefinedColor c)
case PredefinedColor::Brown: return "BROWN";
case PredefinedColor::Green: return "GREEN";
case PredefinedColor::Orange: return "ORANGE";
case PredefinedColor::DeepPurple: return "DEEPPURPLE";
case PredefinedColor::LightBlue: return "LIGHTBLUE";
case PredefinedColor::Cyan: return "CYAN";
case PredefinedColor::Teal: return "TEAL";
case PredefinedColor::Lime: return "LIME";
case PredefinedColor::DeepOrange: return "DEEPORANGE";
case PredefinedColor::Gray: return "GRAY";
case PredefinedColor::BlueGray: return "BLUEGRAY";
case PredefinedColor::Count: CHECK(false, ("Unknown predefined color")); return {};
}
}
@ -343,6 +351,12 @@ std::string BookmarkIconToString(BookmarkIcon icon)
case BookmarkIcon::Sights: return "SIGHTS";
case BookmarkIcon::Swim: return "SWIM";
case BookmarkIcon::Water: return "WATER";
case BookmarkIcon::Bar: return "BAR";
case BookmarkIcon::Transport: return "TRANSPORT";
case BookmarkIcon::Viewpoint: return "VIEWPOINT";
case BookmarkIcon::Sport: return "SPORT";
case BookmarkIcon::Start: return "START";
case BookmarkIcon::Finish: return "FINISH";
case BookmarkIcon::Count: CHECK(false, ("Unknown bookmark icon")); return {};
}
}
@ -698,6 +712,12 @@ BOOST_PYTHON_MODULE(pykmlib)
.value(BookmarkIconToString(BookmarkIcon::Sights).c_str(), BookmarkIcon::Sights)
.value(BookmarkIconToString(BookmarkIcon::Swim).c_str(), BookmarkIcon::Swim)
.value(BookmarkIconToString(BookmarkIcon::Water).c_str(), BookmarkIcon::Water)
.value(BookmarkIconToString(BookmarkIcon::Bar).c_str(), BookmarkIcon::Bar)
.value(BookmarkIconToString(BookmarkIcon::Transport).c_str(), BookmarkIcon::Transport)
.value(BookmarkIconToString(BookmarkIcon::Viewpoint).c_str(), BookmarkIcon::Viewpoint)
.value(BookmarkIconToString(BookmarkIcon::Sport).c_str(), BookmarkIcon::Sport)
.value(BookmarkIconToString(BookmarkIcon::Start).c_str(), BookmarkIcon::Start)
.value(BookmarkIconToString(BookmarkIcon::Finish).c_str(), BookmarkIcon::Finish)
.export_values();
class_<ColorData>("ColorData")

View file

@ -154,7 +154,7 @@ BookmarkIcon GetIcon(std::string const & iconName)
for (size_t i = 0; i < static_cast<size_t>(BookmarkIcon::Count); ++i)
{
auto const icon = static_cast<BookmarkIcon>(i);
if (iconName == DebugPrint(icon))
if (iconName == ToString(icon))
return icon;
}
return BookmarkIcon::None;
@ -375,7 +375,7 @@ void SaveBookmarkExtendedData(KmlWriter::WriterWrapper & writer, BookmarkData co
}
if (bookmarkData.m_icon != BookmarkIcon::None)
writer << kIndent6 << "<mwm:icon>" << DebugPrint(bookmarkData.m_icon) << "</mwm:icon>\n";
writer << kIndent6 << "<mwm:icon>" << ToString(bookmarkData.m_icon) << "</mwm:icon>\n";
if (!bookmarkData.m_boundTracks.empty())
{

View file

@ -26,7 +26,8 @@ enum class Version : uint8_t
V3 = 3, // 7th May 2018 (persistent feature types).
V4 = 4, // 26th August 2019 (key-value properties and nearestToponym for bookmarks and tracks, cities -> toponyms).
V5 = 5, // 21st November 2019 (extended color palette).
Latest = V5
V6 = 6, // 3rd December 2019 (extended bookmark icons).
Latest = V6
};
class SerializerKml
@ -138,8 +139,11 @@ public:
NonOwningReaderSource source(reader);
auto const v = ReadPrimitiveFromSource<Version>(source);
if (v != Version::Latest && v != Version::V2 && v != Version::V3 && v != Version::V4)
if (v != Version::Latest && v != Version::V2 && v != Version::V3 && v != Version::V4 &&
v != Version::V5)
{
MYTHROW(DeserializeException, ("Incorrect file version."));
}
ReadDeviceId(source);
ReadServerId(source);
@ -148,9 +152,9 @@ public:
auto subReader = reader.CreateSubReader(source.Pos(), source.Size());
InitializeIfNeeded(*subReader);
if (v == Version::V5 || v == Version::V4)
if (v == Version::V6 || v == Version::V5 || v == Version::V4)
{
// NOTE: v.4 and v.5 are binary compatible.
// NOTE: v.4, v.5 and v.6 are binary compatible.
DeserializeCategory(subReader, m_data);
DeserializeBookmarks(subReader, m_data);
DeserializeTracks(subReader, m_data);

View file

@ -117,6 +117,15 @@ enum class BookmarkIcon : uint16_t
Sights,
Swim,
Water,
// Extended icons.
Bar,
Transport,
Viewpoint,
Sport,
Start,
Finish,
Count
};
@ -145,6 +154,12 @@ inline std::string ToString(BookmarkIcon icon)
case BookmarkIcon::Sights: return "Sights";
case BookmarkIcon::Swim: return "Swim";
case BookmarkIcon::Water: return "Water";
case BookmarkIcon::Bar: return "Bar";
case BookmarkIcon::Transport: return "Transport";
case BookmarkIcon::Viewpoint: return "Viewpoint";
case BookmarkIcon::Sport: return "Sport";
case BookmarkIcon::Start: return "Start";
case BookmarkIcon::Finish: return "Finish";
case BookmarkIcon::Count: return {};
}
UNREACHABLE();

View file

@ -38,6 +38,12 @@ std::string GetBookmarkIconType(kml::BookmarkIcon const & icon)
case kml::BookmarkIcon::Sights: return "sights";
case kml::BookmarkIcon::Swim: return "swim";
case kml::BookmarkIcon::Water: return "water";
case kml::BookmarkIcon::Bar: return "bar";
case kml::BookmarkIcon::Transport: return "transport";
case kml::BookmarkIcon::Viewpoint: return "viewpoint";
case kml::BookmarkIcon::Sport: return "sport";
case kml::BookmarkIcon::Start: return "start";
case kml::BookmarkIcon::Finish: return "finish";
case kml::BookmarkIcon::Count:
ASSERT(false, ("Invalid bookmark icon type"));
return {};

View file

@ -35,9 +35,10 @@ std::map<std::string, kml::BookmarkIcon> const kFeatureTypeToBookmarkIcon = {
{"amenity-restaurant", kml::BookmarkIcon::Food},
{"amenity-fast_food", kml::BookmarkIcon::Food},
{"amenity-food_court", kml::BookmarkIcon::Food},
{"amenity-bar", kml::BookmarkIcon::Food},
{"amenity-pub", kml::BookmarkIcon::Food},
{"amenity-biergarten", kml::BookmarkIcon::Food},
{"amenity-bar", kml::BookmarkIcon::Bar},
{"amenity-pub", kml::BookmarkIcon::Bar},
{"amenity-biergarten", kml::BookmarkIcon::Bar},
{"waterway-waterfall", kml::BookmarkIcon::Sights},
{"historic-tomb", kml::BookmarkIcon::Sights},
@ -49,7 +50,6 @@ std::map<std::string, kml::BookmarkIcon> const kFeatureTypeToBookmarkIcon = {
{"amenity-place_of_worship", kml::BookmarkIcon::Sights},
{"tourism-attraction", kml::BookmarkIcon::Sights},
{"tourism-theme_park", kml::BookmarkIcon::Sights},
{"tourism-viewpoint", kml::BookmarkIcon::Sights},
{"historic-fort", kml::BookmarkIcon::Sights},
{"historic-castle", kml::BookmarkIcon::Sights},
{"tourism-artwork", kml::BookmarkIcon::Sights},
@ -57,34 +57,47 @@ std::map<std::string, kml::BookmarkIcon> const kFeatureTypeToBookmarkIcon = {
{"historic-wayside_shrine", kml::BookmarkIcon::Sights},
{"historic-wayside_cross", kml::BookmarkIcon::Sights},
{"tourism-viewpoint", kml::BookmarkIcon::Viewpoint},
{"tourism-gallery", kml::BookmarkIcon::Museum},
{"tourism-museum", kml::BookmarkIcon::Museum},
{"amenity-arts_centre", kml::BookmarkIcon::Museum},
{"sport", kml::BookmarkIcon::Entertainment},
{"sport-multi", kml::BookmarkIcon::Entertainment},
{"leisure-playground", kml::BookmarkIcon::Entertainment},
{"leisure-water_park", kml::BookmarkIcon::Entertainment},
{"amenity-casino", kml::BookmarkIcon::Entertainment},
{"sport-archery", kml::BookmarkIcon::Entertainment},
{"sport-shooting", kml::BookmarkIcon::Entertainment},
{"sport-australian_football", kml::BookmarkIcon::Entertainment},
{"sport-bowls", kml::BookmarkIcon::Entertainment},
{"sport-curling", kml::BookmarkIcon::Entertainment},
{"sport-cricket", kml::BookmarkIcon::Entertainment},
{"sport-baseball", kml::BookmarkIcon::Entertainment},
{"sport-basketball", kml::BookmarkIcon::Entertainment},
{"sport-american_football", kml::BookmarkIcon::Entertainment},
{"sport-athletics", kml::BookmarkIcon::Entertainment},
{"sport-golf", kml::BookmarkIcon::Entertainment},
{"sport-gymnastics", kml::BookmarkIcon::Entertainment},
{"sport-tennis", kml::BookmarkIcon::Entertainment},
{"sport-skiing", kml::BookmarkIcon::Entertainment},
{"sport-soccer", kml::BookmarkIcon::Entertainment},
{"amenity-nightclub", kml::BookmarkIcon::Entertainment},
{"amenity-cinema", kml::BookmarkIcon::Entertainment},
{"amenity-theatre", kml::BookmarkIcon::Entertainment},
{"leisure-stadium", kml::BookmarkIcon::Entertainment},
{"sport", kml::BookmarkIcon::Sport},
{"sport-multi", kml::BookmarkIcon::Sport},
{"sport-archery", kml::BookmarkIcon::Sport},
{"sport-shooting", kml::BookmarkIcon::Sport},
{"sport-australian_football", kml::BookmarkIcon::Sport},
{"sport-bowls", kml::BookmarkIcon::Sport},
{"sport-curling", kml::BookmarkIcon::Sport},
{"sport-cricket", kml::BookmarkIcon::Sport},
{"sport-baseball", kml::BookmarkIcon::Sport},
{"sport-basketball", kml::BookmarkIcon::Sport},
{"sport-american_football", kml::BookmarkIcon::Sport},
{"sport-athletics", kml::BookmarkIcon::Sport},
{"sport-golf", kml::BookmarkIcon::Sport},
{"sport-gymnastics", kml::BookmarkIcon::Sport},
{"sport-tennis", kml::BookmarkIcon::Sport},
{"sport-skiing", kml::BookmarkIcon::Sport},
{"sport-soccer", kml::BookmarkIcon::Sport},
{"leisure-stadium", kml::BookmarkIcon::Sport},
{"leisure-skiing", kml::BookmarkIcon::Sport},
{"leisure-fitness_centre", kml::BookmarkIcon::Sport},
{"olympics-stadium_main", kml::BookmarkIcon::Sport},
{"olympics-stadium", kml::BookmarkIcon::Sport},
{"olympics-water_sport", kml::BookmarkIcon::Sport},
{"olympics-bike_sport", kml::BookmarkIcon::Sport},
{"leisure-sports_centre-climbing", kml::BookmarkIcon::Sport},
{"leisure-sports_centre-shooting", kml::BookmarkIcon::Sport},
{"leisure-sports_centre-swimming", kml::BookmarkIcon::Sport},
{"leisure-sports_centre-yoga", kml::BookmarkIcon::Sport},
{"boundary-national_park", kml::BookmarkIcon::Park},
{"leisure-nature_reserve", kml::BookmarkIcon::Park},
@ -219,6 +232,20 @@ std::map<std::string, kml::BookmarkIcon> const kFeatureTypeToBookmarkIcon = {
{"tourism-camp_site", kml::BookmarkIcon::Parking},
{"amenity-motorcycle_parking", kml::BookmarkIcon::Parking},
{"amenity-bus_station", kml::BookmarkIcon::Transport},
{"amenity-car_sharing", kml::BookmarkIcon::Transport},
{"amenity-ferry_terminal", kml::BookmarkIcon::Transport},
{"public_transport-platform", kml::BookmarkIcon::Transport},
{"highway-platform", kml::BookmarkIcon::Transport},
{"aeroway-aerodrome", kml::BookmarkIcon::Transport},
{"aeroway-aerodrome-international", kml::BookmarkIcon::Transport},
{"railway-station-light_rail", kml::BookmarkIcon::Transport},
{"railway-station-subway", kml::BookmarkIcon::Transport},
{"railway-station-monorail", kml::BookmarkIcon::Transport},
{"railway-tram_stop", kml::BookmarkIcon::Transport},
{"highway-bus_stop", kml::BookmarkIcon::Transport},
{"building-train_station", kml::BookmarkIcon::Transport},
{"amenity-fuel", kml::BookmarkIcon::Gas},
{"amenity-charging_station", kml::BookmarkIcon::Gas},
@ -294,6 +321,15 @@ std::map<std::string, BookmarkBaseType> const kFeatureTypeToBookmarkType = {
{"amenity-cinema", BookmarkBaseType::Entertainment},
{"amenity-theatre", BookmarkBaseType::Entertainment},
{"leisure-stadium", BookmarkBaseType::Entertainment},
{"leisure-fitness_centre", BookmarkBaseType::Entertainment},
{"olympics-stadium_main", BookmarkBaseType::Entertainment},
{"olympics-stadium", BookmarkBaseType::Entertainment},
{"olympics-water_sport", BookmarkBaseType::Entertainment},
{"olympics-bike_sport", BookmarkBaseType::Entertainment},
{"leisure-sports_centre-climbing", BookmarkBaseType::Entertainment},
{"leisure-sports_centre-shooting", BookmarkBaseType::Entertainment},
{"leisure-sports_centre-swimming", BookmarkBaseType::Entertainment},
{"leisure-sports_centre-yoga", BookmarkBaseType::Entertainment},
{"boundary-national_park", BookmarkBaseType::Park},
{"leisure-nature_reserve", BookmarkBaseType::Park},