From cae3bab2fe5d08315ea8512dfcbb9f4981730a75 Mon Sep 17 00:00:00 2001 From: Samuel Debionne Date: Fri, 27 Feb 2015 17:03:03 +0100 Subject: [PATCH 1/2] [util][range] Fix back() *(--boost::end(rng)); is not valid for range with pointer as iterators. since the range is supposed to be BidirectionalRange, use rbegin instead. --- include/boost/geometry/util/range.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/geometry/util/range.hpp b/include/boost/geometry/util/range.hpp index 177fca92c..89d981619 100644 --- a/include/boost/geometry/util/range.hpp +++ b/include/boost/geometry/util/range.hpp @@ -138,7 +138,7 @@ back(BidirectionalRange const& rng) { BOOST_RANGE_CONCEPT_ASSERT(( boost::BidirectionalRangeConcept )); BOOST_ASSERT(!boost::empty(rng)); - return *(--boost::end(rng)); + return *(boost::rbegin(rng)); } /*! @@ -151,7 +151,7 @@ back(BidirectionalRange & rng) { BOOST_RANGE_CONCEPT_ASSERT(( boost::BidirectionalRangeConcept )); BOOST_ASSERT(!boost::empty(rng)); - return *(--boost::end(rng)); + return *(boost::rbegin(rng)); } From d9f95e6952555aefe8916e08b3192716e2353d51 Mon Sep 17 00:00:00 2001 From: Samuel Debionne Date: Mon, 2 Mar 2015 09:37:44 +0100 Subject: [PATCH 2/2] [algorithms][within] Use geometry::range Make use of geometry::range algorithms to get front and back values of Linestring (rather than Boost.Range begin() and front()). --- .../algorithms/detail/within/point_in_geometry.hpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/within/point_in_geometry.hpp b/include/boost/geometry/algorithms/detail/within/point_in_geometry.hpp index 454c0d5d0..e7486f0e4 100644 --- a/include/boost/geometry/algorithms/detail/within/point_in_geometry.hpp +++ b/include/boost/geometry/algorithms/detail/within/point_in_geometry.hpp @@ -36,6 +36,7 @@ #include #include +#include #include namespace boost { namespace geometry { @@ -197,11 +198,11 @@ struct point_in_geometry return -1; // exterior // if the linestring doesn't have a boundary - if ( detail::equals::equals_point_point(*boost::begin(linestring), *(--boost::end(linestring))) ) + if (detail::equals::equals_point_point(range::front(linestring), range::back(linestring))) return 1; // interior // else if the point is equal to the one of the terminal points - else if ( detail::equals::equals_point_point(point, *boost::begin(linestring)) - || detail::equals::equals_point_point(point, *(--boost::end(linestring))) ) + else if (detail::equals::equals_point_point(point, range::front(linestring)) + || detail::equals::equals_point_point(point, range::back(linestring))) return 0; // boundary else return 1; // interior @@ -210,7 +211,7 @@ struct point_in_geometry // throw an exception here? /*else if ( count == 1 ) { - if ( detail::equals::equals_point_point(point, *boost::begin(linestring)) ) + if ( detail::equals::equals_point_point(point, range::front(linestring)) ) return 1; }*/ @@ -336,8 +337,8 @@ struct point_in_geometry if ( boost::size(*it) < 2 ) continue; - point_type const& front = *boost::begin(*it); - point_type const& back = *(--boost::end(*it)); + point_type const& front = range::front(*it); + point_type const& back = range::back(*it); // is closed_ring - no boundary if ( detail::equals::equals_point_point(front, back) )