crosses_sph.cpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. // Boost.Geometry
  2. // Copyright (c) 2016 Oracle and/or its affiliates.
  3. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  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 "test_crosses.hpp"
  8. #include <algorithms/overlay/overlay_cases.hpp>
  9. #include <algorithms/overlay/multi_overlay_cases.hpp>
  10. #include <boost/geometry/geometries/geometries.hpp>
  11. template <typename P>
  12. void test_linestring_polygon()
  13. {
  14. typedef bg::model::linestring<P> ls;
  15. typedef bg::model::polygon<P> poly;
  16. typedef bg::model::polygon<P> ring;
  17. test_geometry<ls, poly>("LINESTRING(11 0,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
  18. test_geometry<ls, ring>("LINESTRING(11 0,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
  19. test_geometry<ls, poly>("LINESTRING(0 0,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
  20. test_geometry<ls, poly>("LINESTRING(5 0,5 5,10 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
  21. test_geometry<ls, poly>("LINESTRING(5 1,5 5,9 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
  22. test_geometry<ls, poly>("LINESTRING(11 1,11 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
  23. test_geometry<ls, poly>("LINESTRING(9 1,10 5,9 9)",
  24. "POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
  25. false);
  26. test_geometry<ls, poly>("LINESTRING(9 1,10 5,9 9,1 9,1 1,9 1)",
  27. "POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
  28. false);
  29. test_geometry<ls, poly>("LINESTRING(0 0,10 0,10 10,0 10,0 0)",
  30. "POLYGON((0 0,0 10,10 10,10 0,0 0))",
  31. false);
  32. }
  33. template <typename P>
  34. void test_linestring_multi_polygon()
  35. {
  36. typedef bg::model::linestring<P> ls;
  37. typedef bg::model::polygon<P> poly;
  38. typedef bg::model::multi_polygon<poly> mpoly;
  39. test_geometry<ls, mpoly>("LINESTRING(10 1,10 5,10 9)",
  40. "MULTIPOLYGON(((0 20,0 30,10 30,10 20,0 20)),((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5)))",
  41. false);
  42. }
  43. template <typename P>
  44. void test_multi_linestring_polygon()
  45. {
  46. typedef bg::model::linestring<P> ls;
  47. typedef bg::model::polygon<P> poly;
  48. typedef bg::model::ring<P> ring;
  49. typedef bg::model::multi_linestring<ls> mls;
  50. test_geometry<mls, poly>("MULTILINESTRING((11 11, 20 20),(5 7, 4 1))",
  51. "POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 2,4 4,2 4,2 2))",
  52. true);
  53. test_geometry<mls, ring>("MULTILINESTRING((6 6,15 15),(0 0, 7 7))",
  54. "POLYGON((5 5,5 15,15 15,15 5,5 5))",
  55. true);
  56. test_geometry<mls, poly>("MULTILINESTRING((3 10.031432746397092, 1 5, 1 10.013467818052765, 3 4, 7 8, 6 10.035925377760330, 10 2))",
  57. "POLYGON((0 0,0 10,10 10,10 0,0 0))",
  58. false);
  59. }
  60. template <typename P>
  61. void test_multi_linestring_multi_polygon()
  62. {
  63. typedef bg::model::linestring<P> ls;
  64. typedef bg::model::polygon<P> poly;
  65. typedef bg::model::multi_linestring<ls> mls;
  66. typedef bg::model::multi_polygon<poly> mpoly;
  67. test_geometry<mls, mpoly>("MULTILINESTRING((0 0,10 0,10 10,0 10,0 0),(2 2,5 5,2 8,2 2))",
  68. "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(2 2,5 5,2 8,2 2)))",
  69. false);
  70. test_geometry<mls, mpoly>("MULTILINESTRING((0 0,10 0,10 10),(10 10,0 10,0 0),(20 20,50 50,20 80,20 20))",
  71. "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
  72. false);
  73. test_geometry<mls, mpoly>("MULTILINESTRING((5 -2,4 -2,5 0),(5 -2,6 -2,5 0))",
  74. "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
  75. false);
  76. }
  77. template <typename P>
  78. void test_all()
  79. {
  80. test_linestring_polygon<P>();
  81. test_linestring_multi_polygon<P>();
  82. test_multi_linestring_polygon<P>();
  83. test_multi_linestring_multi_polygon<P>();
  84. }
  85. int test_main( int , char* [] )
  86. {
  87. test_all<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
  88. #if defined(HAVE_TTMATH)
  89. test_cs<bg::model::point<ttmath_big, 2, bg::cs::spherical_equatorial<bg::degree> > >();
  90. #endif
  91. return 0;
  92. }