correct_multi.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. //
  3. // Copyright (c) 2007-2015 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 <geometry_test_common.hpp>
  8. #include <boost/geometry/algorithms/correct.hpp>
  9. #include <boost/geometry/strategies/strategies.hpp>
  10. #include <boost/geometry/io/wkt/wkt.hpp>
  11. #include <boost/geometry/geometries/box.hpp>
  12. #include <boost/geometry/geometries/ring.hpp>
  13. #include <boost/geometry/geometries/linestring.hpp>
  14. #include <boost/geometry/geometries/point_xy.hpp>
  15. #include <boost/geometry/geometries/point.hpp>
  16. #include <boost/geometry/geometries/polygon.hpp>
  17. #include <boost/geometry/geometries/multi_polygon.hpp>
  18. template <typename Geometry>
  19. void test_geometry(std::string const& wkt, std::string const& expected)
  20. {
  21. Geometry geometry;
  22. bg::read_wkt(wkt, geometry);
  23. bg::correct(geometry);
  24. std::ostringstream out;
  25. out << bg::wkt(geometry);
  26. BOOST_CHECK_EQUAL(out.str(), expected);
  27. }
  28. template <typename P>
  29. void test_all()
  30. {
  31. typedef bg::model::multi_polygon<bg::model::polygon<P> > cw_type;
  32. std::string cw_mp =
  33. "MULTIPOLYGON(((0 0,0 1,1 1,1 0,0 0)))";
  34. test_geometry<cw_type>(cw_mp, cw_mp);
  35. test_geometry<cw_type>("MULTIPOLYGON(((0 0,1 0,1 1,0 1,0 0)))",
  36. cw_mp);
  37. }
  38. int test_main( int , char* [] )
  39. {
  40. test_all<bg::model::d2::point_xy<double> >();
  41. #ifdef HAVE_TTMATH
  42. test_all<bg::model::d2::point_xy<ttmath_big> >();
  43. #endif
  44. return 0;
  45. }