touches_box.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. //
  3. // Copyright (c) 2012-2015 Barend Gehrels, Amsterdam, the Netherlands.
  4. // This file was modified by Oracle on 2013, 2014, 2015.
  5. // Modifications copyright (c) 2013-2015, Oracle and/or its affiliates.
  6. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  7. // Use, modification and distribution is subject to the Boost Software License,
  8. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. #include "test_touches.hpp"
  11. template <typename P>
  12. void test_all()
  13. {
  14. typedef bg::model::box<P> box;
  15. test_touches<box, box>("POLYGON((0 0,0 5,5 5,5 0,0 0))", "POLYGON((5 1,5 2,6 2,6 1,5 1))", true);
  16. test_touches<box, box>("POLYGON((0 0,0 5,5 5,5 0,0 0))", "POLYGON((4 1,4 2,5 2,5 1,4 1))", false);
  17. test_touches<box, box>("POLYGON((0 0,0 5,5 5,5 0,0 0))", "POLYGON((4 1,4 2,6 2,6 1,4 1))", false);
  18. // Point-size
  19. test_touches<box, box>("POLYGON((0 0,0 5,5 5,5 0,0 0))", "POLYGON((5 5,5 5,5 5,5 5,5 5))", true);
  20. // TODO: should it be TRUE?
  21. test_touches<box, box>("POLYGON((5 5,5 5,5 5,5 5,5 5))", "POLYGON((5 5,5 5,5 5,5 5,5 5))", true);
  22. }
  23. template <typename P>
  24. void test_box_3d()
  25. {
  26. typedef bg::model::box<P> box;
  27. check_touches<box, box>(box(P(0,0,0),P(5,5,5)), box(P(5,1,2),P(6,6,6)),
  28. "box(P(0,0,0),P(5,5,5))", "box(P(5,1,2),P(6,6,6))",
  29. true);
  30. check_touches<box, box>(box(P(0,0,0),P(5,5,5)), box(P(5,5,5),P(6,6,6)),
  31. "box(P(0,0,0),P(5,5,5))", "box(P(5,5,5),P(6,6,6))",
  32. true);
  33. }
  34. int test_main( int , char* [] )
  35. {
  36. test_all<bg::model::d2::point_xy<double> >();
  37. test_box_3d<bg::model::point<double, 3, bg::cs::cartesian> >();
  38. #if defined(HAVE_TTMATH)
  39. test_all<bg::model::d2::point_xy<ttmath_big> >();
  40. #endif
  41. return 0;
  42. }
  43. /*
  44. with viewy as
  45. (
  46. select geometry::STGeomFromText('POLYGON((0 0,0 100,100 100,100 0,0 0))',0) as p
  47. , geometry::STGeomFromText('POLYGON((200 0,100 50,200 100,200 0))',0) as q
  48. )
  49. -- select p from viewy union all select q from viewy
  50. select p.STTouches(q) from viewy
  51. */