From 5f83095b9df4f2c421d5b2b8f5f101e8a8ec1652 Mon Sep 17 00:00:00 2001 From: rachytski Date: Thu, 20 Sep 2012 12:39:31 +0300 Subject: [PATCH] fixes according to code review. --- map/framework.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/map/framework.cpp b/map/framework.cpp index cf870ca7c2..209672d0ca 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -1255,17 +1255,17 @@ void Framework::SaveFacebookDialogResult(int result) } } -void GetClosestToPivot(list > & l, - m2::PointD const & pxPoint, - shared_ptr & res) +shared_ptr const GetClosestToPivot(list > const & l, + m2::PointD const & pxPoint) { double dist = numeric_limits::max(); + shared_ptr res; for (list >::const_iterator it = l.begin(); it != l.end(); ++it) { - double curDist = pxPoint.Length((*it)->pivot()); + double curDist = pxPoint.SquareLength((*it)->pivot()); if (curDist < dist) { @@ -1273,6 +1273,8 @@ void GetClosestToPivot(list > & l, res = *it; } } + + return res; } bool Framework::GetVisiblePOI(m2::PointD const & pxPoint, @@ -1289,15 +1291,18 @@ bool Framework::GetVisiblePOI(m2::PointD const & pxPoint, shared_ptr overlay = m_renderPolicy->GetOverlay(); - m2::PointD halfSize(12 * m_renderPolicy->VisualScale(), - 12 * m_renderPolicy->VisualScale()); + double halfSize = 12 * m_renderPolicy->VisualScale(); list > candidates; - overlay->selectOverlayElements(m2::RectD(pt - halfSize, pt + halfSize), candidates); + + m2::RectD rect(pt.x - halfSize, pt.y - halfSize, + pt.x + halfSize, pt.y + halfSize); + + overlay->selectOverlayElements(rect, candidates); shared_ptr res; - GetClosestToPivot(candidates, pt, res); + res = GetClosestToPivot(candidates, pt); if (res) {