diff --git a/include/boost/geometry/iterators/point_iterator.hpp b/include/boost/geometry/iterators/point_iterator.hpp index 9d5d13742..192d75d57 100644 --- a/include/boost/geometry/iterators/point_iterator.hpp +++ b/include/boost/geometry/iterators/point_iterator.hpp @@ -7,11 +7,11 @@ // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html -#ifndef BOOST_GEOMETRY_CORE_POINT_ITERATOR_HPP -#define BOOST_GEOMETRY_CORE_POINT_ITERATOR_HPP +#ifndef BOOST_GEOMETRY_ITERATORS_POINT_ITERATOR_HPP +#define BOOST_GEOMETRY_ITERATORS_POINT_ITERATOR_HPP -#include -#include +#include +#include namespace boost { namespace geometry @@ -19,14 +19,13 @@ namespace boost { namespace geometry #ifndef DOXYGEN_NO_DISPATCH -namespace core_dispatch +namespace dispatch { // specializations for points_begin -// linestring template struct points_begin { @@ -38,7 +37,6 @@ struct points_begin }; -// ring template struct points_begin { @@ -50,7 +48,6 @@ struct points_begin }; -// polygon template struct points_begin { @@ -71,7 +68,6 @@ struct points_begin }; -// multi-point template struct points_begin { @@ -83,7 +79,6 @@ struct points_begin }; -// multi-linestring template struct points_begin { @@ -98,7 +93,6 @@ struct points_begin }; -// multi-polygon template struct points_begin { @@ -112,7 +106,7 @@ struct points_begin } }; -} // namespace core_dispatch +} // namespace dispatch #endif // DOXYGEN_NO_DISPATCH @@ -120,14 +114,13 @@ struct points_begin #ifndef DOXYGEN_NO_DISPATCH -namespace core_dispatch +namespace dispatch { // specializations for points_end -// linestring template struct points_end { @@ -139,7 +132,6 @@ struct points_end }; -// ring template struct points_end { @@ -151,7 +143,6 @@ struct points_end }; -// polygon template struct points_end { @@ -169,7 +160,6 @@ struct points_end }; -// multi-point template struct points_end { @@ -181,7 +171,6 @@ struct points_end }; -// multi-linestring template struct points_end { @@ -196,7 +185,6 @@ struct points_end }; -// multi-polygon template struct points_end { @@ -211,32 +199,76 @@ struct points_end }; -} // namespace core_dispatch +} // namespace dispatch #endif // DOXYGEN_NO_DISPATCH +// MK:: need to add doc here +template +class point_iterator + : public dispatch::point_iterator_type::type +{ +private: + typedef typename dispatch::point_iterator_type::type base; + + base* base_ptr() + { + return this; + } + + base const* base_ptr() const + { + return this; + } + + template + struct is_convertible + : boost::is_convertible + < + typename dispatch::point_iterator_type::type, + typename dispatch::point_iterator_type::type + > + {}; + + struct enabler {}; + + template friend class point_iterator; +public: + point_iterator() {} + + point_iterator(base const& base_it) : base(base_it) {} + + template + point_iterator(point_iterator const& other, + typename boost::enable_if + < + is_convertible, + enabler + >::type = enabler()) + + : base(*other.base_ptr()) + {} +}; // MK:: need to add doc here template -inline typename point_iterator_type::type +inline point_iterator points_begin(Geometry& geometry) { - return core_dispatch::points_begin::apply(geometry); + return dispatch::points_begin::apply(geometry); } // MK:: need to add doc here template -inline typename point_iterator_type::type +inline point_iterator points_end(Geometry& geometry) { - return core_dispatch::points_end::apply(geometry); + return dispatch::points_end::apply(geometry); } - - }} // namespace boost::geometry -#endif // BOOST_GEOMETRY_CORE_POINT_ITERATOR_HPP +#endif // BOOST_GEOMETRY_ITERATORS_POINT_ITERATOR_HPP