]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
2 | // Tool reporting Implementation Support Status in QBK or plain text format | |
3 | ||
4 | // Copyright (c) 2011-2015 Bruno Lalande, Paris, France. | |
5 | // Copyright (c) 2011-2015 Barend Gehrels, Amsterdam, the Netherlands. | |
6 | ||
7 | // Use, modification and distribution is subject to the Boost Software License, | |
8 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
9 | // http://www.boost.org/LICENSE_1_0.txt) | |
10 | ||
11 | #include <iostream> | |
12 | #include <fstream> | |
13 | #include <sstream> | |
14 | ||
15 | #include <boost/mpl/for_each.hpp> | |
16 | #include <boost/mpl/vector.hpp> | |
17 | #include <boost/type_traits/is_base_of.hpp> | |
18 | ||
19 | #define BOOST_GEOMETRY_IMPLEMENTATION_STATUS_BUILD true | |
20 | #include <boost/geometry/core/cs.hpp> | |
21 | #include <boost/geometry/geometries/geometries.hpp> | |
22 | #include <boost/geometry/algorithms/append.hpp> | |
23 | #include <boost/geometry/algorithms/area.hpp> | |
24 | #include <boost/geometry/algorithms/buffer.hpp> | |
25 | #include <boost/geometry/algorithms/centroid.hpp> | |
26 | #include <boost/geometry/algorithms/clear.hpp> | |
27 | #include <boost/geometry/algorithms/convert.hpp> | |
28 | #include <boost/geometry/algorithms/convex_hull.hpp> | |
29 | #include <boost/geometry/algorithms/correct.hpp> | |
30 | #include <boost/geometry/algorithms/covered_by.hpp> | |
31 | #include <boost/geometry/algorithms/disjoint.hpp> | |
32 | #include <boost/geometry/algorithms/distance.hpp> | |
33 | #include <boost/geometry/algorithms/envelope.hpp> | |
34 | #include <boost/geometry/algorithms/equals.hpp> | |
35 | #include <boost/geometry/algorithms/expand.hpp> | |
36 | #include <boost/geometry/algorithms/for_each.hpp> | |
37 | #include <boost/geometry/algorithms/is_empty.hpp> | |
38 | #include <boost/geometry/algorithms/is_simple.hpp> | |
39 | #include <boost/geometry/algorithms/is_valid.hpp> | |
40 | #include <boost/geometry/algorithms/length.hpp> | |
41 | #include <boost/geometry/algorithms/num_geometries.hpp> | |
42 | #include <boost/geometry/algorithms/num_interior_rings.hpp> | |
43 | #include <boost/geometry/algorithms/num_points.hpp> | |
44 | #include <boost/geometry/algorithms/num_segments.hpp> | |
45 | #include <boost/geometry/algorithms/overlaps.hpp> | |
46 | #include <boost/geometry/algorithms/perimeter.hpp> | |
47 | #include <boost/geometry/algorithms/reverse.hpp> | |
48 | #include <boost/geometry/algorithms/simplify.hpp> | |
49 | #include <boost/geometry/algorithms/transform.hpp> | |
50 | #include <boost/geometry/algorithms/unique.hpp> | |
51 | #include <boost/geometry/io/wkt/wkt.hpp> | |
52 | #include <boost/geometry/strategies/strategies.hpp> | |
53 | ||
54 | #include "text_outputter.hpp" | |
55 | #include "qbk_outputter.hpp" | |
56 | ||
57 | typedef boost::geometry::cs::cartesian cartesian; | |
58 | ||
59 | typedef boost::geometry::model::point<double, 2, cartesian> point_type; | |
60 | typedef boost::geometry::model::linestring<point_type> linestring_type; | |
61 | typedef boost::geometry::model::polygon<point_type> polygon_type; | |
62 | typedef boost::geometry::model::box<point_type> box_type; | |
63 | typedef boost::geometry::model::ring<point_type> ring_type; | |
64 | typedef boost::geometry::model::segment<point_type> segment_type; | |
65 | ||
66 | typedef boost::geometry::model::multi_point<point_type> multi_point_type; | |
67 | typedef boost::geometry::model::multi_linestring<linestring_type> multi_linestring_type; | |
68 | typedef boost::geometry::model::multi_polygon<polygon_type> multi_polygon_type; | |
69 | ||
70 | typedef boost::mpl::vector< | |
71 | point_type, | |
72 | segment_type, | |
73 | box_type, | |
74 | linestring_type, | |
75 | ring_type, | |
76 | polygon_type, | |
77 | multi_point_type, | |
78 | multi_linestring_type, | |
79 | multi_polygon_type | |
80 | > all_types; | |
81 | ||
82 | #define DECLARE_UNARY_ALGORITHM(algorithm) \ | |
83 | template <typename G> \ | |
84 | struct algorithm: boost::geometry::dispatch::algorithm<G> \ | |
85 | {}; | |
86 | ||
87 | #define DECLARE_UNARY_ALGORITHM_WITH_BOOLEAN(algorithm) \ | |
88 | template <typename G> \ | |
89 | struct algorithm: boost::geometry::dispatch::algorithm<G,false> \ | |
90 | {}; | |
91 | ||
92 | #define DECLARE_BINARY_ALGORITHM(algorithm) \ | |
93 | template <typename G1, typename G2> \ | |
94 | struct algorithm: boost::geometry::dispatch::algorithm<G1, G2> \ | |
95 | {}; | |
96 | ||
97 | DECLARE_BINARY_ALGORITHM(append) | |
98 | DECLARE_UNARY_ALGORITHM(area) | |
99 | DECLARE_BINARY_ALGORITHM(buffer) | |
100 | DECLARE_UNARY_ALGORITHM(centroid) | |
101 | DECLARE_UNARY_ALGORITHM(clear) | |
102 | DECLARE_BINARY_ALGORITHM(convert) | |
103 | DECLARE_UNARY_ALGORITHM(convex_hull) | |
104 | DECLARE_UNARY_ALGORITHM(correct) | |
105 | DECLARE_BINARY_ALGORITHM(covered_by) | |
106 | DECLARE_BINARY_ALGORITHM(disjoint) | |
107 | DECLARE_BINARY_ALGORITHM(distance) | |
108 | DECLARE_UNARY_ALGORITHM(envelope) | |
109 | DECLARE_BINARY_ALGORITHM(equals) | |
110 | DECLARE_BINARY_ALGORITHM(expand) | |
111 | DECLARE_UNARY_ALGORITHM(for_each_point) | |
112 | DECLARE_UNARY_ALGORITHM(for_each_segment) | |
113 | DECLARE_UNARY_ALGORITHM(is_empty) | |
114 | DECLARE_UNARY_ALGORITHM(is_simple) | |
115 | DECLARE_UNARY_ALGORITHM(is_valid) | |
116 | DECLARE_UNARY_ALGORITHM(length) | |
117 | DECLARE_UNARY_ALGORITHM(num_geometries) | |
118 | DECLARE_UNARY_ALGORITHM(num_interior_rings) | |
119 | DECLARE_UNARY_ALGORITHM_WITH_BOOLEAN(num_points) | |
120 | DECLARE_UNARY_ALGORITHM(num_segments) | |
121 | DECLARE_BINARY_ALGORITHM(overlaps) | |
122 | DECLARE_UNARY_ALGORITHM(perimeter) | |
123 | DECLARE_UNARY_ALGORITHM(reverse) | |
124 | DECLARE_UNARY_ALGORITHM(simplify) | |
125 | DECLARE_BINARY_ALGORITHM(transform) | |
126 | DECLARE_UNARY_ALGORITHM(unique) | |
127 | DECLARE_BINARY_ALGORITHM(within) | |
128 | DECLARE_UNARY_ALGORITHM(wkt) | |
129 | ||
130 | ||
131 | template <template <typename> class Dispatcher, typename Outputter, typename G> | |
132 | struct do_unary_test | |
133 | { | |
134 | Outputter& m_outputter; | |
135 | inline do_unary_test(Outputter& outputter) | |
136 | : m_outputter(outputter) | |
137 | {} | |
138 | ||
139 | void operator()() | |
140 | { | |
141 | if (boost::is_base_of<boost::geometry::nyi::not_implemented_tag, Dispatcher<G> >::type::value) | |
142 | { | |
143 | m_outputter.nyi(); | |
144 | } | |
145 | else | |
146 | { | |
147 | m_outputter.ok(); | |
148 | } | |
149 | } | |
150 | }; | |
151 | ||
152 | template <template <typename, typename> class Dispatcher, typename Outputter, typename G2 = void> | |
153 | struct do_binary_test | |
154 | { | |
155 | Outputter& m_outputter; | |
156 | inline do_binary_test(Outputter& outputter) | |
157 | : m_outputter(outputter) | |
158 | {} | |
159 | ||
160 | template <typename G1> | |
161 | void operator()(G1) | |
162 | { | |
163 | if (boost::is_base_of<boost::geometry::nyi::not_implemented_tag, Dispatcher<G1, G2> >::type::value) | |
164 | { | |
165 | m_outputter.nyi(); | |
166 | } | |
167 | else | |
168 | { | |
169 | m_outputter.ok(); | |
170 | } | |
171 | } | |
172 | }; | |
173 | ||
174 | template <template <typename> class Dispatcher, typename Outputter> | |
175 | struct unary_test | |
176 | { | |
177 | Outputter& m_outputter; | |
178 | inline unary_test(Outputter& outputter) | |
179 | : m_outputter(outputter) | |
180 | {} | |
181 | ||
182 | template <typename G> | |
183 | void operator()(G) | |
184 | { | |
185 | m_outputter.template begin_row<G>(); | |
186 | do_unary_test<Dispatcher, Outputter, G> test(m_outputter); | |
187 | test(); | |
188 | m_outputter.end_row(); | |
189 | } | |
190 | }; | |
191 | ||
192 | template <template <typename, typename> class Dispatcher, typename Types, typename Outputter> | |
193 | struct binary_test | |
194 | { | |
195 | Outputter& m_outputter; | |
196 | inline binary_test(Outputter& outputter) | |
197 | : m_outputter(outputter) | |
198 | {} | |
199 | ||
200 | template <typename G2> | |
201 | void operator()(G2) | |
202 | { | |
203 | m_outputter.template begin_row<G2>(); | |
204 | boost::mpl::for_each<Types>(do_binary_test<Dispatcher, Outputter, G2>(m_outputter)); | |
205 | m_outputter.end_row(); | |
206 | } | |
207 | }; | |
208 | ||
209 | template <template <typename> class Dispatcher, typename Types, typename Outputter> | |
210 | void test_unary_algorithm(std::string const& name) | |
211 | { | |
212 | Outputter outputter(name); | |
213 | outputter.header(name); | |
214 | ||
215 | outputter.table_header(); | |
216 | boost::mpl::for_each<Types>(unary_test<Dispatcher, Outputter>(outputter)); | |
217 | ||
218 | outputter.table_footer(); | |
219 | } | |
220 | ||
221 | template <template <typename, typename> class Dispatcher, typename Types1, typename Types2, typename Outputter> | |
222 | void test_binary_algorithm(std::string const& name) | |
223 | { | |
224 | Outputter outputter(name); | |
225 | outputter.header(name); | |
226 | ||
227 | outputter.template table_header<Types2>(); | |
228 | boost::mpl::for_each<Types1>(binary_test<Dispatcher, Types2, Outputter>(outputter)); | |
229 | ||
230 | outputter.table_footer(); | |
231 | } | |
232 | ||
233 | ||
234 | template <typename OutputFactory> | |
235 | void support_status() | |
236 | { | |
237 | test_binary_algorithm<append, all_types, boost::mpl::vector<point_type, std::vector<point_type> >, OutputFactory>("append"); | |
238 | test_unary_algorithm<area, all_types, OutputFactory>("area"); | |
239 | test_binary_algorithm<buffer, all_types, all_types, OutputFactory>("buffer"); | |
240 | test_unary_algorithm<centroid, all_types, OutputFactory>("centroid"); | |
241 | test_unary_algorithm<clear, all_types, OutputFactory>("clear"); | |
242 | test_binary_algorithm<convert, all_types, all_types, OutputFactory>("convert"); | |
243 | test_unary_algorithm<convex_hull, all_types, OutputFactory>("convex_hull"); | |
244 | test_unary_algorithm<correct, all_types, OutputFactory>("correct"); | |
245 | test_binary_algorithm<covered_by, all_types, all_types, OutputFactory>("covered_by"); | |
246 | test_binary_algorithm<disjoint, all_types, all_types, OutputFactory>("disjoint"); | |
247 | test_binary_algorithm<distance, all_types, all_types, OutputFactory>("distance"); | |
248 | test_unary_algorithm<envelope, all_types, OutputFactory>("envelope"); | |
249 | test_binary_algorithm<equals, all_types, all_types, OutputFactory>("equals"); | |
250 | test_binary_algorithm<expand, all_types, all_types, OutputFactory>("expand"); | |
251 | test_unary_algorithm<for_each_point, all_types, OutputFactory>("for_each_point"); | |
252 | test_unary_algorithm<for_each_segment, all_types, OutputFactory>("for_each_segment"); | |
253 | test_unary_algorithm<is_empty, all_types, OutputFactory>("is_empty"); | |
254 | test_unary_algorithm<is_simple, all_types, OutputFactory>("is_simple"); | |
255 | test_unary_algorithm<is_valid, all_types, OutputFactory>("is_valid"); | |
256 | test_unary_algorithm<length, all_types, OutputFactory>("length"); | |
257 | test_unary_algorithm<num_geometries, all_types, OutputFactory>("num_geometries"); | |
258 | test_unary_algorithm<num_interior_rings, all_types, OutputFactory>("num_interior_rings"); | |
259 | test_unary_algorithm<num_points, all_types, OutputFactory>("num_points"); | |
260 | test_binary_algorithm<overlaps, all_types, all_types, OutputFactory>("overlaps"); | |
261 | test_unary_algorithm<perimeter, all_types, OutputFactory>("perimeter"); | |
262 | test_unary_algorithm<reverse, all_types, OutputFactory>("reverse"); | |
263 | test_unary_algorithm<simplify, all_types, OutputFactory>("simplify"); | |
264 | test_binary_algorithm<transform, all_types, all_types, OutputFactory>("transform"); | |
265 | test_unary_algorithm<unique, all_types, OutputFactory>("unique"); | |
266 | test_binary_algorithm<within, all_types, all_types, OutputFactory>("within"); | |
267 | test_unary_algorithm<wkt, all_types, OutputFactory>("wkt"); | |
268 | } | |
269 | ||
270 | ||
271 | int main(int argc, char** argv) | |
272 | { | |
273 | if (argc > 1 && ! strcmp(argv[1], "qbk")) | |
274 | { | |
275 | support_status<qbk_outputter>(); | |
276 | } | |
277 | else | |
278 | { | |
279 | support_status<text_outputter>(); | |
280 | } | |
281 | ||
282 | return 0; | |
283 | } |