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:
authorSergey Magidovich <mgsergio@mapswithme.com>2016-10-24 15:15:36 +0300
committerSergey Magidovich <mgsergio@mapswithme.com>2017-01-31 10:43:14 +0300
commit3e6df70ac10b8e10dd15199fa16bfdd54c6ee1f4 (patch)
treeb8e1d157a64a02d6f304cd4e1eb6ba9eda7b2667 /openlr/road_info_getter.cpp
parent13090e8c57c6191e64eb85c72be5315af46cabba (diff)
OpenLR decoding, markup tool.
Diffstat (limited to 'openlr/road_info_getter.cpp')
-rw-r--r--openlr/road_info_getter.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/openlr/road_info_getter.cpp b/openlr/road_info_getter.cpp
new file mode 100644
index 0000000000..859cf0f8aa
--- /dev/null
+++ b/openlr/road_info_getter.cpp
@@ -0,0 +1,66 @@
+#include "openlr/road_info_getter.hpp"
+
+#include "indexer/classificator.hpp"
+#include "indexer/feature.hpp"
+#include "indexer/index.hpp"
+
+#include "base/assert.hpp"
+
+#include "std/iterator.hpp"
+
+namespace openlr
+{
+RoadInfoGetter::RoadInfoGetter(Index const & index) : m_index(index), m_c(classif()) {}
+
+RoadInfoGetter::RoadInfo RoadInfoGetter::Get(FeatureID const & fid)
+{
+ auto it = m_cache.find(fid);
+ if (it != end(m_cache))
+ return it->second;
+
+ Index::FeaturesLoaderGuard g(m_index, fid.m_mwmId);
+ FeatureType ft;
+ CHECK(g.GetOriginalFeatureByIndex(fid.m_index, ft), ());
+
+ RoadInfo info;
+ info.m_frc = GetFunctionalRoadClass(ft);
+ info.m_fow = GetFormOfWay(ft);
+ it = m_cache.emplace(fid, info).first;
+
+ return it->second;
+}
+
+FunctionalRoadClass RoadInfoGetter::GetFunctionalRoadClass(feature::TypesHolder const & types) const
+{
+ if (m_trunkChecker(types))
+ return FunctionalRoadClass::FRC0;
+
+ if (m_primaryChecker(types))
+ return FunctionalRoadClass::FRC1;
+
+ if (m_secondaryChecker(types))
+ return FunctionalRoadClass::FRC2;
+
+ if (m_tertiaryChecker(types))
+ return FunctionalRoadClass::FRC3;
+
+ if (m_residentialChecker(types))
+ return FunctionalRoadClass::FRC4;
+
+ if (m_livingStreetChecker(types))
+ return FunctionalRoadClass::FRC5;
+
+ return FunctionalRoadClass::FRC7;
+}
+
+FormOfWay RoadInfoGetter::GetFormOfWay(feature::TypesHolder const & types) const
+{
+ if (m_trunkChecker(types))
+ return FormOfWay::Motorway;
+
+ if (m_primaryChecker(types))
+ return FormOfWay::MultipleCarriageway;
+
+ return FormOfWay::SingleCarriageway;
+}
+} // namespace openlr