diff options
author | vng <viktor.govako@gmail.com> | 2011-10-13 17:46:27 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:25:57 +0300 |
commit | f65c01693f802a97befe82067954e562a85eecc8 (patch) | |
tree | 558ddfa4aa0b9eda65af56973381bd6b1ed667de /generator/generator_tests/coasts_test.cpp | |
parent | 62bfbbfc24b6b6e9ead27b6926d090dfe9290eaf (diff) |
Add temporary test for row WorldCoasts.mwm data.
Diffstat (limited to 'generator/generator_tests/coasts_test.cpp')
-rw-r--r-- | generator/generator_tests/coasts_test.cpp | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/generator/generator_tests/coasts_test.cpp b/generator/generator_tests/coasts_test.cpp index 59a5decf0a..424670772c 100644 --- a/generator/generator_tests/coasts_test.cpp +++ b/generator/generator_tests/coasts_test.cpp @@ -1,10 +1,14 @@ #include "../../testing/testing.hpp" +#include "../feature_builder.hpp" + #include "../../indexer/mercator.hpp" #include "../../indexer/cell_id.hpp" #include "../../geometry/cellid.hpp" +#include "../../base/logging.hpp" + namespace { @@ -86,3 +90,80 @@ UNIT_TEST(CellID_CheckRectPoints) } } } + +/* +namespace +{ + class DoGetCoasts + { + vector<string> const & m_vID; + + bool Has(string const & id) const + { + return (find(m_vID.begin(), m_vID.end(), id) != m_vID.end()); + } + + list<m2::RectD> m_rects; + + typedef list<vector<m2::PointD> > polygons_t; + polygons_t m_maxPoly; + + public: + DoGetCoasts(vector<string> const & vID) : m_vID(vID) {} + + void operator() (FeatureBuilder1 const & fb, uint64_t) + { + int64_t dummy; + CHECK(fb.GetCoastCell(dummy), ()); + + string const id = fb.GetName(); + if (Has(id)) + { + LOG(LINFO, ("ID = ", id, "Rect = ", fb.GetLimitRect(), + "Polygons = ", fb.GetPolygonsCount())); + + m_rects.push_back(fb.GetLimitRect()); + + polygons_t const & poly = reinterpret_cast<FeatureBuilder2 const &>(fb).GetPolygons(); + + // get polygon with max points count + size_t maxCount = 0; + m_maxPoly.push_back(vector<m2::PointD>()); + for (polygons_t::const_iterator i = poly.begin(); i != poly.end(); ++i) + if (i->size() > maxCount) + { + maxCount = i->size(); + m_maxPoly.back() = *i; + } + } + } + + void DumpMaxPolygons() + { + LOG(LINFO, ("Original")); + for (polygons_t::const_iterator i = m_maxPoly.begin(); i != m_maxPoly.end(); ++i) + { + m2::RectD r; + feature::CalcRect(*i, r); + LOG(LINFO, ("Polygon points count = ", i->size(), "Polygon rect = ", r)); + } + + LOG(LINFO, ("Simplified")); + /// @todo Check simplified polygons + } + }; +} + +UNIT_TEST(WorldCoasts_CheckBounds) +{ + vector<string> vID; + vID.push_back("2213023"); + vID.push_back("2213021"); + + DoGetCoasts doGet(vID); + feature::ForEachFromDatRawFormat( + "/Users/alena/omim/omim-indexer-tmp/WorldCoasts.mwm", doGet); + + doGet.DumpMaxPolygons(); +} +*/ |