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