diff options
author | vng <viktor.govako@gmail.com> | 2012-06-05 21:56:45 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:39:29 +0300 |
commit | ed61f145b5178dfb60608de6bb78c0f5b7516a46 (patch) | |
tree | 8e0827a61d20258b15f975518d420d08dbf0e0f8 /generator/generator_tests/coasts_test.cpp | |
parent | ae19a29396993eb55a6a4ff73231a2e6a0063334 (diff) |
[generator] Some coastline processing tests.
Diffstat (limited to 'generator/generator_tests/coasts_test.cpp')
-rw-r--r-- | generator/generator_tests/coasts_test.cpp | 70 |
1 files changed, 55 insertions, 15 deletions
diff --git a/generator/generator_tests/coasts_test.cpp b/generator/generator_tests/coasts_test.cpp index 15fce2d399..bb36d88f75 100644 --- a/generator/generator_tests/coasts_test.cpp +++ b/generator/generator_tests/coasts_test.cpp @@ -2,6 +2,7 @@ #include "../feature_builder.hpp" #include "../feature_sorter.hpp" +#include "../feature_generator.hpp" #include "../../indexer/mercator.hpp" #include "../../indexer/cell_id.hpp" @@ -95,25 +96,31 @@ UNIT_TEST(CellID_CheckRectPoints) namespace { - class DoPrintCoasts + class ProcessCoastsBase { vector<string> const & m_vID; - bool Has(string const & id) const + protected: + bool HasID(FeatureBuilder1 const & fb) const { - return (find(m_vID.begin(), m_vID.end(), id) != m_vID.end()); + int64_t dummy; + TEST(fb.GetCoastCell(dummy), ()); + + return (find(m_vID.begin(), m_vID.end(), fb.GetName()) != m_vID.end()); } public: - DoPrintCoasts(vector<string> const & vID) : m_vID(vID) {} + ProcessCoastsBase(vector<string> const & vID) : m_vID(vID) {} + }; + + class DoPrintCoasts : public ProcessCoastsBase + { + public: + DoPrintCoasts(vector<string> const & vID) : ProcessCoastsBase(vID) {} void operator() (FeatureBuilder1 const & fb1, uint64_t) { - int64_t dummy; - TEST(fb1.GetCoastCell(dummy), ()); - - string const id = fb1.GetName(); - if (Has(id)) + if (HasID(fb1)) { FeatureBuilder2 const & fb2 = reinterpret_cast<FeatureBuilder2 const &>(fb1); @@ -123,7 +130,7 @@ namespace TEST(fb2.IsDrawableInRange(0, upperScale), ()); m2::RectD const rect = fb2.GetLimitRect(); - LOG(LINFO, ("ID = ", id, "Rect = ", rect, "Polygons = ", fb2.GetPolygons())); + LOG(LINFO, ("ID = ", fb1.GetName(), "Rect = ", rect, "Polygons = ", fb2.GetPolygons())); // Make bound rect inflated a little. feature::BoundsDistance dist(rect); @@ -137,6 +144,8 @@ namespace // Check that all simplifications are inside bound rect. for (int level = 0; level <= upperScale; ++level) { + TEST(fb2.IsDrawableInRange(level, level), ()); + for (PolygonsT::const_iterator i = poly.begin(); i != poly.end(); ++i) { PointsT pts; @@ -151,19 +160,50 @@ namespace } } }; + + class DoCopyCoasts : public ProcessCoastsBase + { + feature::FeaturesCollector m_collector; + public: + DoCopyCoasts(string const & fName, vector<string> const & vID) + : ProcessCoastsBase(vID), m_collector(fName) + { + } + + void operator() (FeatureBuilder1 const & fb1, uint64_t) + { + if (HasID(fb1)) + m_collector(fb1); + } + }; } /* UNIT_TEST(WorldCoasts_CheckBounds) { vector<string> vID; + + // bounds + vID.push_back("2222"); + vID.push_back("3333"); + vID.push_back("0000"); + vID.push_back("1111"); + + // bad cells + vID.push_back("2021"); + vID.push_back("2333"); + vID.push_back("3313"); vID.push_back("1231"); - vID.push_back("123203"); - vID.push_back("12323"); + vID.push_back("32003"); + vID.push_back("21330"); + vID.push_back("20110"); vID.push_back("03321"); + vID.push_back("12323"); + vID.push_back("1231"); + vID.push_back("1311"); - DoPrintCoasts doGet(vID); - feature::ForEachFromDatRawFormat( - "/Users/alena/omim/omim-indexer-tmp/WorldCoasts.mwm.tmp", doGet); + //DoPrintCoasts doProcess(vID); + DoCopyCoasts doProcess("/Users/alena/omim/omim/data/WorldCoasts.mwm.tmp", vID); + feature::ForEachFromDatRawFormat("/Users/alena/omim/omim-indexer-tmp/WorldCoasts.mwm.tmp", doProcess); } */ |