From 1ec98ac970007efd371e661446f7d55cea6b0645 Mon Sep 17 00:00:00 2001 From: "r.kuznetsov" Date: Thu, 17 May 2018 16:07:08 +0300 Subject: [PATCH] Review fixes --- indexer/classificator.hpp | 2 +- kml/pykmlib/bindings.cpp | 12 ++++++------ kml/pykmlib/bindings_test.py | 4 ++-- kml/serdes.cpp | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/indexer/classificator.hpp b/indexer/classificator.hpp index d6fd14bad9..b01103eb4f 100644 --- a/indexer/classificator.hpp +++ b/indexer/classificator.hpp @@ -178,7 +178,7 @@ public: void Clear(); - bool HasMapping() const { return m_mapping.IsLoaded(); } + bool HasTypesMapping() const { return m_mapping.IsLoaded(); } /// Return type by path in classificator tree, for example /// path = ["natural", "caostline"]. diff --git a/kml/pykmlib/bindings.cpp b/kml/pykmlib/bindings.cpp index 04c97201d5..489d4743fa 100644 --- a/kml/pykmlib/bindings.cpp +++ b/kml/pykmlib/bindings.cpp @@ -597,13 +597,13 @@ void LoadClassificatorTypes(std::string const & classificatorFileStr, classificator::LoadTypes(classificatorFileStr, typesFileStr); } -uint32_t ClassificatorTypeToInt(std::string const & typeStr) +uint32_t ClassificatorTypeToIndex(std::string const & typeStr) { if (typeStr.empty()) throw std::runtime_error("Empty type is not allowed."); auto const & c = classif(); - if (!c.HasMapping()) + if (!c.HasTypesMapping()) throw std::runtime_error("Types mapping is not loaded."); auto const type = c.GetTypeByReadableObjectName(typeStr); @@ -613,10 +613,10 @@ uint32_t ClassificatorTypeToInt(std::string const & typeStr) return c.GetIndexForType(type); } -std::string IntToClassificatorType(uint32_t index) +std::string IndexToClassificatorType(uint32_t index) { auto const & c = classif(); - if (!c.HasMapping()) + if (!c.HasTypesMapping()) throw std::runtime_error("Types mapping is not loaded."); uint32_t t; @@ -843,6 +843,6 @@ BOOST_PYTHON_MODULE(pykmlib) def("import_kml", ImportKml); def("load_classificator_types", LoadClassificatorTypes); - def("classificator_type_to_int", ClassificatorTypeToInt); - def("int_to_classificator_type", IntToClassificatorType); + def("classificator_type_to_index", ClassificatorTypeToIndex); + def("index_to_classificator_type", IndexToClassificatorType); } diff --git a/kml/pykmlib/bindings_test.py b/kml/pykmlib/bindings_test.py index 72add121ce..02f93589fc 100644 --- a/kml/pykmlib/bindings_test.py +++ b/kml/pykmlib/bindings_test.py @@ -41,8 +41,8 @@ class PyKmlibAdsTest(unittest.TestCase): bookmark.description.set_default('Test bookmark description') bookmark.description['ru'] = 'Тестовое описание метки' bookmark.feature_types.set_list([ - pykmlib.classificator_type_to_int('historic-castle'), - pykmlib.classificator_type_to_int('historic-memorial')]) + pykmlib.classificator_type_to_index('historic-castle'), + pykmlib.classificator_type_to_index('historic-memorial')]) bookmark.custom_name.set_default('Мое любимое место') bookmark.custom_name['en'] = 'My favorite place' bookmark.color.predefined_color = pykmlib.PredefinedColor.BLUE diff --git a/kml/serdes.cpp b/kml/serdes.cpp index b5b9bcc45f..b0d16d2b6d 100644 --- a/kml/serdes.cpp +++ b/kml/serdes.cpp @@ -358,7 +358,7 @@ void SaveBookmarkExtendedData(KmlWriter::WriterWrapper & writer, BookmarkData co std::vector types; types.reserve(bookmarkData.m_featureTypes.size()); auto const & c = classif(); - if (!c.HasMapping()) + if (!c.HasTypesMapping()) MYTHROW(SerializerKml::SerializeException, ("Types mapping is not loaded.")); for (auto const & t : bookmarkData.m_featureTypes) types.push_back(c.GetReadableObjectName(c.GetTypeForIndex(t))); @@ -1011,7 +1011,7 @@ void KmlParser::CharData(std::string value) if (prevTag == "mwm:featureTypes") { auto const & c = classif(); - if (!c.HasMapping()) + if (!c.HasTypesMapping()) MYTHROW(DeserializerKml::DeserializeException, ("Types mapping is not loaded.")); auto const type = c.GetTypeByReadableObjectName(value); if (c.IsTypeValid(type))