From 619074e79d76d90f759ce1627e1993658866fa6c Mon Sep 17 00:00:00 2001 From: tatiana-yan Date: Tue, 9 Oct 2018 18:27:33 +0300 Subject: [PATCH] [indexer] Add IATA airport codes to metadata. --- generator/osm2meta.cpp | 15 +++++++++++++++ generator/osm2meta.hpp | 2 ++ indexer/feature_meta.cpp | 5 ++++- indexer/feature_meta.hpp | 1 + indexer/map_object.hpp | 3 ++- 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/generator/osm2meta.cpp b/generator/osm2meta.cpp index 476e1c89b5..4bd7997027 100644 --- a/generator/osm2meta.cpp +++ b/generator/osm2meta.cpp @@ -299,3 +299,18 @@ string MetadataTagProcessorImpl::ValidateAndFormat_wikipedia(string v) const replace(normalized.begin() + colonIndex, normalized.end(), '_', ' '); return normalized; } + +string MetadataTagProcessorImpl::ValidateAndFormat_airport_iata(string const & v) const +{ + if (v.size() != 3) + return {}; + + auto str = v; + for (auto & c : str) + { + if (!isalpha(c)) + return {}; + c = toupper(c); + } + return str; +} diff --git a/generator/osm2meta.hpp b/generator/osm2meta.hpp index d64719a11a..fd3b88abc1 100644 --- a/generator/osm2meta.hpp +++ b/generator/osm2meta.hpp @@ -36,6 +36,7 @@ struct MetadataTagProcessorImpl std::string ValidateAndFormat_price_rate(std::string const & v) const; std::string ValidateAndFormat_sponsored_id(std::string const & v) const; std::string ValidateAndFormat_rating(std::string const & v) const; + std::string ValidateAndFormat_airport_iata(std::string const & v) const; protected: FeatureParams & m_params; @@ -99,6 +100,7 @@ public: case Metadata::FMD_RATING: valid = ValidateAndFormat_rating(v); break; case Metadata::FMD_BANNER_URL: valid = ValidateAndFormat_url(v); break; case Metadata::FMD_LEVEL: valid = ValidateAndFormat_level(v); break; + case Metadata::FMD_AIRPORT_IATA: valid = ValidateAndFormat_airport_iata(v); break; case Metadata::FMD_TEST_ID: case Metadata::FMD_COUNT: CHECK(false, ("FMD_COUNT can not be used as a type.")); } diff --git a/indexer/feature_meta.cpp b/indexer/feature_meta.cpp index c5707cb31a..626978bdb8 100644 --- a/indexer/feature_meta.cpp +++ b/indexer/feature_meta.cpp @@ -96,6 +96,8 @@ bool Metadata::TypeFromString(string const & k, Metadata::EType & outType) outType = Metadata::FMD_BANNER_URL; else if (k == "level") outType = Metadata::FMD_LEVEL; + else if (k == "iata") + outType = Metadata::FMD_AIRPORT_IATA; else return false; @@ -189,12 +191,13 @@ string ToString(feature::Metadata::EType type) case Metadata::FMD_MIN_HEIGHT: return "min_height"; case Metadata::FMD_DENOMINATION: return "denomination"; case Metadata::FMD_BUILDING_LEVELS: return "building:levels"; + case Metadata::FMD_TEST_ID: return "test_id"; case Metadata::FMD_SPONSORED_ID: return "ref:sponsored"; case Metadata::FMD_PRICE_RATE: return "price_rate"; case Metadata::FMD_RATING: return "rating:sponsored"; case Metadata::FMD_BANNER_URL: return "banner_url"; case Metadata::FMD_LEVEL: return "level"; - case Metadata::FMD_TEST_ID: return "test_id"; + case Metadata::FMD_AIRPORT_IATA: return "iata"; case Metadata::FMD_COUNT: CHECK(false, ("FMD_COUNT can not be used as a type.")); }; diff --git a/indexer/feature_meta.hpp b/indexer/feature_meta.hpp index 14830e1e52..a06536d31a 100644 --- a/indexer/feature_meta.hpp +++ b/indexer/feature_meta.hpp @@ -127,6 +127,7 @@ public: FMD_RATING = 26, FMD_BANNER_URL = 27, FMD_LEVEL = 28, + FMD_AIRPORT_IATA = 29, FMD_COUNT }; diff --git a/indexer/map_object.hpp b/indexer/map_object.hpp index 7806fb3889..5bb119b126 100644 --- a/indexer/map_object.hpp +++ b/indexer/map_object.hpp @@ -149,11 +149,12 @@ std::vector MetadataToProps(std::vector const & metadata) case Metadata::FMD_HEIGHT: case Metadata::FMD_MIN_HEIGHT: case Metadata::FMD_DENOMINATION: + case Metadata::FMD_TEST_ID: case Metadata::FMD_SPONSORED_ID: case Metadata::FMD_PRICE_RATE: case Metadata::FMD_RATING: case Metadata::FMD_BANNER_URL: - case Metadata::FMD_TEST_ID: + case Metadata::FMD_AIRPORT_IATA: case Metadata::FMD_COUNT: break; // Please add new cases when compiler issues an "unhandled switch case" warning here.