perimeter.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Unit Test
  3. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  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 <boost/geometry/geometries/geometries.hpp>
  8. #include <boost/geometry/geometries/point_xy.hpp>
  9. #include <algorithms/test_perimeter.hpp>
  10. template <typename P>
  11. void test_all()
  12. {
  13. // 3-4-5 triangle
  14. //test_geometry<std::pair<P, P> >("LINESTRING(0 0,3 4)", 5);
  15. test_geometry<bg::model::ring<P> >(
  16. "POLYGON((0 0,0 1,1 1,1 0,0 0))", 4);
  17. test_geometry<bg::model::polygon<P> >(
  18. "POLYGON((0 0,0 1,1 0,0 0))", 1.0 + 1.0 + sqrt(2.0));
  19. test_geometry<bg::model::polygon<P> >(
  20. "POLYGON((0 0,0 4,4 4,4 0,0 0),(1 1,2 1,2 2,1 2,1 1))", 20);
  21. }
  22. template <typename P>
  23. void test_open()
  24. {
  25. typedef bg::model::polygon<P, true, false> open_polygon;
  26. test_geometry<open_polygon>("POLYGON((0 0,0 1,1 1,1 0))", 4);
  27. }
  28. template <typename P>
  29. void test_empty_input()
  30. {
  31. bg::model::polygon<P> poly_empty;
  32. bg::model::ring<P> ring_empty;
  33. test_empty_input(poly_empty);
  34. test_empty_input(ring_empty);
  35. }
  36. int test_main(int, char* [])
  37. {
  38. //test_all<bg::model::d2::point_xy<int> >();
  39. test_all<bg::model::d2::point_xy<float> >();
  40. test_all<bg::model::d2::point_xy<double> >();
  41. test_open<bg::model::d2::point_xy<double> >();
  42. #if defined(HAVE_TTMATH)
  43. test_all<bg::model::d2::point_xy<ttmath_big> >();
  44. #endif
  45. // test_empty_input<bg::model::d2::point_xy<int> >();
  46. return 0;
  47. }