diff --git a/indexer/classificator.cpp b/indexer/classificator.cpp index ee98dfc95f..1c8f0e2145 100644 --- a/indexer/classificator.cpp +++ b/indexer/classificator.cpp @@ -166,7 +166,7 @@ void ClassifObject::Swap(ClassifObject & r) ClassifObject const * ClassifObject::GetObject(size_t i) const { - ASSERT ( i < m_objs.size(), (i) ); + ASSERT_LESS ( i, m_objs.size(), (m_name) ); return &(m_objs[i]); } @@ -261,7 +261,7 @@ namespace ftype void PopValue(uint32_t & type) { uint8_t const cl = get_control_level(type); - ASSERT ( cl > 0, (cl) ); + ASSERT_GREATER ( cl, 0, () ); // remove control level set_value(type, cl, 0); @@ -269,6 +269,23 @@ namespace ftype // set control level set_value(type, cl-1, 1); } + + void TruncValue(uint32_t & type, uint8_t level) + { + ASSERT_GREATER ( level, 0, () ); + uint8_t cl = get_control_level(type); + + while (cl > level) + { + // remove control level + set_value(type, cl, 0); + + --cl; + + // set control level + set_value(type, cl, 1); + } + } } namespace diff --git a/indexer/classificator.hpp b/indexer/classificator.hpp index 2453b7fd74..d43a8eaf0e 100644 --- a/indexer/classificator.hpp +++ b/indexer/classificator.hpp @@ -19,6 +19,7 @@ namespace ftype void PushValue(uint32_t & type, uint8_t value); bool GetValue(uint32_t type, uint8_t level, uint8_t & value); void PopValue(uint32_t & type); + void TruncValue(uint32_t & type, uint8_t level); } class ClassifObjectPtr diff --git a/indexer/old/feature_loader_101.cpp b/indexer/old/feature_loader_101.cpp index eb7d0ec144..a9669b46d5 100644 --- a/indexer/old/feature_loader_101.cpp +++ b/indexer/old/feature_loader_101.cpp @@ -43,9 +43,66 @@ namespace public: TypeConvertor() { - char const * arr[][2] = { - { "shop", "convenience" }, // new type - { "shop", "hairdresser" } + char const * arr[][3] = { + // first should be the new added type, after which all types should be incremented + { "shop", "convenience", "" }, + { "shop", "hairdresser", "" }, + + { "highway", "minor", "oneway" }, + { "highway", "minor", "tunnel" }, + { "highway", "minor", "turning_circle" }, + + { "highway", "primary", "oneway" }, + { "highway", "primary", "tunnel" }, + + { "highway", "primary_link", "oneway" }, + { "highway", "primary_link", "tunnel" }, + + { "highway", "residential", "oneway" }, + { "highway", "residential", "tunnel" }, + { "highway", "residential", "turning_circle" }, + + { "highway", "road", "oneway" }, + { "highway", "road", "tunnel" }, + { "highway", "road", "turning_circle" }, + + { "highway", "secondary", "oneway" }, + { "highway", "secondary", "tunnel" }, + + { "highway", "secondary_link", "oneway" }, + { "highway", "secondary_link", "tunnel" }, + + { "highway", "service", "oneway" }, + { "highway", "service", "parking_aisle" }, + { "highway", "service", "tunnel" }, + + { "highway", "tertiary", "oneway" }, + { "highway", "tertiary", "tunnel" }, + + { "highway", "tertiary_link", "oneway" }, + { "highway", "tertiary_link", "tunnel" }, + + { "highway", "track", "oneway" }, + { "highway", "track", "permissive" }, + { "highway", "track", "private" }, + { "highway", "track", "race" }, + { "highway", "track", "racetrack" }, + { "highway", "track", "tunnel" }, + + { "highway", "trunk", "oneway" }, + { "highway", "trunk", "tunnel" }, + + { "highway", "trunk_link", "oneway" }, + { "highway", "trunk_link", "tunnel" }, + + { "highway", "unclassified", "oneway" }, + { "highway", "unclassified", "tunnel" }, + { "highway", "unclassified", "turning_circle" }, + + { "highway", "unsurfaced", "oneway" }, + { "highway", "unsurfaced", "permissive" }, + { "highway", "unsurfaced", "private" }, + { "highway", "unsurfaced", "tunnel" } }; Classificator const & c = classif(); @@ -55,12 +112,18 @@ namespace vector v; v.push_back(arr[i][0]); v.push_back(arr[i][1]); + if (strlen(arr[i][2]) > 0) + v.push_back(arr[i][2]); + m_inc.push_back(c.GetTypeByPath(v)); } } uint32_t Convert(uint32_t t) const { + // leave only 3 levels for compare + ftype::TruncValue(t, 3); + size_t const count = m_inc.size(); for (size_t i = 0; i < count; ++i) if (m_inc[i] == t)