Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/geometry/algorithms/covered_by.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children | c530137014c0 |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 // Boost.Geometry (aka GGL, Generic Geometry Library) | |
2 | |
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. | |
4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. | |
5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. | |
6 | |
7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library | |
8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. | |
9 | |
10 // Use, modification and distribution is subject to the Boost Software License, | |
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
12 // http://www.boost.org/LICENSE_1_0.txt) | |
13 | |
14 #ifndef BOOST_GEOMETRY_ALGORITHMS_COVERED_BY_HPP | |
15 #define BOOST_GEOMETRY_ALGORITHMS_COVERED_BY_HPP | |
16 | |
17 | |
18 #include <cstddef> | |
19 | |
20 #include <boost/geometry/algorithms/not_implemented.hpp> | |
21 #include <boost/geometry/algorithms/within.hpp> | |
22 | |
23 #include <boost/geometry/strategies/cartesian/point_in_box.hpp> | |
24 #include <boost/geometry/strategies/cartesian/box_in_box.hpp> | |
25 | |
26 namespace boost { namespace geometry | |
27 { | |
28 | |
29 #ifndef DOXYGEN_NO_DISPATCH | |
30 namespace dispatch | |
31 { | |
32 | |
33 template | |
34 < | |
35 typename Geometry1, | |
36 typename Geometry2, | |
37 typename Tag1 = typename tag<Geometry1>::type, | |
38 typename Tag2 = typename tag<Geometry2>::type | |
39 > | |
40 struct covered_by: not_implemented<Tag1, Tag2> | |
41 {}; | |
42 | |
43 | |
44 template <typename Point, typename Box> | |
45 struct covered_by<Point, Box, point_tag, box_tag> | |
46 { | |
47 template <typename Strategy> | |
48 static inline bool apply(Point const& point, Box const& box, Strategy const& strategy) | |
49 { | |
50 ::boost::ignore_unused_variable_warning(strategy); | |
51 return strategy.apply(point, box); | |
52 } | |
53 }; | |
54 | |
55 template <typename Box1, typename Box2> | |
56 struct covered_by<Box1, Box2, box_tag, box_tag> | |
57 { | |
58 template <typename Strategy> | |
59 static inline bool apply(Box1 const& box1, Box2 const& box2, Strategy const& strategy) | |
60 { | |
61 assert_dimension_equal<Box1, Box2>(); | |
62 ::boost::ignore_unused_variable_warning(strategy); | |
63 return strategy.apply(box1, box2); | |
64 } | |
65 }; | |
66 | |
67 | |
68 | |
69 template <typename Point, typename Ring> | |
70 struct covered_by<Point, Ring, point_tag, ring_tag> | |
71 { | |
72 template <typename Strategy> | |
73 static inline bool apply(Point const& point, Ring const& ring, Strategy const& strategy) | |
74 { | |
75 return detail::within::point_in_ring | |
76 < | |
77 Point, | |
78 Ring, | |
79 order_as_direction<geometry::point_order<Ring>::value>::value, | |
80 geometry::closure<Ring>::value, | |
81 Strategy | |
82 >::apply(point, ring, strategy) >= 0; | |
83 } | |
84 }; | |
85 | |
86 template <typename Point, typename Polygon> | |
87 struct covered_by<Point, Polygon, point_tag, polygon_tag> | |
88 { | |
89 template <typename Strategy> | |
90 static inline bool apply(Point const& point, Polygon const& polygon, Strategy const& strategy) | |
91 { | |
92 return detail::within::point_in_polygon | |
93 < | |
94 Point, | |
95 Polygon, | |
96 order_as_direction<geometry::point_order<Polygon>::value>::value, | |
97 geometry::closure<Polygon>::value, | |
98 Strategy | |
99 >::apply(point, polygon, strategy) >= 0; | |
100 } | |
101 }; | |
102 | |
103 } // namespace dispatch | |
104 #endif // DOXYGEN_NO_DISPATCH | |
105 | |
106 | |
107 /*! | |
108 \brief \brief_check12{is inside or on border} | |
109 \ingroup covered_by | |
110 \details \details_check12{covered_by, is inside or on border}. | |
111 \tparam Geometry1 \tparam_geometry | |
112 \tparam Geometry2 \tparam_geometry | |
113 \param geometry1 \param_geometry which might be inside or on the border of the second geometry | |
114 \param geometry2 \param_geometry which might cover the first geometry | |
115 \return true if geometry1 is inside of or on the border of geometry2, | |
116 else false | |
117 \note The default strategy is used for covered_by detection | |
118 | |
119 \qbk{[include reference/algorithms/covered_by.qbk]} | |
120 | |
121 */ | |
122 template<typename Geometry1, typename Geometry2> | |
123 inline bool covered_by(Geometry1 const& geometry1, Geometry2 const& geometry2) | |
124 { | |
125 concept::check<Geometry1 const>(); | |
126 concept::check<Geometry2 const>(); | |
127 assert_dimension_equal<Geometry1, Geometry2>(); | |
128 | |
129 typedef typename point_type<Geometry1>::type point_type1; | |
130 typedef typename point_type<Geometry2>::type point_type2; | |
131 | |
132 typedef typename strategy::covered_by::services::default_strategy | |
133 < | |
134 typename tag<Geometry1>::type, | |
135 typename tag<Geometry2>::type, | |
136 typename tag<Geometry1>::type, | |
137 typename tag_cast<typename tag<Geometry2>::type, areal_tag>::type, | |
138 typename tag_cast | |
139 < | |
140 typename cs_tag<point_type1>::type, spherical_tag | |
141 >::type, | |
142 typename tag_cast | |
143 < | |
144 typename cs_tag<point_type2>::type, spherical_tag | |
145 >::type, | |
146 Geometry1, | |
147 Geometry2 | |
148 >::type strategy_type; | |
149 | |
150 return dispatch::covered_by | |
151 < | |
152 Geometry1, | |
153 Geometry2 | |
154 >::apply(geometry1, geometry2, strategy_type()); | |
155 } | |
156 | |
157 /*! | |
158 \brief \brief_check12{is inside or on border} \brief_strategy | |
159 \ingroup covered_by | |
160 \details \details_check12{covered_by, is inside or on border}, \brief_strategy. \details_strategy_reasons | |
161 \tparam Geometry1 \tparam_geometry | |
162 \tparam Geometry2 \tparam_geometry | |
163 \param geometry1 \param_geometry which might be inside or on the border of the second geometry | |
164 \param geometry2 \param_geometry which might cover the first geometry | |
165 \param strategy strategy to be used | |
166 \return true if geometry1 is inside of or on the border of geometry2, | |
167 else false | |
168 | |
169 \qbk{distinguish,with strategy} | |
170 \qbk{[include reference/algorithms/covered_by.qbk]} | |
171 | |
172 */ | |
173 template<typename Geometry1, typename Geometry2, typename Strategy> | |
174 inline bool covered_by(Geometry1 const& geometry1, Geometry2 const& geometry2, | |
175 Strategy const& strategy) | |
176 { | |
177 concept::within::check | |
178 < | |
179 typename tag<Geometry1>::type, | |
180 typename tag<Geometry2>::type, | |
181 typename tag_cast<typename tag<Geometry2>::type, areal_tag>::type, | |
182 Strategy | |
183 >(); | |
184 concept::check<Geometry1 const>(); | |
185 concept::check<Geometry2 const>(); | |
186 assert_dimension_equal<Geometry1, Geometry2>(); | |
187 | |
188 return dispatch::covered_by | |
189 < | |
190 Geometry1, | |
191 Geometry2 | |
192 >::apply(geometry1, geometry2, strategy); | |
193 } | |
194 | |
195 }} // namespace boost::geometry | |
196 | |
197 #endif // BOOST_GEOMETRY_ALGORITHMS_COVERED_BY_HPP |