From e66c105604755562c7a79a44c3592d8c6b0078ee Mon Sep 17 00:00:00 2001 From: vng Date: Sun, 12 Dec 2010 23:19:35 +0200 Subject: [PATCH] Added function for : cell_id -> (lat, lon) absolute epsilon. Fix signed\unsigned warning. --- indexer/drawing_rules.cpp | 4 +++- indexer/indexer_tests/feature_test.cpp | 9 +++++---- indexer/mercator.hpp | 2 ++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/indexer/drawing_rules.cpp b/indexer/drawing_rules.cpp index f7a7c72793..518a0c08b2 100644 --- a/indexer/drawing_rules.cpp +++ b/indexer/drawing_rules.cpp @@ -989,7 +989,9 @@ BaseRule const * RulesHolder::Find(Key const & k) const if (i == m_rules.end()) return 0; vector const & v = (i->second)[k.m_type]; - if (k.m_index < v.size()) + + ASSERT ( k.m_index >= 0, (k.m_index) ); + if (static_cast(k.m_index) < v.size()) return m_container[k.m_type][v[k.m_index]]; else return 0; diff --git a/indexer/indexer_tests/feature_test.cpp b/indexer/indexer_tests/feature_test.cpp index 375d1eb160..14d31d9df2 100644 --- a/indexer/indexer_tests/feature_test.cpp +++ b/indexer/indexer_tests/feature_test.cpp @@ -90,10 +90,11 @@ UNIT_TEST(Feature_Deserialize) f.ForEachTriangleRef(featureTriangles); TEST_EQUAL(triangles, featureTriangles.m_V, ()); - TEST_LESS(fabs(f.GetLimitRect().minX() - 0.25), 0.0001, ()); - TEST_LESS(fabs(f.GetLimitRect().minY() - 0.20), 0.0001, ()); - TEST_LESS(fabs(f.GetLimitRect().maxX() - 1.00), 0.0001, ()); - TEST_LESS(fabs(f.GetLimitRect().maxY() - 1.00), 0.0001, ()); + double const eps = MercatorBounds::GetCellID2PointAbsEpsilon(); + TEST_LESS(fabs(f.GetLimitRect().minX() - 0.25), eps, ()); + TEST_LESS(fabs(f.GetLimitRect().minY() - 0.20), eps, ()); + TEST_LESS(fabs(f.GetLimitRect().maxX() - 1.00), eps, ()); + TEST_LESS(fabs(f.GetLimitRect().maxY() - 1.00), eps, ()); vector serial2; FeatureBuilder builder2; diff --git a/indexer/mercator.hpp b/indexer/mercator.hpp index f68eaa473c..026cec97d8 100644 --- a/indexer/mercator.hpp +++ b/indexer/mercator.hpp @@ -40,4 +40,6 @@ struct MercatorBounds double const offset = errorInMetres / 2.0 * metresInDegree; return m2::RectD(LonToX(lon - offset), LatToY(lat - offset), LonToX(lon + offset), LatToY(lat + offset)); } + + static double GetCellID2PointAbsEpsilon() { return 1.0E-4; } };