]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/strategies/thomas.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
4 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
6 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
8 // This file was modified by Oracle on 2015.
9 // Modifications copyright (c) 2015 Oracle and/or its affiliates.
11 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
13 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
14 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
16 // Use, modification and distribution is subject to the Boost Software License,
17 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
18 // http://www.boost.org/LICENSE_1_0.txt)
21 #include <geometry_test_common.hpp>
23 #include <boost/concept_check.hpp>
25 #include <boost/geometry/strategies/geographic/distance_thomas.hpp>
26 #include <boost/geometry/strategies/geographic/side_thomas.hpp>
28 #include <boost/geometry/core/srs.hpp>
29 #include <boost/geometry/strategies/strategies.hpp>
30 #include <boost/geometry/algorithms/assign.hpp>
31 #include <boost/geometry/geometries/point.hpp>
32 #include <test_common/test_point.hpp>
35 # include <boost/geometry/extensions/contrib/ttmath_stub.hpp>
40 template <typename P1
, typename P2
>
41 void test_distance(double lon1
, double lat1
, double lon2
, double lat2
, double expected_km
)
43 // Set radius type, but for integer coordinates we want to have floating point radius type
44 typedef typename
bg::promote_floating_point
46 typename
bg::coordinate_type
<P1
>::type
49 typedef bg::srs::spheroid
<rtype
> stype
;
51 typedef bg::strategy::distance::thomas
<stype
> thomas_type
;
55 (bg::concepts::PointDistanceStrategy
<thomas_type
, P1
, P2
>)
59 typedef typename
bg::strategy::distance
60 ::services::return_type
<thomas_type
, P1
, P2
>::type return_type
;
66 bg::assign_values(p1
, lon1
, lat1
);
67 bg::assign_values(p2
, lon2
, lat2
);
69 BOOST_CHECK_CLOSE(thomas
.apply(p1
, p2
), return_type(1000.0 * expected_km
), 0.001);
70 BOOST_CHECK_CLOSE(bg::distance(p1
, p2
, thomas
), return_type(1000.0 * expected_km
), 0.001);
73 template <typename PS
, typename P
>
74 void test_side(double lon1
, double lat1
,
75 double lon2
, double lat2
,
76 double lon
, double lat
,
79 // Set radius type, but for integer coordinates we want to have floating point radius type
80 typedef typename
bg::promote_floating_point
82 typename
bg::coordinate_type
<PS
>::type
85 typedef bg::srs::spheroid
<rtype
> stype
;
87 typedef bg::strategy::side::thomas
<stype
> strategy_type
;
89 strategy_type strategy
;
94 bg::assign_values(p1
, lon1
, lat1
);
95 bg::assign_values(p2
, lon2
, lat2
);
96 bg::assign_values(p
, lon
, lat
);
98 int side
= strategy
.apply(p1
, p2
, p
);
100 BOOST_CHECK_EQUAL(side
, expected_side
);
103 template <typename P1
, typename P2
>
106 test_distance
<P1
, P2
>(0, 90, 1, 80, 1116.825795); // polar
107 test_distance
<P1
, P2
>(0, -90, 1, -80, 1116.825795); // polar
108 test_distance
<P1
, P2
>(4, 52, 4, 52, 0.0); // no point difference
109 test_distance
<P1
, P2
>(4, 52, 3, 40, 1336.025365); // normal case
111 test_side
<P1
, P2
>(0, 0, 0, 1, 0, 2, 0);
112 test_side
<P1
, P2
>(0, 0, 0, 1, 0, -2, 0);
113 test_side
<P1
, P2
>(10, 0, 10, 1, 10, 2, 0);
114 test_side
<P1
, P2
>(10, 0, 10, -1, 10, 2, 0);
116 test_side
<P1
, P2
>(10, 0, 10, 1, 0, 2, 1); // left
117 test_side
<P1
, P2
>(10, 0, 10, -1, 0, 2, -1); // right
119 test_side
<P1
, P2
>(-10, -10, 10, 10, 10, 0, -1); // right
120 test_side
<P1
, P2
>(-10, -10, 10, 10, -10, 0, 1); // left
121 test_side
<P1
, P2
>(170, -10, -170, 10, -170, 0, -1); // right
122 test_side
<P1
, P2
>(170, -10, -170, 10, 170, 0, 1); // left
125 template <typename P
>
131 int test_main(int, char* [])
133 //test_all<float[2]>();
134 //test_all<double[2]>();
135 test_all
<bg::model::point
<int, 2, bg::cs::geographic
<bg::degree
> > >();
136 test_all
<bg::model::point
<float, 2, bg::cs::geographic
<bg::degree
> > >();
137 test_all
<bg::model::point
<double, 2, bg::cs::geographic
<bg::degree
> > >();
139 #if defined(HAVE_TTMATH)
140 test_all
<bg::model::point
<ttmath::Big
<1,4>, 2, bg::cs::geographic
<bg::degree
> > >();
141 test_all
<bg::model::point
<ttmath_big
, 2, bg::cs::geographic
<bg::degree
> > >();