]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/geometry/algorithms/num_interior_rings.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / geometry / algorithms / num_interior_rings.hpp
CommitLineData
7c673cae
FG
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
20effc67
TL
7// This file was modified by Oracle on 2014-2020.
8// Modifications copyright (c) 2014-2020, Oracle and/or its affiliates.
7c673cae
FG
9// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
10// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
11
12// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
13// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
14
15// Use, modification and distribution is subject to the Boost Software License,
16// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
17// http://www.boost.org/LICENSE_1_0.txt)
18
19#ifndef BOOST_GEOMETRY_ALGORITHMS_NUM_INTERIOR_RINGS_HPP
20#define BOOST_GEOMETRY_ALGORITHMS_NUM_INTERIOR_RINGS_HPP
21
22#include <cstddef>
23
20effc67
TL
24#include <boost/range/size.hpp>
25#include <boost/range/value_type.hpp>
7c673cae
FG
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
41namespace boost { namespace geometry
42{
43
44#ifndef DOXYGEN_NO_DISPATCH
45namespace dispatch
46{
47
48
49template <typename Geometry, typename Tag = typename tag<Geometry>::type>
50struct num_interior_rings
51 : detail::counting::other_count<0>
52{};
53
54
55
56template <typename Polygon>
57struct 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
67template <typename MultiPolygon>
68struct 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
83namespace resolve_variant
84{
85
86template <typename Geometry>
87struct 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
97template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
98struct 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*/
132template <typename Geometry>
133inline 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