From 076cffef794bef7cee14503ed7cbc030f7721d61 Mon Sep 17 00:00:00 2001 From: Daria Volvenkova Date: Tue, 15 May 2018 14:18:24 +0300 Subject: [PATCH] Assign a bookmark icon automatically based on feature types. --- kml/types.hpp | 39 ++++++- map/bookmark.cpp | 19 ++++ map/bookmark_helpers.cpp | 222 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 279 insertions(+), 1 deletion(-) diff --git a/kml/types.hpp b/kml/types.hpp index f625250c98..76d6d525ac 100644 --- a/kml/types.hpp +++ b/kml/types.hpp @@ -67,7 +67,25 @@ enum class BookmarkIcon : uint16_t { None = 0, Hotel, - + Animals, + Buddhism, + Building, + Christianity, + Entertainment, + Exchange, + Food, + Gas, + Judaism, + Medicine, + Mountain, + Museum, + Islam, + Park, + Parking, + Shop, + Sights, + Swim, + Water, Count }; @@ -77,6 +95,25 @@ inline std::string DebugPrint(BookmarkIcon icon) { case BookmarkIcon::None: return "None"; case BookmarkIcon::Hotel: return "Hotel"; + case BookmarkIcon::Animals: return "Animals"; + case BookmarkIcon::Buddhism: return "Buddhism"; + case BookmarkIcon::Building: return "Building"; + case BookmarkIcon::Christianity: return "Christianity"; + case BookmarkIcon::Entertainment: return "Entertainment"; + case BookmarkIcon::Exchange: return "Exchange"; + case BookmarkIcon::Food: return "Food"; + case BookmarkIcon::Gas: return "Gas"; + case BookmarkIcon::Judaism: return "Judaism"; + case BookmarkIcon::Medicine: return "Medicine"; + case BookmarkIcon::Mountain: return "Mountain"; + case BookmarkIcon::Museum: return "Museum"; + case BookmarkIcon::Islam: return "Islam"; + case BookmarkIcon::Park: return "Park"; + case BookmarkIcon::Parking: return "Parking"; + case BookmarkIcon::Shop: return "Shop"; + case BookmarkIcon::Sights: return "Sights"; + case BookmarkIcon::Swim: return "Swim"; + case BookmarkIcon::Water: return "Water"; case BookmarkIcon::Count: return {}; } } diff --git a/map/bookmark.cpp b/map/bookmark.cpp index 06b6d4d976..5424722ca3 100644 --- a/map/bookmark.cpp +++ b/map/bookmark.cpp @@ -9,6 +9,25 @@ std::string GetBookmarkIconType(kml::BookmarkIcon const & icon) { case kml::BookmarkIcon::None: return "default"; case kml::BookmarkIcon::Hotel: return "hotel"; + case kml::BookmarkIcon::Animals: return "animals"; + case kml::BookmarkIcon::Buddhism: return "buddhism"; + case kml::BookmarkIcon::Building: return "building"; + case kml::BookmarkIcon::Christianity: return "christianity"; + case kml::BookmarkIcon::Entertainment: return "entertainment"; + case kml::BookmarkIcon::Exchange: return "exchange"; + case kml::BookmarkIcon::Food: return "food"; + case kml::BookmarkIcon::Gas: return "gas"; + case kml::BookmarkIcon::Judaism: return "judaism"; + case kml::BookmarkIcon::Medicine: return "medicine"; + case kml::BookmarkIcon::Mountain: return "mountain"; + case kml::BookmarkIcon::Museum: return "museum"; + case kml::BookmarkIcon::Islam: return "islam"; + case kml::BookmarkIcon::Park: return "park"; + case kml::BookmarkIcon::Parking: return "parking"; + case kml::BookmarkIcon::Shop: return "shop"; + case kml::BookmarkIcon::Sights: return "sights"; + case kml::BookmarkIcon::Swim: return "swim"; + case kml::BookmarkIcon::Water: return "water"; case kml::BookmarkIcon::Count: ASSERT(false, ("Invalid bookmark icon type")); return {}; diff --git a/map/bookmark_helpers.cpp b/map/bookmark_helpers.cpp index e98ad14256..2d1cf2088f 100644 --- a/map/bookmark_helpers.cpp +++ b/map/bookmark_helpers.cpp @@ -12,8 +12,223 @@ #include "coding/file_reader.hpp" #include "coding/file_writer.hpp" +#include + namespace { +std::map const kBookmarkTypeToIcon = { + {"amenity-bbq", kml::BookmarkIcon::Food}, + {"tourism-picnic_site", kml::BookmarkIcon::Food}, + {"leisure-picnic_table", kml::BookmarkIcon::Food}, + {"amenity-cafe", kml::BookmarkIcon::Food}, + {"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}, + + {"waterway-waterfall", kml::BookmarkIcon::Sights}, + {"historic-tomb", kml::BookmarkIcon::Sights}, + {"historic-boundary_stone", kml::BookmarkIcon::Sights}, + {"historic-ship", kml::BookmarkIcon::Sights}, + {"historic-archaeological_site", kml::BookmarkIcon::Sights}, + {"historic-monument", kml::BookmarkIcon::Sights}, + {"historic-memorial", kml::BookmarkIcon::Sights}, + {"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}, + {"historic-ruins", kml::BookmarkIcon::Sights}, + {"historic-wayside_shrine", kml::BookmarkIcon::Sights}, + {"historic-wayside_cross", kml::BookmarkIcon::Sights}, + + {"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}, + + {"boundary-national_park", kml::BookmarkIcon::Park}, + {"leisure-nature_reserve", kml::BookmarkIcon::Park}, + {"landuse-forest", kml::BookmarkIcon::Park}, + + {"natural-beach", kml::BookmarkIcon::Swim}, + {"sport-diving", kml::BookmarkIcon::Swim}, + {"sport-scuba_diving", kml::BookmarkIcon::Swim}, + {"sport-swimming", kml::BookmarkIcon::Swim}, + {"leisure-swimming_pool", kml::BookmarkIcon::Swim}, + + {"natural-cave_entrance", kml::BookmarkIcon::Mountain}, + {"natural-peak", kml::BookmarkIcon::Mountain}, + {"natural-volcano", kml::BookmarkIcon::Mountain}, + {"natural-rock", kml::BookmarkIcon::Mountain}, + {"natural-bare_rock", kml::BookmarkIcon::Mountain}, + + {"amenity-veterinary", kml::BookmarkIcon::Animals}, + {"leisure-dog_park", kml::BookmarkIcon::Animals}, + {"tourism-zoo", kml::BookmarkIcon::Animals}, + + {"tourism-apartment", kml::BookmarkIcon::Hotel}, + {"tourism-chalet", kml::BookmarkIcon::Hotel}, + {"tourism-guest_house", kml::BookmarkIcon::Hotel}, + {"tourism-alpine_hut", kml::BookmarkIcon::Hotel}, + {"tourism-wilderness_hut", kml::BookmarkIcon::Hotel}, + {"tourism-hostel", kml::BookmarkIcon::Hotel}, + {"tourism-motel", kml::BookmarkIcon::Hotel}, + {"tourism-resort", kml::BookmarkIcon::Hotel}, + {"tourism-hotel", kml::BookmarkIcon::Hotel}, + {"sponsored-booking", kml::BookmarkIcon::Hotel}, + + {"amenity-kindergarten", kml::BookmarkIcon::Building}, + {"amenity-school", kml::BookmarkIcon::Building}, + {"office", kml::BookmarkIcon::Building}, + {"amenity-library", kml::BookmarkIcon::Building}, + {"amenity-courthouse", kml::BookmarkIcon::Building}, + {"amenity-college", kml::BookmarkIcon::Building}, + {"amenity-police", kml::BookmarkIcon::Building}, + {"amenity-prison", kml::BookmarkIcon::Building}, + {"amenity-embassy", kml::BookmarkIcon::Building}, + {"office-lawyer", kml::BookmarkIcon::Building}, + {"building-train_station", kml::BookmarkIcon::Building}, + {"building-university", kml::BookmarkIcon::Building}, + + + {"amenity-atm", kml::BookmarkIcon::Exchange}, + {"amenity-bureau_de_change", kml::BookmarkIcon::Exchange}, + {"amenity-bank", kml::BookmarkIcon::Exchange}, + + {"amenity-vending_machine", kml::BookmarkIcon::Shop}, + {"shop", kml::BookmarkIcon::Shop}, + {"amenity-marketplace", kml::BookmarkIcon::Shop}, + {"craft", kml::BookmarkIcon::Shop}, + {"shop-pawnbroker", kml::BookmarkIcon::Shop}, + {"shop-supermarket", kml::BookmarkIcon::Shop}, + {"shop-car_repair", kml::BookmarkIcon::Shop}, + {"shop-mall", kml::BookmarkIcon::Shop}, + {"highway-services", kml::BookmarkIcon::Shop}, + {"shop-stationery", kml::BookmarkIcon::Shop}, + {"shop-variety_store", kml::BookmarkIcon::Shop}, + {"shop-alcohol", kml::BookmarkIcon::Shop}, + {"shop-wine", kml::BookmarkIcon::Shop}, + {"shop-books", kml::BookmarkIcon::Shop}, + {"shop-bookmaker", kml::BookmarkIcon::Shop}, + {"shop-bakery", kml::BookmarkIcon::Shop}, + {"shop-beauty", kml::BookmarkIcon::Shop}, + {"shop-cosmetics", kml::BookmarkIcon::Shop}, + {"shop-beverages", kml::BookmarkIcon::Shop}, + {"shop-bicycle", kml::BookmarkIcon::Shop}, + {"shop-butcher", kml::BookmarkIcon::Shop}, + {"shop-car", kml::BookmarkIcon::Shop}, + {"shop-motorcycle", kml::BookmarkIcon::Shop}, + {"shop-car_parts", kml::BookmarkIcon::Shop}, + {"shop-car_repair", kml::BookmarkIcon::Shop}, + {"shop-tyres", kml::BookmarkIcon::Shop}, + {"shop-chemist", kml::BookmarkIcon::Shop}, + {"shop-clothes", kml::BookmarkIcon::Shop}, + {"shop-computer", kml::BookmarkIcon::Shop}, + {"shop-tattoo", kml::BookmarkIcon::Shop}, + {"shop-erotic", kml::BookmarkIcon::Shop}, + {"shop-funeral_directors", kml::BookmarkIcon::Shop}, + {"shop-confectionery", kml::BookmarkIcon::Shop}, + {"shop-chocolate", kml::BookmarkIcon::Shop}, + {"amenity-ice_cream", kml::BookmarkIcon::Shop}, + {"shop-convenience", kml::BookmarkIcon::Shop}, + {"shop-copyshop", kml::BookmarkIcon::Shop}, + {"shop-photo", kml::BookmarkIcon::Shop}, + {"shop-pet", kml::BookmarkIcon::Shop}, + {"shop-department_store", kml::BookmarkIcon::Shop}, + {"shop-doityourself", kml::BookmarkIcon::Shop}, + {"shop-electronics", kml::BookmarkIcon::Shop}, + {"shop-florist", kml::BookmarkIcon::Shop}, + {"shop-furniture", kml::BookmarkIcon::Shop}, + {"shop-garden_centre", kml::BookmarkIcon::Shop}, + {"shop-gift", kml::BookmarkIcon::Shop}, + {"shop-music", kml::BookmarkIcon::Shop}, + {"shop-video", kml::BookmarkIcon::Shop}, + {"shop-musical_instrument", kml::BookmarkIcon::Shop}, + {"shop-greengrocer", kml::BookmarkIcon::Shop}, + {"shop-hairdresser", kml::BookmarkIcon::Shop}, + {"shop-hardware", kml::BookmarkIcon::Shop}, + {"shop-jewelry", kml::BookmarkIcon::Shop}, + {"shop-kiosk", kml::BookmarkIcon::Shop}, + {"shop-laundry", kml::BookmarkIcon::Shop}, + {"shop-dry_cleaning", kml::BookmarkIcon::Shop}, + {"shop-mobile_phone", kml::BookmarkIcon::Shop}, + {"shop-optician", kml::BookmarkIcon::Shop}, + {"shop-outdoor", kml::BookmarkIcon::Shop}, + {"shop-seafood", kml::BookmarkIcon::Shop}, + {"shop-shoes", kml::BookmarkIcon::Shop}, + {"shop-sports", kml::BookmarkIcon::Shop}, + {"shop-ticket", kml::BookmarkIcon::Shop}, + {"shop-toys", kml::BookmarkIcon::Shop}, + {"shop-fabric", kml::BookmarkIcon::Shop}, + {"shop-alcohol", kml::BookmarkIcon::Shop}, + + {"amenity-place_of_worship-christian", kml::BookmarkIcon::Christianity}, + {"landuse-cemetery-christian", kml::BookmarkIcon::Christianity}, + {"amenity-grave_yard-christian", kml::BookmarkIcon::Christianity}, + + {"amenity-place_of_worship-jewish", kml::BookmarkIcon::Judaism}, + + {"amenity-place_of_worship-buddhist", kml::BookmarkIcon::Buddhism}, + + {"amenity-place_of_worship-muslim", kml::BookmarkIcon::Islam}, + + {"amenity-parking", kml::BookmarkIcon::Parking}, + {"vending-parking_tickets", kml::BookmarkIcon::Parking}, + {"tourism-caravan_site", kml::BookmarkIcon::Parking}, + {"amenity-bicycle_parking", kml::BookmarkIcon::Parking}, + {"amenity-taxi", kml::BookmarkIcon::Parking}, + {"amenity-car_sharing", kml::BookmarkIcon::Parking}, + {"tourism-camp_site", kml::BookmarkIcon::Parking}, + {"amenity-motorcycle_parking", kml::BookmarkIcon::Parking}, + + {"amenity-fuel", kml::BookmarkIcon::Gas}, + {"amenity-charging_station", kml::BookmarkIcon::Gas}, + + {"amenity-fountain", kml::BookmarkIcon::Water}, + {"natural-spring", kml::BookmarkIcon::Water}, + {"amenity-drinking_water", kml::BookmarkIcon::Water}, + {"man_made-water_tap", kml::BookmarkIcon::Water}, + {"amenity-water_point", kml::BookmarkIcon::Water}, + + {"amenity-dentist", kml::BookmarkIcon::Medicine}, + {"amenity-clinic", kml::BookmarkIcon::Medicine}, + {"amenity-doctors", kml::BookmarkIcon::Medicine}, + {"amenity-hospital", kml::BookmarkIcon::Medicine}, + {"amenity-pharmacy", kml::BookmarkIcon::Medicine}, + {"amenity-clinic", kml::BookmarkIcon::Medicine}, + {"amenity-childcare", kml::BookmarkIcon::Medicine}, + {"emergency-defibrillator", kml::BookmarkIcon::Medicine} +}; + void ValidateKmlData(std::unique_ptr & data) { if (!data) @@ -148,6 +363,13 @@ void SaveFeatureTypes(feature::TypesHolder const & types, kml::BookmarkData & bm for (auto it = copy.begin(); it != copy.end(); ++it) { bmData.m_featureTypes.push_back(c.GetIndexForType(*it)); + if (bmData.m_icon == kml::BookmarkIcon::None) + { + auto const typeStr = c.GetReadableObjectName(*it); + auto const itIcon = kBookmarkTypeToIcon.find(typeStr); + if (itIcon != kBookmarkTypeToIcon.cend()) + bmData.m_icon = itIcon->second; + } } }