projection_interface_d.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Boost.Geometry
  2. // Unit Test
  3. // Copyright (c) 2017-2018, Oracle and/or its affiliates.
  4. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  5. // Use, modification and distribution is subject to the Boost Software License,
  6. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. #include <geometry_test_common.hpp>
  9. #include <boost/geometry.hpp>
  10. #include <boost/geometry/geometries/geometries.hpp>
  11. #include <boost/geometry/srs/epsg.hpp>
  12. #include <boost/geometry/srs/esri.hpp>
  13. #include <boost/geometry/srs/iau2000.hpp>
  14. #include <boost/geometry/srs/projection.hpp>
  15. #include "check_geometry.hpp"
  16. int test_main(int, char*[])
  17. {
  18. using namespace boost::geometry;
  19. using namespace boost::geometry::model;
  20. using namespace boost::geometry::srs;
  21. typedef point<double, 2, cs::geographic<degree> > point_ll;
  22. typedef point<double, 2, cs::cartesian> point_xy;
  23. {
  24. point_ll pt_ll(1, 1);
  25. point_ll pt_ll2(0, 0);
  26. point_xy pt_xy(0, 0);
  27. projection<> prj = epsg(2000);
  28. prj.forward(pt_ll, pt_xy);
  29. test::check_geometry(pt_xy, "POINT(9413505.3284665551 237337.74515944949)", 0.001);
  30. prj.inverse(pt_xy, pt_ll2);
  31. // TODO: investigate this wierd result
  32. test::check_geometry(pt_ll2, "POINT(-2.4463131191981073 1.5066638962045082)", 0.001);
  33. projection<> prj2 = esri(37001);
  34. projection<> prj3 = iau2000(19900);
  35. }
  36. {
  37. using namespace boost::geometry::srs::dpar;
  38. point_ll pt_ll(1, 1);
  39. point_ll pt_ll2(0, 0);
  40. point_xy pt_xy(0, 0);
  41. projection<> prj = parameters<>(proj_tmerc)(ellps_wgs84)(units_m);
  42. prj.forward(pt_ll, pt_xy);
  43. test::check_geometry(pt_xy, "POINT(111308.33561309829 110591.34223734379)", 0.001);
  44. prj.inverse(pt_xy, pt_ll2);
  45. test::check_geometry(pt_ll2, "POINT(1 1)", 0.001);
  46. }
  47. return 0;
  48. }