• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/projection.hpp>
18  #include <boost/geometry/srs/transformation.hpp>
19  #include <boost/geometry/strategies/transform/srs_transformer.hpp>
20  
21  #include <boost/geometry/io/wkt/read.hpp>
22  
23  #include "check_geometry.hpp"
24  
25  
test_main(int,char * [])26  int test_main(int, char*[])
27  {
28      using namespace boost::geometry;
29      using namespace boost::geometry::model;
30      using namespace boost::geometry::srs;
31      using namespace bg::strategy::transform;
32  
33      typedef point<double, 2, cs::geographic<degree> > point_ll;
34      typedef point<double, 2, cs::cartesian> point_xy;
35      //typedef polygon<point_ll> polygon_ll;
36      //typedef polygon<point_xy> polygon_xy;
37  
38      {
39          point_ll pt_ll(1, 1);
40          point_ll pt_ll2(0, 0);
41          point_xy pt_xy(0, 0);
42          point_xy pt_xy2(0, 0);
43  
44          srs_forward_transformer<projection<> > strategy_pf = proj4("+proj=tmerc +ellps=WGS84 +units=m");
45          srs_inverse_transformer<projection<> > strategy_pi = proj4("+proj=tmerc +ellps=WGS84 +units=m");
46          srs_forward_transformer<transformation<> > strategy_tf(proj4("+proj=tmerc +ellps=WGS84 +units=m"),
47                                                                 proj4("+proj=tmerc +ellps=clrk66 +units=m"));
48          srs_inverse_transformer<transformation<> > strategy_ti(proj4("+proj=tmerc +ellps=WGS84 +units=m"),
49                                                                 proj4("+proj=tmerc +ellps=clrk66 +units=m"));
50  
51          bg::transform(pt_ll, pt_xy, strategy_pf);
52          test::check_geometry(pt_xy, "POINT(111308.33561309829 110591.34223734379)", 0.0001);
53  
54          bg::transform(pt_xy, pt_ll2, strategy_pi);
55          test::check_geometry(pt_ll2, "POINT(1 1)", 0.0001);
56  
57          bg::transform(pt_xy, pt_xy2, strategy_tf);
58          test::check_geometry(pt_xy2, "POINT(111309.54843459482 110584.27813586517)", 0.0001);
59  
60          bg::transform(pt_xy2, pt_xy, strategy_ti);
61          test::check_geometry(pt_xy, "POINT(111308.33561309829 110591.34223734379)", 0.0001);
62      }
63  
64      {
65          srs_forward_transformer<projection<> > strategy_pf = epsg(2000);
66          srs_inverse_transformer<projection<> > strategy_pi = epsg(2000);
67          srs_forward_transformer<transformation<> > strategy_tf(epsg(2000), epsg(2001));
68          srs_inverse_transformer<transformation<> > strategy_ti(epsg(2000), epsg(2001));
69      }
70  
71      {
72          using namespace bg::srs::spar;
73  
74          srs_forward_transformer
75              <
76                  projection<parameters<proj_tmerc, ellps_wgs84> >
77              > strategy_pf;
78          srs_forward_transformer
79              <
80                  projection<parameters<proj_tmerc, ellps_wgs84> >
81              > strategy_pi;
82          srs_forward_transformer
83              <
84                  transformation
85                      <
86                          parameters<proj_tmerc, ellps_wgs84>,
87                          parameters<proj_tmerc, ellps_clrk66>
88                      >
89              > strategy_tf;
90          srs_forward_transformer
91              <
92                  transformation
93                      <
94                          parameters<proj_tmerc, ellps_wgs84>,
95                          parameters<proj_tmerc, ellps_clrk66>
96                      >
97              > strategy_ti;
98      }
99  
100      {
101          srs_forward_transformer<projection<static_epsg<2000> > > strategy_pf;
102          srs_forward_transformer<projection<static_epsg<2000> > > strategy_pi;
103          srs_forward_transformer<transformation<static_epsg<2000>, static_epsg<2001> > > strategy_tf;
104          srs_forward_transformer<transformation<static_epsg<2000>, static_epsg<2001> > > strategy_ti;
105      }
106  
107      return 0;
108  }
109