]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/include/boost/geometry/algorithms/num_interior_rings.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / geometry / include / boost / geometry / algorithms / num_interior_rings.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
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.
6
7 // This file was modified by Oracle on 2014.
8 // Modifications copyright (c) 2014, Oracle and/or its affiliates.
9
10 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
11 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
12
13 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
14 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
15
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)
19
20 #ifndef BOOST_GEOMETRY_ALGORITHMS_NUM_INTERIOR_RINGS_HPP
21 #define BOOST_GEOMETRY_ALGORITHMS_NUM_INTERIOR_RINGS_HPP
22
23 #include <cstddef>
24
25 #include <boost/range.hpp>
26
27 #include <boost/variant/apply_visitor.hpp>
28 #include <boost/variant/static_visitor.hpp>
29 #include <boost/variant/variant_fwd.hpp>
30
31 #include <boost/geometry/core/tag.hpp>
32 #include <boost/geometry/core/tags.hpp>
33
34 #include <boost/geometry/core/interior_rings.hpp>
35
36 #include <boost/geometry/algorithms/detail/counting.hpp>
37
38 #include <boost/geometry/geometries/concepts/check.hpp>
39
40
41 namespace boost { namespace geometry
42 {
43
44 #ifndef DOXYGEN_NO_DISPATCH
45 namespace dispatch
46 {
47
48
49 template <typename Geometry, typename Tag = typename tag<Geometry>::type>
50 struct num_interior_rings
51 : detail::counting::other_count<0>
52 {};
53
54
55
56 template <typename Polygon>
57 struct num_interior_rings<Polygon, polygon_tag>
58 {
59 static inline std::size_t apply(Polygon const& polygon)
60 {
61 return boost::size(geometry::interior_rings(polygon));
62 }
63
64 };
65
66
67 template <typename MultiPolygon>
68 struct num_interior_rings<MultiPolygon, multi_polygon_tag>
69 : detail::counting::multi_count
70 <
71 num_interior_rings
72 <
73 typename boost::range_value<MultiPolygon const>::type
74 >
75 >
76 {};
77
78
79 } // namespace dispatch
80 #endif // DOXYGEN_NO_DISPATCH
81
82
83 namespace resolve_variant
84 {
85
86 template <typename Geometry>
87 struct num_interior_rings
88 {
89 static inline std::size_t apply(Geometry const& geometry)
90 {
91 concepts::check<Geometry const>();
92
93 return dispatch::num_interior_rings<Geometry>::apply(geometry);
94 }
95 };
96
97 template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
98 struct num_interior_rings<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
99 {
100 struct visitor: boost::static_visitor<std::size_t>
101 {
102 template <typename Geometry>
103 inline std::size_t operator()(Geometry const& geometry) const
104 {
105 return num_interior_rings<Geometry>::apply(geometry);
106 }
107 };
108
109 static inline std::size_t
110 apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry)
111 {
112 return boost::apply_visitor(visitor(), geometry);
113 }
114 };
115
116 } // namespace resolve_variant
117
118
119 /*!
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}
126
127 \qbk{[include reference/algorithms/num_interior_rings.qbk]}
128
129 \note Defined by OGC as "numInteriorRing". To be consistent with "numPoints"
130 letter "s" is appended
131 */
132 template <typename Geometry>
133 inline std::size_t num_interior_rings(Geometry const& geometry)
134 {
135 return resolve_variant::num_interior_rings<Geometry>::apply(geometry);
136 }
137
138
139 }} // namespace boost::geometry
140
141
142 #endif // BOOST_GEOMETRY_ALGORITHMS_NUM_INTERIOR_RINGS_HPP