area_multi.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. //
  3. // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
  4. //
  5. // This file was modified by Oracle on 2015, 2016.
  6. // Modifications copyright (c) 2015-2016, Oracle and/or its affiliates.
  7. //
  8. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
  9. //
  10. // Use, modification and distribution is subject to the Boost Software License,
  11. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  12. // http://www.boost.org/LICENSE_1_0.txt)
  13. #include <algorithms/area/test_area.hpp>
  14. #include <boost/geometry/geometries/geometries.hpp>
  15. #include <boost/geometry/geometries/point_xy.hpp>
  16. #include <boost/geometry/geometries/multi_polygon.hpp>
  17. #include <boost/geometry/io/wkt/wkt.hpp>
  18. template <typename CT>
  19. void test_all()
  20. {
  21. typedef typename bg::model::d2::point_xy<CT> pt_crt;
  22. typedef typename bg::model::point<CT, 2, bg::cs::spherical_equatorial<bg::degree> > pt_sph;
  23. typedef typename bg::model::point<CT, 2, bg::cs::geographic<bg::degree> > pt_geo;
  24. typedef bg::model::multi_polygon<bg::model::polygon<pt_crt> > mp_crt;
  25. typedef bg::model::multi_polygon<bg::model::polygon<pt_sph> > mp_sph;
  26. typedef bg::model::multi_polygon<bg::model::polygon<pt_geo> > mp_geo;
  27. // mean Earth's radius^2
  28. double r2 = bg::math::sqr(bg::get_radius<0>(bg::srs::sphere<double>()));
  29. std::string poly = "MULTIPOLYGON(((0 0,0 7,4 2,2 0,0 0)))";
  30. test_geometry<mp_crt>(poly, 16.0);
  31. test_geometry<mp_sph>(poly, 197897454752.69489 / r2);
  32. test_geometry<mp_geo>(poly, 197018888665.8331);
  33. }
  34. int test_main( int , char* [] )
  35. {
  36. test_all<double>();
  37. #ifdef HAVE_TTMATH
  38. test_all<bg::model::d2::point_xy<ttmath_big> >();
  39. #endif
  40. return 0;
  41. }