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_COVERED_BY_HPP
|
Chris@16
|
15 #define BOOST_GEOMETRY_ALGORITHMS_COVERED_BY_HPP
|
Chris@16
|
16
|
Chris@16
|
17
|
Chris@16
|
18 #include <cstddef>
|
Chris@16
|
19
|
Chris@16
|
20 #include <boost/geometry/algorithms/not_implemented.hpp>
|
Chris@16
|
21 #include <boost/geometry/algorithms/within.hpp>
|
Chris@16
|
22
|
Chris@16
|
23 #include <boost/geometry/strategies/cartesian/point_in_box.hpp>
|
Chris@16
|
24 #include <boost/geometry/strategies/cartesian/box_in_box.hpp>
|
Chris@16
|
25
|
Chris@16
|
26 namespace boost { namespace geometry
|
Chris@16
|
27 {
|
Chris@16
|
28
|
Chris@16
|
29 #ifndef DOXYGEN_NO_DISPATCH
|
Chris@16
|
30 namespace dispatch
|
Chris@16
|
31 {
|
Chris@16
|
32
|
Chris@16
|
33 template
|
Chris@16
|
34 <
|
Chris@16
|
35 typename Geometry1,
|
Chris@16
|
36 typename Geometry2,
|
Chris@16
|
37 typename Tag1 = typename tag<Geometry1>::type,
|
Chris@16
|
38 typename Tag2 = typename tag<Geometry2>::type
|
Chris@16
|
39 >
|
Chris@16
|
40 struct covered_by: not_implemented<Tag1, Tag2>
|
Chris@16
|
41 {};
|
Chris@16
|
42
|
Chris@16
|
43
|
Chris@16
|
44 template <typename Point, typename Box>
|
Chris@16
|
45 struct covered_by<Point, Box, point_tag, box_tag>
|
Chris@16
|
46 {
|
Chris@16
|
47 template <typename Strategy>
|
Chris@16
|
48 static inline bool apply(Point const& point, Box const& box, Strategy const& strategy)
|
Chris@16
|
49 {
|
Chris@16
|
50 ::boost::ignore_unused_variable_warning(strategy);
|
Chris@16
|
51 return strategy.apply(point, box);
|
Chris@16
|
52 }
|
Chris@16
|
53 };
|
Chris@16
|
54
|
Chris@16
|
55 template <typename Box1, typename Box2>
|
Chris@16
|
56 struct covered_by<Box1, Box2, box_tag, box_tag>
|
Chris@16
|
57 {
|
Chris@16
|
58 template <typename Strategy>
|
Chris@16
|
59 static inline bool apply(Box1 const& box1, Box2 const& box2, Strategy const& strategy)
|
Chris@16
|
60 {
|
Chris@16
|
61 assert_dimension_equal<Box1, Box2>();
|
Chris@16
|
62 ::boost::ignore_unused_variable_warning(strategy);
|
Chris@16
|
63 return strategy.apply(box1, box2);
|
Chris@16
|
64 }
|
Chris@16
|
65 };
|
Chris@16
|
66
|
Chris@16
|
67
|
Chris@16
|
68
|
Chris@16
|
69 template <typename Point, typename Ring>
|
Chris@16
|
70 struct covered_by<Point, Ring, point_tag, ring_tag>
|
Chris@16
|
71 {
|
Chris@16
|
72 template <typename Strategy>
|
Chris@16
|
73 static inline bool apply(Point const& point, Ring const& ring, Strategy const& strategy)
|
Chris@16
|
74 {
|
Chris@16
|
75 return detail::within::point_in_ring
|
Chris@16
|
76 <
|
Chris@16
|
77 Point,
|
Chris@16
|
78 Ring,
|
Chris@16
|
79 order_as_direction<geometry::point_order<Ring>::value>::value,
|
Chris@16
|
80 geometry::closure<Ring>::value,
|
Chris@16
|
81 Strategy
|
Chris@16
|
82 >::apply(point, ring, strategy) >= 0;
|
Chris@16
|
83 }
|
Chris@16
|
84 };
|
Chris@16
|
85
|
Chris@16
|
86 template <typename Point, typename Polygon>
|
Chris@16
|
87 struct covered_by<Point, Polygon, point_tag, polygon_tag>
|
Chris@16
|
88 {
|
Chris@16
|
89 template <typename Strategy>
|
Chris@16
|
90 static inline bool apply(Point const& point, Polygon const& polygon, Strategy const& strategy)
|
Chris@16
|
91 {
|
Chris@16
|
92 return detail::within::point_in_polygon
|
Chris@16
|
93 <
|
Chris@16
|
94 Point,
|
Chris@16
|
95 Polygon,
|
Chris@16
|
96 order_as_direction<geometry::point_order<Polygon>::value>::value,
|
Chris@16
|
97 geometry::closure<Polygon>::value,
|
Chris@16
|
98 Strategy
|
Chris@16
|
99 >::apply(point, polygon, strategy) >= 0;
|
Chris@16
|
100 }
|
Chris@16
|
101 };
|
Chris@16
|
102
|
Chris@16
|
103 } // namespace dispatch
|
Chris@16
|
104 #endif // DOXYGEN_NO_DISPATCH
|
Chris@16
|
105
|
Chris@16
|
106
|
Chris@16
|
107 /*!
|
Chris@16
|
108 \brief \brief_check12{is inside or on border}
|
Chris@16
|
109 \ingroup covered_by
|
Chris@16
|
110 \details \details_check12{covered_by, is inside or on border}.
|
Chris@16
|
111 \tparam Geometry1 \tparam_geometry
|
Chris@16
|
112 \tparam Geometry2 \tparam_geometry
|
Chris@16
|
113 \param geometry1 \param_geometry which might be inside or on the border of the second geometry
|
Chris@16
|
114 \param geometry2 \param_geometry which might cover the first geometry
|
Chris@16
|
115 \return true if geometry1 is inside of or on the border of geometry2,
|
Chris@16
|
116 else false
|
Chris@16
|
117 \note The default strategy is used for covered_by detection
|
Chris@16
|
118
|
Chris@16
|
119 \qbk{[include reference/algorithms/covered_by.qbk]}
|
Chris@16
|
120
|
Chris@16
|
121 */
|
Chris@16
|
122 template<typename Geometry1, typename Geometry2>
|
Chris@16
|
123 inline bool covered_by(Geometry1 const& geometry1, Geometry2 const& geometry2)
|
Chris@16
|
124 {
|
Chris@16
|
125 concept::check<Geometry1 const>();
|
Chris@16
|
126 concept::check<Geometry2 const>();
|
Chris@16
|
127 assert_dimension_equal<Geometry1, Geometry2>();
|
Chris@16
|
128
|
Chris@16
|
129 typedef typename point_type<Geometry1>::type point_type1;
|
Chris@16
|
130 typedef typename point_type<Geometry2>::type point_type2;
|
Chris@16
|
131
|
Chris@16
|
132 typedef typename strategy::covered_by::services::default_strategy
|
Chris@16
|
133 <
|
Chris@16
|
134 typename tag<Geometry1>::type,
|
Chris@16
|
135 typename tag<Geometry2>::type,
|
Chris@16
|
136 typename tag<Geometry1>::type,
|
Chris@16
|
137 typename tag_cast<typename tag<Geometry2>::type, areal_tag>::type,
|
Chris@16
|
138 typename tag_cast
|
Chris@16
|
139 <
|
Chris@16
|
140 typename cs_tag<point_type1>::type, spherical_tag
|
Chris@16
|
141 >::type,
|
Chris@16
|
142 typename tag_cast
|
Chris@16
|
143 <
|
Chris@16
|
144 typename cs_tag<point_type2>::type, spherical_tag
|
Chris@16
|
145 >::type,
|
Chris@16
|
146 Geometry1,
|
Chris@16
|
147 Geometry2
|
Chris@16
|
148 >::type strategy_type;
|
Chris@16
|
149
|
Chris@16
|
150 return dispatch::covered_by
|
Chris@16
|
151 <
|
Chris@16
|
152 Geometry1,
|
Chris@16
|
153 Geometry2
|
Chris@16
|
154 >::apply(geometry1, geometry2, strategy_type());
|
Chris@16
|
155 }
|
Chris@16
|
156
|
Chris@16
|
157 /*!
|
Chris@16
|
158 \brief \brief_check12{is inside or on border} \brief_strategy
|
Chris@16
|
159 \ingroup covered_by
|
Chris@16
|
160 \details \details_check12{covered_by, is inside or on border}, \brief_strategy. \details_strategy_reasons
|
Chris@16
|
161 \tparam Geometry1 \tparam_geometry
|
Chris@16
|
162 \tparam Geometry2 \tparam_geometry
|
Chris@16
|
163 \param geometry1 \param_geometry which might be inside or on the border of the second geometry
|
Chris@16
|
164 \param geometry2 \param_geometry which might cover the first geometry
|
Chris@16
|
165 \param strategy strategy to be used
|
Chris@16
|
166 \return true if geometry1 is inside of or on the border of geometry2,
|
Chris@16
|
167 else false
|
Chris@16
|
168
|
Chris@16
|
169 \qbk{distinguish,with strategy}
|
Chris@16
|
170 \qbk{[include reference/algorithms/covered_by.qbk]}
|
Chris@16
|
171
|
Chris@16
|
172 */
|
Chris@16
|
173 template<typename Geometry1, typename Geometry2, typename Strategy>
|
Chris@16
|
174 inline bool covered_by(Geometry1 const& geometry1, Geometry2 const& geometry2,
|
Chris@16
|
175 Strategy const& strategy)
|
Chris@16
|
176 {
|
Chris@16
|
177 concept::within::check
|
Chris@16
|
178 <
|
Chris@16
|
179 typename tag<Geometry1>::type,
|
Chris@16
|
180 typename tag<Geometry2>::type,
|
Chris@16
|
181 typename tag_cast<typename tag<Geometry2>::type, areal_tag>::type,
|
Chris@16
|
182 Strategy
|
Chris@16
|
183 >();
|
Chris@16
|
184 concept::check<Geometry1 const>();
|
Chris@16
|
185 concept::check<Geometry2 const>();
|
Chris@16
|
186 assert_dimension_equal<Geometry1, Geometry2>();
|
Chris@16
|
187
|
Chris@16
|
188 return dispatch::covered_by
|
Chris@16
|
189 <
|
Chris@16
|
190 Geometry1,
|
Chris@16
|
191 Geometry2
|
Chris@16
|
192 >::apply(geometry1, geometry2, strategy);
|
Chris@16
|
193 }
|
Chris@16
|
194
|
Chris@16
|
195 }} // namespace boost::geometry
|
Chris@16
|
196
|
Chris@16
|
197 #endif // BOOST_GEOMETRY_ALGORITHMS_COVERED_BY_HPP
|