1// Boost.Geometry (aka GGL, Generic Geometry Library)
2
3// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
4// Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
5// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
6
7// This file was modified by Oracle on 2015-2021.
8// Modifications copyright (c) 2015-2021, Oracle and/or its affiliates.
9// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
10// Contributed and/or modified by Adam Wulkiewicz, 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
20#ifndef BOOST_GEOMETRY_CORE_RING_TYPE_HPP
21#define BOOST_GEOMETRY_CORE_RING_TYPE_HPP
22
23#include <type_traits>
24
25#include <boost/range/value_type.hpp>
26
27#include <boost/geometry/core/static_assert.hpp>
28#include <boost/geometry/core/tag.hpp>
29#include <boost/geometry/core/tags.hpp>
30
31
32namespace boost { namespace geometry
33{
34
35namespace traits
36{
37
38
39/*!
40\brief Traits class to indicate ring-type of a polygon's exterior ring/interior rings
41\ingroup traits
42\par Geometries:
43 - polygon
44\par Specializations should provide:
45 - typedef XXX type ( e.g. ring<P> )
46\tparam Geometry geometry
47*/
48template <typename Geometry>
49struct ring_const_type
50{
51 BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
52 "Not implemented for this Geometry type.",
53 Geometry);
54};
55
56template <typename Geometry>
57struct ring_mutable_type
58{
59 BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
60 "Not implemented for this Geometry type.",
61 Geometry);
62};
63
64
65} // namespace traits
66
67
68#ifndef DOXYGEN_NO_DISPATCH
69namespace core_dispatch
70{
71
72template <typename GeometryTag, typename Geometry>
73struct ring_return_type
74{};
75
76
77template <typename LineString>
78struct ring_return_type<linestring_tag, LineString>
79{
80 typedef LineString& type;
81};
82
83
84template <typename Ring>
85struct ring_return_type<ring_tag, Ring>
86{
87 typedef Ring& type;
88};
89
90
91template <typename Polygon>
92struct ring_return_type<polygon_tag, Polygon>
93{
94 typedef typename std::remove_const<Polygon>::type nc_polygon_type;
95
96 typedef std::conditional_t
97 <
98 std::is_const<Polygon>::value,
99 typename traits::ring_const_type<nc_polygon_type>::type,
100 typename traits::ring_mutable_type<nc_polygon_type>::type
101 > type;
102};
103
104
105template <typename MultiLinestring>
106struct ring_return_type<multi_linestring_tag, MultiLinestring>
107{
108 typedef typename ring_return_type
109 <
110 linestring_tag,
111 std::conditional_t
112 <
113 std::is_const<MultiLinestring>::value,
114 typename boost::range_value<MultiLinestring>::type const,
115 typename boost::range_value<MultiLinestring>::type
116 >
117 >::type type;
118};
119
120
121template <typename MultiPolygon>
122struct ring_return_type<multi_polygon_tag, MultiPolygon>
123{
124 typedef typename ring_return_type
125 <
126 polygon_tag,
127 std::conditional_t
128 <
129 std::is_const<MultiPolygon>::value,
130 typename boost::range_value<MultiPolygon>::type const,
131 typename boost::range_value<MultiPolygon>::type
132 >
133 >::type type;
134};
135
136
137template <typename GeometryTag, typename Geometry>
138struct ring_type
139{};
140
141
142template <typename Linestring>
143struct ring_type<linestring_tag, Linestring>
144{
145 typedef Linestring type;
146};
147
148
149template <typename Ring>
150struct ring_type<ring_tag, Ring>
151{
152 typedef Ring type;
153};
154
155
156template <typename Polygon>
157struct ring_type<polygon_tag, Polygon>
158{
159 typedef typename std::remove_reference
160 <
161 typename ring_return_type<polygon_tag, Polygon>::type
162 >::type type;
163};
164
165
166template <typename MultiLinestring>
167struct ring_type<multi_linestring_tag, MultiLinestring>
168{
169 typedef typename std::remove_reference
170 <
171 typename ring_return_type<multi_linestring_tag, MultiLinestring>::type
172 >::type type;
173};
174
175
176template <typename MultiPolygon>
177struct ring_type<multi_polygon_tag, MultiPolygon>
178{
179 typedef typename std::remove_reference
180 <
181 typename ring_return_type<multi_polygon_tag, MultiPolygon>::type
182 >::type type;
183};
184
185
186} // namespace core_dispatch
187#endif
188
189
190/*!
191\brief \brief_meta{type, ring_type, \meta_geometry_type}
192\details A polygon contains one exterior ring
193 and zero or more interior rings (holes).
194 This metafunction retrieves the type of the rings.
195 Exterior ring and each of the interior rings all have the same ring_type.
196\tparam Geometry A type fullfilling the Ring, Polygon or MultiPolygon concept.
197\ingroup core
198
199\qbk{[include reference/core/ring_type.qbk]}
200*/
201template <typename Geometry>
202struct ring_type
203{
204 typedef typename core_dispatch::ring_type
205 <
206 typename tag<Geometry>::type,
207 Geometry
208 >::type type;
209};
210
211
212template <typename Geometry>
213struct ring_return_type
214{
215 typedef typename core_dispatch::ring_return_type
216 <
217 typename tag<Geometry>::type,
218 Geometry
219 >::type type;
220};
221
222
223}} // namespace boost::geometry
224
225
226#endif // BOOST_GEOMETRY_CORE_RING_TYPE_HPP
227

source code of boost/libs/geometry/include/boost/geometry/core/ring_type.hpp