From ce38ea70729e4de2392697bdc914d0bd24e1f5a8 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Sat, 14 Dec 2013 16:52:47 +0100 Subject: [PATCH] [geometry] Adapted buffer for recent changes in within --- .../algorithms/buffer/buffered_ring.hpp | 58 ++++++++++++++----- 1 file changed, 45 insertions(+), 13 deletions(-) diff --git a/include/boost/geometry/extensions/algorithms/buffer/buffered_ring.hpp b/include/boost/geometry/extensions/algorithms/buffer/buffered_ring.hpp index cdef65934..579d4e614 100644 --- a/include/boost/geometry/extensions/algorithms/buffer/buffered_ring.hpp +++ b/include/boost/geometry/extensions/algorithms/buffer/buffered_ring.hpp @@ -209,6 +209,50 @@ struct copy_segments > {}; +// adapted from now refactored point_in_ring +struct point_in_buffered_ring +{ + template + < + typename Point, + typename Ring, + typename Strategy + > + static inline int apply(Point const& point, Ring const& ring, + Strategy const& strategy) + { + boost::ignore_unused_variable_warning(strategy); + + if (boost::size(ring) < 4u) + { + return -1; + } + +// TODO: if this code is, in the end, still used, adapt for open/ccw rings +// Currently it is apparently not used +// order_as_direction +// < +// geometry::point_order::value +// >::value, +// geometry::closure::value, + + typedef typename boost::range_iterator::type iterator_type; + typename Strategy::state_type state; + iterator_type it = boost::begin(ring); + + for (iterator_type previous = it++; + it != boost::end(ring); + ++previous, ++it) + { + if (! strategy.apply(point, *previous, *it, state)) + { + break; + } + } + + return strategy.result(state); + } +}; template @@ -229,19 +273,7 @@ struct within Point, MultiGeometry, Strategy, - detail::within::point_in_ring - < - Point, - typename boost::range_value::type, - //iterate_forward, - //closed, - order_as_direction - < - geometry::point_order::value - >::value, - geometry::closure::value, - Strategy - > + point_in_buffered_ring >::apply(point, multi, strategy) == 1; } };