margin.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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_margin.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::comparable_margin(int_box);
  22. double double_value = bgi::detail::comparable_margin(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_geometry<bg::model::box<P2ic> >("POLYGON((0 1,2 4))", 5);
  34. test_geometry<bg::model::box<P2fc> >("POLYGON((0 1,2 4))", 5.0);
  35. test_geometry<bg::model::box<P2dc> >("POLYGON((0 1,2 4))", 5.0);
  36. test_geometry<bg::model::box<P3ic> >("POLYGON((0 1 2,2 4 6))", 9);
  37. test_geometry<bg::model::box<P3fc> >("POLYGON((0 1 2,2 4 6))", 9.0);
  38. test_geometry<bg::model::box<P3dc> >("POLYGON((0 1 2,2 4 6))", 9.0);
  39. #ifdef HAVE_TTMATH
  40. typedef bg::model::point<ttmath_big, 2, bg::cs::cartesian> P2ttmc;
  41. typedef bg::model::point<ttmath_big, 3, bg::cs::cartesian> P3ttmc;
  42. test_geometry<bg::model::box<P2ttmc> >("POLYGON((0 1,2 4))", 10.0);
  43. test_geometry<bg::model::box<P3ttmc> >("POLYGON((0 1 2,2 4 6))", 52.0);
  44. #endif
  45. test_large_integers();
  46. // test_empty_input<bg::model::d2::point_xy<int> >();
  47. return 0;
  48. }