From 037e2a80271dab576fd34eef80a1d1eb9b1121e2 Mon Sep 17 00:00:00 2001 From: vng Date: Sun, 16 Jan 2011 14:24:42 +0200 Subject: [PATCH] Fix bug with early closed polygon point filtration. We should leave equal first and last point in polygon during simplification. --- indexer/feature.cpp | 7 ------- indexer/indexer_tool/feature_sorter.cpp | 7 ++++++- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/indexer/feature.cpp b/indexer/feature.cpp index 5b3ddbd7fa..0804021d5e 100644 --- a/indexer/feature.cpp +++ b/indexer/feature.cpp @@ -48,13 +48,6 @@ void FeatureBuilder1::AddPoint(m2::PointD const & p) void FeatureBuilder1::SetAreaAddHoles(list > & holes) { - // this function is called from InitFeatureBuilder, when no geometry present - if (!m_Geometry.empty()) - { - ASSERT ( IsGeometryClosed(), () ); - m_Geometry.pop_back(); - } - m_bArea = true; m_Holes.swap(holes); diff --git a/indexer/indexer_tool/feature_sorter.cpp b/indexer/indexer_tool/feature_sorter.cpp index 04c7fad1de..dca2066360 100644 --- a/indexer/indexer_tool/feature_sorter.cpp +++ b/indexer/indexer_tool/feature_sorter.cpp @@ -75,7 +75,7 @@ namespace feature { bool is_equal(m2::PointD const & p1, m2::PointD const & p2) { - return p1.EqualDxDy(p2, MercatorBounds::GetCellID2PointAbsEpsilon()); + return AlmostEqual(p1, p2); } } @@ -265,6 +265,11 @@ namespace feature bool TryToMakeStrip(points_t & points) { + ASSERT ( is_equal(points.front(), points.back()), () ); + // At this point we don't need last point equal to first. + // If you try to remove it in first step, 'simplify' will work bad for such polygons. + points.pop_back(); + size_t const count = points.size(); if (!m_trgInner || count > 15 + 2) {