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