1 // Boost.Geometry
2 // Unit Test
3
4 // Copyright (c) 2017-2018, Oracle and/or its affiliates.
5 // Contributed and/or modified by Adam Wulkiewicz, 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
12 #include <geometry_test_common.hpp>
13
14 #include <boost/geometry.hpp>
15 #include <boost/geometry/geometries/geometries.hpp>
16 #include <boost/geometry/srs/epsg.hpp>
17 #include <boost/geometry/srs/esri.hpp>
18 #include <boost/geometry/srs/iau2000.hpp>
19 #include <boost/geometry/srs/projection.hpp>
20
21 #include "check_geometry.hpp"
22
test_main(int,char * [])23 int test_main(int, char*[])
24 {
25 using namespace boost::geometry;
26 using namespace boost::geometry::model;
27 using namespace boost::geometry::srs;
28
29 typedef point<double, 2, cs::geographic<degree> > point_ll;
30 typedef point<double, 2, cs::cartesian> point_xy;
31
32 {
33 using namespace boost::geometry::srs::spar;
34
35 point_ll pt_ll(1, 1);
36 point_ll pt_ll2(0, 0);
37 point_xy pt_xy(0, 0);
38
39 projection<parameters<proj_tmerc, ellps_wgs84, units_m> > prj;
40
41 prj.forward(pt_ll, pt_xy);
42 test::check_geometry(pt_xy, "POINT(111308.33561309829 110591.34223734379)", 0.001);
43
44 prj.inverse(pt_xy, pt_ll2);
45 test::check_geometry(pt_ll2, "POINT(1 1)", 0.001);
46 }
47
48 {
49 using namespace boost::geometry::srs::spar;
50
51 projection<parameters<proj_tmerc> > prj1;
52 projection<parameters<proj_tmerc, ellps_wgs84> > prj2;
53 projection<parameters<proj_tmerc, ellps_wgs84, datum_wgs84> > prj3;
54 projection<parameters<proj_tmerc, ellps_wgs84, x_0<>, y_0<> > > prj4
55 = parameters<proj_tmerc, ellps_wgs84, x_0<>, y_0<> >(
56 proj_tmerc(), ellps_wgs84(), x_0<>(0), y_0<>(0));
57
58 typedef spheroid<double> sph;
59 typedef ellps<sph> ell;
60 typedef proj_tmerc prj;
61 projection<parameters<ell, prj> > prj5
62 = parameters<ell, prj>(ell(sph(1000, 999)));
63 }
64
65 {
66 point_ll pt_ll(1, 1);
67 point_ll pt_ll2(0, 0);
68 point_xy pt_xy(0, 0);
69
70 projection<static_epsg<2000> > prj;
71
72 prj.forward(pt_ll, pt_xy);
73 test::check_geometry(pt_xy, "POINT(9413505.3284665551 237337.74515944949)", 0.001);
74
75 prj.inverse(pt_xy, pt_ll2);
76 // TODO: investigate this wierd result
77 test::check_geometry(pt_ll2, "POINT(-2.4463131191981073 1.5066638962045082)", 0.001);
78
79 projection<static_esri<37001> > prj2;
80 projection<static_iau2000<19900> > prj3;
81 }
82
83 // compile-time errors
84 {
85 point_ll pt_ll(1, 1);
86 point_xy pt_xy(0, 0);
87
88 //projection<spar::parameters<int> > prj1;
89 //projection<int> prj2;
90
91 projection<spar::parameters<spar::proj_bacon> > prj3;
92 //prj3.inverse(pt_xy, pt_ll);
93 }
94
95 return 0;
96 }
97