convex_hull_multi.cpp 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Unit Test
  3. // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
  4. // Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
  5. // Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
  6. // This file was modified by Oracle on 2014, 2015.
  7. // Modifications copyright (c) 2014-2015 Oracle and/or its affiliates.
  8. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  9. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  10. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  11. // Use, modification and distribution is subject to the Boost Software License,
  12. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  13. // http://www.boost.org/LICENSE_1_0.txt)
  14. #include <cstddef>
  15. #include <iterator>
  16. #include <string>
  17. #include <algorithms/test_convex_hull.hpp>
  18. #include <boost/geometry/geometries/geometries.hpp>
  19. #include <boost/geometry/geometries/point_xy.hpp>
  20. #include <boost/geometry/core/point_order.hpp>
  21. #include <boost/geometry/core/point_type.hpp>
  22. #include <boost/geometry/views/detail/range_type.hpp>
  23. #include <boost/geometry/algorithms/detail/for_each_range.hpp>
  24. #include <boost/geometry/geometries/multi_point.hpp>
  25. #include <boost/geometry/geometries/multi_linestring.hpp>
  26. #include <boost/geometry/geometries/multi_polygon.hpp>
  27. template <typename P>
  28. void test_all()
  29. {
  30. typedef bg::model::multi_point<P> mp;
  31. typedef bg::model::multi_linestring<bg::model::linestring<P> > ml;
  32. typedef bg::model::multi_polygon<bg::model::polygon<P> > mpoly;
  33. // All points below in upper-points and lower-points
  34. test_geometry<mp>("MULTIPOINT((0 0),(5 0),(1 1),(4 1))", 0, 5, 4.0);
  35. test_geometry<mp>("MULTIPOINT((0 1),(5 1),(1 0),(4 0))", 0, 5, 4.0);
  36. // All points in vertical line (this delivers an empty polygon with 3 points and closing point for closed)
  37. test_geometry<mp>("MULTIPOINT((1 0),(5 0),(3 0),(4 0),(2 0))", 0, 4, 0.0);
  38. // One point only
  39. test_geometry<mp>("MULTIPOINT((1 0))", 0, 4, 0.0);
  40. // Problem of 6019, reproduced by the convex hull robustness test:
  41. test_geometry<mp>("MULTIPOINT((2 9),(1 3),(9 4),(1 1),(1 0),(7 9),(2 5),(3 7),(3 6),(2 4))",
  42. 0, 6, 48.0);
  43. // Ticket 6019:
  44. test_geometry<mp>("MULTIPOINT((0 53),(0 103),(0 53),(0 3),(0 3),(0 0),(1 0),(1 1),(2 1),(2 0),(2 0),(2 0),(3 0),(3 1),(4 1),(4 0),(5 0),(0 3),(10 3),(10 2),(10 2),(10 2),(5 2),(5 0),(5 0),(55 0),(105 0))",
  45. 0, 4, 5407.5);
  46. // Ticket 6021:
  47. test_geometry<mp>("multipoint((0 53), (0 103), (1 53))", 3, 4, 25);
  48. test_geometry<mp>("multipoint((1.1 1.1), (2.5 2.1), (3.1 3.1), (4.9 1.1), (3.1 1.9))", 5, 4, 3.8);
  49. test_geometry<ml>("multilinestring((2 4, 3 4, 3 5), (4 3,4 4,5 4))", 6, 5, 3.0);
  50. test_geometry<mpoly>("multipolygon(((1 4,1 6,2 5,3 5,4 6,4 4,1 4)), ((4 2,4 3,6 3,6 2,4 2)))", 12, 7, 14.0);
  51. test_empty_input<mp>();
  52. test_empty_input<ml>();
  53. test_empty_input<mpoly>();
  54. }
  55. int test_main(int, char* [])
  56. {
  57. //test_all<bg::model::d2::point_xy<int> >();
  58. //test_all<bg::model::d2::point_xy<float> >();
  59. test_all<bg::model::d2::point_xy<double> >();
  60. #ifdef HAVE_TTMATH
  61. test_all<bg::model::d2::point_xy<ttmath_big> >();
  62. #endif
  63. return 0;
  64. }