1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
4 // Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
5 // Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
7 // This file was modified by Oracle on 2014.
8 // Modifications copyright (c) 2014, Oracle and/or its affiliates.
10 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
11 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
13 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
14 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
16 // Use, modification and distribution is subject to the Boost Software License,
17 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
18 // http://www.boost.org/LICENSE_1_0.txt)
20 #ifndef BOOST_GEOMETRY_ALGORITHMS_NUM_INTERIOR_RINGS_HPP
21 #define BOOST_GEOMETRY_ALGORITHMS_NUM_INTERIOR_RINGS_HPP
25 #include <boost/range.hpp>
27 #include <boost/variant/apply_visitor.hpp>
28 #include <boost/variant/static_visitor.hpp>
29 #include <boost/variant/variant_fwd.hpp>
31 #include <boost/geometry/core/tag.hpp>
32 #include <boost/geometry/core/tags.hpp>
34 #include <boost/geometry/core/interior_rings.hpp>
36 #include <boost/geometry/algorithms/detail/counting.hpp>
38 #include <boost/geometry/geometries/concepts/check.hpp>
41 namespace boost { namespace geometry
44 #ifndef DOXYGEN_NO_DISPATCH
49 template <typename Geometry, typename Tag = typename tag<Geometry>::type>
50 struct num_interior_rings
51 : detail::counting::other_count<0>
56 template <typename Polygon>
57 struct num_interior_rings<Polygon, polygon_tag>
59 static inline std::size_t apply(Polygon const& polygon)
61 return boost::size(geometry::interior_rings(polygon));
67 template <typename MultiPolygon>
68 struct num_interior_rings<MultiPolygon, multi_polygon_tag>
69 : detail::counting::multi_count
73 typename boost::range_value<MultiPolygon const>::type
79 } // namespace dispatch
80 #endif // DOXYGEN_NO_DISPATCH
83 namespace resolve_variant
86 template <typename Geometry>
87 struct num_interior_rings
89 static inline std::size_t apply(Geometry const& geometry)
91 concepts::check<Geometry const>();
93 return dispatch::num_interior_rings<Geometry>::apply(geometry);
97 template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
98 struct num_interior_rings<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
100 struct visitor: boost::static_visitor<std::size_t>
102 template <typename Geometry>
103 inline std::size_t operator()(Geometry const& geometry) const
105 return num_interior_rings<Geometry>::apply(geometry);
109 static inline std::size_t
110 apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry)
112 return boost::apply_visitor(visitor(), geometry);
116 } // namespace resolve_variant
120 \brief \brief_calc{number of interior rings}
121 \ingroup num_interior_rings
122 \details \details_calc{num_interior_rings, number of interior rings}.
123 \tparam Geometry \tparam_geometry
124 \param geometry \param_geometry
125 \return \return_calc{number of interior rings}
127 \qbk{[include reference/algorithms/num_interior_rings.qbk]}
129 \note Defined by OGC as "numInteriorRing". To be consistent with "numPoints"
130 letter "s" is appended
132 template <typename Geometry>
133 inline std::size_t num_interior_rings(Geometry const& geometry)
135 return resolve_variant::num_interior_rings<Geometry>::apply(geometry);
139 }} // namespace boost::geometry
142 #endif // BOOST_GEOMETRY_ALGORITHMS_NUM_INTERIOR_RINGS_HPP