/Src/Dependencies/Boost/libs/geometry/test/multi/algorithms/multi_num_interior_rings.cpp

http://hadesmem.googlecode.com/ · C++ · 54 lines · 36 code · 12 blank · 6 comment · 1 complexity · 4d965699188eddc8786a17267b334638 MD5 · raw file

  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. //
  3. // Copyright 2011 Barend Gehrels (barend@xs4all.nl), 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 <geometry_test_common.hpp>
  8. #include <boost/geometry/algorithms/num_interior_rings.hpp>
  9. #include <boost/geometry/multi/algorithms/num_interior_rings.hpp>
  10. #include <boost/geometry/domains/gis/io/wkt/wkt.hpp>
  11. #include <boost/geometry/geometries/geometries.hpp>
  12. #include <boost/geometry/geometries/point_xy.hpp>
  13. #include <boost/geometry/multi/geometries/multi_point.hpp>
  14. #include <boost/geometry/multi/geometries/multi_linestring.hpp>
  15. #include <boost/geometry/multi/geometries/multi_polygon.hpp>
  16. template <typename Geometry>
  17. void test_geometry(std::string const& wkt, int expected)
  18. {
  19. Geometry geometry;
  20. bg::read_wkt(wkt, geometry);
  21. int detected = bg::num_interior_rings(geometry);
  22. BOOST_CHECK_MESSAGE(detected == expected,
  23. "num_interior_rings: " << wkt
  24. << " -> Expected: " << expected
  25. << " detected: " << detected);
  26. }
  27. template <typename Point>
  28. void test_all()
  29. {
  30. typedef bg::model::polygon<Point> poly;
  31. typedef bg::model::multi_polygon<poly> mpoly;
  32. test_geometry<poly>("POLYGON((0 0,0 10,10 0,0 0),(1 1,1 9,9 1,1 1))", 1);
  33. test_geometry<mpoly>("MULTIPOLYGON(((0 0,0 10,10 0,0 0),(1 1,1 9,9 1,1 1)),((0 0,0 10,10 0,0 0),(1 1,1 4,4 1,1 1),(5 1,5 4,9 1,5 1)))", 3);
  34. }
  35. int test_main( int , char* [] )
  36. {
  37. test_all<bg::model::d2::point_xy<double> >();
  38. #ifdef HAVE_TTMATH
  39. test_all<bg::model::d2::point_xy<ttmath_big> >();
  40. #endif
  41. return 0;
  42. }