summaryrefslogtreecommitdiff
path: root/libs/geometry/doc/src/docutils/tools/support_status/support_status.cpp
blob: 6bf00b5d08a537c0d1192ee7011587da0a5f72cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Tool reporting Implementation Support Status in QBK or plain text format

// Copyright (c) 2011-2015 Bruno Lalande, Paris, France.
// Copyright (c) 2011-2015 Barend Gehrels, Amsterdam, the Netherlands.

// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#include <iostream>
#include <fstream>
#include <sstream>

#include <boost/mpl/for_each.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/type_traits/is_base_of.hpp>

#define BOOST_GEOMETRY_IMPLEMENTATION_STATUS_BUILD true
#include <boost/geometry/core/cs.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/algorithms/append.hpp>
#include <boost/geometry/algorithms/area.hpp>
#include <boost/geometry/algorithms/buffer.hpp>
#include <boost/geometry/algorithms/centroid.hpp>
#include <boost/geometry/algorithms/clear.hpp>
#include <boost/geometry/algorithms/convert.hpp>
#include <boost/geometry/algorithms/convex_hull.hpp>
#include <boost/geometry/algorithms/correct.hpp>
#include <boost/geometry/algorithms/covered_by.hpp>
#include <boost/geometry/algorithms/disjoint.hpp>
#include <boost/geometry/algorithms/distance.hpp>
#include <boost/geometry/algorithms/envelope.hpp>
#include <boost/geometry/algorithms/equals.hpp>
#include <boost/geometry/algorithms/expand.hpp>
#include <boost/geometry/algorithms/for_each.hpp>
#include <boost/geometry/algorithms/is_simple.hpp>
#include <boost/geometry/algorithms/is_valid.hpp>
#include <boost/geometry/algorithms/length.hpp>
#include <boost/geometry/algorithms/num_geometries.hpp>
#include <boost/geometry/algorithms/num_interior_rings.hpp>
#include <boost/geometry/algorithms/num_points.hpp>
#include <boost/geometry/algorithms/num_segments.hpp>
#include <boost/geometry/algorithms/overlaps.hpp>
#include <boost/geometry/algorithms/perimeter.hpp>
#include <boost/geometry/algorithms/reverse.hpp>
#include <boost/geometry/algorithms/simplify.hpp>
#include <boost/geometry/algorithms/transform.hpp>
#include <boost/geometry/algorithms/unique.hpp>
#include <boost/geometry/io/wkt/wkt.hpp>
#include <boost/geometry/strategies/strategies.hpp>

#include "text_outputter.hpp"
#include "qbk_outputter.hpp"

typedef boost::geometry::cs::cartesian cartesian;

typedef boost::geometry::model::point<double, 2, cartesian> point_type;
typedef boost::geometry::model::linestring<point_type>      linestring_type;
typedef boost::geometry::model::polygon<point_type>         polygon_type;
typedef boost::geometry::model::box<point_type>             box_type;
typedef boost::geometry::model::ring<point_type>            ring_type;
typedef boost::geometry::model::segment<point_type>         segment_type;

typedef boost::geometry::model::multi_point<point_type>           multi_point_type;
typedef boost::geometry::model::multi_linestring<linestring_type> multi_linestring_type;
typedef boost::geometry::model::multi_polygon<polygon_type>       multi_polygon_type;

typedef boost::mpl::vector<
    point_type,
    segment_type,
    box_type,
    linestring_type,
    ring_type,
    polygon_type,
    multi_point_type,
    multi_linestring_type,
    multi_polygon_type
> all_types;

#define DECLARE_UNARY_ALGORITHM(algorithm) \
    template <typename G> \
    struct algorithm: boost::geometry::dispatch::algorithm<G> \
    {};

#define DECLARE_UNARY_ALGORITHM_WITH_BOOLEAN(algorithm) \
    template <typename G> \
    struct algorithm: boost::geometry::dispatch::algorithm<G,false>  \
    {};

#define DECLARE_BINARY_ALGORITHM(algorithm) \
    template <typename G1, typename G2> \
    struct algorithm: boost::geometry::dispatch::algorithm<G1, G2> \
    {};

DECLARE_BINARY_ALGORITHM(append)
DECLARE_UNARY_ALGORITHM(area)
DECLARE_BINARY_ALGORITHM(buffer)
DECLARE_UNARY_ALGORITHM(centroid)
DECLARE_UNARY_ALGORITHM(clear)
DECLARE_BINARY_ALGORITHM(convert)
DECLARE_UNARY_ALGORITHM(convex_hull)
DECLARE_UNARY_ALGORITHM(correct)
DECLARE_BINARY_ALGORITHM(covered_by)
DECLARE_BINARY_ALGORITHM(disjoint)
DECLARE_BINARY_ALGORITHM(distance)
DECLARE_UNARY_ALGORITHM(envelope)
DECLARE_BINARY_ALGORITHM(equals)
DECLARE_BINARY_ALGORITHM(expand)
DECLARE_UNARY_ALGORITHM(for_each_point)
DECLARE_UNARY_ALGORITHM(for_each_segment)
DECLARE_UNARY_ALGORITHM(is_simple)
DECLARE_UNARY_ALGORITHM(is_valid)
DECLARE_UNARY_ALGORITHM(length)
DECLARE_UNARY_ALGORITHM(num_geometries)
DECLARE_UNARY_ALGORITHM(num_interior_rings)
DECLARE_UNARY_ALGORITHM_WITH_BOOLEAN(num_points)
DECLARE_UNARY_ALGORITHM(num_segments)
DECLARE_BINARY_ALGORITHM(overlaps)
DECLARE_UNARY_ALGORITHM(perimeter)
DECLARE_UNARY_ALGORITHM(reverse)
DECLARE_UNARY_ALGORITHM(simplify)
DECLARE_BINARY_ALGORITHM(transform)
DECLARE_UNARY_ALGORITHM(unique)
DECLARE_BINARY_ALGORITHM(within)
DECLARE_UNARY_ALGORITHM(wkt)


template <template <typename> class Dispatcher, typename Outputter, typename G>
struct do_unary_test
{
    Outputter& m_outputter;
    inline do_unary_test(Outputter& outputter)
        : m_outputter(outputter)
    {}

    void operator()()
    {
        if (boost::is_base_of<boost::geometry::nyi::not_implemented_tag, Dispatcher<G> >::type::value)
        {
            m_outputter.nyi();
        }
        else
        {
            m_outputter.ok();
        }
    }
};

template <template <typename, typename> class Dispatcher, typename Outputter, typename G2 = void>
struct do_binary_test
{
    Outputter& m_outputter;
    inline do_binary_test(Outputter& outputter)
        : m_outputter(outputter)
    {}

    template <typename G1>
    void operator()(G1)
    {
        if (boost::is_base_of<boost::geometry::nyi::not_implemented_tag, Dispatcher<G1, G2> >::type::value)
        {
            m_outputter.nyi();
        }
        else
        {
            m_outputter.ok();
        }
    }
};

template <template <typename> class Dispatcher, typename Outputter>
struct unary_test
{
    Outputter& m_outputter;
    inline unary_test(Outputter& outputter)
        : m_outputter(outputter)
    {}

    template <typename G>
    void operator()(G)
    {
         m_outputter.template begin_row<G>();
         do_unary_test<Dispatcher, Outputter, G> test(m_outputter);
         test();
         m_outputter.end_row();
    }
};

template <template <typename, typename> class Dispatcher, typename Types, typename Outputter>
struct binary_test
{
    Outputter& m_outputter;
    inline binary_test(Outputter& outputter)
        : m_outputter(outputter)
    {}

    template <typename G2>
    void operator()(G2)
    {
         m_outputter.template begin_row<G2>();
         boost::mpl::for_each<Types>(do_binary_test<Dispatcher, Outputter, G2>(m_outputter));
         m_outputter.end_row();
    }
};

template <template <typename> class Dispatcher, typename Types, typename Outputter>
void test_unary_algorithm(std::string const& name)
{
    Outputter outputter(name);
    outputter.header(name);

    outputter.table_header();
    boost::mpl::for_each<Types>(unary_test<Dispatcher, Outputter>(outputter));

    outputter.table_footer();
}

template <template <typename, typename> class Dispatcher, typename Types1, typename Types2, typename Outputter>
void test_binary_algorithm(std::string const& name)
{
    Outputter outputter(name);
    outputter.header(name);

    outputter.template table_header<Types2>();
    boost::mpl::for_each<Types1>(binary_test<Dispatcher, Types2, Outputter>(outputter));

    outputter.table_footer();
}


template <typename OutputFactory>
void support_status()
{
    test_binary_algorithm<append, all_types, boost::mpl::vector<point_type, std::vector<point_type> >, OutputFactory>("append");
    test_unary_algorithm<area, all_types, OutputFactory>("area");
    test_binary_algorithm<buffer, all_types, all_types, OutputFactory>("buffer");
    test_unary_algorithm<centroid, all_types, OutputFactory>("centroid");
    test_unary_algorithm<clear, all_types, OutputFactory>("clear");
    test_binary_algorithm<convert, all_types, all_types, OutputFactory>("convert");
    test_unary_algorithm<convex_hull, all_types, OutputFactory>("convex_hull");
    test_unary_algorithm<correct, all_types, OutputFactory>("correct");
    test_binary_algorithm<covered_by, all_types, all_types, OutputFactory>("covered_by");
    test_binary_algorithm<disjoint, all_types, all_types, OutputFactory>("disjoint");
    test_binary_algorithm<distance, all_types, all_types, OutputFactory>("distance");
    test_unary_algorithm<envelope, all_types, OutputFactory>("envelope");
    test_binary_algorithm<equals, all_types, all_types, OutputFactory>("equals");
    test_binary_algorithm<expand, all_types, all_types, OutputFactory>("expand");
    test_unary_algorithm<for_each_point, all_types, OutputFactory>("for_each_point");
    test_unary_algorithm<for_each_segment, all_types, OutputFactory>("for_each_segment");
    test_unary_algorithm<is_simple, all_types, OutputFactory>("is_simple");
    test_unary_algorithm<is_valid, all_types, OutputFactory>("is_valid");
    test_unary_algorithm<length, all_types, OutputFactory>("length");
    test_unary_algorithm<num_geometries, all_types, OutputFactory>("num_geometries");
    test_unary_algorithm<num_interior_rings, all_types, OutputFactory>("num_interior_rings");
    test_unary_algorithm<num_points, all_types, OutputFactory>("num_points");
    test_binary_algorithm<overlaps, all_types, all_types, OutputFactory>("overlaps");
    test_unary_algorithm<perimeter, all_types, OutputFactory>("perimeter");
    test_unary_algorithm<reverse, all_types, OutputFactory>("reverse");
    test_unary_algorithm<simplify, all_types, OutputFactory>("simplify");
    test_binary_algorithm<transform, all_types, all_types, OutputFactory>("transform");
    test_unary_algorithm<unique, all_types, OutputFactory>("unique");
    test_binary_algorithm<within, all_types, all_types, OutputFactory>("within");
    test_unary_algorithm<wkt, all_types, OutputFactory>("wkt");
}


int main(int argc, char** argv)
{
    if (argc > 1 && ! strcmp(argv[1], "qbk"))
    {
        support_status<qbk_outputter>();
    }
    else
    {
        support_status<text_outputter>();
    }

    return 0;
}