]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/include/boost/geometry/algorithms/detail/is_simple/areal.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / geometry / include / boost / geometry / algorithms / detail / is_simple / areal.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2014-2015, Oracle and/or its affiliates.
4
5 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
6
7 // Licensed under the Boost Software License version 1.0.
8 // http://www.boost.org/users/license.html
9
10 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_SIMPLE_AREAL_HPP
11 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_SIMPLE_AREAL_HPP
12
13 #include <boost/range.hpp>
14
15 #include <boost/geometry/core/closure.hpp>
16 #include <boost/geometry/core/exterior_ring.hpp>
17 #include <boost/geometry/core/interior_rings.hpp>
18 #include <boost/geometry/core/ring_type.hpp>
19 #include <boost/geometry/core/tags.hpp>
20
21 #include <boost/geometry/algorithms/detail/check_iterator_range.hpp>
22 #include <boost/geometry/algorithms/detail/is_simple/failure_policy.hpp>
23 #include <boost/geometry/algorithms/detail/is_valid/has_duplicates.hpp>
24
25 #include <boost/geometry/algorithms/dispatch/is_simple.hpp>
26
27
28 namespace boost { namespace geometry
29 {
30
31
32 #ifndef DOXYGEN_NO_DETAIL
33 namespace detail { namespace is_simple
34 {
35
36
37 template <typename Ring>
38 struct is_simple_ring
39 {
40 static inline bool apply(Ring const& ring)
41 {
42 simplicity_failure_policy policy;
43 return ! boost::empty(ring)
44 && ! detail::is_valid::has_duplicates
45 <
46 Ring, geometry::closure<Ring>::value
47 >::apply(ring, policy);
48 }
49 };
50
51
52 template <typename Polygon>
53 class is_simple_polygon
54 {
55 private:
56 template <typename InteriorRings>
57 static inline
58 bool are_simple_interior_rings(InteriorRings const& interior_rings)
59 {
60 return
61 detail::check_iterator_range
62 <
63 is_simple_ring
64 <
65 typename boost::range_value<InteriorRings>::type
66 >
67 >::apply(boost::begin(interior_rings),
68 boost::end(interior_rings));
69 }
70
71 public:
72 static inline bool apply(Polygon const& polygon)
73 {
74 return
75 is_simple_ring
76 <
77 typename ring_type<Polygon>::type
78 >::apply(exterior_ring(polygon))
79 &&
80 are_simple_interior_rings(geometry::interior_rings(polygon));
81 }
82 };
83
84
85 }} // namespace detail::is_simple
86 #endif // DOXYGEN_NO_DETAIL
87
88
89
90
91 #ifndef DOXYGEN_NO_DISPATCH
92 namespace dispatch
93 {
94
95
96 // A Ring is a Polygon.
97 // A Polygon is always a simple geometric object provided that it is valid.
98 //
99 // Reference (for polygon validity): OGC 06-103r4 (6.1.11.1)
100 template <typename Ring>
101 struct is_simple<Ring, ring_tag>
102 : detail::is_simple::is_simple_ring<Ring>
103 {};
104
105
106 // A Polygon is always a simple geometric object provided that it is valid.
107 //
108 // Reference (for validity of Polygons): OGC 06-103r4 (6.1.11.1)
109 template <typename Polygon>
110 struct is_simple<Polygon, polygon_tag>
111 : detail::is_simple::is_simple_polygon<Polygon>
112 {};
113
114
115 // Not clear what the definition is.
116 // Right now we consider a MultiPolygon as simple if it is valid.
117 //
118 // Reference (for validity of MultiPolygons): OGC 06-103r4 (6.1.14)
119 template <typename MultiPolygon>
120 struct is_simple<MultiPolygon, multi_polygon_tag>
121 {
122 static inline bool apply(MultiPolygon const& multipolygon)
123 {
124 return
125 detail::check_iterator_range
126 <
127 detail::is_simple::is_simple_polygon
128 <
129 typename boost::range_value<MultiPolygon>::type
130 >,
131 true // allow empty multi-polygon
132 >::apply(boost::begin(multipolygon), boost::end(multipolygon));
133 }
134 };
135
136
137 } // namespace dispatch
138 #endif // DOXYGEN_NO_DISPATCH
139
140
141 }} // namespace boost::geometry
142
143 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_SIMPLE_AREAL_HPP