Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:36

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2014-2021, Oracle and/or its affiliates.
0004 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
0005 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0006 
0007 // Licensed under the Boost Software License version 1.0.
0008 // http://www.boost.org/users/license.html
0009 
0010 #ifndef BOOST_GEOMETRY_ITERATORS_POINT_ITERATOR_HPP
0011 #define BOOST_GEOMETRY_ITERATORS_POINT_ITERATOR_HPP
0012 
0013 
0014 #include <type_traits>
0015 
0016 #include <boost/iterator/iterator_adaptor.hpp>
0017 #include <boost/range/begin.hpp>
0018 #include <boost/range/end.hpp>
0019 
0020 #include <boost/geometry/core/exterior_ring.hpp>
0021 #include <boost/geometry/core/interior_rings.hpp>
0022 #include <boost/geometry/core/tags.hpp>
0023 
0024 #include <boost/geometry/iterators/dispatch/point_iterator.hpp>
0025 #include <boost/geometry/iterators/detail/point_iterator/iterator_type.hpp>
0026 
0027 
0028 namespace boost { namespace geometry
0029 {
0030 
0031 
0032 #ifndef DOXYGEN_NO_DISPATCH
0033 namespace dispatch
0034 {
0035 
0036 
0037 // specializations for points_begin
0038 
0039 
0040 template <typename Linestring>
0041 struct points_begin<Linestring, linestring_tag>
0042 {
0043     static inline typename detail::point_iterator::iterator_type
0044         <
0045             Linestring
0046         >::type
0047     apply(Linestring& linestring)
0048     {
0049         return boost::begin(linestring);
0050     }
0051 };
0052 
0053 
0054 template <typename Ring>
0055 struct points_begin<Ring, ring_tag>
0056 {
0057     static inline typename detail::point_iterator::iterator_type<Ring>::type
0058     apply(Ring& ring)
0059     {
0060         return boost::begin(ring);
0061     }
0062 };
0063 
0064 
0065 template <typename Polygon>
0066 struct points_begin<Polygon, polygon_tag>
0067 {
0068     typedef typename detail::point_iterator::iterator_type
0069         <
0070             Polygon
0071         >::type return_type;
0072 
0073     static inline return_type apply(Polygon& polygon)
0074     {
0075         typedef typename return_type::second_iterator_type flatten_iterator;
0076 
0077         return return_type
0078             (boost::begin(geometry::exterior_ring(polygon)),
0079              boost::end(geometry::exterior_ring(polygon)),
0080              flatten_iterator(boost::begin(geometry::interior_rings(polygon)),
0081                               boost::end(geometry::interior_rings(polygon))
0082                               ),
0083              flatten_iterator(boost::begin(geometry::interior_rings(polygon)),
0084                               boost::end(geometry::interior_rings(polygon))
0085                               )
0086              );
0087     }
0088 };
0089 
0090 
0091 template <typename MultiPoint>
0092 struct points_begin<MultiPoint, multi_point_tag>
0093 {
0094     static inline typename detail::point_iterator::iterator_type
0095         <
0096             MultiPoint
0097         >::type
0098     apply(MultiPoint& multipoint)
0099     {
0100         return boost::begin(multipoint);
0101     }
0102 };
0103 
0104 
0105 template <typename MultiLinestring>
0106 struct points_begin<MultiLinestring, multi_linestring_tag>
0107 {
0108     typedef typename detail::point_iterator::iterator_type
0109         <
0110             MultiLinestring
0111         >::type return_type;
0112 
0113     static inline return_type apply(MultiLinestring& multilinestring)
0114     {
0115         return return_type(boost::begin(multilinestring),
0116                            boost::end(multilinestring));
0117     }
0118 };
0119 
0120 
0121 template <typename MultiPolygon>
0122 struct points_begin<MultiPolygon, multi_polygon_tag>
0123 {
0124     typedef typename detail::point_iterator::iterator_type
0125         <
0126             MultiPolygon
0127         >::type return_type;
0128 
0129     static inline return_type apply(MultiPolygon& multipolygon)
0130     {
0131         return return_type(boost::begin(multipolygon),
0132                            boost::end(multipolygon));
0133     }
0134 };
0135 
0136 } // namespace dispatch
0137 #endif // DOXYGEN_NO_DISPATCH
0138 
0139 
0140 
0141 
0142 
0143 #ifndef DOXYGEN_NO_DISPATCH
0144 namespace dispatch
0145 {
0146 
0147 
0148 // specializations for points_end
0149 
0150 
0151 template <typename Linestring>
0152 struct points_end<Linestring, linestring_tag>
0153 {
0154     static inline typename detail::point_iterator::iterator_type
0155         <
0156             Linestring
0157         >::type
0158     apply(Linestring& linestring)
0159     {
0160         return boost::end(linestring);
0161     }
0162 };
0163 
0164 
0165 template <typename Ring>
0166 struct points_end<Ring, ring_tag>
0167 {
0168     static inline typename detail::point_iterator::iterator_type<Ring>::type
0169     apply(Ring& ring)
0170     {
0171         return boost::end(ring);
0172     }
0173 };
0174 
0175 
0176 template <typename Polygon>
0177 struct points_end<Polygon, polygon_tag>
0178 {
0179     typedef typename detail::point_iterator::iterator_type
0180         <
0181             Polygon
0182         >::type return_type;
0183 
0184     static inline return_type apply(Polygon& polygon)
0185     {
0186         typedef typename return_type::second_iterator_type flatten_iterator;
0187 
0188         return return_type
0189             (boost::end(geometry::exterior_ring(polygon)),
0190              flatten_iterator(boost::begin(geometry::interior_rings(polygon)),
0191                               boost::end(geometry::interior_rings(polygon))
0192                               ),
0193              flatten_iterator( boost::end(geometry::interior_rings(polygon)) )
0194              );
0195     }
0196 };
0197 
0198 
0199 template <typename MultiPoint>
0200 struct points_end<MultiPoint, multi_point_tag>
0201 {
0202     static inline typename detail::point_iterator::iterator_type
0203         <
0204             MultiPoint
0205         >::type
0206     apply(MultiPoint& multipoint)
0207     {
0208         return boost::end(multipoint);
0209     }
0210 };
0211 
0212 
0213 template <typename MultiLinestring>
0214 struct points_end<MultiLinestring, multi_linestring_tag>
0215 {
0216     typedef typename detail::point_iterator::iterator_type
0217         <
0218             MultiLinestring
0219         >::type return_type;
0220 
0221     static inline return_type apply(MultiLinestring& multilinestring)
0222     {
0223         return return_type(boost::end(multilinestring));
0224     }
0225 };
0226 
0227 
0228 template <typename MultiPolygon>
0229 struct points_end<MultiPolygon, multi_polygon_tag>
0230 {
0231     typedef typename detail::point_iterator::iterator_type
0232         <
0233             MultiPolygon
0234         >::type return_type;
0235 
0236     static inline return_type apply(MultiPolygon& multipolygon)
0237     {
0238         return return_type(boost::end(multipolygon));
0239     }
0240 };
0241 
0242 
0243 } // namespace dispatch
0244 #endif // DOXYGEN_NO_DISPATCH
0245 
0246 
0247 // MK:: need to add doc here
0248 template <typename Geometry>
0249 class point_iterator
0250     : public boost::iterator_adaptor
0251         <
0252             point_iterator<Geometry>,
0253             typename detail::point_iterator::iterator_type<Geometry>::type
0254         >
0255 {
0256 private:
0257     template <typename OtherGeometry> friend class point_iterator;
0258     template <typename G> friend inline point_iterator<G> points_begin(G&);
0259     template <typename G> friend inline point_iterator<G> points_end(G&);
0260 
0261     inline point_iterator(typename point_iterator::base_type const& base_it)
0262         : point_iterator::iterator_adaptor_(base_it) {}
0263 
0264 public:
0265     inline point_iterator() = default;
0266 
0267     template
0268     <
0269         typename OtherGeometry,
0270         std::enable_if_t
0271             <
0272                 std::is_convertible
0273                     <
0274                         typename detail::point_iterator::iterator_type<OtherGeometry>::type,
0275                         typename detail::point_iterator::iterator_type<Geometry>::type
0276                     >::value,
0277                 int
0278             > = 0
0279     >
0280     inline point_iterator(point_iterator<OtherGeometry> const& other)
0281         : point_iterator::iterator_adaptor_(other.base())
0282     {}
0283 };
0284 
0285 
0286 // MK:: need to add doc here
0287 template <typename Geometry>
0288 inline point_iterator<Geometry>
0289 points_begin(Geometry& geometry)
0290 {
0291     return dispatch::points_begin<Geometry>::apply(geometry);
0292 }
0293 
0294 
0295 // MK:: need to add doc here
0296 template <typename Geometry>
0297 inline point_iterator<Geometry>
0298 points_end(Geometry& geometry)
0299 {
0300     return dispatch::points_end<Geometry>::apply(geometry);
0301 }
0302 
0303 
0304 }} // namespace boost::geometry
0305 
0306 #endif // BOOST_GEOMETRY_ITERATORS_POINT_ITERATOR_HPP