]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
2 | // Unit Test | |
3 | ||
4 | // Copyright (c) 2016 Oracle and/or its affiliates. | |
5 | // Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle | |
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 <algorithms/test_length.hpp> | |
12 | #include <algorithms/length/linestring_cases.hpp> | |
13 | ||
14 | #include <boost/geometry/geometries/geometries.hpp> | |
15 | #include <boost/geometry/geometries/point_xy.hpp> | |
16 | #include <boost/geometry/geometries/adapted/std_pair_as_segment.hpp> | |
17 | ||
18 | #include <test_geometries/all_custom_linestring.hpp> | |
19 | #include <test_geometries/wrapped_boost_array.hpp> | |
20 | ||
21 | template <typename P> | |
22 | struct geo_strategies | |
23 | { | |
24 | // Set radius type, but for integer coordinates we want to have floating | |
25 | // point radius type | |
26 | typedef typename bg::promote_floating_point | |
27 | < | |
28 | typename bg::coordinate_type<P>::type | |
29 | >::type rtype; | |
30 | ||
31 | typedef bg::srs::spheroid<rtype> stype; | |
32 | typedef bg::strategy::distance::andoyer<stype> andoyer_type; | |
33 | typedef bg::strategy::distance::thomas<stype> thomas_type; | |
34 | typedef bg::strategy::distance::vincenty<stype> vincenty_type; | |
35 | }; | |
36 | ||
37 | template <typename P> | |
38 | void test_default() //this should use andoyer strategy | |
39 | { | |
40 | for(std::size_t i = 0; i < 2; ++i) | |
41 | { | |
42 | test_geometry<bg::model::linestring<P> >(Ls_data_geo[i], | |
43 | 1116814.237 + 1116152.605); | |
44 | } | |
45 | // Geometries with length zero | |
46 | test_geometry<P>("POINT(0 0)", 0); | |
47 | test_geometry<bg::model::polygon<P> >("POLYGON((0 0,0 1,1 1,1 0,0 0))", 0); | |
48 | } | |
49 | ||
50 | template <typename P, typename N, typename Strategy> | |
51 | void test_with_strategy(N exp_length, Strategy strategy) | |
52 | { | |
53 | for(std::size_t i = 0; i < 2; ++i) | |
54 | { | |
55 | test_geometry<bg::model::linestring<P> >(Ls_data_geo[i], | |
56 | exp_length, | |
57 | strategy); | |
58 | } | |
59 | // Geometries with length zero | |
60 | test_geometry<P>("POINT(0 0)", 0, strategy); | |
61 | test_geometry<bg::model::polygon<P> >("POLYGON((0 0,0 1,1 1,1 0,0 0))", 0, | |
62 | strategy); | |
63 | } | |
64 | ||
65 | template <typename P> | |
66 | void test_andoyer() | |
67 | { | |
68 | typename geo_strategies<P>::andoyer_type andoyer; | |
69 | test_with_strategy<P>(1116814.237 + 1116152.605, andoyer); | |
70 | } | |
71 | ||
72 | template <typename P> | |
73 | void test_thomas() | |
74 | { | |
75 | typename geo_strategies<P>::thomas_type thomas; | |
76 | test_with_strategy<P>(1116825.795 + 1116158.7417, thomas); | |
77 | } | |
78 | ||
79 | template <typename P> | |
80 | void test_vincenty() | |
81 | { | |
82 | typename geo_strategies<P>::vincenty_type vincenty; | |
b32b8144 | 83 | test_with_strategy<P>(1116825.857 + 1116159.144, vincenty); |
7c673cae FG |
84 | } |
85 | ||
86 | template <typename P> | |
87 | void test_all() | |
88 | { | |
89 | test_default<P>(); | |
90 | test_andoyer<P>(); | |
91 | test_thomas<P>(); | |
92 | test_vincenty<P>(); | |
93 | } | |
94 | ||
95 | template <typename P> | |
96 | void test_empty_input() | |
97 | { | |
98 | test_empty_input(bg::model::linestring<P>()); | |
99 | test_empty_input(bg::model::multi_linestring<P>()); | |
100 | } | |
101 | ||
102 | int test_main(int, char* []) | |
103 | { | |
104 | // Works only for double(?!) | |
105 | //test_all<bg::model::d2::point_xy<int, | |
106 | // bg::cs::geographic<bg::degree> > >(); | |
107 | //test_all<bg::model::d2::point_xy<float, | |
108 | // bg::cs::geographic<bg::degree> > >(); | |
109 | test_all<bg::model::d2::point_xy<double, | |
110 | bg::cs::geographic<bg::degree> > >(); | |
111 | ||
112 | #if defined(HAVE_TTMATH) | |
113 | test_all<bg::model::d2::point_xy<ttmath_big> >(); | |
114 | #endif | |
115 | ||
116 | //test_empty_input<bg::model::d2::point_xy<double, | |
117 | // bg::cs::geographic<bg::degree> > >(); | |
118 | ||
119 | return 0; | |
120 | } | |
121 |