diff options
author | Maxim Pimenov <m@maps.me> | 2018-07-27 15:27:42 +0300 |
---|---|---|
committer | Vladimir Byko-Ianko <bykoianko@gmail.com> | 2018-08-01 13:45:25 +0300 |
commit | 00f2b4c78b3b4edb4218bcc59a5722e20f49a8e6 (patch) | |
tree | ad20c58cd0881fd33c121ea35666f48feb53c968 /search | |
parent | 2bc35257235bd3e4a6c6ba94f44d3eea8ad6a8fd (diff) |
[geometry] ForEachCorner and ForEachSide helpers in Rect.
Diffstat (limited to 'search')
-rw-r--r-- | search/geocoder.cpp | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/search/geocoder.cpp b/search/geocoder.cpp index 8c9ce19cd5..5e1133b8dc 100644 --- a/search/geocoder.cpp +++ b/search/geocoder.cpp @@ -264,26 +264,10 @@ double GetDistanceMeters(m2::PointD const & pivot, m2::RectD const & rect) double distance = numeric_limits<double>::max(); - // todo(@m) Replace with rect.ForEachSide(). - { - m2::ParametrizedSegment<m2::PointD> segment(rect.LeftTop(), rect.RightTop()); - distance = min(distance, MercatorBounds::DistanceOnEarth(pivot, segment.ClosestPointTo(pivot))); - } - - { - m2::ParametrizedSegment<m2::PointD> segment(rect.LeftBottom(), rect.RightBottom()); + rect.ForEachSide([&](m2::PointD const & a, m2::PointD const & b) { + m2::ParametrizedSegment<m2::PointD> segment(a, b); distance = min(distance, MercatorBounds::DistanceOnEarth(pivot, segment.ClosestPointTo(pivot))); - } - - { - m2::ParametrizedSegment<m2::PointD> segment(rect.LeftTop(), rect.LeftBottom()); - distance = min(distance, MercatorBounds::DistanceOnEarth(pivot, segment.ClosestPointTo(pivot))); - } - - { - m2::ParametrizedSegment<m2::PointD> segment(rect.RightTop(), rect.RightBottom()); - distance = min(distance, MercatorBounds::DistanceOnEarth(pivot, segment.ClosestPointTo(pivot))); - } + }); return distance; } |