From cd1d490d2e53568addd2ab122f4c14b64bd181b8 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Mon, 5 May 2014 09:50:04 +0300 Subject: [PATCH] [point_iterator] add free functions points_front and points_back that return the first and last point of a geometry --- .../geometry/iterators/point_iterator.hpp | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/include/boost/geometry/iterators/point_iterator.hpp b/include/boost/geometry/iterators/point_iterator.hpp index 0c21127f3..aa01a0eaa 100644 --- a/include/boost/geometry/iterators/point_iterator.hpp +++ b/include/boost/geometry/iterators/point_iterator.hpp @@ -10,6 +10,7 @@ #ifndef BOOST_GEOMETRY_ITERATORS_POINT_ITERATOR_HPP #define BOOST_GEOMETRY_ITERATORS_POINT_ITERATOR_HPP +#include #include #include #include @@ -280,6 +281,30 @@ points_end(Geometry& geometry) } +// MK:: need to add doc here +template +inline typename point_type::type +points_front(Geometry& geometry) +{ + BOOST_ASSERT( dispatch::points_begin::apply(geometry) + != dispatch::points_end::apply(geometry) ); + return *dispatch::points_begin::apply(geometry); +} + + +// MK:: need to add doc here +template +inline typename point_type::type +points_back(Geometry& geometry) +{ + BOOST_ASSERT( dispatch::points_begin::apply(geometry) + != dispatch::points_end::apply(geometry) ); + return *--dispatch::points_end::apply(geometry); +} + + + + }} // namespace boost::geometry #endif // BOOST_GEOMETRY_ITERATORS_POINT_ITERATOR_HPP