for_each_multi.cpp 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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/for_each.hpp>
  9. #include <boost/geometry/io/wkt/wkt.hpp>
  10. #include <boost/geometry/geometries/box.hpp>
  11. #include <boost/geometry/geometries/ring.hpp>
  12. #include <boost/geometry/geometries/linestring.hpp>
  13. #include <boost/geometry/geometries/point.hpp>
  14. #include <boost/geometry/geometries/point_xy.hpp>
  15. #include <boost/geometry/geometries/polygon.hpp>
  16. #include <boost/geometry/geometries/multi_point.hpp>
  17. #include <boost/geometry/geometries/multi_linestring.hpp>
  18. #include <boost/geometry/geometries/multi_polygon.hpp>
  19. #include <algorithms/test_for_each.hpp>
  20. template <typename P>
  21. void test_all()
  22. {
  23. test_geometry<bg::model::multi_point<P> >
  24. (
  25. "MULTIPOINT((1 1))"
  26. // per point
  27. , 1
  28. , "MULTIPOINT((101 1))"
  29. , "MULTIPOINT((101 100))"
  30. // per segment
  31. , ""
  32. , 0
  33. , "MULTIPOINT((1 1))"
  34. );
  35. test_geometry<bg::model::multi_linestring<bg::model::linestring<P> > >
  36. (
  37. "MULTILINESTRING((1 1,2 2))"
  38. , 3
  39. , "MULTILINESTRING((101 1,102 2))"
  40. , "MULTILINESTRING((101 100,102 200))"
  41. , "((1, 1), (2, 2))"
  42. , std::sqrt(2.0)
  43. , "MULTILINESTRING((10 1,2 2))"
  44. );
  45. typedef bg::model::multi_polygon<bg::model::polygon<P> > mp;
  46. test_geometry<mp>
  47. (
  48. "MULTIPOLYGON(((1 1,1 4,4 4,4 1,1 1)))"
  49. , 11
  50. , "MULTIPOLYGON(((101 1,101 4,104 4,104 1,101 1)))"
  51. , "MULTIPOLYGON(((101 100,101 400,104 400,104 100,101 100)))"
  52. , "((1, 1), (1, 4)) ((1, 4), (4, 4)) ((4, 4), (4, 1)) ((4, 1), (1, 1))"
  53. , 4 * 3.0
  54. , "MULTIPOLYGON(((10 1,10 4,4 4,4 1,1 1,10 1)))"
  55. );
  56. // open multipolygon
  57. typedef bg::model::multi_polygon<bg::model::polygon<P, true, false> > omp;
  58. test_geometry<omp>
  59. (
  60. "MULTIPOLYGON(((1 1,1 4,4 4,4 1)))"
  61. , 10
  62. , "MULTIPOLYGON(((101 1,101 4,104 4,104 1,101 1)))"
  63. , "MULTIPOLYGON(((101 100,101 400,104 400,104 100,101 100)))"
  64. , "((1, 1), (1, 4)) ((1, 4), (4, 4)) ((4, 4), (4, 1)) ((4, 1), (1, 1))"
  65. , 4 * 3.0
  66. , "MULTIPOLYGON(((10 1,10 4,4 4,4 1,10 1)))"
  67. );
  68. }
  69. int test_main( int , char* [] )
  70. {
  71. test_all<bg::model::d2::point_xy<double> >();
  72. #ifdef HAVE_TTMATH
  73. test_all<bg::model::d2::point_xy<ttmath_big> >();
  74. #endif
  75. return 0;
  76. }