Chris@16
|
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
|
Chris@16
|
2
|
Chris@16
|
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
Chris@16
|
4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
|
Chris@16
|
5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
|
Chris@16
|
6
|
Chris@16
|
7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
Chris@16
|
8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
Chris@16
|
9
|
Chris@16
|
10 // Use, modification and distribution is subject to the Boost Software License,
|
Chris@16
|
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
12 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
13
|
Chris@16
|
14 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_AS_RANGE_HPP
|
Chris@16
|
15 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_AS_RANGE_HPP
|
Chris@16
|
16
|
Chris@16
|
17
|
Chris@16
|
18 #include <boost/type_traits.hpp>
|
Chris@16
|
19
|
Chris@16
|
20 #include <boost/geometry/core/exterior_ring.hpp>
|
Chris@16
|
21 #include <boost/geometry/core/tag.hpp>
|
Chris@16
|
22 #include <boost/geometry/core/tags.hpp>
|
Chris@16
|
23
|
Chris@16
|
24 #include <boost/geometry/util/add_const_if_c.hpp>
|
Chris@16
|
25
|
Chris@16
|
26
|
Chris@16
|
27 namespace boost { namespace geometry
|
Chris@16
|
28 {
|
Chris@16
|
29
|
Chris@16
|
30
|
Chris@16
|
31 #ifndef DOXYGEN_NO_DISPATCH
|
Chris@16
|
32 namespace dispatch
|
Chris@16
|
33 {
|
Chris@16
|
34
|
Chris@16
|
35
|
Chris@16
|
36 template <typename GeometryTag, typename Geometry, typename Range, bool IsConst>
|
Chris@16
|
37 struct as_range
|
Chris@16
|
38 {
|
Chris@16
|
39 static inline typename add_const_if_c<IsConst, Range>::type& get(
|
Chris@16
|
40 typename add_const_if_c<IsConst, Geometry>::type& input)
|
Chris@16
|
41 {
|
Chris@16
|
42 return input;
|
Chris@16
|
43 }
|
Chris@16
|
44 };
|
Chris@16
|
45
|
Chris@16
|
46
|
Chris@16
|
47 template <typename Geometry, typename Range, bool IsConst>
|
Chris@16
|
48 struct as_range<polygon_tag, Geometry, Range, IsConst>
|
Chris@16
|
49 {
|
Chris@16
|
50 static inline typename add_const_if_c<IsConst, Range>::type& get(
|
Chris@16
|
51 typename add_const_if_c<IsConst, Geometry>::type& input)
|
Chris@16
|
52 {
|
Chris@16
|
53 return exterior_ring(input);
|
Chris@16
|
54 }
|
Chris@16
|
55 };
|
Chris@16
|
56
|
Chris@16
|
57
|
Chris@16
|
58 } // namespace dispatch
|
Chris@16
|
59 #endif // DOXYGEN_NO_DISPATCH
|
Chris@16
|
60
|
Chris@16
|
61 // Will probably be replaced by the more generic "view_as", therefore in detail
|
Chris@16
|
62 namespace detail
|
Chris@16
|
63 {
|
Chris@16
|
64
|
Chris@16
|
65 /*!
|
Chris@16
|
66 \brief Function getting either the range (ring, linestring) itself
|
Chris@16
|
67 or the outer ring (polygon)
|
Chris@16
|
68 \details Utility to handle polygon's outer ring as a range
|
Chris@16
|
69 \ingroup utility
|
Chris@16
|
70 */
|
Chris@16
|
71 template <typename Range, typename Geometry>
|
Chris@16
|
72 inline Range& as_range(Geometry& input)
|
Chris@16
|
73 {
|
Chris@16
|
74 return dispatch::as_range
|
Chris@16
|
75 <
|
Chris@16
|
76 typename tag<Geometry>::type,
|
Chris@16
|
77 Geometry,
|
Chris@16
|
78 Range,
|
Chris@16
|
79 false
|
Chris@16
|
80 >::get(input);
|
Chris@16
|
81 }
|
Chris@16
|
82
|
Chris@16
|
83
|
Chris@16
|
84 /*!
|
Chris@16
|
85 \brief Function getting either the range (ring, linestring) itself
|
Chris@16
|
86 or the outer ring (polygon), const version
|
Chris@16
|
87 \details Utility to handle polygon's outer ring as a range
|
Chris@16
|
88 \ingroup utility
|
Chris@16
|
89 */
|
Chris@16
|
90 template <typename Range, typename Geometry>
|
Chris@16
|
91 inline Range const& as_range(Geometry const& input)
|
Chris@16
|
92 {
|
Chris@16
|
93 return dispatch::as_range
|
Chris@16
|
94 <
|
Chris@16
|
95 typename tag<Geometry>::type,
|
Chris@16
|
96 Geometry,
|
Chris@16
|
97 Range,
|
Chris@16
|
98 true
|
Chris@16
|
99 >::get(input);
|
Chris@16
|
100 }
|
Chris@16
|
101
|
Chris@16
|
102 }
|
Chris@16
|
103
|
Chris@16
|
104 }} // namespace boost::geometry
|
Chris@16
|
105
|
Chris@16
|
106
|
Chris@16
|
107 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_AS_RANGE_HPP
|