projection_interface_s.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. using namespace boost::geometry::srs::spar;
  25. point_ll pt_ll(1, 1);
  26. point_ll pt_ll2(0, 0);
  27. point_xy pt_xy(0, 0);
  28. projection<parameters<proj_tmerc, ellps_wgs84, units_m> > prj;
  29. prj.forward(pt_ll, pt_xy);
  30. test::check_geometry(pt_xy, "POINT(111308.33561309829 110591.34223734379)", 0.001);
  31. prj.inverse(pt_xy, pt_ll2);
  32. test::check_geometry(pt_ll2, "POINT(1 1)", 0.001);
  33. }
  34. {
  35. using namespace boost::geometry::srs::spar;
  36. projection<parameters<proj_tmerc> > prj1;
  37. projection<parameters<proj_tmerc, ellps_wgs84> > prj2;
  38. projection<parameters<proj_tmerc, ellps_wgs84, datum_wgs84> > prj3;
  39. projection<parameters<proj_tmerc, ellps_wgs84, x_0<>, y_0<> > > prj4
  40. = parameters<proj_tmerc, ellps_wgs84, x_0<>, y_0<> >(
  41. proj_tmerc(), ellps_wgs84(), x_0<>(0), y_0<>(0));
  42. typedef spheroid<double> sph;
  43. typedef ellps<sph> ell;
  44. typedef proj_tmerc prj;
  45. projection<parameters<ell, prj> > prj5
  46. = parameters<ell, prj>(ell(sph(1000, 999)));
  47. }
  48. {
  49. point_ll pt_ll(1, 1);
  50. point_ll pt_ll2(0, 0);
  51. point_xy pt_xy(0, 0);
  52. projection<static_epsg<2000> > prj;
  53. prj.forward(pt_ll, pt_xy);
  54. test::check_geometry(pt_xy, "POINT(9413505.3284665551 237337.74515944949)", 0.001);
  55. prj.inverse(pt_xy, pt_ll2);
  56. // TODO: investigate this wierd result
  57. test::check_geometry(pt_ll2, "POINT(-2.4463131191981073 1.5066638962045082)", 0.001);
  58. projection<static_esri<37001> > prj2;
  59. projection<static_iau2000<19900> > prj3;
  60. }
  61. // compile-time errors
  62. {
  63. point_ll pt_ll(1, 1);
  64. point_xy pt_xy(0, 0);
  65. //projection<spar::parameters<int> > prj1;
  66. //projection<int> prj2;
  67. projection<spar::parameters<spar::proj_bacon> > prj3;
  68. //prj3.inverse(pt_xy, pt_ll);
  69. }
  70. return 0;
  71. }