content.cpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Boost.Geometry Index
  2. // Unit Test
  3. // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
  4. // Use, modification and distribution is subject to the Boost Software License,
  5. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. #include <algorithms/test_content.hpp>
  8. #include <boost/geometry/geometries/point_xy.hpp>
  9. #include <boost/geometry/geometries/point.hpp>
  10. #include <boost/geometry/geometries/box.hpp>
  11. //#define BOOST_GEOMETRY_TEST_DEBUG
  12. void test_large_integers()
  13. {
  14. typedef bg::model::point<int, 2, bg::cs::cartesian> int_point_type;
  15. typedef bg::model::point<double, 2, bg::cs::cartesian> double_point_type;
  16. bg::model::box<int_point_type> int_box;
  17. bg::model::box<double_point_type> double_box;
  18. std::string const box_li = "POLYGON((1536119 192000, 1872000 528000))";
  19. bg::read_wkt(box_li, int_box);
  20. bg::read_wkt(box_li, double_box);
  21. double int_value = bgi::detail::content(int_box);
  22. double double_value = bgi::detail::content(double_box);
  23. BOOST_CHECK_CLOSE(int_value, double_value, 0.0001);
  24. }
  25. int test_main(int, char* [])
  26. {
  27. typedef bg::model::point<int, 2, bg::cs::cartesian> P2ic;
  28. typedef bg::model::point<float, 2, bg::cs::cartesian> P2fc;
  29. typedef bg::model::point<double, 2, bg::cs::cartesian> P2dc;
  30. typedef bg::model::point<int, 3, bg::cs::cartesian> P3ic;
  31. typedef bg::model::point<float, 3, bg::cs::cartesian> P3fc;
  32. typedef bg::model::point<double, 3, bg::cs::cartesian> P3dc;
  33. test_content(P2ic(0, 0), 0);
  34. test_content(P2fc(0, 0), 0);
  35. test_content(P2dc(0, 0), 0);
  36. test_content(P3ic(0, 0, 0), 0);
  37. test_content(P3fc(0, 0, 0), 0);
  38. test_content(P3dc(0, 0, 0), 0);
  39. test_geometry<bg::model::box<P2ic> >("POLYGON((0 1,2 4))", 6.0);
  40. test_geometry<bg::model::box<P2fc> >("POLYGON((0 1,2 4))", 6.0);
  41. test_geometry<bg::model::box<P2dc> >("POLYGON((0 1,2 4))", 6.0);
  42. test_geometry<bg::model::box<P3ic> >("POLYGON((0 1 2,2 4 6))", 24.0);
  43. test_geometry<bg::model::box<P3fc> >("POLYGON((0 1 2,2 4 6))", 24.0);
  44. test_geometry<bg::model::box<P3dc> >("POLYGON((0 1 2,2 4 6))", 24.0);
  45. #ifdef HAVE_TTMATH
  46. typedef bg::model::point<ttmath_big, 2, bg::cs::cartesian> P2ttmc;
  47. typedef bg::model::point<ttmath_big, 3, bg::cs::cartesian> P3ttmc;
  48. test_geometry<bg::model::box<P2ttmc> >("POLYGON((0 1,2 4))", 6.0);
  49. test_geometry<bg::model::box<P3ttmc> >("POLYGON((0 1 2,2 4 6))", 24.0);
  50. #endif
  51. test_large_integers();
  52. return 0;
  53. }