1 // Boost.Geometry (aka GGL, Generic Geometry Library)
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.
7 // This file was modified by Oracle on 2015.
8 // Modifications copyright (c) 2015, Oracle and/or its affiliates.
10 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
12 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
13 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
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)
20 #ifndef BOOST_GEOMETRY_CORE_RING_TYPE_HPP
21 #define BOOST_GEOMETRY_CORE_RING_TYPE_HPP
24 #include <boost/mpl/assert.hpp>
25 #include <boost/mpl/if.hpp>
26 #include <boost/range/value_type.hpp>
27 #include <boost/type_traits/is_const.hpp>
28 #include <boost/type_traits/remove_const.hpp>
29 #include <boost/type_traits/remove_reference.hpp>
31 #include <boost/geometry/core/tag.hpp>
32 #include <boost/geometry/core/tags.hpp>
35 namespace boost { namespace geometry
43 \brief Traits class to indicate ring-type of a polygon's exterior ring/interior rings
47 \par Specializations should provide:
48 - typedef XXX type ( e.g. ring<P> )
49 \tparam Geometry geometry
51 template <typename Geometry>
52 struct ring_const_type
56 false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
61 template <typename Geometry>
62 struct ring_mutable_type
66 false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
75 #ifndef DOXYGEN_NO_DISPATCH
76 namespace core_dispatch
79 template <typename GeometryTag, typename Geometry>
80 struct ring_return_type
84 template <typename LineString>
85 struct ring_return_type<linestring_tag, LineString>
87 typedef LineString& type;
91 template <typename Ring>
92 struct ring_return_type<ring_tag, Ring>
98 template <typename Polygon>
99 struct ring_return_type<polygon_tag, Polygon>
101 typedef typename boost::remove_const<Polygon>::type nc_polygon_type;
103 typedef typename boost::mpl::if_
105 boost::is_const<Polygon>,
106 typename traits::ring_const_type<nc_polygon_type>::type,
107 typename traits::ring_mutable_type<nc_polygon_type>::type
112 template <typename MultiLinestring>
113 struct ring_return_type<multi_linestring_tag, MultiLinestring>
115 typedef typename ring_return_type
118 typename boost::mpl::if_
120 boost::is_const<MultiLinestring>,
121 typename boost::range_value<MultiLinestring>::type const,
122 typename boost::range_value<MultiLinestring>::type
128 template <typename MultiPolygon>
129 struct ring_return_type<multi_polygon_tag, MultiPolygon>
131 typedef typename ring_return_type
134 typename boost::mpl::if_
136 boost::is_const<MultiPolygon>,
137 typename boost::range_value<MultiPolygon>::type const,
138 typename boost::range_value<MultiPolygon>::type
144 template <typename GeometryTag, typename Geometry>
149 template <typename Ring>
150 struct ring_type<ring_tag, Ring>
156 template <typename Polygon>
157 struct ring_type<polygon_tag, Polygon>
159 typedef typename boost::remove_reference
161 typename ring_return_type<polygon_tag, Polygon>::type
166 template <typename MultiLinestring>
167 struct ring_type<multi_linestring_tag, MultiLinestring>
169 typedef typename boost::remove_reference
171 typename ring_return_type<multi_linestring_tag, MultiLinestring>::type
176 template <typename MultiPolygon>
177 struct ring_type<multi_polygon_tag, MultiPolygon>
179 typedef typename boost::remove_reference
181 typename ring_return_type<multi_polygon_tag, MultiPolygon>::type
186 } // namespace core_dispatch
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.
199 \qbk{[include reference/core/ring_type.qbk]}
201 template <typename Geometry>
204 typedef typename core_dispatch::ring_type
206 typename tag<Geometry>::type,
212 template <typename Geometry>
213 struct ring_return_type
215 typedef typename core_dispatch::ring_return_type
217 typename tag<Geometry>::type,
223 }} // namespace boost::geometry
226 #endif // BOOST_GEOMETRY_CORE_RING_TYPE_HPP