diff options
author | Vladimir Byko-Ianko <v.bykoianko@corp.mail.ru> | 2016-11-16 14:19:32 +0300 |
---|---|---|
committer | Vladimir Byko-Ianko <v.bykoianko@corp.mail.ru> | 2016-11-16 14:20:40 +0300 |
commit | ba4656b2ee9e35744669ad8e2e29afe443214253 (patch) | |
tree | c2d21c5f106dcedc2165261098de585b9e4697d5 /generator | |
parent | 71f64bdbbf1dacb1aed4b1d9a546b400fb4e2f81 (diff) |
Review fixes.
Diffstat (limited to 'generator')
-rw-r--r-- | generator/gen_mwm_info.hpp | 11 | ||||
-rw-r--r-- | generator/generator_tests/restriction_test.cpp | 12 | ||||
-rw-r--r-- | generator/generator_tests_support/restriction_helpers.cpp | 2 | ||||
-rw-r--r-- | generator/restriction_collector.cpp | 12 |
4 files changed, 18 insertions, 19 deletions
diff --git a/generator/gen_mwm_info.hpp b/generator/gen_mwm_info.hpp index b1f875b0f9..6b18742a21 100644 --- a/generator/gen_mwm_info.hpp +++ b/generator/gen_mwm_info.hpp @@ -31,9 +31,7 @@ public: } }; -using OsmIdAndFeatureId = pair<uint64_t /* osm id */, uint32_t /* feature id */>; - -class OsmID2FeatureID : public Accumulator<OsmIdAndFeatureId> +class OsmID2FeatureID : public Accumulator<pair<uint64_t /* osm id */, uint32_t /* feature id */>> { typedef Accumulator<ValueT> BaseT; @@ -64,6 +62,11 @@ public: return 0; } - vector<OsmIdAndFeatureId> const & GetData() const { return m_data; } + template <class Fn> + void ForEach(Fn && fn) const + { + for (ValueT const & v : m_data) + fn(v); + } }; } // namespace gen diff --git a/generator/generator_tests/restriction_test.cpp b/generator/generator_tests/restriction_test.cpp index 71b5aef962..d0e4d2d03a 100644 --- a/generator/generator_tests/restriction_test.cpp +++ b/generator/generator_tests/restriction_test.cpp @@ -116,9 +116,9 @@ UNIT_TEST(RestrictionGenerationTest_ThreeRestrictions) Only, 10, 20 Only, 30, 40)"; string const osmIdsToFeatureIdsContent = R"(10, 1, - 20, 2 - 30, 3, - 40, 4)"; + 20, 2 + 30, 3, + 40, 4)"; TestRestrictionBuilding(restrictionContent, osmIdsToFeatureIdsContent); } @@ -132,9 +132,9 @@ UNIT_TEST(RestrictionGenerationTest_SevenRestrictions) No, 40, 40, Only, 30, 40,)"; string const osmIdsToFeatureIdsContent = R"(10, 1, - 20, 2, - 30, 3, - 40, 4)"; + 20, 2, + 30, 3, + 40, 4)"; TestRestrictionBuilding(restrictionContent, osmIdsToFeatureIdsContent); } diff --git a/generator/generator_tests_support/restriction_helpers.cpp b/generator/generator_tests_support/restriction_helpers.cpp index 3ac0aacba3..c65a1f2f64 100644 --- a/generator/generator_tests_support/restriction_helpers.cpp +++ b/generator/generator_tests_support/restriction_helpers.cpp @@ -30,6 +30,8 @@ void ReEncodeOsmIdsToFeatureIdsMapping(string const & mappingContent, string con TEST(idIter, ()); TEST(strings::to_uint(*idIter, featureId), ("Cannot covert to uint:", *idIter)); osmIdsToFeatureIds.Add(make_pair(osmId, featureId)); + ++idIter; + TEST(!idIter, ()); } FileWriter osm2ftWriter(outputFilePath); diff --git a/generator/restriction_collector.cpp b/generator/restriction_collector.cpp index 7e6ff19828..6f655a6157 100644 --- a/generator/restriction_collector.cpp +++ b/generator/restriction_collector.cpp @@ -85,15 +85,9 @@ bool RestrictionCollector::ParseOsmIdToFeatureIdMapping(string const & osmIdsToF return false; } - vector<gen::OsmIdAndFeatureId> const & mapping = osmIdsToFeatureIds.GetData(); - if (mapping.empty()) - { - LOG(LINFO, ("No osm ids to feature ids mapping in file", osmIdsToFeatureIdPath)); - return true; - } - - for (auto const osmIdToFeatureId : mapping) - AddFeatureId(osmIdToFeatureId.second /* feature id */, osmIdToFeatureId.first /* osm id */); + osmIdsToFeatureIds.ForEach([this](gen::OsmID2FeatureID::ValueT const & p){ + AddFeatureId(p.second /* feature id */, p.first /* osm id */); + }); return true; } |