diff options
author | vng <viktor.govako@gmail.com> | 2012-06-03 22:30:21 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:39:12 +0300 |
commit | 8b41efdc9c03061b300c094a51461ea9bd3c7aca (patch) | |
tree | 360deebc93c7d3a53c3ca6137f5a2e43ca400323 /generator/generator_tests/coasts_test.cpp | |
parent | f9c99c5c9a0b6b418d9ffcfcb1db0cd9c2d6a353 (diff) |
[generator] Add coasts generator test.
Diffstat (limited to 'generator/generator_tests/coasts_test.cpp')
-rw-r--r-- | generator/generator_tests/coasts_test.cpp | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/generator/generator_tests/coasts_test.cpp b/generator/generator_tests/coasts_test.cpp index 424670772c..15fce2d399 100644 --- a/generator/generator_tests/coasts_test.cpp +++ b/generator/generator_tests/coasts_test.cpp @@ -1,9 +1,11 @@ #include "../../testing/testing.hpp" #include "../feature_builder.hpp" +#include "../feature_sorter.hpp" #include "../../indexer/mercator.hpp" #include "../../indexer/cell_id.hpp" +#include "../../indexer/scales.hpp" #include "../../geometry/cellid.hpp" @@ -91,10 +93,9 @@ UNIT_TEST(CellID_CheckRectPoints) } } -/* namespace { - class DoGetCoasts + class DoPrintCoasts { vector<string> const & m_vID; @@ -103,67 +104,66 @@ namespace 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) {} + DoPrintCoasts(vector<string> const & vID) : m_vID(vID) {} - void operator() (FeatureBuilder1 const & fb, uint64_t) + void operator() (FeatureBuilder1 const & fb1, uint64_t) { int64_t dummy; - CHECK(fb.GetCoastCell(dummy), ()); + TEST(fb1.GetCoastCell(dummy), ()); - string const id = fb.GetName(); + string const id = fb1.GetName(); if (Has(id)) { - LOG(LINFO, ("ID = ", id, "Rect = ", fb.GetLimitRect(), - "Polygons = ", fb.GetPolygonsCount())); + FeatureBuilder2 const & fb2 = reinterpret_cast<FeatureBuilder2 const &>(fb1); + + // Check common params. + TEST(fb2.IsArea(), ()); + int const upperScale = scales::GetUpperScale(); + TEST(fb2.IsDrawableInRange(0, upperScale), ()); - m_rects.push_back(fb.GetLimitRect()); + m2::RectD const rect = fb2.GetLimitRect(); + LOG(LINFO, ("ID = ", id, "Rect = ", rect, "Polygons = ", fb2.GetPolygons())); - polygons_t const & poly = reinterpret_cast<FeatureBuilder2 const &>(fb).GetPolygons(); + // Make bound rect inflated a little. + feature::BoundsDistance dist(rect); + m2::RectD const boundRect = m2::Inflate(rect, dist.GetEpsilon(), dist.GetEpsilon()); - // 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) + typedef vector<m2::PointD> PointsT; + typedef list<PointsT> PolygonsT; + + PolygonsT const & poly = fb2.GetPolygons(); + + // Check that all simplifications are inside bound rect. + for (int level = 0; level <= upperScale; ++level) + { + for (PolygonsT::const_iterator i = poly.begin(); i != poly.end(); ++i) { - maxCount = i->size(); - m_maxPoly.back() = *i; - } - } - } + PointsT pts; + feature::SimplifyPoints(dist, *i, pts, level); - 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. Level = ", level, "Points = ", pts)); - LOG(LINFO, ("Simplified")); - /// @todo Check simplified polygons + for (size_t j = 0; j < pts.size(); ++j) + TEST(boundRect.IsPointInside(pts[j]), (pts[j])); + } + } + } } }; } +/* UNIT_TEST(WorldCoasts_CheckBounds) { vector<string> vID; - vID.push_back("2213023"); - vID.push_back("2213021"); + vID.push_back("1231"); + vID.push_back("123203"); + vID.push_back("12323"); + vID.push_back("03321"); - DoGetCoasts doGet(vID); + DoPrintCoasts doGet(vID); feature::ForEachFromDatRawFormat( - "/Users/alena/omim/omim-indexer-tmp/WorldCoasts.mwm", doGet); - - doGet.DumpMaxPolygons(); + "/Users/alena/omim/omim-indexer-tmp/WorldCoasts.mwm.tmp", doGet); } */ |