From 1e2efd7a07e5849107ddb2a900e30476eda5b223 Mon Sep 17 00:00:00 2001 From: Alex Zolotarev Date: Thu, 27 Jan 2011 21:25:01 +0200 Subject: [PATCH] Fix bug in feature -> country polygonizer (equivalent coordinates for search rect and polygon coordinates). --- indexer/indexer_tool/polygonizer.hpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/indexer/indexer_tool/polygonizer.hpp b/indexer/indexer_tool/polygonizer.hpp index 264498c617..91d758e874 100644 --- a/indexer/indexer_tool/polygonizer.hpp +++ b/indexer/indexer_tool/polygonizer.hpp @@ -22,6 +22,8 @@ namespace feature template class Polygonizer { + typedef CellIdConverter CellIdConverterType; + public: template Polygonizer(TInfo & info) @@ -41,10 +43,14 @@ namespace feature for_each(m_Buckets.begin(), m_Buckets.end(), DeleteFunctor()); } + static m2::PointU Mercator2CellId(m2::PointD const & pt) + { + return m2::PointU(static_cast(CellIdConverterType::XToCellIdX(pt.x)), + static_cast(CellIdConverterType::YToCellIdY(pt.y))); + } + struct PointChecker { - typedef CellIdConverter CellIdConverterType; - kml::RegionsContainerT const & m_regions; bool m_belongs; @@ -53,9 +59,7 @@ namespace feature bool operator()(m2::PointD const & pt) { - kml::Region::value_type const point( - static_cast(CellIdConverterType::XToCellIdX(pt.x)), - static_cast(CellIdConverterType::YToCellIdY(pt.y))); + kml::Region::value_type const point = Mercator2CellId(pt); m_regions.ForEachInRect(m2::RectD(point, point), bind(ref(*this), _1, cref(point))); @@ -71,7 +75,10 @@ namespace feature void operator () (FeatureBuilder1 const & fb) { - m_countries.ForEachInRect(fb.GetLimitRect(), bind(ref(*this), _1, cref(fb))); + m2::RectD const r = fb.GetLimitRect(); + m_countries.ForEachInRect( + m2::RectD(Mercator2CellId(r.LeftBottom()), Mercator2CellId(r.RightTop())), + bind(ref(*this), _1, cref(fb))); } void operator() (kml::CountryPolygons const & country, FeatureBuilder1 const & fb)