reverse.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Unit Test
  3. // Copyright (c) 2010-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 <algorithms/test_reverse.hpp>
  8. #include <boost/geometry/geometries/geometries.hpp>
  9. #include <boost/geometry/geometries/point_xy.hpp>
  10. #include <test_common/test_point.hpp>
  11. #include <test_geometries/all_custom_linestring.hpp>
  12. #include <test_geometries/all_custom_ring.hpp>
  13. #include <test_geometries/wrapped_boost_array.hpp>
  14. template <typename LineString>
  15. void test_linestring()
  16. {
  17. // Simplex
  18. test_geometry<LineString >(
  19. "LINESTRING(0 0,1 1)",
  20. "LINESTRING(1 1,0 0)");
  21. // Three points, middle should stay the same
  22. test_geometry<LineString >(
  23. "LINESTRING(0 0,1 1,2 2)",
  24. "LINESTRING(2 2,1 1,0 0)");
  25. // Four points
  26. test_geometry<LineString >(
  27. "LINESTRING(0 0,1 1,2 2,3 3)",
  28. "LINESTRING(3 3,2 2,1 1,0 0)");
  29. }
  30. template <typename Ring>
  31. void test_ring()
  32. {
  33. test_geometry<Ring>(
  34. "POLYGON((4 0,8 2,8 7,4 9,0 7,0 2,2 1,4 0))",
  35. "POLYGON((4 0,2 1,0 2,0 7,4 9,8 7,8 2,4 0))");
  36. }
  37. template <typename Point>
  38. void test_all()
  39. {
  40. test_linestring<bg::model::linestring<Point> >();
  41. test_linestring<all_custom_linestring<Point> >();
  42. // Polygon with holes
  43. test_geometry<bg::model::polygon<Point> >(
  44. "POLYGON((4 0,8 2,8 7,4 9,0 7,0 2,2 1,4 0),(7 3,7 6,1 6,1 3,4 3,7 3))",
  45. "POLYGON((4 0,2 1,0 2,0 7,4 9,8 7,8 2,4 0),(7 3,4 3,1 3,1 6,7 6,7 3))");
  46. // Check compilation
  47. test_geometry<Point>("POINT(0 0)", "POINT(0 0)");
  48. test_ring<bg::model::ring<Point> >();
  49. test_ring<all_custom_ring<Point> >();
  50. }
  51. int test_main(int, char* [])
  52. {
  53. test_all<bg::model::d2::point_xy<int> >();
  54. test_all<bg::model::d2::point_xy<double> >();
  55. #if defined(HAVE_TTMATH)
  56. test_all<bg::model::d2::point_xy<ttmath_big> >();
  57. #endif
  58. return 0;
  59. }