]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
2 | // Unit Test | |
3 | ||
4 | // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. | |
1e59de90 TL |
5 | |
6 | // This file was modified by Oracle on 2021. | |
7 | // Modifications copyright (c) 2021, Oracle and/or its affiliates. | |
8 | // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle | |
9 | ||
7c673cae FG |
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_TEST_CONVERT_HPP | |
15 | #define BOOST_GEOMETRY_TEST_CONVERT_HPP | |
16 | ||
17 | ||
18 | #include <boost/geometry/algorithms/assign.hpp> | |
19 | #include <boost/geometry/algorithms/convert.hpp> | |
20 | #include <boost/geometry/algorithms/make.hpp> | |
21 | #include <boost/geometry/algorithms/num_points.hpp> | |
22 | ||
23 | #include <boost/geometry/io/wkt/wkt.hpp> | |
24 | ||
25 | #include <boost/geometry/geometries/geometries.hpp> | |
26 | #include <boost/geometry/geometries/adapted/c_array.hpp> | |
27 | #include <boost/geometry/geometries/adapted/boost_tuple.hpp> | |
28 | ||
29 | #include <boost/variant/variant.hpp> | |
30 | ||
31 | #include <geometry_test_common.hpp> | |
32 | ||
33 | #include <test_common/test_point.hpp> | |
34 | ||
35 | BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian) | |
36 | BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) | |
37 | ||
38 | ||
39 | ||
40 | template <typename Geometry2, typename Geometry1> | |
1e59de90 | 41 | void check(Geometry1 const& geometry1, std::string const& expected, int expected_point_count = -1) |
7c673cae FG |
42 | { |
43 | Geometry2 geometry2; | |
44 | bg::convert(geometry1, geometry2); | |
45 | ||
46 | std::ostringstream out; | |
47 | out << bg::wkt(geometry2); | |
48 | BOOST_CHECK_EQUAL(out.str(), expected); | |
49 | ||
50 | std::size_t n = bg::num_points(geometry2); | |
51 | BOOST_CHECK_MESSAGE(expected_point_count < 0 || int(n) == expected_point_count, | |
52 | "convert: " | |
53 | << " #points expected: " << expected_point_count | |
54 | << " detected: " << n | |
55 | << " expected wkt: " << expected | |
56 | ); | |
57 | } | |
58 | ||
59 | template <typename Geometry1, typename Geometry2> | |
1e59de90 | 60 | void check(std::string const& wkt, std::string const& expected = "", int expected_point_count = -1) |
7c673cae FG |
61 | { |
62 | Geometry1 geometry1; | |
63 | bg::read_wkt(wkt, geometry1); | |
1e59de90 TL |
64 | std::string const& used_expected = expected.empty() ? wkt : expected; |
65 | check<Geometry2>(geometry1, used_expected, expected_point_count); | |
66 | check<Geometry2>(boost::variant<Geometry1>(geometry1), used_expected, expected_point_count); | |
7c673cae FG |
67 | } |
68 | ||
7c673cae | 69 | |
1e59de90 | 70 | #endif // BOOST_GEOMETRY_TEST_CONVERT_HPP |