From df726efe29f8e6d7a78ea2cc993b80a080416f79 Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Wed, 21 Feb 2018 15:38:20 +0300 Subject: [PATCH] Adding highway class Transported for ferry and trains which transports cars. --- indexer/ftypes_matcher.cpp | 8 +++++--- indexer/ftypes_matcher.hpp | 1 + indexer/indexer_tests/checker_test.cpp | 16 ++++++++++------ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/indexer/ftypes_matcher.cpp b/indexer/ftypes_matcher.cpp index d4c3ec0fd9..6eabbb5225 100644 --- a/indexer/ftypes_matcher.cpp +++ b/indexer/ftypes_matcher.cpp @@ -24,13 +24,14 @@ public: HighwayClasses() { auto const & c = classif(); + m_map[c.GetTypeByPath({"route", "ferry"})] = ftypes::HighwayClass::Transported; + m_map[c.GetTypeByPath({"route", "shuttle_train"})] = ftypes::HighwayClass::Transported; + m_map[c.GetTypeByPath({"railway", "rail"})] = ftypes::HighwayClass::Transported; + m_map[c.GetTypeByPath({"highway", "motorway"})] = ftypes::HighwayClass::Trunk; m_map[c.GetTypeByPath({"highway", "motorway_link"})] = ftypes::HighwayClass::Trunk; m_map[c.GetTypeByPath({"highway", "trunk"})] = ftypes::HighwayClass::Trunk; m_map[c.GetTypeByPath({"highway", "trunk_link"})] = ftypes::HighwayClass::Trunk; - m_map[c.GetTypeByPath({"route", "ferry"})] = ftypes::HighwayClass::Trunk; - m_map[c.GetTypeByPath({"route", "shuttle_train"})] = ftypes::HighwayClass::Trunk; - m_map[c.GetTypeByPath({"railway", "rail"})] = ftypes::HighwayClass::Trunk; m_map[c.GetTypeByPath({"highway", "primary"})] = ftypes::HighwayClass::Primary; m_map[c.GetTypeByPath({"highway", "primary_link"})] = ftypes::HighwayClass::Primary; @@ -72,6 +73,7 @@ char const * HighwayClassToString(ftypes::HighwayClass const cls) { case ftypes::HighwayClass::Undefined: return "Undefined"; case ftypes::HighwayClass::Error: return "Error"; + case ftypes::HighwayClass::Transported: return "Transported"; case ftypes::HighwayClass::Trunk: return "Trunk"; case ftypes::HighwayClass::Primary: return "Primary"; case ftypes::HighwayClass::Secondary: return "Secondary"; diff --git a/indexer/ftypes_matcher.hpp b/indexer/ftypes_matcher.hpp index 9a484efa8d..97010a120c 100644 --- a/indexer/ftypes_matcher.hpp +++ b/indexer/ftypes_matcher.hpp @@ -263,6 +263,7 @@ enum class HighwayClass { Undefined = 0, // There has not been any attempt of calculating HighwayClass. Error, // There was an attempt of calculating HighwayClass but it was not successful. + Transported, // Vehicles are transported by a train or a ferry. Trunk, Primary, Secondary, diff --git a/indexer/indexer_tests/checker_test.cpp b/indexer/indexer_tests/checker_test.cpp index c08e550817..ff41a464d8 100644 --- a/indexer/indexer_tests/checker_test.cpp +++ b/indexer/indexer_tests/checker_test.cpp @@ -148,14 +148,18 @@ UNIT_TEST(GetHighwayClassTest) Classificator const & c = classif(); feature::TypesHolder types1; - types1.Add(c.GetTypeByPath({"highway", "motorway_link", "tunnel"})); - TEST_EQUAL(ftypes::GetHighwayClass(types1), ftypes::HighwayClass::Trunk, ()); + types1.Add(c.GetTypeByPath({"route", "shuttle_train"})); + TEST_EQUAL(ftypes::GetHighwayClass(types1), ftypes::HighwayClass::Transported, ()); feature::TypesHolder types2; - types2.Add(c.GetTypeByPath({"highway", "unclassified"})); - TEST_EQUAL(ftypes::GetHighwayClass(types2), ftypes::HighwayClass::LivingStreet, ()); + types2.Add(c.GetTypeByPath({"highway", "motorway_link", "tunnel"})); + TEST_EQUAL(ftypes::GetHighwayClass(types2), ftypes::HighwayClass::Trunk, ()); feature::TypesHolder types3; - types3.Add(c.GetTypeByPath({"highway"})); - TEST_EQUAL(ftypes::GetHighwayClass(types3), ftypes::HighwayClass::Error, ()); + types3.Add(c.GetTypeByPath({"highway", "unclassified"})); + TEST_EQUAL(ftypes::GetHighwayClass(types3), ftypes::HighwayClass::LivingStreet, ()); + + feature::TypesHolder types4; + types4.Add(c.GetTypeByPath({"highway"})); + TEST_EQUAL(ftypes::GetHighwayClass(types4), ftypes::HighwayClass::Error, ()); }