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
diff options
context:
space:
mode:
authortatiana-kondakova <tatiana.kondakova@gmail.com>2017-08-07 19:49:25 +0300
committerVladimir Byko-Ianko <bykoianko@gmail.com>2017-09-05 16:57:21 +0300
commitb1b1edbbc2d3b05f637c911764f03f0065379c7d (patch)
tree12d9d8b6fe294221ed4d57b84ad8123f04ceedab /storage
parent62e3177639416107240544835f3a10c4365e15cd (diff)
Add mwm tree callback to VehicleModelFactory
Rename abstract VehicleModelFactory to VehicleModelFactoryInterface, create VehicleModelFactory and move common code from Car/Bicycle/PedestrianModelFactory to VehicleModelFactory
Diffstat (limited to 'storage')
-rw-r--r--storage/CMakeLists.txt2
-rw-r--r--storage/country_parent_getter.cpp18
-rw-r--r--storage/country_parent_getter.hpp20
-rw-r--r--storage/storage.cpp18
-rw-r--r--storage/storage.hpp4
-rw-r--r--storage/storage.pro2
6 files changed, 64 insertions, 0 deletions
diff --git a/storage/CMakeLists.txt b/storage/CMakeLists.txt
index ce55713621..b681a692a8 100644
--- a/storage/CMakeLists.txt
+++ b/storage/CMakeLists.txt
@@ -13,6 +13,8 @@ set(
country_info_getter.hpp
country_name_getter.cpp
country_name_getter.hpp
+ country_parent_getter.cpp
+ country_parent_getter.hpp
country_polygon.hpp
country_tree.hpp
diff_scheme/diff_scheme_checker.cpp
diff --git a/storage/country_parent_getter.cpp b/storage/country_parent_getter.cpp
new file mode 100644
index 0000000000..fe1a541fbf
--- /dev/null
+++ b/storage/country_parent_getter.cpp
@@ -0,0 +1,18 @@
+#include "storage/country_parent_getter.hpp"
+
+namespace storage
+{
+CountryParentGetter::CountryParentGetter(std::string const & countriesFile,
+ std::string const & countriesDir)
+{
+ if (countriesFile.empty())
+ m_storage = make_shared<Storage>();
+ else
+ m_storage = make_shared<Storage>(countriesFile, countriesDir);
+}
+
+std::string CountryParentGetter::operator()(std::string const & id) const
+{
+ return m_storage->GetParentIdFor(id);
+}
+} // namespace storage
diff --git a/storage/country_parent_getter.hpp b/storage/country_parent_getter.hpp
new file mode 100644
index 0000000000..35ed843eec
--- /dev/null
+++ b/storage/country_parent_getter.hpp
@@ -0,0 +1,20 @@
+#pragma once
+
+#include "storage/storage.hpp"
+
+#include <memory>
+#include <string>
+
+namespace storage
+{
+class CountryParentGetter
+{
+public:
+ CountryParentGetter(std::string const & countriesFile = "",
+ std::string const & countriesDir = "");
+ std::string operator()(std::string const & id) const;
+
+private:
+ shared_ptr<Storage> m_storage;
+};
+} // namespace storage
diff --git a/storage/storage.cpp b/storage/storage.cpp
index 8b874ec683..866f29a099 100644
--- a/storage/storage.cpp
+++ b/storage/storage.cpp
@@ -1680,4 +1680,22 @@ void Storage::GetTopmostNodesFor(TCountryId const & countryId, TCountriesVec & n
}
}
+TCountryId const Storage::GetParentIdFor(TCountryId const & countryId) const
+{
+ vector<TCountryTreeNode const *> nodes;
+ m_countries.Find(countryId, nodes);
+ if (nodes.empty())
+ {
+ LOG(LWARNING, ("TCountryId =", countryId, "not found in m_countries."));
+ return string();
+ }
+
+ if (nodes.size() > 1)
+ {
+ // Disputed territory. Has multiple parents.
+ return string();
+ }
+
+ return nodes[0]->Value().GetParent();
+}
} // namespace storage
diff --git a/storage/storage.hpp b/storage/storage.hpp
index cf753e040f..d93f0a820b 100644
--- a/storage/storage.hpp
+++ b/storage/storage.hpp
@@ -365,6 +365,10 @@ public:
/// Puts |countryId| to |nodes| when |level| is greater than the level of |countyId|.
void GetTopmostNodesFor(TCountryId const & countryId, TCountriesVec & nodes, size_t level = 0) const;
+ /// \brief Returns parent id for node if node has single parent. Otherwise (if node is disputed
+ /// territory and has multiple parents or does not exist) returns empty TCountryId
+ TCountryId const GetParentIdFor(TCountryId const & countryId) const;
+
/// \brief Returns current version for mwms which are used by storage.
inline int64_t GetCurrentDataVersion() const { return m_currentVersion; }
diff --git a/storage/storage.pro b/storage/storage.pro
index bcafbcb1ab..81860a7b2c 100644
--- a/storage/storage.pro
+++ b/storage/storage.pro
@@ -15,6 +15,7 @@ HEADERS += \
country_decl.hpp \
country_info_getter.hpp \
country_name_getter.hpp \
+ country_parent_getter.hpp \
country_polygon.hpp \
country_tree.hpp \
diff_scheme/diff_scheme_checker.hpp \
@@ -34,6 +35,7 @@ SOURCES += \
country_decl.cpp \
country_info_getter.cpp \
country_name_getter.cpp \
+ country_parent_getter.cpp \
diff_scheme/diff_scheme_checker.cpp \
downloading_policy.cpp \
http_map_files_downloader.cpp \