union_content.cpp 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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_union_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_box1, int_box2;
  17. bg::model::box<double_point_type> double_box1, double_box2;
  18. std::string const box_li1 = "POLYGON((1536119 192000, 1872000 528000))";
  19. std::string const box_li2 = "POLYGON((1701234 368250, 2673400 777400))";
  20. bg::read_wkt(box_li1, int_box1);
  21. bg::read_wkt(box_li1, double_box1);
  22. bg::read_wkt(box_li2, int_box2);
  23. bg::read_wkt(box_li2, double_box2);
  24. double int_value = bgi::detail::union_content(int_box1, int_box2);
  25. double double_value = bgi::detail::union_content(double_box1, double_box2);
  26. BOOST_CHECK_CLOSE(int_value, double_value, 0.0001);
  27. }
  28. int test_main(int, char* [])
  29. {
  30. typedef bg::model::point<int, 2, bg::cs::cartesian> P2ic;
  31. typedef bg::model::point<float, 2, bg::cs::cartesian> P2fc;
  32. typedef bg::model::point<double, 2, bg::cs::cartesian> P2dc;
  33. typedef bg::model::point<int, 3, bg::cs::cartesian> P3ic;
  34. typedef bg::model::point<float, 3, bg::cs::cartesian> P3fc;
  35. typedef bg::model::point<double, 3, bg::cs::cartesian> P3dc;
  36. test_geometry<bg::model::box<P2ic> >("POLYGON((0 1,2 4))", "POLYGON((1 2,3 5))", 12.0);
  37. test_geometry<bg::model::box<P2fc> >("POLYGON((0 1,2 4))", "POLYGON((1 2,3 5))", 12.0);
  38. test_geometry<bg::model::box<P2dc> >("POLYGON((0 1,2 4))", "POLYGON((1 2,3 5))", 12.0);
  39. test_geometry<bg::model::box<P3ic> >("POLYGON((0 1 2,2 4 6))", "POLYGON((1 2 3,3 5 7))", 60.0);
  40. test_geometry<bg::model::box<P3fc> >("POLYGON((0 1 2,2 4 6))", "POLYGON((1 2 3,3 5 7))", 60.0);
  41. test_geometry<bg::model::box<P3dc> >("POLYGON((0 1 2,2 4 6))", "POLYGON((1 2 3,3 5 7))", 60.0);
  42. test_geometry<bg::model::box<P2dc> >("POLYGON((0 1,2 4))", "POLYGON((2 1,3 4))", 9.0);
  43. test_geometry<bg::model::box<P2dc> >("POLYGON((0 1,2 4))", "POLYGON((2 4,3 5))", 12.0);
  44. #ifdef HAVE_TTMATH
  45. typedef bg::model::point<ttmath_big, 2, bg::cs::cartesian> P2ttmc;
  46. typedef bg::model::point<ttmath_big, 3, bg::cs::cartesian> P3ttmc;
  47. test_geometry<bg::model::box<P2ttmc> >("POLYGON((0 1,2 4))", "POLYGON((1 2,3 5))", 12.0);
  48. test_geometry<bg::model::box<P3ttmc> >("POLYGON((0 1 2,2 4 6))", "POLYGON((1 2 3,3 5 7))", 60.0);
  49. #endif
  50. test_large_integers();
  51. return 0;
  52. }