diff options
Diffstat (limited to 'src/boost/libs/geometry/test/algorithms/intersects')
8 files changed, 1091 insertions, 0 deletions
diff --git a/src/boost/libs/geometry/test/algorithms/intersects/Jamfile.v2 b/src/boost/libs/geometry/test/algorithms/intersects/Jamfile.v2 new file mode 100644 index 00000000..cf8800bb --- /dev/null +++ b/src/boost/libs/geometry/test/algorithms/intersects/Jamfile.v2 @@ -0,0 +1,26 @@ +# Boost.Geometry (aka GGL, Generic Geometry Library) +# +# Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +# Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +# Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +# +# This file was modified by Oracle on 2014, 2015, 2016. +# Modifications copyright (c) 2014-2016, Oracle and/or its affiliates. +# +# Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle +# Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle +# +# Use, modification and distribution is subject to the Boost Software License, +# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +test-suite boost-geometry-algorithms-intersects + : + [ run intersects.cpp : : : : algorithms_intersects ] + [ run intersects_box_geometry.cpp : : : : algorithms_intersects_box_geometry ] + [ run intersects_multi.cpp : : : : algorithms_intersects_multi ] + [ run intersects_self.cpp : : : : algorithms_intersects_self ] + [ run intersects_sph_geo.cpp : : : : algorithms_intersects_sph_geo ] + [ run intersects_sph.cpp : : : : algorithms_intersects_sph ] + ; + diff --git a/src/boost/libs/geometry/test/algorithms/intersects/intersects.cpp b/src/boost/libs/geometry/test/algorithms/intersects/intersects.cpp new file mode 100644 index 00000000..a2487249 --- /dev/null +++ b/src/boost/libs/geometry/test/algorithms/intersects/intersects.cpp @@ -0,0 +1,227 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. + +// This file was modified by Oracle on 2013, 2015, 2016. +// Modifications copyright (c) 2013-2016, Oracle and/or its affiliates. +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include "test_intersects.hpp" + + +#include <boost/geometry/geometries/geometries.hpp> +#include <boost/geometry/geometries/point_xy.hpp> + +#include <boost/geometry/util/rational.hpp> + +template <typename P1, typename P2> +void test_intersects_polygon_polygon() +{ + typedef bg::model::polygon<P1, false, false> poly_ccw_o1; + typedef bg::model::polygon<P2, false, false> poly_ccw_o2; + test_geometry<poly_ccw_o1, poly_ccw_o2>("POLYGON((1 1, 3 3, 2 5))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", true); + test_geometry<poly_ccw_o1, poly_ccw_o2>("POLYGON((6 6, 7 6, 7 7, 6 7))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", false); + test_geometry<poly_ccw_o1, poly_ccw_o2>("POLYGON((7 7, 9 7, 9 9, 7 9))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", true); +} + +template <typename P1, typename P2> +void test_intersects_linestring_segment() +{ + typedef bg::model::linestring<P1> ls; + typedef bg::model::segment<P2> seg; + + test_geometry<ls, seg>("LINESTRING(1 1, 3 3, 2 5)", "SEGMENT(2 0, 2 6)", true); + test_geometry<ls, seg>("LINESTRING(1 1, 3 3)", "SEGMENT(1 0, 1 1)", true); + test_geometry<ls, seg>("LINESTRING(1 1, 3 3)", "SEGMENT(2 0, 2 2)", true); + test_geometry<ls, seg>("LINESTRING(1 1, 3 3)", "SEGMENT(3 0, 4 1)", false); +} + +template <typename P1, typename P2> +void test_intersects_linestring_linestring() +{ + typedef bg::model::linestring<P1> ls1; + typedef bg::model::linestring<P2> ls2; + + test_geometry<ls1, ls2>("LINESTRING(0 0,2 0,3 0)", "LINESTRING(0 0,1 1,2 2)", true); + test_geometry<ls1, ls2>("LINESTRING(0 0,2 0,3 0)", "LINESTRING(2 2,1 1,0 0)", true); + test_geometry<ls1, ls2>("LINESTRING(3 0,2 0,0 0)", "LINESTRING(0 0,1 1,2 2)", true); + test_geometry<ls1, ls2>("LINESTRING(3 0,2 0,0 0)", "LINESTRING(2 2,1 1,0 0)", true); + + test_geometry<ls1, ls2>("LINESTRING(0 0,2 0,3 0)", "LINESTRING(1 0,4 0,5 0)", true); + test_geometry<ls1, ls2>("LINESTRING(1 0,2 0)", "LINESTRING(1 0,0 0)", true); +} + +template <typename P1, typename P2> +void test_intersects_linestring_polygon() +{ + typedef bg::model::linestring<P1> ls; + typedef bg::model::multi_linestring<ls> mls; + typedef bg::model::polygon<P2> poly_cw_c; + typedef bg::model::polygon<P2, false> poly_ccw_c; + typedef bg::model::polygon<P2, false, false> poly_ccw_o; + typedef bg::model::multi_polygon<poly_ccw_c> mpoly_ccw_c; + + test_geometry<ls, poly_ccw_c>("LINESTRING(1 1,2 2)", "POLYGON((0 0,10 0,10 10,0 10,0 0))", true); + test_geometry<ls, poly_ccw_c>("LINESTRING(1 0,2 2)", "POLYGON((0 0,10 0,10 10,0 10,0 0))", true); + test_geometry<ls, poly_ccw_c>("LINESTRING(11 0,12 12)", "POLYGON((0 0,10 0,10 10,0 10,0 0))", false); + + test_geometry<ls, poly_ccw_o>("LINESTRING(1 1, 3 3, 2 5)", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", true); + test_geometry<ls, poly_ccw_o>("LINESTRING(6 6, 7 6, 7 7, 6 7)", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", false); + test_geometry<ls, poly_ccw_o>("LINESTRING(7 7, 9 7, 9 9, 7 9)", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", true); + + test_geometry<poly_cw_c, ls>("POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))", "LINESTRING(-2 -2, 12 7)", true); + test_geometry<poly_cw_c, ls>("POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))", "LINESTRING(5 5, 15 4)", true); + test_geometry<poly_cw_c, ls>("POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))", "LINESTRING(7 6, 15 4)", true); + test_geometry<poly_cw_c, ls>("POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))", "LINESTRING(6 2, 12 1)", true); + + // MULTI + test_geometry<ls, mpoly_ccw_c>("LINESTRING(1 1,2 2)", "MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0)))", true); + test_geometry<mls, mpoly_ccw_c>("MULTILINESTRING((1 1,2 2))", "MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0)))", true); +} + +template <typename P1, typename P2> +void test_intersects_linestring_ring() +{ + typedef bg::model::linestring<P1> ls; + typedef bg::model::multi_linestring<ls> mls; + typedef bg::model::ring<P2, false> ring_ccw_c; + + test_geometry<ls, ring_ccw_c>("LINESTRING(1 1,2 2)", "POLYGON((0 0,10 0,10 10,0 10,0 0))", true); + test_geometry<ls, ring_ccw_c>("LINESTRING(1 0,2 2)", "POLYGON((0 0,10 0,10 10,0 10,0 0))", true); + test_geometry<ls, ring_ccw_c>("LINESTRING(11 0,12 12)", "POLYGON((0 0,10 0,10 10,0 10,0 0))", false); + + // MULTI + test_geometry<mls, ring_ccw_c>("MULTILINESTRING((1 1,2 2))", "POLYGON((0 0,10 0,10 10,0 10,0 0))", true); +} + +template <typename P1, typename P2> +void test_intersects_ring_polygon() +{ + typedef bg::model::ring<P1, false, false> ring_ccw_o; + typedef bg::model::polygon<P2, false, false> poly_ccw_o; + + test_geometry<ring_ccw_o, poly_ccw_o>("POLYGON((1 1, 3 3, 2 5))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", true); + test_geometry<ring_ccw_o, poly_ccw_o>("POLYGON((6 6, 7 6, 7 7, 6 7))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", false); + test_geometry<ring_ccw_o, poly_ccw_o>("POLYGON((7 7, 9 7, 9 9, 7 9))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", true); + + test_geometry<ring_ccw_o, poly_ccw_o>("POLYGON((6 6,7 6,7 7,6 7))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", false); +} + +template <typename P1, typename P2> +void test_intersects_point_linestring() +{ + typedef bg::model::linestring<P2> ls; + typedef bg::model::multi_linestring<ls> mls; + + test_geometry<P1, ls>("POINT(0 0)", "LINESTRING(0 0,2 2,4 0)", true); + test_geometry<P1, ls>("POINT(1 1)", "LINESTRING(0 0,2 2,4 0)", true); + test_geometry<P1, ls>("POINT(1 0)", "LINESTRING(0 0,2 2,4 0)", false); + + // MULTI + test_geometry<P1, mls>("POINT(0 0)", "MULTILINESTRING((0 0,2 2,4 0))", true); +} + +template <typename P1, typename P2> +void test_intersects_point_segment() +{ + typedef bg::model::segment<P2> seg; + + test_geometry<P1, seg>("POINT(0 0)", "LINESTRING(0 0,2 2)", true); + test_geometry<P1, seg>("POINT(1 1)", "LINESTRING(0 0,2 2)", true); + test_geometry<P1, seg>("POINT(1 0)", "LINESTRING(0 0,2 2)", false); +} + +template <typename P1, typename P2> +void test_multi_linestring_polygon() +{ + typedef bg::model::linestring<P1> ls; + typedef bg::model::multi_linestring<ls> mls; + typedef bg::model::polygon<P2> poly; + + test_geometry<mls, poly>("MULTILINESTRING((11 11, 20 20),(5 7, 4 1))", + "POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 2,4 4,2 4,2 2))", + true); + test_geometry<mls, poly>("MULTILINESTRING((10 0, 18 12),(2 2,2 1))", + "POLYGON((5 0,0 -5,-5 0,0 5,5 0))", + true); +} + +template <typename P1, typename P2> +void test_multi_polygon_polygon() +{ + typedef bg::model::polygon<P1> poly1; + typedef bg::model::multi_polygon<poly1> mpoly; + typedef bg::model::polygon<P2> poly2; + + test_geometry<mpoly, poly2>("MULTIPOLYGON(((11 11,11 20,20 20,20 11,11 11)),((5 5,5 6,6 6,6 5,5 5)))", + "POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 2,4 4,2 4,2 2))", + true); +} + +template <typename P1, typename P2> +void test_point_polygon() +{ + typedef bg::model::ring<P2> ring; + typedef bg::model::polygon<P2> poly; + + test_geometry<P1, ring>( + "POINT(0 0)", + "POLYGON((0 0,3 3,3 3,4 1))", + true); + test_geometry<P1, poly>( + "POINT(0 0)", + "POLYGON((0 0,3 3,3 3,4 1))", + true); + + test_geometry<ring, P1>( + "POLYGON((0 0,3 3,3 3,4 1))", + "POINT(0 0)", + true); + test_geometry<poly, P1>( + "POLYGON((0 0,3 3,3 3,4 1))", + "POINT(0 0)", + true); +} + +template <typename P1, typename P2> +void test_all() +{ + test_intersects_point_segment<P1, P2>(); + test_intersects_point_linestring<P1, P2>(); + test_intersects_polygon_polygon<P1, P2>(); + test_intersects_linestring_polygon<P1, P2>(); + test_intersects_linestring_ring<P1, P2>(); + test_intersects_linestring_segment<P1, P2>(); + test_intersects_linestring_linestring<P1, P2>(); + test_intersects_ring_polygon<P1, P2>(); + test_multi_linestring_polygon<P1, P2>(); + test_multi_polygon_polygon<P1, P2>(); + test_point_polygon<P1, P2>(); +} + +template <typename P> +void test_all() +{ + test_all<P, P>(); +} + +int test_main( int , char* [] ) +{ + test_all<bg::model::d2::point_xy<double> >(); + test_all<bg::model::d2::point_xy<double>, bg::model::point<double, 2, bg::cs::cartesian> >(); + +#if ! defined(BOOST_GEOMETRY_RESCALE_TO_ROBUST) + test_all<bg::model::d2::point_xy<boost::rational<int> > >(); +#endif + +#if defined(HAVE_TTMATH) + test_all<bg::model::d2::point_xy<ttmath_big> >(); +#endif + + return 0; +} diff --git a/src/boost/libs/geometry/test/algorithms/intersects/intersects_box_geometry.cpp b/src/boost/libs/geometry/test/algorithms/intersects/intersects_box_geometry.cpp new file mode 100644 index 00000000..692a0f69 --- /dev/null +++ b/src/boost/libs/geometry/test/algorithms/intersects/intersects_box_geometry.cpp @@ -0,0 +1,172 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. + +// This file was modified by Oracle on 2013, 2015, 2016. +// Modifications copyright (c) 2013-2016, Oracle and/or its affiliates. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include "test_intersects.hpp" + + +#include <boost/geometry/geometries/geometries.hpp> +#include <boost/geometry/geometries/point_xy.hpp> + +#include <boost/geometry/util/rational.hpp> + + +template <typename P1, typename P2> +void test_all() +{ + typedef bg::model::polygon<P1> polygon; + typedef bg::model::ring<P1> ring; + + // intersect <=> ! disjoint (in most cases) + // so most tests are done in disjoint test. + // We only test compilation of a few cases. + test_geometry<P1, bg::model::box<P2> >("POINT(1 1)", "BOX(0 0,2 2)", true); + + test_geometry<polygon, bg::model::box<P2> >( + "POLYGON((1992 3240,1992 1440,3792 1800,3792 3240,1992 3240))", + "BOX(1941 2066, 2055 2166)", true); + + test_geometry<ring, bg::model::box<P2> >( + "POLYGON((1992 3240,1992 1440,3792 1800,3792 3240,1992 3240))", + "BOX(1941 2066, 2055 2166)", true); + + test_geometry<polygon, bg::model::box<P2> >( + "POLYGON((1941 2066,2055 2066,2055 2166,1941 2166))", + "BOX(1941 2066, 2055 2166)", true); + + test_geometry<P1, bg::model::box<P2> >( + "POINT(0 0)", + "BOX(0 0,4 4)", + true); +} + +template <typename P> +void test_all() +{ + test_all<P, P>(); +} + +// Those tests won't pass for rational<> because numeric_limits<> isn't specialized for this type +template <typename P> +void test_additional() +{ + test_geometry<bg::model::segment<P>, bg::model::box<P> >( + "SEGMENT(0 0,3 3)", + "BOX(1 2,3 5)", + true); + test_geometry<bg::model::segment<P>, bg::model::box<P> >( + "SEGMENT(1 1,2 3)", + "BOX(0 0,4 4)", + true); + test_geometry<bg::model::segment<P>, bg::model::box<P> >( + "SEGMENT(1 1,1 1)", + "BOX(1 0,3 5)", + true); + test_geometry<bg::model::segment<P>, bg::model::box<P> >( + "SEGMENT(0 1,0 1)", + "BOX(1 0,3 5)", + false); + test_geometry<bg::model::segment<P>, bg::model::box<P> >( + "SEGMENT(2 1,2 1)", + "BOX(1 0,3 5)", + true); + test_geometry<bg::model::linestring<P>, bg::model::box<P> >( + "LINESTRING(0 0,1 0,10 10)", + "BOX(1 2,3 5)", + true); + test_geometry<bg::model::linestring<P>, bg::model::box<P> >( + "LINESTRING(1 2)", + "BOX(0 0,3 5)", + true); + + // http://stackoverflow.com/questions/32457920/boost-rtree-of-box-gives-wrong-intersection-with-segment + // http://lists.boost.org/geometry/2015/09/3476.php + typedef bg::model::point<typename bg::coordinate_type<P>::type, 3, bg::cs::cartesian> point3d_t; + test_geometry<bg::model::segment<point3d_t>, bg::model::box<point3d_t> >( + "SEGMENT(2 1 0,2 1 10)", + "BOX(0 0 0,10 0 10)", + false); + test_geometry<bg::model::segment<point3d_t>, bg::model::box<point3d_t> >( + "SEGMENT(2 1 0,2 1 10)", + "BOX(0 -5 0,10 0 10)", + false); + // and derived from the cases above + test_geometry<bg::model::segment<P>, bg::model::box<P> >( + "SEGMENT(12 0,20 10)", + "BOX(0 0,10 10)", + false); + test_geometry<bg::model::segment<P>, bg::model::box<P> >( + "SEGMENT(2 0,8 6)", + "BOX(0 0,10 10)", + true); + test_geometry<bg::model::segment<P>, bg::model::box<P> >( + "SEGMENT(2 0,18 8)", + "BOX(0 0,10 10)", + true); + test_geometry<bg::model::segment<P>, bg::model::box<P> >( + "SEGMENT(1 0,1 10)", + "BOX(0 0,0 10)", + false); + test_geometry<bg::model::segment<P>, bg::model::box<P> >( + "SEGMENT(-1 0,-1 10)", + "BOX(0 0,0 10)", + false); + test_geometry<bg::model::segment<P>, bg::model::box<P> >( + "SEGMENT(2 1,2 1)", + "BOX(0 0,10 0)", + false); + test_geometry<bg::model::segment<P>, bg::model::box<P> >( + "SEGMENT(2 3,2 3)", + "BOX(0 0,10 0)", + false); + test_geometry<bg::model::segment<P>, bg::model::box<P> >( + "SEGMENT(0 0,10 0)", + "BOX(0 0,10 0)", + true); + test_geometry<bg::model::segment<P>, bg::model::box<P> >( + "SEGMENT(10 0,10 0)", + "BOX(0 0,10 0)", + true); + test_geometry<bg::model::segment<P>, bg::model::box<P> >( + "SEGMENT(1 0,1 0)", + "BOX(0 0,10 0)", + true); + test_geometry<bg::model::segment<P>, bg::model::box<P> >( + "SEGMENT(0 0,0 10)", + "BOX(0 0,0 10)", + true); + test_geometry<bg::model::segment<P>, bg::model::box<P> >( + "SEGMENT(0 10,0 10)", + "BOX(0 0,0 10)", + true); + test_geometry<bg::model::segment<P>, bg::model::box<P> >( + "SEGMENT(0 1,0 1)", + "BOX(0 0,0 10)", + true); +} + + +int test_main( int , char* [] ) +{ + test_all<bg::model::d2::point_xy<float>, bg::model::point<double, 2, bg::cs::cartesian> >(); + test_all<bg::model::d2::point_xy<double> >(); + test_additional<bg::model::d2::point_xy<double> >(); + +#if ! defined(BOOST_GEOMETRY_RESCALE_TO_ROBUST) + test_all<bg::model::d2::point_xy<boost::rational<int> > >(); +#endif + +#if defined(HAVE_TTMATH) + test_all<bg::model::d2::point_xy<ttmath_big> >(); +#endif + + return 0; +} diff --git a/src/boost/libs/geometry/test/algorithms/intersects/intersects_multi.cpp b/src/boost/libs/geometry/test/algorithms/intersects/intersects_multi.cpp new file mode 100644 index 00000000..d2c70d1f --- /dev/null +++ b/src/boost/libs/geometry/test/algorithms/intersects/intersects_multi.cpp @@ -0,0 +1,63 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2012-2015 Barend Gehrels, Amsterdam, the Netherlands. + +// This file was modified by Oracle on 2016. +// Modifications copyright (c) 2016, Oracle and/or its affiliates. +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include <iostream> +#include <string> + + +#include <geometry_test_common.hpp> + +#include "test_intersects.hpp" + +#include <boost/geometry.hpp> + +#include <boost/geometry/geometries/geometries.hpp> +#include <boost/geometry/geometries/point_xy.hpp> + +template <typename P1, typename P2> +void test_all() +{ + typedef bg::model::polygon<P1> polygon1; + typedef bg::model::multi_polygon<polygon1> mp1; + typedef bg::model::polygon<P2> polygon2; + typedef bg::model::multi_polygon<polygon2> mp2; + + test_geometry<mp1, mp2>("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))", + "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))", + true); + + test_geometry<P1, mp2>("POINT(0 0)", + "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))", + true); + +} + +template <typename P> +void test_all() +{ + test_all<P, P>(); +} + +int test_main(int, char* []) +{ + //test_all<bg::model::d2::point_xy<float> >(); + test_all<bg::model::d2::point_xy<double> >(); + test_all<bg::model::d2::point_xy<double>, bg::model::point<double, 2, bg::cs::cartesian> >(); + +#ifdef HAVE_TTMATH + test_all<bg::model::d2::point_xy<ttmath_big> >(); +#endif + + return 0; +} + diff --git a/src/boost/libs/geometry/test/algorithms/intersects/intersects_self.cpp b/src/boost/libs/geometry/test/algorithms/intersects/intersects_self.cpp new file mode 100644 index 00000000..6d6c4172 --- /dev/null +++ b/src/boost/libs/geometry/test/algorithms/intersects/intersects_self.cpp @@ -0,0 +1,133 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. + +// This file was modified by Oracle on 2013, 2015. +// Modifications copyright (c) 2013-2015, Oracle and/or its affiliates. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include "test_intersects.hpp" + + +#include <boost/geometry/geometries/geometries.hpp> +#include <boost/geometry/geometries/point_xy.hpp> + +#include <boost/geometry/util/rational.hpp> + + +template <typename P> +void test_all() +{ + typedef bg::model::linestring<P> linestring; + typedef bg::model::polygon<P> polygon; + typedef bg::model::ring<P> ring; + typedef bg::model::ring<P, true, false> ring_open; + + // self-intersecting is not tested in disjoint, so that is done here. + + // Just a normal polygon + test_self_intersects<polygon>("POLYGON((0 0,0 4,1.5 2.5,2.5 1.5,4 0,0 0))", false); + + // Self intersecting + test_self_intersects<polygon>("POLYGON((1 2,1 1,2 1,2 2.25,3 2.25,3 0,0 0,0 3,3 3,2.75 2,1 2))", true); + + // Self intersecting in last segment + test_self_intersects<polygon>("POLYGON((0 2,2 4,2 0,4 2,0 2))", true); + + // Self tangent + test_self_intersects<polygon>("POLYGON((0 0,0 4,4 4,4 0,2 4,0 0))", true); + + // Self tangent in corner + test_self_intersects<polygon>("POLYGON((0 0,0 4,4 4,4 0,0 4,2 0,0 0))", true); + + // With spike + test_self_intersects<polygon>("POLYGON((0 0,0 4,4 4,4 2,6 2,4 2,4 0,0 0))", true); + + // Non intersection, but with duplicate + test_self_intersects<polygon>("POLYGON((0 0,0 4,4 0,4 0,0 0))", false); + + // With many duplicates + test_self_intersects<polygon>( + "POLYGON((0 0,0 1,0 1,0 1,0 2,0 2,0 3,0 3,0 3,0 3,0 4,2 4,2 4,4 4,4 0,4 0,3 0,3 0,3 0,3 0,3 0,0 0))", + false); + + // Hole: interior tangent to exterior + test_self_intersects<polygon>("POLYGON((0 0,0 4,4 4,4 0,0 0),(1 2,2 4,3 2,1 2))", true); + + // Hole: interior intersecting exterior + test_self_intersects<polygon>("POLYGON((0 0,0 4,4 4,4 0,0 0),(1 1,1 3,5 4,1 1))", true); + + // Hole: two intersecting holes + test_self_intersects<polygon>( + "POLYGON((0 0,0 4,4 4,4 0,0 0),(1 1,1 3,3 3,3 1,1 1),(2 2,2 3.5,3.5 3.5,3.5 2,2 2))", true); + + // Mail Akira T on [Boost-users] at 27-7-2011 3:17 + test_self_intersects<linestring>( + "LINESTRING(0 0,0 4,4 4,2 2,2 5)", true); + + test_self_intersects<linestring>( + "LINESTRING(0 4,4 4,2 2,2 5)", true); + + // Test self-intersections at last segment in close/open rings: + test_self_intersects<ring>( + "POLYGON((0 0,3 3,4 1,0 0))", false); + + test_self_intersects<ring_open>( + "POLYGON((0 0,3 3,4 1))", false); + + test_self_intersects<ring>( + "POLYGON((0 0,3 3,4 1,0 1,0 0))", true); + + test_self_intersects<ring_open>( + "POLYGON((0 0,3 3,4 1,0 1))", true); + + // Duplicates in first or last + test_self_intersects<ring>( + "POLYGON((0 0,3 3,4 1,0 1,0 1,0 0))", true); + test_self_intersects<ring>( + "POLYGON((0 0,3 3,4 1,0 1,0 0,0 0))", true); + test_self_intersects<ring_open>( + "POLYGON((0 0,3 3,4 1,0 1,0 1))", true); + test_self_intersects<ring>( + "POLYGON((0 0,0 0,3 3,4 1,0 1,0 1,0 0))", true); + test_self_intersects<ring_open>( + "POLYGON((0 0,0 0,3 3,4 1,0 1,0 1))", true); + test_self_intersects<ring>( + "POLYGON((0 0,3 3,3 3,4 1,0 1,0 1,0 0))", true); + test_self_intersects<ring_open>( + "POLYGON((0 0,3 3,3 3,4 1,0 1,0 1))", true); + + test_self_intersects<ring>( + "POLYGON((0 0,3 3,4 1,0 0,0 0))", false); + test_self_intersects<ring>( + "POLYGON((0 0,3 3,4 1,4 1,0 0))", false); + test_self_intersects<ring_open>( + "POLYGON((0 0,3 3,4 1,4 1))", false); + test_self_intersects<ring>( + "POLYGON((0 0,0 0,3 3,4 1,0 0))", false); + test_self_intersects<ring_open>( + "POLYGON((0 0,0 0,3 3,4 1))", false); + test_self_intersects<ring>( + "POLYGON((0 0,3 3,3 3,4 1,0 0))", false); + test_self_intersects<ring_open>( + "POLYGON((0 0,3 3,3 3,4 1))", false); +} + +int test_main( int , char* [] ) +{ + test_all<bg::model::d2::point_xy<double> >(); + +#if ! defined(BOOST_GEOMETRY_RESCALE_TO_ROBUST) + test_all<bg::model::d2::point_xy<boost::rational<int> > >(); +#endif + +#if defined(HAVE_TTMATH) + test_all<bg::model::d2::point_xy<ttmath_big> >(); +#endif + + return 0; +} diff --git a/src/boost/libs/geometry/test/algorithms/intersects/intersects_sph.cpp b/src/boost/libs/geometry/test/algorithms/intersects/intersects_sph.cpp new file mode 100644 index 00000000..0981c0af --- /dev/null +++ b/src/boost/libs/geometry/test/algorithms/intersects/intersects_sph.cpp @@ -0,0 +1,269 @@ +// Boost.Geometry + +// Copyright (c) 2016 Oracle and/or its affiliates. +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include "test_intersects.hpp" + +#include <algorithms/overlay/overlay_cases.hpp> +#include <algorithms/overlay/multi_overlay_cases.hpp> + +#include <boost/geometry/geometries/geometries.hpp> + + +template <typename P> +void test_polygon_polygon() +{ + typedef bg::model::polygon<P> poly; + typedef bg::model::ring<P> ring; + + test_geometry<ring, ring>(case_1[0], case_1[1], + true); + test_geometry<ring, poly>(case_1[0], case_1[1], + true); + + test_geometry<poly, poly>(case_1[0], case_1[1], + true); + test_geometry<poly, poly>(case_2[0], case_2[1], + true); + test_geometry<poly, poly>(case_3_sph[0], case_3_sph[1], + true); + test_geometry<poly, poly>(case_3_2_sph[0], case_3_2_sph[1], + true); + test_geometry<poly, poly>(case_4[0], case_4[1], + true); + test_geometry<poly, poly>(case_5[0], case_5[1], + true); + test_geometry<poly, poly>(case_6_sph[0], case_6_sph[1], + true); + + test_geometry<poly, poly>(case_7[0], case_7[1], + true); + test_geometry<poly, poly>(case_8_sph[0], case_8_sph[1], + true); + test_geometry<poly, poly>(case_9_sph[0], case_9_sph[1], + true); + test_geometry<poly, poly>(case_10_sph[0], case_10_sph[1], + true); + test_geometry<poly, poly>(case_11_sph[0], case_11_sph[1], + true); + test_geometry<poly, poly>(case_12[0], case_12[1], + true); + + test_geometry<poly, poly>(case_13_sph[0], case_13_sph[1], + true); + test_geometry<poly, poly>(case_14_sph[0], case_14_sph[1], + true); + test_geometry<poly, poly>(case_15_sph[0], case_15_sph[1], + true); + test_geometry<poly, poly>(case_16_sph[0], case_16_sph[1], + true); + test_geometry<poly, poly>(case_17_sph[0], case_17_sph[1], + true); + test_geometry<poly, poly>(case_17_sph[1], case_17_sph[0], + true); + test_geometry<poly, poly>(case_18_sph[0], case_18_sph[1], + true); + test_geometry<poly, poly>(case_18_sph[1], case_18_sph[0], + true); +} + +template <typename P> +void test_polygon_multi_polygon() +{ + typedef bg::model::polygon<P> poly; + typedef bg::model::ring<P> ring; + typedef bg::model::multi_polygon<poly> mpoly; + + test_geometry<ring, mpoly>(case_1[0], case_multi_2[0], + true); + test_geometry<poly, mpoly>(case_2[0], case_multi_2[0], + true); +} + +template <typename P> +void test_multi_polygon_multi_polygon() +{ + typedef bg::model::polygon<P> poly; + typedef bg::model::multi_polygon<poly> mpoly; + + test_geometry<mpoly, mpoly>(case_multi_2[0], case_multi_2[1], + true); +} + +template <typename P> +void test_linestring_polygon() +{ + typedef bg::model::linestring<P> ls; + typedef bg::model::polygon<P> poly; + typedef bg::model::polygon<P> ring; + + test_geometry<ls, poly>("LINESTRING(11 0,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false); + test_geometry<ls, ring>("LINESTRING(11 0,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false); + test_geometry<ls, poly>("LINESTRING(0 0,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", true); + test_geometry<ls, poly>("LINESTRING(5 0,5 5,10 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", true); + test_geometry<ls, poly>("LINESTRING(5 1,5 5,9 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", true); + test_geometry<ls, poly>("LINESTRING(11 1,11 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false); + + test_geometry<ls, poly>("LINESTRING(9 1,10 5,9 9)", + "POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))", + true); + + test_geometry<ls, poly>("LINESTRING(9 1,10 5,9 9,1 9,1 1,9 1)", + "POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))", + true); + + test_geometry<ls, poly>("LINESTRING(0 0,10 0,10 10,0 10,0 0)", + "POLYGON((0 0,0 10,10 10,10 0,0 0))", + true); +} + +template <typename P> +void test_linestring_multi_polygon() +{ + typedef bg::model::linestring<P> ls; + typedef bg::model::polygon<P> poly; + typedef bg::model::multi_polygon<poly> mpoly; + + test_geometry<ls, mpoly>("LINESTRING(10 1,10 5,10 9)", + "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)))", + true); +} + +template <typename P> +void test_multi_linestring_polygon() +{ + typedef bg::model::linestring<P> ls; + typedef bg::model::polygon<P> poly; + typedef bg::model::ring<P> ring; + typedef bg::model::multi_linestring<ls> mls; + + test_geometry<mls, poly>("MULTILINESTRING((11 11, 20 20),(5 7, 4 1))", + "POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 2,4 4,2 4,2 2))", + true); + + test_geometry<mls, ring>("MULTILINESTRING((6 6,15 15),(0 0, 7 7))", + "POLYGON((5 5,5 15,15 15,15 5,5 5))", + true); + + test_geometry<mls, poly>("MULTILINESTRING((3 10.031432746397092, 1 5, 1 10.013467818052765, 3 4, 7 8, 6 10.035925377760330, 10 2))", + "POLYGON((0 0,0 10,10 10,10 0,0 0))", + true); +} + +template <typename P> +void test_multi_linestring_multi_polygon() +{ + typedef bg::model::linestring<P> ls; + typedef bg::model::polygon<P> poly; + typedef bg::model::multi_linestring<ls> mls; + typedef bg::model::multi_polygon<poly> mpoly; + + test_geometry<mls, mpoly>("MULTILINESTRING((0 0,10 0,10 10,0 10,0 0),(2 2,5 5,2 8,2 2))", + "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(2 2,5 5,2 8,2 2)))", + true); + + 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))", + "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))", + true); + + test_geometry<mls, mpoly>("MULTILINESTRING((5 -2,4 -2,5 0),(5 -2,6 -2,5 0))", + "MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))", + true); +} + +template <typename P> +void test_linestring_linestring() +{ + typedef bg::model::linestring<P> ls; + + test_geometry<ls, ls>("LINESTRING(0 0, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 3 2)", true); + + test_geometry<ls, ls>("LINESTRING(1 0,2 2,2 3)", "LINESTRING(0 0, 2 2, 3 2)", true); +} + +template <typename P> +void test_linestring_multi_linestring() +{ + typedef bg::model::linestring<P> ls; + typedef bg::model::multi_linestring<ls> mls; + + test_geometry<ls, mls>("LINESTRING(0 0,10 0)", + "MULTILINESTRING((1 0,2 0),(1 1,2 1))", + true); + + test_geometry<ls, mls>("LINESTRING(0 0,5 0,5 5,0 5,0 0)", + "MULTILINESTRING((5 5,0 5,0 0),(0 0,5 0,5 5))", + true); +} + +template <typename P> +void test_multi_linestring_multi_linestring() +{ + typedef bg::model::linestring<P> ls; + typedef bg::model::multi_linestring<ls> mls; + + test_geometry<mls, mls>("MULTILINESTRING((0 0,0 0,18 0,18 0,19 0,19 0,19 0,30 0,30 0))", + "MULTILINESTRING((0 10,5 0,20 0,20 0,30 0))", + true); +} + +template <typename P> +void test_point_polygon() +{ + typedef bg::model::polygon<P> poly; + + // https://svn.boost.org/trac/boost/ticket/9162 + test_geometry<P, poly>("POINT(0 90)", + "POLYGON((0 80,-90 80, -180 80, 90 80, 0 80))", + true); + test_geometry<P, poly>("POINT(-120 21)", + "POLYGON((30 0,30 30,90 30, 90 0, 30 0))", + false); + // extended + test_geometry<P, poly>("POINT(0 -90)", + "POLYGON((0 -80,90 -80, -180 -80, -90 -80, 0 -80))", + true); + test_geometry<P, poly>("POINT(0 89)", + "POLYGON((0 80,-90 80, -180 80, 90 80, 0 80))", + true); + test_geometry<P, poly>("POINT(-180 89)", + "POLYGON((0 80,-90 80, -180 80, 90 80, 0 80))", + true); +} + + +template <typename P> +void test_all() +{ + test_polygon_polygon<P>(); + test_polygon_multi_polygon<P>(); + test_multi_polygon_multi_polygon<P>(); + + test_linestring_polygon<P>(); + test_linestring_multi_polygon<P>(); + test_multi_linestring_polygon<P>(); + test_multi_linestring_multi_polygon<P>(); + + test_linestring_linestring<P>(); + test_linestring_multi_linestring<P>(); + test_multi_linestring_multi_linestring<P>(); + + test_point_polygon<P>(); +} + + +int test_main( int , char* [] ) +{ + test_all<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >(); + +#if defined(HAVE_TTMATH) + test_cs<bg::model::point<ttmath_big, 2, bg::cs::spherical_equatorial<bg::degree> > >(); +#endif + + return 0; +} diff --git a/src/boost/libs/geometry/test/algorithms/intersects/intersects_sph_geo.cpp b/src/boost/libs/geometry/test/algorithms/intersects/intersects_sph_geo.cpp new file mode 100644 index 00000000..c4cd283d --- /dev/null +++ b/src/boost/libs/geometry/test/algorithms/intersects/intersects_sph_geo.cpp @@ -0,0 +1,86 @@ +// Boost.Geometry + +// Copyright (c) 2016 Oracle and/or its affiliates. +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include "test_intersects.hpp" + + +#include <boost/geometry/geometries/geometries.hpp> + + +template <typename P> +void test_point_box() +{ + typedef bg::model::box<P> box_t; + + test_geometry<P, box_t>("POINT(0 0)", "BOX(0 0, 1 1)", true); + test_geometry<P, box_t>("POINT(1 1)", "BOX(0 0, 2 2)", true); + + test_geometry<P, box_t>("POINT(180 1)", "BOX(170 0, 190 2)", true); + test_geometry<P, box_t>("POINT(-180 1)", "BOX(170 0, 190 2)", true); + test_geometry<P, box_t>("POINT(180 1)", "BOX(170 0, 180 2)", true); + test_geometry<P, box_t>("POINT(-180 1)", "BOX(170 0, 180 2)", true); + test_geometry<P, box_t>("POINT(179 1)", "BOX(170 0, 190 2)", true); + test_geometry<P, box_t>("POINT(-179 1)", "BOX(170 0, 190 2)", true); + test_geometry<P, box_t>("POINT(179 1)", "BOX(170 0, 180 2)", true); + test_geometry<P, box_t>("POINT(-179 1)", "BOX(170 0, 180 2)", false); + test_geometry<P, box_t>("POINT(169 1)", "BOX(170 0, 180 2)", false); +} + +template <typename P> +void test_box_box() +{ + typedef bg::model::box<P> box_t; + + test_geometry<box_t, box_t>("BOX(0 0, 1 1)", "BOX(0 0, 1 1)", true); + + test_geometry<box_t, box_t>("BOX(-170 0,-160 1)", "BOX(-180 0, 180 1)", true); + test_geometry<box_t, box_t>("BOX(-170 0,-160 1)", "BOX(170 0, 200 1)", true); + test_geometry<box_t, box_t>("BOX(-170 0,-150 1)", "BOX(170 0, 200 1)", true); + test_geometry<box_t, box_t>("BOX(201 0,202 1)", "BOX(170 0, 200 1)", false); // invalid g1? + test_geometry<box_t, box_t>("BOX(-159 0,-158 1)", "BOX(170 0, 200 1)", false); + test_geometry<box_t, box_t>("BOX(160 0,169 1)", "BOX(170 0, 200 1)", false); + test_geometry<box_t, box_t>("BOX(-159 0,169 1)", "BOX(170 0, 200 1)", false); + test_geometry<box_t, box_t>("BOX(0 0,1 1)", "BOX(170 0, 370 1)", true); + test_geometry<box_t, box_t>("BOX(0 0,10 1)", "BOX(170 0, 370 1)", true); + test_geometry<box_t, box_t>("BOX(-180 0,10 1)", "BOX(170 0, 370 1)", true); + test_geometry<box_t, box_t>("BOX(-180 0,20 1)", "BOX(170 0, 370 1)", true); + test_geometry<box_t, box_t>("BOX(10 0,20 1)", "BOX(170 0, 370 1)", true); + test_geometry<box_t, box_t>("BOX(160 0,180 1)", "BOX(170 0, 370 1)", true); + test_geometry<box_t, box_t>("BOX(160 0,165 1)", "BOX(170 0, 370 1)", false); + test_geometry<box_t, box_t>("BOX(15 0,20 1)", "BOX(170 0, 370 1)", false); + test_geometry<box_t, box_t>("BOX(375 0,380 1)", "BOX(170 0, 370 1)", false); // invalid g1? + + test_geometry<box_t, box_t>("BOX(-180 0,-170 1)", "BOX(180 0, 190 1)", true); // invalid? + test_geometry<box_t, box_t>("BOX(-180 0,-170 1)", "BOX(180 0, 191 1)", true); // invalid? + test_geometry<box_t, box_t>("BOX(-180 0,-170 1)", "BOX(179 0, 190 1)", true); + test_geometry<box_t, box_t>("BOX(-180 0,-170 1)", "BOX(181 0, 190 1)", true); // invalid? + test_geometry<box_t, box_t>("BOX(-180 0,-170 1)", "BOX(180 0, 189 1)", true); // invalid? +} + + +template <typename P> +void test_cs() +{ + test_point_box<P>(); + test_box_box<P>(); +} + + +int test_main( int , char* [] ) +{ + test_cs<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >(); + test_cs<bg::model::point<double, 2, bg::cs::geographic<bg::degree> > >(); + +#if defined(HAVE_TTMATH) + test_cs<bg::model::point<ttmath_big, 2, bg::cs::spherical_equatorial<bg::degree> > >(); + test_cs<bg::model::point<ttmath_big, 2, bg::cs::geographic<bg::degree> > >();; +#endif + + return 0; +} diff --git a/src/boost/libs/geometry/test/algorithms/intersects/test_intersects.hpp b/src/boost/libs/geometry/test/algorithms/intersects/test_intersects.hpp new file mode 100644 index 00000000..c9ffe557 --- /dev/null +++ b/src/boost/libs/geometry/test/algorithms/intersects/test_intersects.hpp @@ -0,0 +1,115 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. + +// This file was modified by Oracle on 2017. +// Modifications copyright (c) 2017 Oracle and/or its affiliates. +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_TEST_INTERSECTS_HPP +#define BOOST_GEOMETRY_TEST_INTERSECTS_HPP + + +#include <geometry_test_common.hpp> + + +#include <boost/geometry/core/geometry_id.hpp> +#include <boost/geometry/core/point_order.hpp> +#include <boost/geometry/core/ring_type.hpp> +#include <boost/geometry/algorithms/covered_by.hpp> +#include <boost/geometry/algorithms/intersects.hpp> +#include <boost/geometry/strategies/strategies.hpp> +#include <boost/geometry/geometries/ring.hpp> +#include <boost/geometry/geometries/polygon.hpp> +#include <boost/geometry/geometries/multi_linestring.hpp> +#include <boost/geometry/geometries/multi_polygon.hpp> + +#include <boost/geometry/io/wkt/read.hpp> + + +struct no_strategy {}; + +template <typename Geometry1, typename Geometry2, typename Strategy> +bool call_intersects(Geometry1 const& geometry1, + Geometry2 const& geometry2, + Strategy const& strategy) +{ + return bg::intersects(geometry1, geometry2, strategy); +} + +template <typename Geometry1, typename Geometry2> +bool call_intersects(Geometry1 const& geometry1, + Geometry2 const& geometry2, + no_strategy) +{ + return bg::intersects(geometry1, geometry2); +} + +template <typename G1, typename G2, typename Strategy> +void check_intersects(std::string const& wkt1, + std::string const& wkt2, + G1 const& g1, + G2 const& g2, + bool expected, + Strategy const& strategy) +{ + bool detected = call_intersects(g1, g2, strategy); + + BOOST_CHECK_MESSAGE(detected == expected, + "intersects: " << wkt1 + << " with " << wkt2 + << " -> Expected: " << expected + << " detected: " << detected); +} + +template <typename Geometry1, typename Geometry2> +void test_geometry(std::string const& wkt1, + std::string const& wkt2, bool expected) +{ + Geometry1 geometry1; + Geometry2 geometry2; + + bg::read_wkt(wkt1, geometry1); + bg::read_wkt(wkt2, geometry2); + + check_intersects(wkt1, wkt2, geometry1, geometry2, expected, no_strategy()); + check_intersects(wkt2, wkt1, geometry2, geometry1, expected, no_strategy()); + + typedef typename bg::strategy::disjoint::services::default_strategy + < + Geometry1, Geometry2 + >::type strategy12_type; + typedef typename bg::strategy::disjoint::services::default_strategy + < + Geometry2, Geometry1 + >::type strategy21_type; + + check_intersects(wkt1, wkt2, geometry1, geometry2, expected, strategy12_type()); + check_intersects(wkt2, wkt1, geometry2, geometry1, expected, strategy21_type()); +} + + +template <typename Geometry> +void test_self_intersects(std::string const& wkt, bool expected) +{ + Geometry geometry; + + bg::read_wkt(wkt, geometry); + + bool detected = bg::intersects(geometry); + + BOOST_CHECK_MESSAGE(detected == expected, + "intersects: " << wkt + << " -> Expected: " << expected + << " detected: " << detected); +} + + + +#endif |