]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/srs/projection.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / geometry / test / srs / projection.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit Test
3
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.
7
8 // This file was modified by Oracle on 2017, 2018.
9 // Modifications copyright (c) 2017-2018, Oracle and/or its affiliates.
10 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
11
12 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
13 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
14
15 // Use, modification and distribution is subject to the Boost Software License,
16 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
17 // http://www.boost.org/LICENSE_1_0.txt)
18
19
20 #if defined(_MSC_VER)
21 #pragma warning( disable : 4305 ) // truncation double -> float
22 #endif // defined(_MSC_VER)
23
24
25 #define BOOST_GEOMETRY_SRS_ENABLE_STATIC_PROJECTION_HYBRID_INTERFACE
26
27 #include <geometry_test_common.hpp>
28
29 #include <boost/geometry/srs/projection.hpp>
30
31 #include <boost/geometry/algorithms/transform.hpp>
32 #include <boost/geometry/core/coordinate_type.hpp>
33
34 #include <boost/geometry/geometries/geometries.hpp>
35 #include <boost/geometry/geometries/point_xy.hpp>
36 #include <boost/geometry/geometries/adapted/c_array.hpp>
37 #include <test_common/test_point.hpp>
38
39
40 namespace srs = bg::srs;
41
42 template <typename P1, typename P2, typename Params>
43 void test_one(double lon, double lat,
44 typename bg::coordinate_type<P2>::type x,
45 typename bg::coordinate_type<P2>::type y,
46 Params const& params)
47 {
48 // hybrid interface disabled by default
49 // static_proj4 default ctor, dynamic parameters passed
50 srs::projection<Params> prj(params);
51
52 P1 ll;
53 bg::set<0>(ll, lon);
54 bg::set<1>(ll, lat);
55
56 P2 xy;
57 prj.forward(ll, xy);
58
59 BOOST_CHECK_CLOSE(bg::get<0>(xy), x, 0.001);
60 BOOST_CHECK_CLOSE(bg::get<1>(xy), y, 0.001);
61 }
62
63 template <typename P>
64 void test_all()
65 {
66 typedef typename bg::coordinate_type<P>::type coord_type;
67 typedef bg::model::point<coord_type, 2, bg::cs::geographic<bg::degree> > point_type;
68
69 using namespace srs::spar;
70
71 // aea
72 test_one<point_type, P>
73 (4.897000, 52.371000, 334609.583974, 5218502.503686,
74 parameters<proj_aea, ellps_wgs84, units_m, lat_1<>, lat_2<> >(
75 proj_aea(), ellps_wgs84(), units_m(), lat_1<>(55), lat_2<>(65)));
76 }
77
78 BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(bg::cs::cartesian)
79
80 int test_main(int, char* [])
81 {
82 //test_all<int[2]>();
83 test_all<float[2]>();
84 test_all<double[2]>();
85
86 // 2D -> 3D
87 //test_all<test::test_point>();
88
89 //test_all<bg::model::d2::point_xy<int> >();
90 test_all<bg::model::d2::point_xy<float> >();
91 test_all<bg::model::d2::point_xy<double> >();
92 test_all<bg::model::d2::point_xy<long double> >();
93
94 return 0;
95 }