From 2ecf2d393af173b997f4b60d7ffd27f0e9b18746 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Mon, 1 Jun 2015 13:10:45 +0300 Subject: [PATCH 01/18] [policies][rescale policy] initialize the rescale policy only if the input geometries are non-empty; this fixes unit test failures (union, intersection, difference) when BOOST_GEOMETRY_ENABLE_ACCESS_DEBUGGING is enabled; --- .../robustness/get_rescale_policy.hpp | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/include/boost/geometry/policies/robustness/get_rescale_policy.hpp b/include/boost/geometry/policies/robustness/get_rescale_policy.hpp index 52570995f..0a1d7e355 100644 --- a/include/boost/geometry/policies/robustness/get_rescale_policy.hpp +++ b/include/boost/geometry/policies/robustness/get_rescale_policy.hpp @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -86,6 +87,11 @@ static inline void init_rescale_policy(Geometry const& geometry, RobustPoint& min_robust_point, Factor& factor) { + if (geometry::num_points(geometry) == 0) + { + return; + } + // Get bounding boxes model::box env = geometry::return_envelope >(geometry); @@ -99,10 +105,30 @@ static inline void init_rescale_policy(Geometry1 const& geometry1, RobustPoint& min_robust_point, Factor& factor) { - // Get bounding boxes - model::box env = geometry::return_envelope >(geometry1); - model::box env2 = geometry::return_envelope >(geometry2); - geometry::expand(env, env2); + // Get bounding boxes (when at least one of the geometries is not empty) + model::box env; + if (geometry::num_points(geometry1) == 0 + && geometry::num_points(geometry2) == 0) + { + return; + } + else if (geometry::num_points(geometry1) == 0) + { + geometry::envelope(geometry2, env); + } + else if (geometry::num_points(geometry2) == 0) + { + geometry::envelope(geometry1, env); + } + else + { + geometry::envelope(geometry1, env); + model::box env2 = geometry::return_envelope + < + model::box + >(geometry2); + geometry::expand(env, env2); + } scale_box_to_integer_range(env, min_point, min_robust_point, factor); } From 87052dcebaf0c005e2b41ac02a799f508469ee2a Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Mon, 1 Jun 2015 16:21:27 +0300 Subject: [PATCH 02/18] [policies][rescale policy] compute number of points of each geometry only once --- .../geometry/policies/robustness/get_rescale_policy.hpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/include/boost/geometry/policies/robustness/get_rescale_policy.hpp b/include/boost/geometry/policies/robustness/get_rescale_policy.hpp index 0a1d7e355..1268d4cdb 100644 --- a/include/boost/geometry/policies/robustness/get_rescale_policy.hpp +++ b/include/boost/geometry/policies/robustness/get_rescale_policy.hpp @@ -107,16 +107,17 @@ static inline void init_rescale_policy(Geometry1 const& geometry1, { // Get bounding boxes (when at least one of the geometries is not empty) model::box env; - if (geometry::num_points(geometry1) == 0 - && geometry::num_points(geometry2) == 0) + bool is_empty1 = (geometry::num_points(geometry1) == 0); + bool is_empty2 = (geometry::num_points(geometry2) == 0); + if (is_empty1 == 0 && is_empty2) { return; } - else if (geometry::num_points(geometry1) == 0) + else if (is_empty1) { geometry::envelope(geometry2, env); } - else if (geometry::num_points(geometry2) == 0) + else if (is_empty2) { geometry::envelope(geometry1, env); } From da9b4c99392226e8e8fa0af256d2a632dd32273e Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Mon, 1 Jun 2015 23:45:52 +0300 Subject: [PATCH 03/18] [policies][rescale policy] apply coding rules; polish code; fix conditional expression; add comment regarding the computation of the bounding box when the geometries are in the spherical equatorial or geographic coordinate system; --- .../policies/robustness/get_rescale_policy.hpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/include/boost/geometry/policies/robustness/get_rescale_policy.hpp b/include/boost/geometry/policies/robustness/get_rescale_policy.hpp index 1268d4cdb..f985cf3bf 100644 --- a/include/boost/geometry/policies/robustness/get_rescale_policy.hpp +++ b/include/boost/geometry/policies/robustness/get_rescale_policy.hpp @@ -106,14 +106,15 @@ static inline void init_rescale_policy(Geometry1 const& geometry1, Factor& factor) { // Get bounding boxes (when at least one of the geometries is not empty) - model::box env; - bool is_empty1 = (geometry::num_points(geometry1) == 0); - bool is_empty2 = (geometry::num_points(geometry2) == 0); - if (is_empty1 == 0 && is_empty2) + bool const is_empty1 = geometry::num_points(geometry1) == 0; + bool const is_empty2 = geometry::num_points(geometry2) == 0; + if (is_empty1 && is_empty2) { return; } - else if (is_empty1) + + model::box env; + if (is_empty1) { geometry::envelope(geometry2, env); } @@ -123,6 +124,10 @@ static inline void init_rescale_policy(Geometry1 const& geometry1, } else { + // The following approach (envelope + expand) may not give the + // optimal MBR when then two geometries are in the spherical + // equatorial or geographic coordinate systems. + // TODO: implement envelope for two (or possibly more geometries) geometry::envelope(geometry1, env); model::box env2 = geometry::return_envelope < From 32cf69186084c0fe7a7edf8025580c3f9af2085c Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Wed, 3 Jun 2015 17:31:45 +0300 Subject: [PATCH 04/18] [policies][get_rescale_policy] replace use of num_points() by is_empty() --- .../geometry/policies/robustness/get_rescale_policy.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/boost/geometry/policies/robustness/get_rescale_policy.hpp b/include/boost/geometry/policies/robustness/get_rescale_policy.hpp index f985cf3bf..e48fd28d6 100644 --- a/include/boost/geometry/policies/robustness/get_rescale_policy.hpp +++ b/include/boost/geometry/policies/robustness/get_rescale_policy.hpp @@ -27,7 +27,7 @@ #include #include -#include +#include #include #include #include @@ -87,7 +87,7 @@ static inline void init_rescale_policy(Geometry const& geometry, RobustPoint& min_robust_point, Factor& factor) { - if (geometry::num_points(geometry) == 0) + if (geometry::is_empty(geometry)) { return; } @@ -106,8 +106,8 @@ static inline void init_rescale_policy(Geometry1 const& geometry1, Factor& factor) { // Get bounding boxes (when at least one of the geometries is not empty) - bool const is_empty1 = geometry::num_points(geometry1) == 0; - bool const is_empty2 = geometry::num_points(geometry2) == 0; + bool const is_empty1 = geometry::is_empty(geometry1); + bool const is_empty2 = geometry::is_empty(geometry2); if (is_empty1 && is_empty2) { return; From 7422c6c400cf0860d6aa2a7ff8c2e6ad47fb6d48 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Mon, 15 Jun 2015 03:42:27 +0200 Subject: [PATCH 05/18] [test][intersects] Group the tests in separate files. --- .../relational_operations/Jamfile.v2 | 3 +- .../intersects/Jamfile.v2 | 24 +++ .../{ => intersects}/intersects.cpp | 154 +----------------- .../intersects/intersects_box_geometry.cpp | 100 ++++++++++++ .../{ => intersects}/intersects_multi.cpp | 0 .../intersects/intersects_self.cpp | 131 +++++++++++++++ .../{ => intersects}/test_intersects.hpp | 0 7 files changed, 260 insertions(+), 152 deletions(-) create mode 100644 test/algorithms/relational_operations/intersects/Jamfile.v2 rename test/algorithms/relational_operations/{ => intersects}/intersects.cpp (58%) create mode 100644 test/algorithms/relational_operations/intersects/intersects_box_geometry.cpp rename test/algorithms/relational_operations/{ => intersects}/intersects_multi.cpp (100%) create mode 100644 test/algorithms/relational_operations/intersects/intersects_self.cpp rename test/algorithms/relational_operations/{ => intersects}/test_intersects.hpp (100%) diff --git a/test/algorithms/relational_operations/Jamfile.v2 b/test/algorithms/relational_operations/Jamfile.v2 index a0c110b1b..b6955f5dc 100644 --- a/test/algorithms/relational_operations/Jamfile.v2 +++ b/test/algorithms/relational_operations/Jamfile.v2 @@ -22,13 +22,12 @@ test-suite boost-geometry-algorithms-relational [ run equals.cpp : : : : algorithms_equals ] [ run equals_multi.cpp : : : : algorithms_equals_multi ] [ run equals_on_spheroid.cpp : : : : algorithms_equals_on_spheroid ] - [ run intersects.cpp : : : : algorithms_intersects ] - [ run intersects_multi.cpp : : : : algorithms_intersects_multi ] [ run overlaps.cpp : : : : algorithms_overlaps ] [ run touches.cpp : : : : algorithms_touches ] [ run touches_multi.cpp : : : : algorithms_touches_multi ] ; build-project disjoint ; +build-project intersects ; build-project relate ; build-project within ; diff --git a/test/algorithms/relational_operations/intersects/Jamfile.v2 b/test/algorithms/relational_operations/intersects/Jamfile.v2 new file mode 100644 index 000000000..a8a0d9127 --- /dev/null +++ b/test/algorithms/relational_operations/intersects/Jamfile.v2 @@ -0,0 +1,24 @@ +# 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. +# Modifications copyright (c) 2014-2015, 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-relational-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 ] + ; + diff --git a/test/algorithms/relational_operations/intersects.cpp b/test/algorithms/relational_operations/intersects/intersects.cpp similarity index 58% rename from test/algorithms/relational_operations/intersects.cpp rename to test/algorithms/relational_operations/intersects/intersects.cpp index 8a2f9cf14..876d6bb29 100644 --- a/test/algorithms/relational_operations/intersects.cpp +++ b/test/algorithms/relational_operations/intersects/intersects.cpp @@ -1,10 +1,10 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. +// 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. -// Modifications copyright (c) 2013, Oracle and/or its affiliates. +// 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 @@ -165,23 +165,6 @@ void test_all() typedef bg::model::polygon

polygon; typedef bg::model::ring

ring; - // intersect <=> ! disjoint (in most cases) - // so most tests are done in disjoint test. - // We only test compilation of a few cases. - test_geometry >("POINT(1 1)", "BOX(0 0,2 2)", true); - - test_geometry >( - "POLYGON((1992 3240,1992 1440,3792 1800,3792 3240,1992 3240))", - "BOX(1941 2066, 2055 2166)", true); - - test_geometry >( - "POLYGON((1992 3240,1992 1440,3792 1800,3792 3240,1992 3240))", - "BOX(1941 2066, 2055 2166)", true); - - test_geometry >( - "POLYGON((1941 2066,2055 2066,2055 2166,1941 2166))", - "BOX(1941 2066, 2055 2166)", true); - test_intersects_point_segment

(); test_intersects_point_linestring

(); test_intersects_polygon_polygon

(); @@ -193,99 +176,6 @@ void test_all() test_multi_linestring_polygon

(); test_multi_polygon_polygon

(); - // self-intersecting is not tested in disjoint, so that is done here. - - // Just a normal polygon - test_self_intersects("POLYGON((0 0,0 4,1.5 2.5,2.5 1.5,4 0,0 0))", false); - - // Self intersecting - test_self_intersects("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((0 2,2 4,2 0,4 2,0 2))", true); - - // Self tangent - test_self_intersects("POLYGON((0 0,0 4,4 4,4 0,2 4,0 0))", true); - - // Self tangent in corner - test_self_intersects("POLYGON((0 0,0 4,4 4,4 0,0 4,2 0,0 0))", true); - - // With spike - test_self_intersects("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((0 0,0 4,4 0,4 0,0 0))", false); - - // With many duplicates - test_self_intersects( - "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((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((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((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(0 0,0 4,4 4,2 2,2 5)", true); - - test_self_intersects >( - "LINESTRING(0 4,4 4,2 2,2 5)", true); - - // Test self-intersections at last segment in close/open rings: - test_self_intersects >( - "POLYGON((0 0,3 3,4 1,0 0))", false); - - test_self_intersects >( - "POLYGON((0 0,3 3,4 1))", false); - - test_self_intersects >( - "POLYGON((0 0,3 3,4 1,0 1,0 0))", true); - - test_self_intersects >( - "POLYGON((0 0,3 3,4 1,0 1))", true); - - // Duplicates in first or last - test_self_intersects >( - "POLYGON((0 0,3 3,4 1,0 1,0 1,0 0))", true); - test_self_intersects >( - "POLYGON((0 0,3 3,4 1,0 1,0 0,0 0))", true); - test_self_intersects >( - "POLYGON((0 0,3 3,4 1,0 1,0 1))", true); - test_self_intersects >( - "POLYGON((0 0,0 0,3 3,4 1,0 1,0 1,0 0))", true); - test_self_intersects >( - "POLYGON((0 0,0 0,3 3,4 1,0 1,0 1))", true); - test_self_intersects >( - "POLYGON((0 0,3 3,3 3,4 1,0 1,0 1,0 0))", true); - test_self_intersects >( - "POLYGON((0 0,3 3,3 3,4 1,0 1,0 1))", true); - - test_self_intersects >( - "POLYGON((0 0,3 3,4 1,0 0,0 0))", false); - test_self_intersects >( - "POLYGON((0 0,3 3,4 1,4 1,0 0))", false); - test_self_intersects >( - "POLYGON((0 0,3 3,4 1,4 1))", false); - test_self_intersects >( - "POLYGON((0 0,0 0,3 3,4 1,0 0))", false); - test_self_intersects >( - "POLYGON((0 0,0 0,3 3,4 1))", false); - test_self_intersects >( - "POLYGON((0 0,3 3,3 3,4 1,0 0))", false); - test_self_intersects >( - "POLYGON((0 0,3 3,3 3,4 1))", false); - - test_geometry >( - "POINT(0 0)", - "BOX(0 0,4 4)", - true); test_geometry >( "POINT(0 0)", "POLYGON((0 0,3 3,3 3,4 1))", @@ -305,45 +195,9 @@ void test_all() true); } -// Those tests won't pass for rational<> because numeric_limits<> isn't specialized for this type -template -void test_additional() -{ - test_geometry, bg::model::box

>( - "SEGMENT(0 0,3 3)", - "BOX(1 2,3 5)", - true); - test_geometry, bg::model::box

>( - "SEGMENT(1 1,2 3)", - "BOX(0 0,4 4)", - true); - test_geometry, bg::model::box

>( - "SEGMENT(1 1,1 1)", - "BOX(1 0,3 5)", - true); - test_geometry, bg::model::box

>( - "SEGMENT(0 1,0 1)", - "BOX(1 0,3 5)", - false); - test_geometry, bg::model::box

>( - "SEGMENT(2 1,2 1)", - "BOX(1 0,3 5)", - true); - test_geometry, bg::model::box

>( - "LINESTRING(0 0,1 0,10 10)", - "BOX(1 2,3 5)", - true); - test_geometry, bg::model::box

>( - "LINESTRING(1 2)", - "BOX(0 0,3 5)", - true); -} - - int test_main( int , char* [] ) { test_all >(); - test_additional >(); #if ! defined(BOOST_GEOMETRY_RESCALE_TO_ROBUST) test_all > >(); diff --git a/test/algorithms/relational_operations/intersects/intersects_box_geometry.cpp b/test/algorithms/relational_operations/intersects/intersects_box_geometry.cpp new file mode 100644 index 000000000..50a332436 --- /dev/null +++ b/test/algorithms/relational_operations/intersects/intersects_box_geometry.cpp @@ -0,0 +1,100 @@ +// 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 +#include + +#include + + +template +void test_all() +{ + typedef bg::model::polygon

polygon; + typedef bg::model::ring

ring; + + // intersect <=> ! disjoint (in most cases) + // so most tests are done in disjoint test. + // We only test compilation of a few cases. + test_geometry >("POINT(1 1)", "BOX(0 0,2 2)", true); + + test_geometry >( + "POLYGON((1992 3240,1992 1440,3792 1800,3792 3240,1992 3240))", + "BOX(1941 2066, 2055 2166)", true); + + test_geometry >( + "POLYGON((1992 3240,1992 1440,3792 1800,3792 3240,1992 3240))", + "BOX(1941 2066, 2055 2166)", true); + + test_geometry >( + "POLYGON((1941 2066,2055 2066,2055 2166,1941 2166))", + "BOX(1941 2066, 2055 2166)", true); + + test_geometry >( + "POINT(0 0)", + "BOX(0 0,4 4)", + true); +} + +// Those tests won't pass for rational<> because numeric_limits<> isn't specialized for this type +template +void test_additional() +{ + test_geometry, bg::model::box

>( + "SEGMENT(0 0,3 3)", + "BOX(1 2,3 5)", + true); + test_geometry, bg::model::box

>( + "SEGMENT(1 1,2 3)", + "BOX(0 0,4 4)", + true); + test_geometry, bg::model::box

>( + "SEGMENT(1 1,1 1)", + "BOX(1 0,3 5)", + true); + test_geometry, bg::model::box

>( + "SEGMENT(0 1,0 1)", + "BOX(1 0,3 5)", + false); + test_geometry, bg::model::box

>( + "SEGMENT(2 1,2 1)", + "BOX(1 0,3 5)", + true); + test_geometry, bg::model::box

>( + "LINESTRING(0 0,1 0,10 10)", + "BOX(1 2,3 5)", + true); + test_geometry, bg::model::box

>( + "LINESTRING(1 2)", + "BOX(0 0,3 5)", + true); +} + + +int test_main( int , char* [] ) +{ + test_all >(); + test_additional >(); + +#if ! defined(BOOST_GEOMETRY_RESCALE_TO_ROBUST) + test_all > >(); +#endif + +#if defined(HAVE_TTMATH) + test_all >(); +#endif + + return 0; +} diff --git a/test/algorithms/relational_operations/intersects_multi.cpp b/test/algorithms/relational_operations/intersects/intersects_multi.cpp similarity index 100% rename from test/algorithms/relational_operations/intersects_multi.cpp rename to test/algorithms/relational_operations/intersects/intersects_multi.cpp diff --git a/test/algorithms/relational_operations/intersects/intersects_self.cpp b/test/algorithms/relational_operations/intersects/intersects_self.cpp new file mode 100644 index 000000000..5bfb79b5a --- /dev/null +++ b/test/algorithms/relational_operations/intersects/intersects_self.cpp @@ -0,0 +1,131 @@ +// 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 +#include + +#include + + +template +void test_all() +{ + typedef bg::model::polygon

polygon; + typedef bg::model::ring

ring; + + // self-intersecting is not tested in disjoint, so that is done here. + + // Just a normal polygon + test_self_intersects("POLYGON((0 0,0 4,1.5 2.5,2.5 1.5,4 0,0 0))", false); + + // Self intersecting + test_self_intersects("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((0 2,2 4,2 0,4 2,0 2))", true); + + // Self tangent + test_self_intersects("POLYGON((0 0,0 4,4 4,4 0,2 4,0 0))", true); + + // Self tangent in corner + test_self_intersects("POLYGON((0 0,0 4,4 4,4 0,0 4,2 0,0 0))", true); + + // With spike + test_self_intersects("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((0 0,0 4,4 0,4 0,0 0))", false); + + // With many duplicates + test_self_intersects( + "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((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((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((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(0 0,0 4,4 4,2 2,2 5)", true); + + test_self_intersects >( + "LINESTRING(0 4,4 4,2 2,2 5)", true); + + // Test self-intersections at last segment in close/open rings: + test_self_intersects >( + "POLYGON((0 0,3 3,4 1,0 0))", false); + + test_self_intersects >( + "POLYGON((0 0,3 3,4 1))", false); + + test_self_intersects >( + "POLYGON((0 0,3 3,4 1,0 1,0 0))", true); + + test_self_intersects >( + "POLYGON((0 0,3 3,4 1,0 1))", true); + + // Duplicates in first or last + test_self_intersects >( + "POLYGON((0 0,3 3,4 1,0 1,0 1,0 0))", true); + test_self_intersects >( + "POLYGON((0 0,3 3,4 1,0 1,0 0,0 0))", true); + test_self_intersects >( + "POLYGON((0 0,3 3,4 1,0 1,0 1))", true); + test_self_intersects >( + "POLYGON((0 0,0 0,3 3,4 1,0 1,0 1,0 0))", true); + test_self_intersects >( + "POLYGON((0 0,0 0,3 3,4 1,0 1,0 1))", true); + test_self_intersects >( + "POLYGON((0 0,3 3,3 3,4 1,0 1,0 1,0 0))", true); + test_self_intersects >( + "POLYGON((0 0,3 3,3 3,4 1,0 1,0 1))", true); + + test_self_intersects >( + "POLYGON((0 0,3 3,4 1,0 0,0 0))", false); + test_self_intersects >( + "POLYGON((0 0,3 3,4 1,4 1,0 0))", false); + test_self_intersects >( + "POLYGON((0 0,3 3,4 1,4 1))", false); + test_self_intersects >( + "POLYGON((0 0,0 0,3 3,4 1,0 0))", false); + test_self_intersects >( + "POLYGON((0 0,0 0,3 3,4 1))", false); + test_self_intersects >( + "POLYGON((0 0,3 3,3 3,4 1,0 0))", false); + test_self_intersects >( + "POLYGON((0 0,3 3,3 3,4 1))", false); +} + +int test_main( int , char* [] ) +{ + test_all >(); + +#if ! defined(BOOST_GEOMETRY_RESCALE_TO_ROBUST) + test_all > >(); +#endif + +#if defined(HAVE_TTMATH) + test_all >(); +#endif + + return 0; +} diff --git a/test/algorithms/relational_operations/test_intersects.hpp b/test/algorithms/relational_operations/intersects/test_intersects.hpp similarity index 100% rename from test/algorithms/relational_operations/test_intersects.hpp rename to test/algorithms/relational_operations/intersects/test_intersects.hpp From e660e9fb1972536a42e44ea76f37ab8f2a6c45ec Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Mon, 15 Jun 2015 03:53:01 +0200 Subject: [PATCH 06/18] [test][overlaps] Group the tests in separate files. --- .../relational_operations/Jamfile.v2 | 2 +- .../relational_operations/overlaps/Jamfile.v2 | 23 +++++++ .../overlaps/overlaps.cpp | 56 ++++++++++++++++ .../overlaps_areal.cpp} | 61 +----------------- .../overlaps/overlaps_box.cpp | 64 +++++++++++++++++++ .../{ => overlaps}/test_overlaps.hpp | 0 6 files changed, 145 insertions(+), 61 deletions(-) create mode 100644 test/algorithms/relational_operations/overlaps/Jamfile.v2 create mode 100644 test/algorithms/relational_operations/overlaps/overlaps.cpp rename test/algorithms/relational_operations/{overlaps.cpp => overlaps/overlaps_areal.cpp} (53%) create mode 100644 test/algorithms/relational_operations/overlaps/overlaps_box.cpp rename test/algorithms/relational_operations/{ => overlaps}/test_overlaps.hpp (100%) diff --git a/test/algorithms/relational_operations/Jamfile.v2 b/test/algorithms/relational_operations/Jamfile.v2 index b6955f5dc..cc94fd560 100644 --- a/test/algorithms/relational_operations/Jamfile.v2 +++ b/test/algorithms/relational_operations/Jamfile.v2 @@ -22,12 +22,12 @@ test-suite boost-geometry-algorithms-relational [ run equals.cpp : : : : algorithms_equals ] [ run equals_multi.cpp : : : : algorithms_equals_multi ] [ run equals_on_spheroid.cpp : : : : algorithms_equals_on_spheroid ] - [ run overlaps.cpp : : : : algorithms_overlaps ] [ run touches.cpp : : : : algorithms_touches ] [ run touches_multi.cpp : : : : algorithms_touches_multi ] ; build-project disjoint ; build-project intersects ; +build-project overlaps ; build-project relate ; build-project within ; diff --git a/test/algorithms/relational_operations/overlaps/Jamfile.v2 b/test/algorithms/relational_operations/overlaps/Jamfile.v2 new file mode 100644 index 000000000..2f9410b62 --- /dev/null +++ b/test/algorithms/relational_operations/overlaps/Jamfile.v2 @@ -0,0 +1,23 @@ +# 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. +# Modifications copyright (c) 2014-2015, 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-relational-overlaps + : + [ run overlaps.cpp : : : : algorithms_overlaps ] + [ run overlaps_areal.cpp : : : : algorithms_overlaps_areal ] + [ run overlaps_box.cpp : : : : algorithms_overlaps_box ] + ; + diff --git a/test/algorithms/relational_operations/overlaps/overlaps.cpp b/test/algorithms/relational_operations/overlaps/overlaps.cpp new file mode 100644 index 000000000..c6407f756 --- /dev/null +++ b/test/algorithms/relational_operations/overlaps/overlaps.cpp @@ -0,0 +1,56 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. + +// This file was modified by Oracle on 2014, 2015. +// Modifications copyright (c) 2014-2015 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_overlaps.hpp" + +template +void test_pp() +{ + typedef bg::model::multi_point

mpt; + + test_geometry("MULTIPOINT(0 0,1 1,2 2)", "MULTIPOINT(1 1,3 3,4 4)", true); + test_geometry("MULTIPOINT(0 0,1 1,2 2)", "MULTIPOINT(1 1,2 2)", false); +} + +template +void test_ll() +{ + typedef bg::model::linestring

ls; + typedef bg::model::multi_linestring mls; + + test_geometry("LINESTRING(0 0,2 2,3 1)", "LINESTRING(1 1,2 2,4 4)", true); + test_geometry("LINESTRING(0 0,2 2,4 0)", "LINESTRING(0 1,2 1,3 2)", false); + + test_geometry("LINESTRING(0 0,2 2,3 1)", "MULTILINESTRING((1 1,2 2),(2 2,4 4))", true); + test_geometry("LINESTRING(0 0,2 2,3 1)", "MULTILINESTRING((1 1,2 2),(3 3,4 4))", true); + test_geometry("LINESTRING(0 0,3 3,3 1)", "MULTILINESTRING((3 3,2 2),(0 0,1 1))", false); +} + +template +void test_2d() +{ + test_pp

(); + test_ll

(); +} + +int test_main( int , char* [] ) +{ + test_2d >(); + test_2d >(); + +#if defined(HAVE_TTMATH) + test_2d >(); +#endif + + return 0; +} diff --git a/test/algorithms/relational_operations/overlaps.cpp b/test/algorithms/relational_operations/overlaps/overlaps_areal.cpp similarity index 53% rename from test/algorithms/relational_operations/overlaps.cpp rename to test/algorithms/relational_operations/overlaps/overlaps_areal.cpp index 3d627af43..c41da0639 100644 --- a/test/algorithms/relational_operations/overlaps.cpp +++ b/test/algorithms/relational_operations/overlaps/overlaps_areal.cpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. // This file was modified by Oracle on 2014, 2015. // Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. @@ -13,59 +13,6 @@ #include "test_overlaps.hpp" -template -void test_box_box_2d() -{ -#if defined(BOOST_GEOMETRY_COMPILE_FAIL) - test_geometry("POINT(1 1)", "POINT(1 1)", true); -#endif - - test_geometry, bg::model::box

>("BOX(1 1, 3 3)", "BOX(0 0,2 2)", true); - - // touch -> false - test_geometry, bg::model::box

>("BOX(1 1, 3 3)", "BOX(3 3,5 5)", false); - - // disjoint -> false - test_geometry, bg::model::box

>("BOX(1 1, 3 3)", "BOX(4 4,6 6)", false); - - // within -> false - test_geometry, bg::model::box

>("BOX(1 1, 5 5)", "BOX(2 2,3 3)", false); - - // within+touch -> false - test_geometry, bg::model::box

>("BOX(1 1, 5 5)", "BOX(2 2,5 5)", false); -} - -template -void test_3d() -{ - test_geometry, bg::model::box

>("BOX(1 1 1, 3 3 3)", "BOX(0 0 0,2 2 2)", true); - test_geometry, bg::model::box

>("BOX(1 1 1, 3 3 3)", "BOX(3 3 3,5 5 5)", false); - test_geometry, bg::model::box

>("BOX(1 1 1, 3 3 3)", "BOX(4 4 4,6 6 6)", false); -} - -template -void test_pp() -{ - typedef bg::model::multi_point

mpt; - - test_geometry("MULTIPOINT(0 0,1 1,2 2)", "MULTIPOINT(1 1,3 3,4 4)", true); - test_geometry("MULTIPOINT(0 0,1 1,2 2)", "MULTIPOINT(1 1,2 2)", false); -} - -template -void test_ll() -{ - typedef bg::model::linestring

ls; - typedef bg::model::multi_linestring mls; - - test_geometry("LINESTRING(0 0,2 2,3 1)", "LINESTRING(1 1,2 2,4 4)", true); - test_geometry("LINESTRING(0 0,2 2,4 0)", "LINESTRING(0 1,2 1,3 2)", false); - - test_geometry("LINESTRING(0 0,2 2,3 1)", "MULTILINESTRING((1 1,2 2),(2 2,4 4))", true); - test_geometry("LINESTRING(0 0,2 2,3 1)", "MULTILINESTRING((1 1,2 2),(3 3,4 4))", true); - test_geometry("LINESTRING(0 0,3 3,3 1)", "MULTILINESTRING((3 3,2 2),(0 0,1 1))", false); -} - template void test_aa() { @@ -102,11 +49,7 @@ void test_aa() template void test_2d() { - test_pp

(); - test_ll

(); test_aa

(); - - test_box_box_2d

(); } int test_main( int , char* [] ) @@ -118,7 +61,5 @@ int test_main( int , char* [] ) test_2d >(); #endif - //test_3d >(); - return 0; } diff --git a/test/algorithms/relational_operations/overlaps/overlaps_box.cpp b/test/algorithms/relational_operations/overlaps/overlaps_box.cpp new file mode 100644 index 000000000..c80ff6de4 --- /dev/null +++ b/test/algorithms/relational_operations/overlaps/overlaps_box.cpp @@ -0,0 +1,64 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. + +// This file was modified by Oracle on 2014, 2015. +// Modifications copyright (c) 2014-2015 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_overlaps.hpp" + +template +void test_box_box_2d() +{ +#if defined(BOOST_GEOMETRY_COMPILE_FAIL) + test_geometry("POINT(1 1)", "POINT(1 1)", true); +#endif + + test_geometry, bg::model::box

>("BOX(1 1, 3 3)", "BOX(0 0,2 2)", true); + + // touch -> false + test_geometry, bg::model::box

>("BOX(1 1, 3 3)", "BOX(3 3,5 5)", false); + + // disjoint -> false + test_geometry, bg::model::box

>("BOX(1 1, 3 3)", "BOX(4 4,6 6)", false); + + // within -> false + test_geometry, bg::model::box

>("BOX(1 1, 5 5)", "BOX(2 2,3 3)", false); + + // within+touch -> false + test_geometry, bg::model::box

>("BOX(1 1, 5 5)", "BOX(2 2,5 5)", false); +} + +template +void test_3d() +{ + test_geometry, bg::model::box

>("BOX(1 1 1, 3 3 3)", "BOX(0 0 0,2 2 2)", true); + test_geometry, bg::model::box

>("BOX(1 1 1, 3 3 3)", "BOX(3 3 3,5 5 5)", false); + test_geometry, bg::model::box

>("BOX(1 1 1, 3 3 3)", "BOX(4 4 4,6 6 6)", false); +} + +template +void test_2d() +{ + test_box_box_2d

(); +} + +int test_main( int , char* [] ) +{ + test_2d >(); + test_2d >(); + +#if defined(HAVE_TTMATH) + test_2d >(); +#endif + + //test_3d >(); + + return 0; +} diff --git a/test/algorithms/relational_operations/test_overlaps.hpp b/test/algorithms/relational_operations/overlaps/test_overlaps.hpp similarity index 100% rename from test/algorithms/relational_operations/test_overlaps.hpp rename to test/algorithms/relational_operations/overlaps/test_overlaps.hpp From dd3f58194c7d2d63bc53a6bbdcc7e3cbfc985630 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Mon, 15 Jun 2015 13:44:08 +0200 Subject: [PATCH 07/18] [test][touches] Group the tests in separate files. --- .../relational_operations/Jamfile.v2 | 3 +- .../relational_operations/touches/Jamfile.v2 | 23 +++++++ .../{ => touches}/test_touches.hpp | 0 .../{ => touches}/touches.cpp | 47 ++------------ .../touches/touches_box.cpp | 65 +++++++++++++++++++ .../{ => touches}/touches_multi.cpp | 0 .../touches/touches_self.cpp | 43 ++++++++++++ 7 files changed, 137 insertions(+), 44 deletions(-) create mode 100644 test/algorithms/relational_operations/touches/Jamfile.v2 rename test/algorithms/relational_operations/{ => touches}/test_touches.hpp (100%) rename test/algorithms/relational_operations/{ => touches}/touches.cpp (82%) create mode 100644 test/algorithms/relational_operations/touches/touches_box.cpp rename test/algorithms/relational_operations/{ => touches}/touches_multi.cpp (100%) create mode 100644 test/algorithms/relational_operations/touches/touches_self.cpp diff --git a/test/algorithms/relational_operations/Jamfile.v2 b/test/algorithms/relational_operations/Jamfile.v2 index cc94fd560..89ce7c88b 100644 --- a/test/algorithms/relational_operations/Jamfile.v2 +++ b/test/algorithms/relational_operations/Jamfile.v2 @@ -22,12 +22,11 @@ test-suite boost-geometry-algorithms-relational [ run equals.cpp : : : : algorithms_equals ] [ run equals_multi.cpp : : : : algorithms_equals_multi ] [ run equals_on_spheroid.cpp : : : : algorithms_equals_on_spheroid ] - [ run touches.cpp : : : : algorithms_touches ] - [ run touches_multi.cpp : : : : algorithms_touches_multi ] ; build-project disjoint ; build-project intersects ; build-project overlaps ; build-project relate ; +build-project touches ; build-project within ; diff --git a/test/algorithms/relational_operations/touches/Jamfile.v2 b/test/algorithms/relational_operations/touches/Jamfile.v2 new file mode 100644 index 000000000..b2d6afef8 --- /dev/null +++ b/test/algorithms/relational_operations/touches/Jamfile.v2 @@ -0,0 +1,23 @@ +# 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. +# Modifications copyright (c) 2014-2015, 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-relational-touches + : + [ run touches.cpp : : : : algorithms_touches ] + [ run touches_box.cpp : : : : algorithms_touches_box ] + [ run touches_multi.cpp : : : : algorithms_touches_multi ] + [ run touches_self.cpp : : : : algorithms_touches_self ] + ; diff --git a/test/algorithms/relational_operations/test_touches.hpp b/test/algorithms/relational_operations/touches/test_touches.hpp similarity index 100% rename from test/algorithms/relational_operations/test_touches.hpp rename to test/algorithms/relational_operations/touches/test_touches.hpp diff --git a/test/algorithms/relational_operations/touches.cpp b/test/algorithms/relational_operations/touches/touches.cpp similarity index 82% rename from test/algorithms/relational_operations/touches.cpp rename to test/algorithms/relational_operations/touches/touches.cpp index d7a92c8e0..88a0cc269 100644 --- a/test/algorithms/relational_operations/touches.cpp +++ b/test/algorithms/relational_operations/touches/touches.cpp @@ -1,40 +1,27 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // -// Copyright (c) 2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2012-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2013, 2014. -// Modifications copyright (c) 2013, 2014, Oracle and/or its affiliates. +// This file was modified by Oracle on 2013, 2014. 2015. +// Modifications copyright (c) 2013-2015, 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) -// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle - #include "test_touches.hpp" template void test_all() { - typedef bg::model::box

box; typedef bg::model::ring

ring; typedef bg::model::polygon

polygon; typedef bg::model::linestring

linestring; typedef bg::model::multi_polygon mpolygon; typedef bg::model::multi_linestring mlinestring; - // Just a normal polygon - test_self_touches("POLYGON((0 0,0 4,1.5 2.5,2.5 1.5,4 0,0 0))", false); - - // Self intersecting - test_self_touches("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))", false); - - // Self touching at a point - test_self_touches("POLYGON((0 0,0 3,2 3,2 2,1 2,1 1,2 1,2 2,3 2,3 0,0 0))", true); - - // Self touching at a segment - test_self_touches("POLYGON((0 0,0 3,2 3,2 2,1 2,1 1,2 1,2 2.5,3 2.5,3 0,0 0))", true); - // Touching at corner test_touches ( @@ -196,35 +183,11 @@ void test_all() test_touches("LINESTRING(-1 -1,3 3)", "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(0 0,9 1,9 9,1 9,0 0)))", true); test_touches("MULTILINESTRING((0 0,11 11))", "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(0 0,9 1,9 9,1 9,0 0)))", false); - - test_touches("POLYGON((0 0,0 5,5 5,5 0,0 0))", "POLYGON((5 1,5 2,6 2,6 1,5 1))", true); - test_touches("POLYGON((0 0,0 5,5 5,5 0,0 0))", "POLYGON((4 1,4 2,5 2,5 1,4 1))", false); - test_touches("POLYGON((0 0,0 5,5 5,5 0,0 0))", "POLYGON((4 1,4 2,6 2,6 1,4 1))", false); - - // Point-size - test_touches("POLYGON((0 0,0 5,5 5,5 0,0 0))", "POLYGON((5 5,5 5,5 5,5 5,5 5))", true); - // TODO: should it be TRUE? - test_touches("POLYGON((5 5,5 5,5 5,5 5,5 5))", "POLYGON((5 5,5 5,5 5,5 5,5 5))", true); -} - -template -void test_box_3d() -{ - typedef bg::model::box

box; - - check_touches(box(P(0,0,0),P(5,5,5)), box(P(5,1,2),P(6,6,6)), - "box(P(0,0,0),P(5,5,5))", "box(P(5,1,2),P(6,6,6))", - true); - - check_touches(box(P(0,0,0),P(5,5,5)), box(P(5,5,5),P(6,6,6)), - "box(P(0,0,0),P(5,5,5))", "box(P(5,5,5),P(6,6,6))", - true); } int test_main( int , char* [] ) { test_all >(); - test_box_3d >(); #if defined(HAVE_TTMATH) test_all >(); diff --git a/test/algorithms/relational_operations/touches/touches_box.cpp b/test/algorithms/relational_operations/touches/touches_box.cpp new file mode 100644 index 000000000..4e8b932f1 --- /dev/null +++ b/test/algorithms/relational_operations/touches/touches_box.cpp @@ -0,0 +1,65 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright (c) 2012-2015 Barend Gehrels, Amsterdam, the Netherlands. + +// This file was modified by Oracle on 2013, 2014. 2015. +// Modifications copyright (c) 2013-2015, 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_touches.hpp" + +template +void test_all() +{ + typedef bg::model::box

box; + + test_touches("POLYGON((0 0,0 5,5 5,5 0,0 0))", "POLYGON((5 1,5 2,6 2,6 1,5 1))", true); + test_touches("POLYGON((0 0,0 5,5 5,5 0,0 0))", "POLYGON((4 1,4 2,5 2,5 1,4 1))", false); + test_touches("POLYGON((0 0,0 5,5 5,5 0,0 0))", "POLYGON((4 1,4 2,6 2,6 1,4 1))", false); + + // Point-size + test_touches("POLYGON((0 0,0 5,5 5,5 0,0 0))", "POLYGON((5 5,5 5,5 5,5 5,5 5))", true); + // TODO: should it be TRUE? + test_touches("POLYGON((5 5,5 5,5 5,5 5,5 5))", "POLYGON((5 5,5 5,5 5,5 5,5 5))", true); +} + +template +void test_box_3d() +{ + typedef bg::model::box

box; + + check_touches(box(P(0,0,0),P(5,5,5)), box(P(5,1,2),P(6,6,6)), + "box(P(0,0,0),P(5,5,5))", "box(P(5,1,2),P(6,6,6))", + true); + + check_touches(box(P(0,0,0),P(5,5,5)), box(P(5,5,5),P(6,6,6)), + "box(P(0,0,0),P(5,5,5))", "box(P(5,5,5),P(6,6,6))", + true); +} + +int test_main( int , char* [] ) +{ + test_all >(); + test_box_3d >(); + +#if defined(HAVE_TTMATH) + test_all >(); +#endif + + return 0; +} + +/* +with viewy as +( +select geometry::STGeomFromText('POLYGON((0 0,0 100,100 100,100 0,0 0))',0) as p + , geometry::STGeomFromText('POLYGON((200 0,100 50,200 100,200 0))',0) as q +) +-- select p from viewy union all select q from viewy +select p.STTouches(q) from viewy +*/ diff --git a/test/algorithms/relational_operations/touches_multi.cpp b/test/algorithms/relational_operations/touches/touches_multi.cpp similarity index 100% rename from test/algorithms/relational_operations/touches_multi.cpp rename to test/algorithms/relational_operations/touches/touches_multi.cpp diff --git a/test/algorithms/relational_operations/touches/touches_self.cpp b/test/algorithms/relational_operations/touches/touches_self.cpp new file mode 100644 index 000000000..00ea47daa --- /dev/null +++ b/test/algorithms/relational_operations/touches/touches_self.cpp @@ -0,0 +1,43 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright (c) 2012-2015 Barend Gehrels, Amsterdam, the Netherlands. + +// This file was modified by Oracle on 2013, 2014. 2015. +// Modifications copyright (c) 2013-2015, 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_touches.hpp" + +template +void test_all() +{ + typedef bg::model::polygon

polygon; + + // Just a normal polygon + test_self_touches("POLYGON((0 0,0 4,1.5 2.5,2.5 1.5,4 0,0 0))", false); + + // Self intersecting + test_self_touches("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))", false); + + // Self touching at a point + test_self_touches("POLYGON((0 0,0 3,2 3,2 2,1 2,1 1,2 1,2 2,3 2,3 0,0 0))", true); + + // Self touching at a segment + test_self_touches("POLYGON((0 0,0 3,2 3,2 2,1 2,1 1,2 1,2 2.5,3 2.5,3 0,0 0))", true); +} + +int test_main( int , char* [] ) +{ + test_all >(); + +#if defined(HAVE_TTMATH) + test_all >(); +#endif + + return 0; +} From 7ddb2eca092202a281d7abc8c9e1bd4bf73c9756 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Mon, 15 Jun 2015 16:46:57 +0200 Subject: [PATCH 08/18] [test][disjoint] Group the tests in separate files. --- .../relational_operations/disjoint/Jamfile.v2 | 12 +- .../disjoint/disjoint.cpp | 81 +- .../disjoint/disjoint_coverage.cpp | 1759 ----------------- .../disjoint/disjoint_coverage_a_a.cpp | 387 ++++ .../disjoint/disjoint_coverage_l_a.cpp | 538 +++++ .../disjoint/disjoint_coverage_l_l.cpp | 379 ++++ .../disjoint/disjoint_coverage_p_a.cpp | 291 +++ .../disjoint/disjoint_coverage_p_l.cpp | 391 ++++ .../disjoint/disjoint_coverage_p_p.cpp | 169 ++ .../disjoint/disjoint_point_box_geometry.cpp | 127 ++ 10 files changed, 2299 insertions(+), 1835 deletions(-) delete mode 100644 test/algorithms/relational_operations/disjoint/disjoint_coverage.cpp create mode 100644 test/algorithms/relational_operations/disjoint/disjoint_coverage_a_a.cpp create mode 100644 test/algorithms/relational_operations/disjoint/disjoint_coverage_l_a.cpp create mode 100644 test/algorithms/relational_operations/disjoint/disjoint_coverage_l_l.cpp create mode 100644 test/algorithms/relational_operations/disjoint/disjoint_coverage_p_a.cpp create mode 100644 test/algorithms/relational_operations/disjoint/disjoint_coverage_p_l.cpp create mode 100644 test/algorithms/relational_operations/disjoint/disjoint_coverage_p_p.cpp create mode 100644 test/algorithms/relational_operations/disjoint/disjoint_point_box_geometry.cpp diff --git a/test/algorithms/relational_operations/disjoint/Jamfile.v2 b/test/algorithms/relational_operations/disjoint/Jamfile.v2 index f05fff767..ef3122f91 100644 --- a/test/algorithms/relational_operations/disjoint/Jamfile.v2 +++ b/test/algorithms/relational_operations/disjoint/Jamfile.v2 @@ -16,7 +16,13 @@ test-suite boost-geometry-algorithms-disjoint : - [ run disjoint.cpp : : : : algorithms_disjoint ] - [ run disjoint_coverage.cpp : : : : algorithms_disjoint_coverage ] - [ run disjoint_multi.cpp : : : : algorithms_disjoint_multi ] + [ run disjoint.cpp : : : : algorithms_disjoint ] + [ run disjoint_coverage_a_a.cpp : : : : algorithms_disjoint_coverage_a_a ] + [ run disjoint_coverage_l_a.cpp : : : : algorithms_disjoint_coverage_l_a ] + [ run disjoint_coverage_l_l.cpp : : : : algorithms_disjoint_coverage_l_l ] + [ run disjoint_coverage_p_a.cpp : : : : algorithms_disjoint_coverage_p_a ] + [ run disjoint_coverage_p_l.cpp : : : : algorithms_disjoint_coverage_p_l ] + [ run disjoint_coverage_p_p.cpp : : : : algorithms_disjoint_coverage_p_p ] + [ run disjoint_multi.cpp : : : : algorithms_disjoint_multi ] + [ run disjoint_point_box_geometry.cpp : : : : algorithms_disjoint_point_box_geometry ] ; diff --git a/test/algorithms/relational_operations/disjoint/disjoint.cpp b/test/algorithms/relational_operations/disjoint/disjoint.cpp index 7299af406..2d0225daf 100644 --- a/test/algorithms/relational_operations/disjoint/disjoint.cpp +++ b/test/algorithms/relational_operations/disjoint/disjoint.cpp @@ -1,9 +1,14 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test -// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2012 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +// 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 2015. +// Modifications copyright (c) 2015, Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -29,33 +34,6 @@ template void test_all() { - typedef bg::model::box

box; - - test_disjoint("pp1", "point(1 1)", "point(1 1)", false); - test_disjoint("pp2", "point(1 1)", "point(1.001 1)", true); - - // left-right - test_disjoint("bb1", "box(1 1, 2 2)", "box(3 1, 4 2)", true); - test_disjoint("bb2", "box(1 1, 2 2)", "box(2 1, 3 2)", false); - test_disjoint("bb3", "box(1 1, 2 2)", "box(2 2, 3 3)", false); - test_disjoint("bb4", "box(1 1, 2 2)", "box(2.001 2, 3 3)", true); - - // up-down - test_disjoint("bb5", "box(1 1, 2 2)", "box(1 3, 2 4)", true); - test_disjoint("bb6", "box(1 1, 2 2)", "box(1 2, 2 3)", false); - // right-left - test_disjoint("bb7", "box(1 1, 2 2)", "box(0 1, 1 2)", false); - test_disjoint("bb8", "box(1 1, 2 2)", "box(0 1, 1 2)", false); - - // point-box - test_disjoint("pb1", "point(1 1)", "box(0 0, 2 2)", false); - test_disjoint("pb2", "point(2 2)", "box(0 0, 2 2)", false); - test_disjoint("pb3", "point(2.0001 2)", "box(1 1, 2 2)", true); - test_disjoint("pb4", "point(0.9999 2)", "box(1 1, 2 2)", true); - - // box-point (to test reverse compiling) - test_disjoint("bp1", "box(1 1, 2 2)", "point(2 2)", false); - // Test triangles for polygons/rings, boxes // Note that intersections are tested elsewhere, they don't need // thorough test at this place @@ -75,27 +53,10 @@ void test_all() // Testing touch test_disjoint("touch_simplex_pp", touch_simplex[0], touch_simplex[1], false); - // Testing overlap (and test compiling with box) - test_disjoint("overlaps_box_pp", overlaps_box[0], overlaps_box[1], false); - test_disjoint("overlaps_box_bp", overlaps_box[0], overlaps_box[1], false); - test_disjoint("overlaps_box_br", overlaps_box[0], overlaps_box[1], false); - test_disjoint("overlaps_box_pb", overlaps_box[1], overlaps_box[0], false); - test_disjoint("overlaps_box_rb", overlaps_box[1], overlaps_box[0], false); - // Test if within(a,b) returns false for disjoint test_disjoint("within_simplex_rr1", within_simplex[0], within_simplex[1], false); test_disjoint("within_simplex_rr2", within_simplex[1], within_simplex[0], false); - test_disjoint("point_ring1", "POINT(0 0)", "POLYGON((0 0,3 3,6 0,0 0))", false); - test_disjoint("point_ring2", "POINT(3 1)", "POLYGON((0 0,3 3,6 0,0 0))", false); - test_disjoint("point_ring3", "POINT(0 3)", "POLYGON((0 0,3 3,6 0,0 0))", true); - test_disjoint("point_polygon1", "POINT(0 0)", "POLYGON((0 0,3 3,6 0,0 0))", false); - test_disjoint("point_polygon2", "POINT(3 1)", "POLYGON((0 0,3 3,6 0,0 0))", false); - test_disjoint("point_polygon3", "POINT(0 3)", "POLYGON((0 0,3 3,6 0,0 0))", true); - - test_disjoint("point_ring2", "POLYGON((0 0,3 3,6 0,0 0))", "POINT(0 0)", false); - test_disjoint("point_polygon2", "POLYGON((0 0,3 3,6 0,0 0))", "POINT(0 0)", false); - // Linear typedef bg::model::linestring

ls; typedef bg::model::segment

segment; @@ -116,15 +77,6 @@ void test_all() test_disjoint("ls/ls co-e", "linestring(0 0,1 1)", "linestring(1 1,0 0)", false); - // Problem described by Volker/Albert 2012-06-01 - test_disjoint("volker_albert_1", - "POLYGON((1992 3240,1992 1440,3792 1800,3792 3240,1992 3240))", - "BOX(1941 2066, 2055 2166)", false); - - test_disjoint("volker_albert_2", - "POLYGON((1941 2066,2055 2066,2055 2166,1941 2166))", - "BOX(1941 2066, 2055 2166)", false); - // Degenerate linestrings { // Submitted by Zachary on the Boost.Geometry Mailing List, on 2012-01-29 @@ -199,21 +151,6 @@ void test_all() } -template -void test_3d() -{ - typedef bg::model::box

box; - - test_disjoint("pp 3d 1", "point(1 1 1)", "point(1 1 1)", false); - test_disjoint("pp 3d 2", "point(1 1 1)", "point(1.001 1 1)", true); - - test_disjoint("bb1", "box(1 1 1, 2 2 2)", "box(3 1 1, 4 2 1)", true); - test_disjoint("bb2", "box(1 1 1, 2 2 2)", "box(2 1 1, 3 2 1)", false); - test_disjoint("bb3", "box(1 1 1, 2 2 2)", "box(2 2 1, 3 3 1)", false); - test_disjoint("bb4", "box(1 1 1, 2 2 2)", "box(2.001 2 1, 3 3 1)", true); - -} - int test_main(int, char* []) { test_all >(); @@ -223,8 +160,6 @@ int test_main(int, char* []) test_all >(); #endif - test_3d >(); - return 0; } diff --git a/test/algorithms/relational_operations/disjoint/disjoint_coverage.cpp b/test/algorithms/relational_operations/disjoint/disjoint_coverage.cpp deleted file mode 100644 index d0d6bdc40..000000000 --- a/test/algorithms/relational_operations/disjoint/disjoint_coverage.cpp +++ /dev/null @@ -1,1759 +0,0 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) - -// Copyright (c) 2014-2015, Oracle and/or its affiliates. - -// Licensed under the Boost Software License version 1.0. -// http://www.boost.org/users/license.html - -// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle - -#ifndef BOOST_TEST_MODULE -#define BOOST_TEST_MODULE test_disjoint_coverage -#endif - -// unit test to test disjoint for all geometry combinations - -#include - -#include - -#include -#include - -#include - -#include -#include - -#include - -#include - -#include - - -#ifdef HAVE_TTMATH -#include -#endif - -namespace bg = ::boost::geometry; - -//============================================================================ - -struct test_disjoint -{ - template - static inline void apply(std::string const& case_id, - Geometry1 const& geometry1, - Geometry2 const& geometry2, - bool expected_result) - { - bool result = bg::disjoint(geometry1, geometry2); - BOOST_CHECK_MESSAGE(result == expected_result, - "case ID: " << case_id << ", G1: " << bg::wkt(geometry1) - << ", G2: " << bg::wkt(geometry2) << " -> Expected: " - << expected_result << ", detected: " << result); - - result = bg::disjoint(geometry2, geometry1); - BOOST_CHECK_MESSAGE(result == expected_result, - "case ID: " << case_id << ", G1: " << bg::wkt(geometry2) - << ", G2: " << bg::wkt(geometry1) << " -> Expected: " - << expected_result << ", detected: " << result); - -#ifdef BOOST_GEOMETRY_TEST_DEBUG - std::cout << "case ID: " << case_id << "; G1 - G2: "; - std::cout << bg::wkt(geometry1) << " - "; - std::cout << bg::wkt(geometry2) << std::endl; - std::cout << std::boolalpha; - std::cout << "expected/computed result: " - << expected_result << " / " << result << std::endl; - std::cout << std::endl; - std::cout << std::noboolalpha; -#endif - } -}; - -//============================================================================ - -// pointlike-pointlike geometries -template -inline void test_point_point() -{ - typedef test_disjoint tester; - - tester::apply("p-p-01", - from_wkt

("POINT(0 0)"), - from_wkt

("POINT(0 0)"), - false); - - tester::apply("p-p-02", - from_wkt

("POINT(0 0)"), - from_wkt

("POINT(1 1)"), - true); -} - -template -inline void test_point_multipoint() -{ - typedef bg::model::multi_point

MP; - - typedef test_disjoint tester; - - tester::apply("p-mp-01", - from_wkt

("POINT(0 0)"), - from_wkt("MULTIPOINT(0 0,1 1)"), - false); - - tester::apply("p-mp-02", - from_wkt

("POINT(0 0)"), - from_wkt("MULTIPOINT(1 1,2 2)"), - true); - - tester::apply("p-mp-03", - from_wkt

("POINT(0 0)"), - from_wkt("MULTIPOINT()"), - true); -} - -template -inline void test_multipoint_multipoint() -{ - typedef bg::model::multi_point

MP; - - typedef test_disjoint tester; - - tester::apply("mp-mp-01", - from_wkt("MULTIPOINT(0 0,1 0)"), - from_wkt("MULTIPOINT(0 0,1 1)"), - false); - - tester::apply("mp-mp-02", - from_wkt("MULTIPOINT(0 0,1 0)"), - from_wkt("MULTIPOINT(1 1,2 2)"), - true); - - tester::apply("mp-mp-03", - from_wkt("MULTIPOINT()"), - from_wkt("MULTIPOINT(1 1,2 2)"), - true); - - tester::apply("mp-mp-04", - from_wkt("MULTIPOINT(0 0,1 0)"), - from_wkt("MULTIPOINT()"), - true); -} - -//============================================================================ - -// pointlike-linear geometries -template -inline void test_point_segment() -{ - typedef test_disjoint tester; - typedef bg::model::segment

S; - - tester::apply("p-s-01", - from_wkt

("POINT(0 0)"), - from_wkt("SEGMENT(0 0,2 0)"), - false); - - tester::apply("p-s-02", - from_wkt

("POINT(2 0)"), - from_wkt("SEGMENT(0 0,2 0)"), - false); - - tester::apply("p-s-03", - from_wkt

("POINT(1 0)"), - from_wkt("SEGMENT(0 0,2 0)"), - false); - - tester::apply("p-s-04", - from_wkt

("POINT(1 1)"), - from_wkt("SEGMENT(0 0,2 0)"), - true); - - tester::apply("p-s-05", - from_wkt

("POINT(3 0)"), - from_wkt("SEGMENT(0 0,2 0)"), - true); - - tester::apply("p-s-06", - from_wkt

("POINT(-1 0)"), - from_wkt("SEGMENT(0 0,2 0)"), - true); - - // degenerate segment - tester::apply("p-s-07", - from_wkt

("POINT(-1 0)"), - from_wkt("SEGMENT(2 0,2 0)"), - true); - - // degenerate segment - tester::apply("p-s-08", - from_wkt

("POINT(2 0)"), - from_wkt("SEGMENT(2 0,2 0)"), - false); - - // degenerate segment - tester::apply("p-s-09", - from_wkt

("POINT(3 0)"), - from_wkt("SEGMENT(2 0,2 0)"), - true); - - // degenerate segment - tester::apply("p-s-10", - from_wkt

("POINT(1 1)"), - from_wkt("SEGMENT(2 0,2 0)"), - true); -} - -template -inline void test_point_linestring() -{ - typedef bg::model::linestring

L; - - typedef test_disjoint tester; - - tester::apply("p-l-01", - from_wkt

("POINT(0 0)"), - from_wkt("LINESTRING(0 0,2 2,4 4)"), - false); - - tester::apply("p-l-02", - from_wkt

("POINT(1 1)"), - from_wkt("LINESTRING(0 0,2 2,4 4)"), - false); - - tester::apply("p-l-03", - from_wkt

("POINT(3 3)"), - from_wkt("LINESTRING(0 0,2 2,4 4)"), - false); - - tester::apply("p-l-04", - from_wkt

("POINT(1 0)"), - from_wkt("LINESTRING(0 0,2 2,4 4)"), - true); - - tester::apply("p-l-05", - from_wkt

("POINT(5 5)"), - from_wkt("LINESTRING(0 0,2 2,4 4)"), - true); - - tester::apply("p-l-06", - from_wkt

("POINT(5 5)"), - from_wkt("LINESTRING(0 0,2 2)"), - true); -} - -template -inline void test_point_multilinestring() -{ - typedef bg::model::linestring

L; - typedef bg::model::multi_linestring ML; - - typedef test_disjoint tester; - - tester::apply("p-ml-01", - from_wkt

("POINT(0 1)"), - from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), - true); - - tester::apply("p-ml-02", - from_wkt

("POINT(0 0)"), - from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), - false); - - tester::apply("p-ml-03", - from_wkt

("POINT(1 1)"), - from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), - false); - - tester::apply("p-ml-04", - from_wkt

("POINT(1 0)"), - from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), - false); - - tester::apply("p-ml-05", - from_wkt

("POINT(0 0)"), - from_wkt("MULTILINESTRING((1 1,2 2,4 4),(3 0,4 0))"), - true); - - tester::apply("p-ml-06", - from_wkt

("POINT(0 0)"), - from_wkt("MULTILINESTRING((1 1,2 2,4 4),(0 0,4 0))"), - false); - - tester::apply("p-ml-07", - from_wkt

("POINT(0 0)"), - from_wkt("MULTILINESTRING((1 1,2 2,4 4),(-1 0,4 0))"), - false); -} - -template -inline void test_multipoint_segment() -{ - typedef test_disjoint tester; - typedef bg::model::multi_point

MP; - typedef bg::model::segment

S; - - tester::apply("mp-s-01", - from_wkt("MULTIPOINT(0 0,1 1)"), - from_wkt("SEGMENT(0 0,2 0)"), - false); - - tester::apply("mp-s-02", - from_wkt("MULTIPOINT(1 0,1 1)"), - from_wkt("SEGMENT(0 0,2 0)"), - false); - - tester::apply("mp-s-03", - from_wkt("MULTIPOINT(1 1,2 2)"), - from_wkt("SEGMENT(0 0,2 0)"), - true); - - tester::apply("mp-s-04", - from_wkt("MULTIPOINT()"), - from_wkt("SEGMENT(0 0,2 0)"), - true); - - tester::apply("mp-s-05", - from_wkt("MULTIPOINT(3 0,4 0)"), - from_wkt("SEGMENT(0 0,2 0)"), - true); - - tester::apply("mp-s-06", - from_wkt("MULTIPOINT(1 0,4 0)"), - from_wkt("SEGMENT(0 0,2 0)"), - false); - - // segments that degenerate to a point - tester::apply("mp-s-07", - from_wkt("MULTIPOINT(1 1,2 2)"), - from_wkt("SEGMENT(0 0,0 0)"), - true); - - tester::apply("mp-s-08", - from_wkt("MULTIPOINT(1 1,2 2)"), - from_wkt("SEGMENT(1 1,1 1)"), - false); -} - -template -inline void test_multipoint_linestring() -{ - typedef bg::model::multi_point

MP; - typedef bg::model::linestring

L; - - typedef test_disjoint tester; - - tester::apply("mp-l-01", - from_wkt("MULTIPOINT(0 0,1 0)"), - from_wkt("LINESTRING(0 0,2 2,4 4)"), - false); - - tester::apply("mp-l-02", - from_wkt("MULTIPOINT(1 0,1 1)"), - from_wkt("LINESTRING(0 0,2 2,4 4)"), - false); - - tester::apply("mp-l-03", - from_wkt("MULTIPOINT(1 0,3 3)"), - from_wkt("LINESTRING(0 0,2 2,4 4)"), - false); - - tester::apply("mp-l-04", - from_wkt("MULTIPOINT(1 0,2 0)"), - from_wkt("LINESTRING(0 0,2 2,4 4)"), - true); - - tester::apply("mp-l-05", - from_wkt("MULTIPOINT(-1 -1,2 0)"), - from_wkt("LINESTRING(0 0,2 2,4 4)"), - true); - - tester::apply("mp-l-06", - from_wkt("MULTIPOINT(-1 -1,2 0)"), - from_wkt("LINESTRING(1 0,3 0)"), - false); - - tester::apply("mp-l-07", - from_wkt("MULTIPOINT(-1 -1,2 0,-1 -1,2 0)"), - from_wkt("LINESTRING(1 0,3 0)"), - false); - - tester::apply("mp-l-08", - from_wkt("MULTIPOINT(2 0)"), - from_wkt("LINESTRING(1 0)"), - true); - - tester::apply("mp-l-09", - from_wkt("MULTIPOINT(3 0,0 0,3 0)"), - from_wkt("LINESTRING(1 0,2 0)"), - true); -} - -template -inline void test_multipoint_multilinestring() -{ - typedef bg::model::multi_point

MP; - typedef bg::model::linestring

L; - typedef bg::model::multi_linestring ML; - - typedef test_disjoint tester; - - tester::apply("mp-ml-01", - from_wkt("MULTIPOINT(0 1,0 2)"), - from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), - true); - - tester::apply("mp-ml-02", - from_wkt("MULTIPOINT(0 0,1 0)"), - from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), - false); - - tester::apply("mp-ml-03", - from_wkt("MULTIPOINT(0 1,1 1)"), - from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), - false); - - tester::apply("mp-ml-04", - from_wkt("MULTIPOINT(0 1,1 0)"), - from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), - false); - - tester::apply("mp-ml-05", - from_wkt("MULTIPOINT(0 0,10 0)"), - from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), - false); - - tester::apply("mp-ml-06", - from_wkt("MULTIPOINT(-1 0,3 0)"), - from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), - false); -} - -//============================================================================ - -// pointlike-areal geometries -template -inline void test_point_box() -{ - typedef test_disjoint tester; - typedef bg::model::box

B; - - tester::apply("p-b-01", - from_wkt

("POINT(0 0)"), - from_wkt("BOX(0 0,1 1)"), - false); - - tester::apply("p-b-02", - from_wkt

("POINT(2 2)"), - from_wkt("BOX(0 0,1 0)"), - true); -} - -template -inline void test_point_ring() -{ - typedef bg::model::ring R; // ccw, open - - typedef test_disjoint tester; - - tester::apply("p-r-01", - from_wkt

("POINT(0 0)"), - from_wkt("POLYGON((0 0,1 0,0 1))"), - false); - - tester::apply("p-r-02", - from_wkt

("POINT(1 1)"), - from_wkt("POLYGON((0 0,1 0,0 1))"), - true); -} - -template -inline void test_point_polygon() -{ - typedef bg::model::polygon PL; // ccw, open - - typedef test_disjoint tester; - - tester::apply("p-pg-01", - from_wkt

("POINT(0 0)"), - from_wkt("POLYGON((0 0,1 0,0 1))"), - false); - - tester::apply("p-pg-02", - from_wkt

("POINT(1 1)"), - from_wkt("POLYGON((0 0,1 0,0 1))"), - true); -} - -template -inline void test_point_multipolygon() -{ - typedef bg::model::polygon PL; // ccw, open - typedef bg::model::multi_polygon MPL; - - typedef test_disjoint tester; - - tester::apply("p-mpg-01", - from_wkt

("POINT(0 0)"), - from_wkt("MULTIPOLYGON(((0 0,1 0,0 1)),((2 0,3 0,2 1)))"), - false); - - tester::apply("p-mpg-02", - from_wkt

("POINT(1 1)"), - from_wkt("MULTIPOLYGON(((0 0,1 0,0 1)),((2 0,3 0,2 1)))"), - true); -} - -template -inline void test_multipoint_box() -{ - typedef test_disjoint tester; - typedef bg::model::multi_point

MP; - typedef bg::model::box

B; - - tester::apply("mp-b-01", - from_wkt("MULTIPOINT(0 0,1 1)"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("mp-b-02", - from_wkt("MULTIPOINT(1 1,3 3)"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("mp-b-03", - from_wkt("MULTIPOINT(3 3,4 4)"), - from_wkt("BOX(0 0,2 2)"), - true); - - tester::apply("mp-b-04", - from_wkt("MULTIPOINT()"), - from_wkt("BOX(0 0,2 2)"), - true); -} - -template -inline void test_multipoint_ring() -{ - typedef bg::model::multi_point

MP; - typedef bg::model::ring R; // ccw, open - - typedef test_disjoint tester; - - tester::apply("mp-r-01", - from_wkt("MULTIPOINT(0 0,1 0)"), - from_wkt("POLYGON((0 0,1 0,0 1))"), - false); - - tester::apply("mp-r-02", - from_wkt("MULTIPOINT(1 0,1 1)"), - from_wkt("POLYGON((0 0,1 0,0 1))"), - false); - - tester::apply("mp-r-03", - from_wkt("MULTIPOINT(1 1,2 2)"), - from_wkt("POLYGON((0 0,1 0,0 1))"), - true); -} - -template -inline void test_multipoint_polygon() -{ - typedef bg::model::multi_point

MP; - typedef bg::model::polygon PL; // ccw, open - - typedef test_disjoint tester; - - tester::apply("mp-pg-01", - from_wkt("MULTIPOINT(0 0,1 0)"), - from_wkt("POLYGON(((0 0,1 0,0 1)))"), - false); - - tester::apply("mp-pg-02", - from_wkt("MULTIPOINT(0 0,2 0)"), - from_wkt("POLYGON(((0 0,1 0,0 1)))"), - false); - - tester::apply("mp-pg-03", - from_wkt("MULTIPOINT(1 1,2 0)"), - from_wkt("POLYGON(((0 0,1 0,0 1)))"), - true); - - tester::apply("mp-pg-04", - from_wkt("MULTIPOINT(1 1,2 3)"), - from_wkt("POLYGON(((0 0,1 0,0 1)))"), - true); -} - -template -inline void test_multipoint_multipolygon() -{ - typedef bg::model::multi_point

MP; - typedef bg::model::polygon PL; // ccw, open - typedef bg::model::multi_polygon MPL; - - typedef test_disjoint tester; - - tester::apply("mp-mp-01", - from_wkt("MULTIPOINT(0 0,2 0)"), - from_wkt("MULTIPOLYGON((0 0,1 0,0 1)),(2 0,3 0,2 1))"), - false); - - tester::apply("mp-mp-02", - from_wkt("MULTIPOINT(0 0,1 0)"), - from_wkt("MULTIPOLYGON((0 0,1 0,0 1)),(2 0,3 0,2 1))"), - false); - - tester::apply("mp-mp-03", - from_wkt("MULTIPOINT(1 1,2 0)"), - from_wkt("MULTIPOLYGON((0 0,1 0,0 1)),(2 0,3 0,2 1))"), - false); - - tester::apply("mp-mp-04", - from_wkt("MULTIPOINT(1 1,2 3)"), - from_wkt("MULTIPOLYGON((0 0,1 0,0 1)),(2 0,3 0,2 1))"), - true); -} - -//============================================================================ - -// linear-linear geometries -template -inline void test_segment_segment() -{ - typedef bg::model::segment

S; - - typedef test_disjoint tester; - - tester::apply("s-s-01", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("SEGMENT(0 0,0 2)"), - false); - - tester::apply("s-s-02", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("SEGMENT(2 0,3 0)"), - false); - - tester::apply("s-s-03", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("SEGMENT(1 0,3 0)"), - false); - - tester::apply("s-s-04", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("SEGMENT(1 0,1 1)"), - false); - - tester::apply("s-s-05", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("SEGMENT(1 1,2 2)"), - true); - - tester::apply("s-s-06", - from_wkt("SEGMENT(0 0,1 1)"), - from_wkt("SEGMENT(1 1,1 1)"), - false); - - tester::apply("s-s-07", - from_wkt("SEGMENT(0 0,1 1)"), - from_wkt("SEGMENT(2 2,2 2)"), - true); - - tester::apply("s-s-08", - from_wkt("SEGMENT(0 0,1 1)"), - from_wkt("SEGMENT(2 2,3 3)"), - true); -} - -template -inline void test_linestring_segment() -{ - typedef bg::model::segment

S; - typedef bg::model::linestring

L; - - typedef test_disjoint tester; - - tester::apply("l-s-01", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("LINESTRING(0 0,0 2)"), - false); - - tester::apply("l-s-02", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("LINESTRING(2 0,3 0)"), - false); - - tester::apply("l-s-03", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("LINESTRING(1 0,3 0)"), - false); - - tester::apply("l-s-04", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("LINESTRING(1 0,1 1)"), - false); - - tester::apply("l-s-05", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("LINESTRING(1 1,2 2)"), - true); - - tester::apply("l-s-06", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("LINESTRING(1 1,1 1,2 2)"), - true); - - tester::apply("l-s-07", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("LINESTRING(1 0,1 0,1 1,2 2)"), - false); - - tester::apply("l-s-08", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("LINESTRING(1 0,1 0,3 0)"), - false); - - tester::apply("l-s-09", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("LINESTRING(3 0,3 0,4 0)"), - true); - - tester::apply("l-s-10", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("LINESTRING(3 0,3 0)"), - true); - - tester::apply("l-s-11", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("LINESTRING(-1 0,-1 0)"), - true); - - tester::apply("l-s-12", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("LINESTRING(1 0,1 0)"), - false); - - tester::apply("l-s-13", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("LINESTRING(1 1,1 1)"), - true); -} - -template -inline void test_multilinestring_segment() -{ - typedef bg::model::segment

S; - typedef bg::model::linestring

L; - typedef bg::model::multi_linestring ML; - - typedef test_disjoint tester; - - tester::apply("s-ml-01", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("MULTILINESTRING((0 0,0 2))"), - false); - - tester::apply("s-ml-02", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("MULTILINESTRING((2 0,3 0))"), - false); - - tester::apply("s-ml-03", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("MULTILINESTRING((1 0,3 0))"), - false); - - tester::apply("s-ml-04", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("MULTILINESTRING((1 0,1 1))"), - false); - - tester::apply("s-ml-05", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("MULTILINESTRING((1 1,2 2))"), - true); - - tester::apply("s-ml-06", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("MULTILINESTRING((1 1,2 2),(3 3,3 3))"), - true); - - tester::apply("s-ml-07", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("MULTILINESTRING((1 1,2 2),(1 0,1 0))"), - false); - - tester::apply("s-ml-08", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("MULTILINESTRING((1 1,2 2),(3 0,3 0))"), - true); -} - -template -inline void test_linestring_linestring() -{ - typedef bg::model::linestring

L; - - typedef test_disjoint tester; - - tester::apply("l-l-01", - from_wkt("LINESTRING(0 0,2 0)"), - from_wkt("LINESTRING(0 0,0 2)"), - false); - - tester::apply("l-l-02", - from_wkt("LINESTRING(0 0,2 0)"), - from_wkt("LINESTRING(2 0,3 0)"), - false); - - tester::apply("l-l-03", - from_wkt("LINESTRING(0 0,2 0)"), - from_wkt("LINESTRING(1 0,3 0)"), - false); - - tester::apply("l-l-04", - from_wkt("LINESTRING(0 0,2 0)"), - from_wkt("LINESTRING(1 0,1 1)"), - false); - - tester::apply("l-l-05", - from_wkt("LINESTRING(0 0,2 0)"), - from_wkt("LINESTRING(1 1,2 2)"), - true); -} - -template -inline void test_linestring_multilinestring() -{ - typedef bg::model::linestring

L; - typedef bg::model::multi_linestring ML; - - typedef test_disjoint tester; - - tester::apply("l-ml-01", - from_wkt("LINESTRING(0 0,2 0)"), - from_wkt("MULTILINESTRING((0 0,0 2))"), - false); - - tester::apply("l-ml-02", - from_wkt("LINESTRING(0 0,2 0)"), - from_wkt("MULTILINESTRING((2 0,3 0))"), - false); - - tester::apply("l-ml-03", - from_wkt("LINESTRING(0 0,2 0)"), - from_wkt("MULTILINESTRING((1 0,3 0))"), - false); - - tester::apply("l-ml-04", - from_wkt("LINESTRING(0 0,2 0)"), - from_wkt("MULTILINESTRING((1 0,1 1))"), - false); - - tester::apply("l-ml-05", - from_wkt("LINESTRING(0 0,2 0)"), - from_wkt("MULTILINESTRING((1 1,2 2))"), - true); -} - -template -inline void test_multilinestring_multilinestring() -{ - typedef bg::model::linestring

L; - typedef bg::model::multi_linestring ML; - - typedef test_disjoint tester; - - tester::apply("ml-ml-01", - from_wkt("MULTILINESTRING((0 0,2 0))"), - from_wkt("MULTILINESTRING((0 0,0 2))"), - false); - - tester::apply("ml-ml-02", - from_wkt("MULTILINESTRING((0 0,2 0))"), - from_wkt("MULTILINESTRING((2 0,3 0))"), - false); - - tester::apply("ml-ml-03", - from_wkt("MULTILINESTRING((0 0,2 0))"), - from_wkt("MULTILINESTRING((1 0,3 0))"), - false); - - tester::apply("ml-ml-04", - from_wkt("MULTILINESTRING((0 0,2 0))"), - from_wkt("MULTILINESTRING((1 0,1 1))"), - false); - - tester::apply("ml-ml-05", - from_wkt("MULTILINESTRING((0 0,2 0))"), - from_wkt("MULTILINESTRING((1 1,2 2))"), - true); -} - -//============================================================================ - -// linear-areal geometries -template -inline void test_segment_box() -{ - typedef bg::model::segment

S; - typedef bg::model::box

B; - - typedef test_disjoint tester; - - tester::apply("s-b-01", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("s-b-02", - from_wkt("SEGMENT(1 1,3 3)"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("s-b-03", - from_wkt("SEGMENT(2 2,3 3)"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("s-b-04", - from_wkt("SEGMENT(4 4,3 3)"), - from_wkt("BOX(0 0,2 2)"), - true); - - tester::apply("s-b-05", - from_wkt("SEGMENT(0 4,4 4)"), - from_wkt("BOX(0 0,2 2)"), - true); - - tester::apply("s-b-06", - from_wkt("SEGMENT(4 0,4 4)"), - from_wkt("BOX(0 0,2 2)"), - true); - - tester::apply("s-b-07", - from_wkt("SEGMENT(0 -2,0 -1)"), - from_wkt("BOX(0 0,1 1)"), - true); - - tester::apply("s-b-08", - from_wkt("SEGMENT(-2 -2,-2 -1)"), - from_wkt("BOX(0 0,1 1)"), - true); - - tester::apply("s-b-09", - from_wkt("SEGMENT(-2 -2,-2 -2)"), - from_wkt("BOX(0 0,1 1)"), - true); - - tester::apply("s-b-10", - from_wkt("SEGMENT(-2 0,-2 0)"), - from_wkt("BOX(0 0,1 1)"), - true); - - tester::apply("s-b-11", - from_wkt("SEGMENT(0 -2,0 -2)"), - from_wkt("BOX(0 0,1 1)"), - true); - - tester::apply("s-b-12", - from_wkt("SEGMENT(-2 0,-1 0)"), - from_wkt("BOX(0 0,1 1)"), - true); - - // segment degenerates to a point - tester::apply("s-b-13", - from_wkt("SEGMENT(0 0,0 0)"), - from_wkt("BOX(0 0,1 1)"), - false); - - tester::apply("s-b-14", - from_wkt("SEGMENT(1 1,1 1)"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("s-b-15", - from_wkt("SEGMENT(2 2,2 2)"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("s-b-16", - from_wkt("SEGMENT(2 0,2 0)"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("s-b-17", - from_wkt("SEGMENT(0 2,0 2)"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("s-b-18", - from_wkt("SEGMENT(2 2,2 2)"), - from_wkt("BOX(0 0,1 1)"), - true); -} - -template -inline void test_segment_ring() -{ - typedef bg::model::segment

S; - typedef bg::model::ring R; // ccw, open - - typedef test_disjoint tester; - - tester::apply("s-r-01", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("s-r-02", - from_wkt("SEGMENT(1 0,3 3)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("s-r-03", - from_wkt("SEGMENT(1 1,3 3)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("s-r-04", - from_wkt("SEGMENT(2 2,3 3)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - true); -} - -template -inline void test_segment_polygon() -{ - typedef bg::model::segment

S; - typedef bg::model::polygon PL; // ccw, open - - typedef test_disjoint tester; - - tester::apply("s-pg-01", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("s-pg-02", - from_wkt("SEGMENT(1 0,3 3)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("s-pg-03", - from_wkt("SEGMENT(1 1,3 3)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("s-pg-04", - from_wkt("SEGMENT(2 2,3 3)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - true); -} - -template -inline void test_segment_multipolygon() -{ - typedef bg::model::segment

S; - typedef bg::model::polygon PL; // ccw, open - typedef bg::model::multi_polygon MPL; - - typedef test_disjoint tester; - - tester::apply("s-mpg-01", - from_wkt("SEGMENT(0 0,2 0)"), - from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), - false); - - tester::apply("s-mpg-02", - from_wkt("SEGMENT(1 0,3 3)"), - from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), - false); - - tester::apply("s-mpg-03", - from_wkt("SEGMENT(1 1,3 3)"), - from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), - false); - - tester::apply("s-mpg-04", - from_wkt("SEGMENT(2 2,3 3)"), - from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), - true); -} - -template -inline void test_linestring_box() -{ - typedef bg::model::linestring

L; - typedef bg::model::box

B; - - typedef test_disjoint tester; - - tester::apply("l-b-01", - from_wkt("LINESTRING(0 0,2 0)"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("l-b-02", - from_wkt("LINESTRING(1 1,3 3)"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("l-b-03", - from_wkt("LINESTRING(2 2,3 3)"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("l-b-04", - from_wkt("LINESTRING(4 4,3 3)"), - from_wkt("BOX(0 0,2 2)"), - true); -} - -template -inline void test_linestring_ring() -{ - typedef bg::model::linestring

L; - typedef bg::model::ring R; // ccw, open - - typedef test_disjoint tester; - - tester::apply("l-r-01", - from_wkt("LINESTRING(0 0,2 0)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("l-r-02", - from_wkt("LINESTRING(1 0,3 3)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("l-r-03", - from_wkt("LINESTRING(1 1,3 3)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("l-r-04", - from_wkt("LINESTRING(2 2,3 3)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - true); -} - -template -inline void test_linestring_polygon() -{ - typedef bg::model::linestring

L; - typedef bg::model::polygon PL; // ccw, open - - typedef test_disjoint tester; - - tester::apply("l-pg-01", - from_wkt("LINESTRING(0 0,2 0)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("l-pg-02", - from_wkt("LINESTRING(1 0,3 3)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("l-pg-03", - from_wkt("LINESTRING(1 1,3 3)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("l-pg-04", - from_wkt("LINESTRING(2 2,3 3)"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - true); -} - -template -inline void test_linestring_multipolygon() -{ - typedef bg::model::linestring

L; - typedef bg::model::polygon PL; // ccw, open - typedef bg::model::multi_polygon MPL; - - typedef test_disjoint tester; - - tester::apply("l-mpg-01", - from_wkt("LINESTRING(0 0,2 0)"), - from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), - false); - - tester::apply("l-mpg-02", - from_wkt("LINESTRING(1 0,3 3)"), - from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), - false); - - tester::apply("l-mpg-03", - from_wkt("LINESTRING(1 1,3 3)"), - from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), - false); - - tester::apply("l-mpg-04", - from_wkt("LINESTRING(2 2,3 3)"), - from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), - true); -} - -template -inline void test_multilinestring_box() -{ - typedef bg::model::linestring

L; - typedef bg::model::multi_linestring ML; - typedef bg::model::box

B; - - typedef test_disjoint tester; - - tester::apply("ml-b-01", - from_wkt("MULTILINESTRING((0 0,2 0))"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("ml-b-02", - from_wkt("MULTILINESTRING((1 1,3 3))"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("ml-b-03", - from_wkt("MULTILINESTRING((2 2,3 3))"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("ml-b-04", - from_wkt("MULTILINESTRING((4 4,3 3))"), - from_wkt("BOX(0 0,2 2)"), - true); -} - -template -inline void test_multilinestring_ring() -{ - typedef bg::model::linestring

L; - typedef bg::model::multi_linestring ML; - typedef bg::model::ring R; // ccw, open - - typedef test_disjoint tester; - - tester::apply("ml-r-01", - from_wkt("MULTILINESTRING((0 0,2 0))"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("ml-r-02", - from_wkt("MULTILINESTRING((1 0,3 3))"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("ml-r-03", - from_wkt("MULTILINESTRING((1 1,3 3))"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("ml-r-04", - from_wkt("MULTILINESTRING((2 2,3 3))"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - true); -} - -template -inline void test_multilinestring_polygon() -{ - typedef bg::model::linestring

L; - typedef bg::model::multi_linestring ML; - typedef bg::model::polygon PL; // ccw, open - - typedef test_disjoint tester; - - tester::apply("ml-pg-01", - from_wkt("MULTILINESTRING((0 0,2 0))"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("ml-pg-02", - from_wkt("MULTILINESTRING((1 0,3 3))"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("ml-pg-03", - from_wkt("MULTILINESTRING((1 1,3 3))"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - false); - - tester::apply("ml-pg-04", - from_wkt("MULTILINESTRING((2 2,3 3))"), - from_wkt("POLYGON((0 0,2 0,0 2))"), - true); -} - -template -inline void test_multilinestring_multipolygon() -{ - typedef bg::model::linestring

L; - typedef bg::model::multi_linestring ML; - typedef bg::model::polygon PL; // ccw, open - typedef bg::model::multi_polygon MPL; - - typedef test_disjoint tester; - - tester::apply("ml-mpg-01", - from_wkt("MULTILINESTRING((0 0,2 0))"), - from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), - false); - - tester::apply("ml-mpg-02", - from_wkt("MULTILINESTRING((1 0,3 3))"), - from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), - false); - - tester::apply("ml-mpg-03", - from_wkt("MULTILINESTRING((1 1,3 3))"), - from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), - false); - - tester::apply("ml-mpg-04", - from_wkt("MULTILINESTRING((2 2,3 3))"), - from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), - true); -} - -//============================================================================ - -// areal-areal geometries -template -inline void test_box_box() -{ - typedef bg::model::box

B; - - typedef test_disjoint tester; - - tester::apply("b-b-01", - from_wkt("BOX(2 2,3 3)"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("b-b-02", - from_wkt("BOX(1 1,3 3)"), - from_wkt("BOX(0 0,2 2)"), - false); - - tester::apply("b-b-03", - from_wkt("BOX(3 3,4 4)"), - from_wkt("BOX(0 0,2 2)"), - true); -} - -template -inline void test_ring_box() -{ - typedef bg::model::box

B; - typedef bg::model::ring R; // ccw, open - - typedef test_disjoint tester; - - tester::apply("r-b-01", - from_wkt("BOX(2 2,3 3)"), - from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), - false); - - tester::apply("r-b-02", - from_wkt("BOX(1 1,3 3)"), - from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), - false); - - tester::apply("r-b-03", - from_wkt("BOX(3 3,4 4)"), - from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), - true); -} - -template -inline void test_polygon_box() -{ - typedef bg::model::box

B; - typedef bg::model::polygon PL; // ccw, open - - typedef test_disjoint tester; - - tester::apply("pg-b-01", - from_wkt("BOX(2 2,3 3)"), - from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), - false); - - tester::apply("pg-b-02", - from_wkt("BOX(1 1,3 3)"), - from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), - false); - - tester::apply("pg-b-03", - from_wkt("BOX(3 3,4 4)"), - from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), - true); -} - -template -inline void test_multipolygon_box() -{ - typedef bg::model::box

B; - typedef bg::model::polygon PL; // ccw, open - typedef bg::model::multi_polygon MPL; - - typedef test_disjoint tester; - - tester::apply("mpg-b-01", - from_wkt("BOX(2 2,3 3)"), - from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), - false); - - tester::apply("mpg-b-02", - from_wkt("BOX(1 1,3 3)"), - from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), - false); - - tester::apply("mpg-b-03", - from_wkt("BOX(3 3,4 4)"), - from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), - true); -} - -template -inline void test_ring_ring() -{ - typedef bg::model::ring R; // ccw, open - - typedef test_disjoint tester; - - tester::apply("r-r-01", - from_wkt("POLYGON((2 2,2 3,3 3,3 2))"), - from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), - false); - - tester::apply("r-r-02", - from_wkt("POLYGON((1 1,1 3,3 3,3 1))"), - from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), - false); - - tester::apply("r-r-03", - from_wkt("POLYGON((3 3,3 4,4 4,4 3))"), - from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), - true); -} - -template -inline void test_polygon_ring() -{ - typedef bg::model::ring R; // ccw, open - typedef bg::model::polygon PL; // ccw, open - - typedef test_disjoint tester; - - tester::apply("pg-r-01", - from_wkt("POLYGON((2 2,2 3,3 3,3 2))"), - from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), - false); - - tester::apply("pg-r-02", - from_wkt("POLYGON((1 1,1 3,3 3,3 1))"), - from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), - false); - - tester::apply("pg-r-03", - from_wkt("POLYGON((3 3,3 4,4 4,4 3))"), - from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), - true); -} - -template -inline void test_multipolygon_ring() -{ - typedef bg::model::ring R; // ccw, open - typedef bg::model::polygon PL; // ccw, open - typedef bg::model::multi_polygon MPL; - - typedef test_disjoint tester; - - tester::apply("mpg-r-01", - from_wkt("POLYGON((2 2,2 3,3 3,3 2))"), - from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), - false); - - tester::apply("mpg-r-02", - from_wkt("POLYGON((1 1,1 3,3 3,3 1))"), - from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), - false); - - tester::apply("mpg-r-03", - from_wkt("POLYGON((3 3,3 4,4 4,4 3))"), - from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), - true); -} - -template -inline void test_polygon_polygon() -{ - typedef bg::model::polygon PL; // ccw, open - - typedef test_disjoint tester; - - tester::apply("pg-pg-01", - from_wkt("POLYGON((2 2,2 3,3 3,3 2))"), - from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), - false); - - tester::apply("pg-pg-02", - from_wkt("POLYGON((1 1,1 3,3 3,3 1))"), - from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), - false); - - tester::apply("pg-pg-03", - from_wkt("POLYGON((3 3,3 4,4 4,4 3))"), - from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), - true); - - tester::apply("pg-pg-04", - from_wkt("POLYGON((0 0,9 0,9 9,0 9))"), - from_wkt("POLYGON((3 3,6 3,6 6,3 6))"), - false); - // polygon with a hole which entirely contains the other polygon - tester::apply("pg-pg-05", - from_wkt("POLYGON((0 0,9 0,9 9,0 9),(2 2,2 7,7 7,7 2))"), - from_wkt("POLYGON((3 3,6 3,6 6,3 6))"), - true); - // polygon with a hole, but the inner ring intersects the other polygon - tester::apply("pg-pg-06", - from_wkt("POLYGON((0 0,9 0,9 9,0 9),(3 2,3 7,7 7,7 2))"), - from_wkt("POLYGON((2 3,6 3,6 6,2 6))"), - false); - // polygon with a hole, but the other polygon is entirely contained - // between the inner and outer rings. - tester::apply("pg-pg-07", - from_wkt("POLYGON((0 0,9 0,9 9,0 9),(6 2,6 7,7 7,7 2))"), - from_wkt("POLYGON((3 3,5 3,5 6,3 6))"), - false); - // polygon with a hole and the outer ring of the other polygon lies - // between the inner and outer, but without touching either. - tester::apply("pg-pg-08", - from_wkt("POLYGON((0 0,9 0,9 9,0 9),(3 3,3 6,6 6,6 3))"), - from_wkt("POLYGON((2 2,7 2,7 7,2 7))"), - false); - - { - typedef bg::model::polygon

PL; // cw, closed - - // https://svn.boost.org/trac/boost/ticket/10647 - tester::apply("ticket-10647", - from_wkt("POLYGON((0 0, 0 5, 5 5, 5 0, 0 0)(1 1, 4 1, 4 4, 1 4, 1 1))"), - from_wkt("POLYGON((2 2, 2 3, 3 3, 3 2, 2 2))"), - true); - } -} - -template -inline void test_polygon_multipolygon() -{ - typedef bg::model::polygon PL; // ccw, open - typedef bg::model::multi_polygon MPL; - - typedef test_disjoint tester; - - tester::apply("pg-mpg-01", - from_wkt("POLYGON((2 2,2 3,3 3,3 2))"), - from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), - false); - - tester::apply("pg-mpg-02", - from_wkt("POLYGON((1 1,1 3,3 3,3 1))"), - from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), - false); - - tester::apply("pg-mpg-03", - from_wkt("POLYGON((3 3,3 4,4 4,4 3))"), - from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), - true); -} - -template -inline void test_multipolygon_multipolygon() -{ - typedef bg::model::polygon PL; // ccw, open - typedef bg::model::multi_polygon MPL; - - typedef test_disjoint tester; - - tester::apply("mpg-mpg-01", - from_wkt("MULTIPOLYGON(((2 2,2 3,3 3,3 2)))"), - from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), - false); - - tester::apply("mpg-mpg-02", - from_wkt("MULTIPOLYGON(((1 1,1 3,3 3,3 1)))"), - from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), - false); - - tester::apply("mpg-mpg-03", - from_wkt("MULTIPOLYGON(((3 3,3 4,4 4,4 3)))"), - from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), - true); -} - -//============================================================================ - -template -inline void test_pointlike_pointlike() -{ - typedef bg::model::point point_type; - - test_point_point(); - test_point_multipoint(); - - test_multipoint_multipoint(); -} - -template -inline void test_pointlike_linear() -{ - typedef bg::model::point point_type; - - test_point_linestring(); - test_point_multilinestring(); - test_point_segment(); - - test_multipoint_linestring(); - test_multipoint_multilinestring(); - test_multipoint_segment(); -} - -template -inline void test_pointlike_areal() -{ - typedef bg::model::point point_type; - - test_point_polygon(); - test_point_multipolygon(); - test_point_ring(); - test_point_box(); - - // not implemented yet - // test_multipoint_polygon(); - // test_multipoint_multipolygon(); - // test_multipoint_ring(); - test_multipoint_box(); -} - -template -inline void test_linear_linear() -{ - typedef bg::model::point point_type; - - test_linestring_linestring(); - test_linestring_multilinestring(); - test_linestring_segment(); - - test_multilinestring_multilinestring(); - test_multilinestring_segment(); - - test_segment_segment(); -} - -template -inline void test_linear_areal() -{ - typedef bg::model::point point_type; - - test_segment_polygon(); - test_segment_multipolygon(); - test_segment_ring(); - test_segment_box(); - - test_linestring_polygon(); - test_linestring_multipolygon(); - test_linestring_ring(); - test_linestring_box(); - - test_multilinestring_polygon(); - test_multilinestring_multipolygon(); - test_multilinestring_ring(); - test_multilinestring_box(); -} - -template -inline void test_areal_areal() -{ - typedef bg::model::point point_type; - - test_polygon_polygon(); - test_polygon_multipolygon(); - test_polygon_ring(); - test_polygon_box(); - - test_multipolygon_multipolygon(); - test_multipolygon_ring(); - test_multipolygon_box(); - - test_ring_ring(); - test_ring_box(); - - test_box_box(); -} - -//============================================================================ - -BOOST_AUTO_TEST_CASE( test_pointlike_pointlike_all ) -{ - test_pointlike_pointlike(); - test_pointlike_pointlike(); -#ifdef HAVE_TTMATH - test_pointlike_pointlike(); -#endif -} - -BOOST_AUTO_TEST_CASE( test_pointlike_linear_all ) -{ - test_pointlike_linear(); - test_pointlike_linear(); -#ifdef HAVE_TTMATH - test_pointlike_linear(); -#endif -} - -BOOST_AUTO_TEST_CASE( test_pointlike_areal_all ) -{ - test_pointlike_areal(); - test_pointlike_areal(); -#ifdef HAVE_TTMATH - test_pointlike_areal(); -#endif -} - -BOOST_AUTO_TEST_CASE( test_linear_linear_all ) -{ - test_linear_linear(); - test_linear_linear(); -#ifdef HAVE_TTMATH - test_linear_linear(); -#endif -} - -BOOST_AUTO_TEST_CASE( test_linear_areal_all ) -{ - test_linear_areal(); - test_linear_areal(); -#ifdef HAVE_TTMATH - test_linear_areal(); -#endif -} - -BOOST_AUTO_TEST_CASE( test_areal_areal_all ) -{ - test_areal_areal(); - test_areal_areal(); -#ifdef HAVE_TTMATH - test_areal_areal(); -#endif -} diff --git a/test/algorithms/relational_operations/disjoint/disjoint_coverage_a_a.cpp b/test/algorithms/relational_operations/disjoint/disjoint_coverage_a_a.cpp new file mode 100644 index 000000000..25d6c5d77 --- /dev/null +++ b/test/algorithms/relational_operations/disjoint/disjoint_coverage_a_a.cpp @@ -0,0 +1,387 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014-2015, Oracle and/or its affiliates. + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_disjoint_coverage +#endif + +// unit test to test disjoint for all geometry combinations + +#include + +#include + +#include +#include + +#include + +#include +#include + +#include + +#include + +#include + + +#ifdef HAVE_TTMATH +#include +#endif + +namespace bg = ::boost::geometry; + +//============================================================================ + +struct test_disjoint +{ + template + static inline void apply(std::string const& case_id, + Geometry1 const& geometry1, + Geometry2 const& geometry2, + bool expected_result) + { + bool result = bg::disjoint(geometry1, geometry2); + BOOST_CHECK_MESSAGE(result == expected_result, + "case ID: " << case_id << ", G1: " << bg::wkt(geometry1) + << ", G2: " << bg::wkt(geometry2) << " -> Expected: " + << expected_result << ", detected: " << result); + + result = bg::disjoint(geometry2, geometry1); + BOOST_CHECK_MESSAGE(result == expected_result, + "case ID: " << case_id << ", G1: " << bg::wkt(geometry2) + << ", G2: " << bg::wkt(geometry1) << " -> Expected: " + << expected_result << ", detected: " << result); + +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << "case ID: " << case_id << "; G1 - G2: "; + std::cout << bg::wkt(geometry1) << " - "; + std::cout << bg::wkt(geometry2) << std::endl; + std::cout << std::boolalpha; + std::cout << "expected/computed result: " + << expected_result << " / " << result << std::endl; + std::cout << std::endl; + std::cout << std::noboolalpha; +#endif + } +}; + +//============================================================================ + +// areal-areal geometries +template +inline void test_box_box() +{ + typedef bg::model::box

B; + + typedef test_disjoint tester; + + tester::apply("b-b-01", + from_wkt("BOX(2 2,3 3)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("b-b-02", + from_wkt("BOX(1 1,3 3)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("b-b-03", + from_wkt("BOX(3 3,4 4)"), + from_wkt("BOX(0 0,2 2)"), + true); +} + +template +inline void test_ring_box() +{ + typedef bg::model::box

B; + typedef bg::model::ring R; // ccw, open + + typedef test_disjoint tester; + + tester::apply("r-b-01", + from_wkt("BOX(2 2,3 3)"), + from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), + false); + + tester::apply("r-b-02", + from_wkt("BOX(1 1,3 3)"), + from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), + false); + + tester::apply("r-b-03", + from_wkt("BOX(3 3,4 4)"), + from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), + true); +} + +template +inline void test_polygon_box() +{ + typedef bg::model::box

B; + typedef bg::model::polygon PL; // ccw, open + + typedef test_disjoint tester; + + tester::apply("pg-b-01", + from_wkt("BOX(2 2,3 3)"), + from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), + false); + + tester::apply("pg-b-02", + from_wkt("BOX(1 1,3 3)"), + from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), + false); + + tester::apply("pg-b-03", + from_wkt("BOX(3 3,4 4)"), + from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), + true); +} + +template +inline void test_multipolygon_box() +{ + typedef bg::model::box

B; + typedef bg::model::polygon PL; // ccw, open + typedef bg::model::multi_polygon MPL; + + typedef test_disjoint tester; + + tester::apply("mpg-b-01", + from_wkt("BOX(2 2,3 3)"), + from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), + false); + + tester::apply("mpg-b-02", + from_wkt("BOX(1 1,3 3)"), + from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), + false); + + tester::apply("mpg-b-03", + from_wkt("BOX(3 3,4 4)"), + from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), + true); +} + +template +inline void test_ring_ring() +{ + typedef bg::model::ring R; // ccw, open + + typedef test_disjoint tester; + + tester::apply("r-r-01", + from_wkt("POLYGON((2 2,2 3,3 3,3 2))"), + from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), + false); + + tester::apply("r-r-02", + from_wkt("POLYGON((1 1,1 3,3 3,3 1))"), + from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), + false); + + tester::apply("r-r-03", + from_wkt("POLYGON((3 3,3 4,4 4,4 3))"), + from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), + true); +} + +template +inline void test_polygon_ring() +{ + typedef bg::model::ring R; // ccw, open + typedef bg::model::polygon PL; // ccw, open + + typedef test_disjoint tester; + + tester::apply("pg-r-01", + from_wkt("POLYGON((2 2,2 3,3 3,3 2))"), + from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), + false); + + tester::apply("pg-r-02", + from_wkt("POLYGON((1 1,1 3,3 3,3 1))"), + from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), + false); + + tester::apply("pg-r-03", + from_wkt("POLYGON((3 3,3 4,4 4,4 3))"), + from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), + true); +} + +template +inline void test_multipolygon_ring() +{ + typedef bg::model::ring R; // ccw, open + typedef bg::model::polygon PL; // ccw, open + typedef bg::model::multi_polygon MPL; + + typedef test_disjoint tester; + + tester::apply("mpg-r-01", + from_wkt("POLYGON((2 2,2 3,3 3,3 2))"), + from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), + false); + + tester::apply("mpg-r-02", + from_wkt("POLYGON((1 1,1 3,3 3,3 1))"), + from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), + false); + + tester::apply("mpg-r-03", + from_wkt("POLYGON((3 3,3 4,4 4,4 3))"), + from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), + true); +} + +template +inline void test_polygon_polygon() +{ + typedef bg::model::polygon PL; // ccw, open + + typedef test_disjoint tester; + + tester::apply("pg-pg-01", + from_wkt("POLYGON((2 2,2 3,3 3,3 2))"), + from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), + false); + + tester::apply("pg-pg-02", + from_wkt("POLYGON((1 1,1 3,3 3,3 1))"), + from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), + false); + + tester::apply("pg-pg-03", + from_wkt("POLYGON((3 3,3 4,4 4,4 3))"), + from_wkt("POLYGON((0 0,2 0,2 2,0 2))"), + true); + + tester::apply("pg-pg-04", + from_wkt("POLYGON((0 0,9 0,9 9,0 9))"), + from_wkt("POLYGON((3 3,6 3,6 6,3 6))"), + false); + // polygon with a hole which entirely contains the other polygon + tester::apply("pg-pg-05", + from_wkt("POLYGON((0 0,9 0,9 9,0 9),(2 2,2 7,7 7,7 2))"), + from_wkt("POLYGON((3 3,6 3,6 6,3 6))"), + true); + // polygon with a hole, but the inner ring intersects the other polygon + tester::apply("pg-pg-06", + from_wkt("POLYGON((0 0,9 0,9 9,0 9),(3 2,3 7,7 7,7 2))"), + from_wkt("POLYGON((2 3,6 3,6 6,2 6))"), + false); + // polygon with a hole, but the other polygon is entirely contained + // between the inner and outer rings. + tester::apply("pg-pg-07", + from_wkt("POLYGON((0 0,9 0,9 9,0 9),(6 2,6 7,7 7,7 2))"), + from_wkt("POLYGON((3 3,5 3,5 6,3 6))"), + false); + // polygon with a hole and the outer ring of the other polygon lies + // between the inner and outer, but without touching either. + tester::apply("pg-pg-08", + from_wkt("POLYGON((0 0,9 0,9 9,0 9),(3 3,3 6,6 6,6 3))"), + from_wkt("POLYGON((2 2,7 2,7 7,2 7))"), + false); + + { + typedef bg::model::polygon

PL; // cw, closed + + // https://svn.boost.org/trac/boost/ticket/10647 + tester::apply("ticket-10647", + from_wkt("POLYGON((0 0, 0 5, 5 5, 5 0, 0 0)(1 1, 4 1, 4 4, 1 4, 1 1))"), + from_wkt("POLYGON((2 2, 2 3, 3 3, 3 2, 2 2))"), + true); + } +} + +template +inline void test_polygon_multipolygon() +{ + typedef bg::model::polygon PL; // ccw, open + typedef bg::model::multi_polygon MPL; + + typedef test_disjoint tester; + + tester::apply("pg-mpg-01", + from_wkt("POLYGON((2 2,2 3,3 3,3 2))"), + from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), + false); + + tester::apply("pg-mpg-02", + from_wkt("POLYGON((1 1,1 3,3 3,3 1))"), + from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), + false); + + tester::apply("pg-mpg-03", + from_wkt("POLYGON((3 3,3 4,4 4,4 3))"), + from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), + true); +} + +template +inline void test_multipolygon_multipolygon() +{ + typedef bg::model::polygon PL; // ccw, open + typedef bg::model::multi_polygon MPL; + + typedef test_disjoint tester; + + tester::apply("mpg-mpg-01", + from_wkt("MULTIPOLYGON(((2 2,2 3,3 3,3 2)))"), + from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), + false); + + tester::apply("mpg-mpg-02", + from_wkt("MULTIPOLYGON(((1 1,1 3,3 3,3 1)))"), + from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), + false); + + tester::apply("mpg-mpg-03", + from_wkt("MULTIPOLYGON(((3 3,3 4,4 4,4 3)))"), + from_wkt("MULTIPOLYGON(((0 0,2 0,2 2,0 2)))"), + true); +} + +//============================================================================ + +template +inline void test_areal_areal() +{ + typedef bg::model::point point_type; + + test_polygon_polygon(); + test_polygon_multipolygon(); + test_polygon_ring(); + test_polygon_box(); + + test_multipolygon_multipolygon(); + test_multipolygon_ring(); + test_multipolygon_box(); + + test_ring_ring(); + test_ring_box(); + + test_box_box(); +} + +//============================================================================ + +BOOST_AUTO_TEST_CASE( test_areal_areal_all ) +{ + test_areal_areal(); + test_areal_areal(); +#ifdef HAVE_TTMATH + test_areal_areal(); +#endif +} diff --git a/test/algorithms/relational_operations/disjoint/disjoint_coverage_l_a.cpp b/test/algorithms/relational_operations/disjoint/disjoint_coverage_l_a.cpp new file mode 100644 index 000000000..cb55aaa8d --- /dev/null +++ b/test/algorithms/relational_operations/disjoint/disjoint_coverage_l_a.cpp @@ -0,0 +1,538 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014-2015, Oracle and/or its affiliates. + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_disjoint_coverage +#endif + +// unit test to test disjoint for all geometry combinations + +#include + +#include + +#include +#include + +#include + +#include +#include + +#include + +#include + +#include + + +#ifdef HAVE_TTMATH +#include +#endif + +namespace bg = ::boost::geometry; + +//============================================================================ + +struct test_disjoint +{ + template + static inline void apply(std::string const& case_id, + Geometry1 const& geometry1, + Geometry2 const& geometry2, + bool expected_result) + { + bool result = bg::disjoint(geometry1, geometry2); + BOOST_CHECK_MESSAGE(result == expected_result, + "case ID: " << case_id << ", G1: " << bg::wkt(geometry1) + << ", G2: " << bg::wkt(geometry2) << " -> Expected: " + << expected_result << ", detected: " << result); + + result = bg::disjoint(geometry2, geometry1); + BOOST_CHECK_MESSAGE(result == expected_result, + "case ID: " << case_id << ", G1: " << bg::wkt(geometry2) + << ", G2: " << bg::wkt(geometry1) << " -> Expected: " + << expected_result << ", detected: " << result); + +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << "case ID: " << case_id << "; G1 - G2: "; + std::cout << bg::wkt(geometry1) << " - "; + std::cout << bg::wkt(geometry2) << std::endl; + std::cout << std::boolalpha; + std::cout << "expected/computed result: " + << expected_result << " / " << result << std::endl; + std::cout << std::endl; + std::cout << std::noboolalpha; +#endif + } +}; + +//============================================================================ + +// linear-areal geometries +template +inline void test_segment_box() +{ + typedef bg::model::segment

S; + typedef bg::model::box

B; + + typedef test_disjoint tester; + + tester::apply("s-b-01", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("s-b-02", + from_wkt("SEGMENT(1 1,3 3)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("s-b-03", + from_wkt("SEGMENT(2 2,3 3)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("s-b-04", + from_wkt("SEGMENT(4 4,3 3)"), + from_wkt("BOX(0 0,2 2)"), + true); + + tester::apply("s-b-05", + from_wkt("SEGMENT(0 4,4 4)"), + from_wkt("BOX(0 0,2 2)"), + true); + + tester::apply("s-b-06", + from_wkt("SEGMENT(4 0,4 4)"), + from_wkt("BOX(0 0,2 2)"), + true); + + tester::apply("s-b-07", + from_wkt("SEGMENT(0 -2,0 -1)"), + from_wkt("BOX(0 0,1 1)"), + true); + + tester::apply("s-b-08", + from_wkt("SEGMENT(-2 -2,-2 -1)"), + from_wkt("BOX(0 0,1 1)"), + true); + + tester::apply("s-b-09", + from_wkt("SEGMENT(-2 -2,-2 -2)"), + from_wkt("BOX(0 0,1 1)"), + true); + + tester::apply("s-b-10", + from_wkt("SEGMENT(-2 0,-2 0)"), + from_wkt("BOX(0 0,1 1)"), + true); + + tester::apply("s-b-11", + from_wkt("SEGMENT(0 -2,0 -2)"), + from_wkt("BOX(0 0,1 1)"), + true); + + tester::apply("s-b-12", + from_wkt("SEGMENT(-2 0,-1 0)"), + from_wkt("BOX(0 0,1 1)"), + true); + + // segment degenerates to a point + tester::apply("s-b-13", + from_wkt("SEGMENT(0 0,0 0)"), + from_wkt("BOX(0 0,1 1)"), + false); + + tester::apply("s-b-14", + from_wkt("SEGMENT(1 1,1 1)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("s-b-15", + from_wkt("SEGMENT(2 2,2 2)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("s-b-16", + from_wkt("SEGMENT(2 0,2 0)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("s-b-17", + from_wkt("SEGMENT(0 2,0 2)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("s-b-18", + from_wkt("SEGMENT(2 2,2 2)"), + from_wkt("BOX(0 0,1 1)"), + true); +} + +template +inline void test_segment_ring() +{ + typedef bg::model::segment

S; + typedef bg::model::ring R; // ccw, open + + typedef test_disjoint tester; + + tester::apply("s-r-01", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("s-r-02", + from_wkt("SEGMENT(1 0,3 3)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("s-r-03", + from_wkt("SEGMENT(1 1,3 3)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("s-r-04", + from_wkt("SEGMENT(2 2,3 3)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + true); +} + +template +inline void test_segment_polygon() +{ + typedef bg::model::segment

S; + typedef bg::model::polygon PL; // ccw, open + + typedef test_disjoint tester; + + tester::apply("s-pg-01", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("s-pg-02", + from_wkt("SEGMENT(1 0,3 3)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("s-pg-03", + from_wkt("SEGMENT(1 1,3 3)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("s-pg-04", + from_wkt("SEGMENT(2 2,3 3)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + true); +} + +template +inline void test_segment_multipolygon() +{ + typedef bg::model::segment

S; + typedef bg::model::polygon PL; // ccw, open + typedef bg::model::multi_polygon MPL; + + typedef test_disjoint tester; + + tester::apply("s-mpg-01", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), + false); + + tester::apply("s-mpg-02", + from_wkt("SEGMENT(1 0,3 3)"), + from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), + false); + + tester::apply("s-mpg-03", + from_wkt("SEGMENT(1 1,3 3)"), + from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), + false); + + tester::apply("s-mpg-04", + from_wkt("SEGMENT(2 2,3 3)"), + from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), + true); +} + +template +inline void test_linestring_box() +{ + typedef bg::model::linestring

L; + typedef bg::model::box

B; + + typedef test_disjoint tester; + + tester::apply("l-b-01", + from_wkt("LINESTRING(0 0,2 0)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("l-b-02", + from_wkt("LINESTRING(1 1,3 3)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("l-b-03", + from_wkt("LINESTRING(2 2,3 3)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("l-b-04", + from_wkt("LINESTRING(4 4,3 3)"), + from_wkt("BOX(0 0,2 2)"), + true); +} + +template +inline void test_linestring_ring() +{ + typedef bg::model::linestring

L; + typedef bg::model::ring R; // ccw, open + + typedef test_disjoint tester; + + tester::apply("l-r-01", + from_wkt("LINESTRING(0 0,2 0)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("l-r-02", + from_wkt("LINESTRING(1 0,3 3)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("l-r-03", + from_wkt("LINESTRING(1 1,3 3)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("l-r-04", + from_wkt("LINESTRING(2 2,3 3)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + true); +} + +template +inline void test_linestring_polygon() +{ + typedef bg::model::linestring

L; + typedef bg::model::polygon PL; // ccw, open + + typedef test_disjoint tester; + + tester::apply("l-pg-01", + from_wkt("LINESTRING(0 0,2 0)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("l-pg-02", + from_wkt("LINESTRING(1 0,3 3)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("l-pg-03", + from_wkt("LINESTRING(1 1,3 3)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("l-pg-04", + from_wkt("LINESTRING(2 2,3 3)"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + true); +} + +template +inline void test_linestring_multipolygon() +{ + typedef bg::model::linestring

L; + typedef bg::model::polygon PL; // ccw, open + typedef bg::model::multi_polygon MPL; + + typedef test_disjoint tester; + + tester::apply("l-mpg-01", + from_wkt("LINESTRING(0 0,2 0)"), + from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), + false); + + tester::apply("l-mpg-02", + from_wkt("LINESTRING(1 0,3 3)"), + from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), + false); + + tester::apply("l-mpg-03", + from_wkt("LINESTRING(1 1,3 3)"), + from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), + false); + + tester::apply("l-mpg-04", + from_wkt("LINESTRING(2 2,3 3)"), + from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), + true); +} + +template +inline void test_multilinestring_box() +{ + typedef bg::model::linestring

L; + typedef bg::model::multi_linestring ML; + typedef bg::model::box

B; + + typedef test_disjoint tester; + + tester::apply("ml-b-01", + from_wkt("MULTILINESTRING((0 0,2 0))"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("ml-b-02", + from_wkt("MULTILINESTRING((1 1,3 3))"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("ml-b-03", + from_wkt("MULTILINESTRING((2 2,3 3))"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("ml-b-04", + from_wkt("MULTILINESTRING((4 4,3 3))"), + from_wkt("BOX(0 0,2 2)"), + true); +} + +template +inline void test_multilinestring_ring() +{ + typedef bg::model::linestring

L; + typedef bg::model::multi_linestring ML; + typedef bg::model::ring R; // ccw, open + + typedef test_disjoint tester; + + tester::apply("ml-r-01", + from_wkt("MULTILINESTRING((0 0,2 0))"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("ml-r-02", + from_wkt("MULTILINESTRING((1 0,3 3))"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("ml-r-03", + from_wkt("MULTILINESTRING((1 1,3 3))"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("ml-r-04", + from_wkt("MULTILINESTRING((2 2,3 3))"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + true); +} + +template +inline void test_multilinestring_polygon() +{ + typedef bg::model::linestring

L; + typedef bg::model::multi_linestring ML; + typedef bg::model::polygon PL; // ccw, open + + typedef test_disjoint tester; + + tester::apply("ml-pg-01", + from_wkt("MULTILINESTRING((0 0,2 0))"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("ml-pg-02", + from_wkt("MULTILINESTRING((1 0,3 3))"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("ml-pg-03", + from_wkt("MULTILINESTRING((1 1,3 3))"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + false); + + tester::apply("ml-pg-04", + from_wkt("MULTILINESTRING((2 2,3 3))"), + from_wkt("POLYGON((0 0,2 0,0 2))"), + true); +} + +template +inline void test_multilinestring_multipolygon() +{ + typedef bg::model::linestring

L; + typedef bg::model::multi_linestring ML; + typedef bg::model::polygon PL; // ccw, open + typedef bg::model::multi_polygon MPL; + + typedef test_disjoint tester; + + tester::apply("ml-mpg-01", + from_wkt("MULTILINESTRING((0 0,2 0))"), + from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), + false); + + tester::apply("ml-mpg-02", + from_wkt("MULTILINESTRING((1 0,3 3))"), + from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), + false); + + tester::apply("ml-mpg-03", + from_wkt("MULTILINESTRING((1 1,3 3))"), + from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), + false); + + tester::apply("ml-mpg-04", + from_wkt("MULTILINESTRING((2 2,3 3))"), + from_wkt("MULTIPOLYGON(((0 0,2 0,0 2)))"), + true); +} + +//============================================================================ + +template +inline void test_linear_areal() +{ + typedef bg::model::point point_type; + + test_segment_polygon(); + test_segment_multipolygon(); + test_segment_ring(); + test_segment_box(); + + test_linestring_polygon(); + test_linestring_multipolygon(); + test_linestring_ring(); + test_linestring_box(); + + test_multilinestring_polygon(); + test_multilinestring_multipolygon(); + test_multilinestring_ring(); + test_multilinestring_box(); +} + +//============================================================================ + +BOOST_AUTO_TEST_CASE( test_linear_areal_all ) +{ + test_linear_areal(); + test_linear_areal(); +#ifdef HAVE_TTMATH + test_linear_areal(); +#endif +} diff --git a/test/algorithms/relational_operations/disjoint/disjoint_coverage_l_l.cpp b/test/algorithms/relational_operations/disjoint/disjoint_coverage_l_l.cpp new file mode 100644 index 000000000..1d1161e1c --- /dev/null +++ b/test/algorithms/relational_operations/disjoint/disjoint_coverage_l_l.cpp @@ -0,0 +1,379 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014-2015, Oracle and/or its affiliates. + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_disjoint_coverage +#endif + +// unit test to test disjoint for all geometry combinations + +#include + +#include + +#include +#include + +#include + +#include +#include + +#include + +#include + +#include + + +#ifdef HAVE_TTMATH +#include +#endif + +namespace bg = ::boost::geometry; + +//============================================================================ + +struct test_disjoint +{ + template + static inline void apply(std::string const& case_id, + Geometry1 const& geometry1, + Geometry2 const& geometry2, + bool expected_result) + { + bool result = bg::disjoint(geometry1, geometry2); + BOOST_CHECK_MESSAGE(result == expected_result, + "case ID: " << case_id << ", G1: " << bg::wkt(geometry1) + << ", G2: " << bg::wkt(geometry2) << " -> Expected: " + << expected_result << ", detected: " << result); + + result = bg::disjoint(geometry2, geometry1); + BOOST_CHECK_MESSAGE(result == expected_result, + "case ID: " << case_id << ", G1: " << bg::wkt(geometry2) + << ", G2: " << bg::wkt(geometry1) << " -> Expected: " + << expected_result << ", detected: " << result); + +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << "case ID: " << case_id << "; G1 - G2: "; + std::cout << bg::wkt(geometry1) << " - "; + std::cout << bg::wkt(geometry2) << std::endl; + std::cout << std::boolalpha; + std::cout << "expected/computed result: " + << expected_result << " / " << result << std::endl; + std::cout << std::endl; + std::cout << std::noboolalpha; +#endif + } +}; + +//============================================================================ + +// linear-linear geometries +template +inline void test_segment_segment() +{ + typedef bg::model::segment

S; + + typedef test_disjoint tester; + + tester::apply("s-s-01", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("SEGMENT(0 0,0 2)"), + false); + + tester::apply("s-s-02", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("SEGMENT(2 0,3 0)"), + false); + + tester::apply("s-s-03", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("SEGMENT(1 0,3 0)"), + false); + + tester::apply("s-s-04", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("SEGMENT(1 0,1 1)"), + false); + + tester::apply("s-s-05", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("SEGMENT(1 1,2 2)"), + true); + + tester::apply("s-s-06", + from_wkt("SEGMENT(0 0,1 1)"), + from_wkt("SEGMENT(1 1,1 1)"), + false); + + tester::apply("s-s-07", + from_wkt("SEGMENT(0 0,1 1)"), + from_wkt("SEGMENT(2 2,2 2)"), + true); + + tester::apply("s-s-08", + from_wkt("SEGMENT(0 0,1 1)"), + from_wkt("SEGMENT(2 2,3 3)"), + true); +} + +template +inline void test_linestring_segment() +{ + typedef bg::model::segment

S; + typedef bg::model::linestring

L; + + typedef test_disjoint tester; + + tester::apply("l-s-01", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("LINESTRING(0 0,0 2)"), + false); + + tester::apply("l-s-02", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("LINESTRING(2 0,3 0)"), + false); + + tester::apply("l-s-03", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("LINESTRING(1 0,3 0)"), + false); + + tester::apply("l-s-04", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("LINESTRING(1 0,1 1)"), + false); + + tester::apply("l-s-05", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("LINESTRING(1 1,2 2)"), + true); + + tester::apply("l-s-06", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("LINESTRING(1 1,1 1,2 2)"), + true); + + tester::apply("l-s-07", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("LINESTRING(1 0,1 0,1 1,2 2)"), + false); + + tester::apply("l-s-08", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("LINESTRING(1 0,1 0,3 0)"), + false); + + tester::apply("l-s-09", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("LINESTRING(3 0,3 0,4 0)"), + true); + + tester::apply("l-s-10", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("LINESTRING(3 0,3 0)"), + true); + + tester::apply("l-s-11", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("LINESTRING(-1 0,-1 0)"), + true); + + tester::apply("l-s-12", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("LINESTRING(1 0,1 0)"), + false); + + tester::apply("l-s-13", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("LINESTRING(1 1,1 1)"), + true); +} + +template +inline void test_multilinestring_segment() +{ + typedef bg::model::segment

S; + typedef bg::model::linestring

L; + typedef bg::model::multi_linestring ML; + + typedef test_disjoint tester; + + tester::apply("s-ml-01", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("MULTILINESTRING((0 0,0 2))"), + false); + + tester::apply("s-ml-02", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("MULTILINESTRING((2 0,3 0))"), + false); + + tester::apply("s-ml-03", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("MULTILINESTRING((1 0,3 0))"), + false); + + tester::apply("s-ml-04", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("MULTILINESTRING((1 0,1 1))"), + false); + + tester::apply("s-ml-05", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("MULTILINESTRING((1 1,2 2))"), + true); + + tester::apply("s-ml-06", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("MULTILINESTRING((1 1,2 2),(3 3,3 3))"), + true); + + tester::apply("s-ml-07", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("MULTILINESTRING((1 1,2 2),(1 0,1 0))"), + false); + + tester::apply("s-ml-08", + from_wkt("SEGMENT(0 0,2 0)"), + from_wkt("MULTILINESTRING((1 1,2 2),(3 0,3 0))"), + true); +} + +template +inline void test_linestring_linestring() +{ + typedef bg::model::linestring

L; + + typedef test_disjoint tester; + + tester::apply("l-l-01", + from_wkt("LINESTRING(0 0,2 0)"), + from_wkt("LINESTRING(0 0,0 2)"), + false); + + tester::apply("l-l-02", + from_wkt("LINESTRING(0 0,2 0)"), + from_wkt("LINESTRING(2 0,3 0)"), + false); + + tester::apply("l-l-03", + from_wkt("LINESTRING(0 0,2 0)"), + from_wkt("LINESTRING(1 0,3 0)"), + false); + + tester::apply("l-l-04", + from_wkt("LINESTRING(0 0,2 0)"), + from_wkt("LINESTRING(1 0,1 1)"), + false); + + tester::apply("l-l-05", + from_wkt("LINESTRING(0 0,2 0)"), + from_wkt("LINESTRING(1 1,2 2)"), + true); +} + +template +inline void test_linestring_multilinestring() +{ + typedef bg::model::linestring

L; + typedef bg::model::multi_linestring ML; + + typedef test_disjoint tester; + + tester::apply("l-ml-01", + from_wkt("LINESTRING(0 0,2 0)"), + from_wkt("MULTILINESTRING((0 0,0 2))"), + false); + + tester::apply("l-ml-02", + from_wkt("LINESTRING(0 0,2 0)"), + from_wkt("MULTILINESTRING((2 0,3 0))"), + false); + + tester::apply("l-ml-03", + from_wkt("LINESTRING(0 0,2 0)"), + from_wkt("MULTILINESTRING((1 0,3 0))"), + false); + + tester::apply("l-ml-04", + from_wkt("LINESTRING(0 0,2 0)"), + from_wkt("MULTILINESTRING((1 0,1 1))"), + false); + + tester::apply("l-ml-05", + from_wkt("LINESTRING(0 0,2 0)"), + from_wkt("MULTILINESTRING((1 1,2 2))"), + true); +} + +template +inline void test_multilinestring_multilinestring() +{ + typedef bg::model::linestring

L; + typedef bg::model::multi_linestring ML; + + typedef test_disjoint tester; + + tester::apply("ml-ml-01", + from_wkt("MULTILINESTRING((0 0,2 0))"), + from_wkt("MULTILINESTRING((0 0,0 2))"), + false); + + tester::apply("ml-ml-02", + from_wkt("MULTILINESTRING((0 0,2 0))"), + from_wkt("MULTILINESTRING((2 0,3 0))"), + false); + + tester::apply("ml-ml-03", + from_wkt("MULTILINESTRING((0 0,2 0))"), + from_wkt("MULTILINESTRING((1 0,3 0))"), + false); + + tester::apply("ml-ml-04", + from_wkt("MULTILINESTRING((0 0,2 0))"), + from_wkt("MULTILINESTRING((1 0,1 1))"), + false); + + tester::apply("ml-ml-05", + from_wkt("MULTILINESTRING((0 0,2 0))"), + from_wkt("MULTILINESTRING((1 1,2 2))"), + true); +} + +//============================================================================ + +template +inline void test_linear_linear() +{ + typedef bg::model::point point_type; + + test_linestring_linestring(); + test_linestring_multilinestring(); + test_linestring_segment(); + + test_multilinestring_multilinestring(); + test_multilinestring_segment(); + + test_segment_segment(); +} + +//============================================================================ + +BOOST_AUTO_TEST_CASE( test_linear_linear_all ) +{ + test_linear_linear(); + test_linear_linear(); +#ifdef HAVE_TTMATH + test_linear_linear(); +#endif +} diff --git a/test/algorithms/relational_operations/disjoint/disjoint_coverage_p_a.cpp b/test/algorithms/relational_operations/disjoint/disjoint_coverage_p_a.cpp new file mode 100644 index 000000000..0f42fd7ec --- /dev/null +++ b/test/algorithms/relational_operations/disjoint/disjoint_coverage_p_a.cpp @@ -0,0 +1,291 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014-2015, Oracle and/or its affiliates. + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_disjoint_coverage +#endif + +// unit test to test disjoint for all geometry combinations + +#include + +#include + +#include +#include + +#include + +#include +#include + +#include + +#include + +#include + + +#ifdef HAVE_TTMATH +#include +#endif + +namespace bg = ::boost::geometry; + +//============================================================================ + +struct test_disjoint +{ + template + static inline void apply(std::string const& case_id, + Geometry1 const& geometry1, + Geometry2 const& geometry2, + bool expected_result) + { + bool result = bg::disjoint(geometry1, geometry2); + BOOST_CHECK_MESSAGE(result == expected_result, + "case ID: " << case_id << ", G1: " << bg::wkt(geometry1) + << ", G2: " << bg::wkt(geometry2) << " -> Expected: " + << expected_result << ", detected: " << result); + + result = bg::disjoint(geometry2, geometry1); + BOOST_CHECK_MESSAGE(result == expected_result, + "case ID: " << case_id << ", G1: " << bg::wkt(geometry2) + << ", G2: " << bg::wkt(geometry1) << " -> Expected: " + << expected_result << ", detected: " << result); + +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << "case ID: " << case_id << "; G1 - G2: "; + std::cout << bg::wkt(geometry1) << " - "; + std::cout << bg::wkt(geometry2) << std::endl; + std::cout << std::boolalpha; + std::cout << "expected/computed result: " + << expected_result << " / " << result << std::endl; + std::cout << std::endl; + std::cout << std::noboolalpha; +#endif + } +}; + +//============================================================================ + +// pointlike-areal geometries +template +inline void test_point_box() +{ + typedef test_disjoint tester; + typedef bg::model::box

B; + + tester::apply("p-b-01", + from_wkt

("POINT(0 0)"), + from_wkt("BOX(0 0,1 1)"), + false); + + tester::apply("p-b-02", + from_wkt

("POINT(2 2)"), + from_wkt("BOX(0 0,1 0)"), + true); +} + +template +inline void test_point_ring() +{ + typedef bg::model::ring R; // ccw, open + + typedef test_disjoint tester; + + tester::apply("p-r-01", + from_wkt

("POINT(0 0)"), + from_wkt("POLYGON((0 0,1 0,0 1))"), + false); + + tester::apply("p-r-02", + from_wkt

("POINT(1 1)"), + from_wkt("POLYGON((0 0,1 0,0 1))"), + true); +} + +template +inline void test_point_polygon() +{ + typedef bg::model::polygon PL; // ccw, open + + typedef test_disjoint tester; + + tester::apply("p-pg-01", + from_wkt

("POINT(0 0)"), + from_wkt("POLYGON((0 0,1 0,0 1))"), + false); + + tester::apply("p-pg-02", + from_wkt

("POINT(1 1)"), + from_wkt("POLYGON((0 0,1 0,0 1))"), + true); +} + +template +inline void test_point_multipolygon() +{ + typedef bg::model::polygon PL; // ccw, open + typedef bg::model::multi_polygon MPL; + + typedef test_disjoint tester; + + tester::apply("p-mpg-01", + from_wkt

("POINT(0 0)"), + from_wkt("MULTIPOLYGON(((0 0,1 0,0 1)),((2 0,3 0,2 1)))"), + false); + + tester::apply("p-mpg-02", + from_wkt

("POINT(1 1)"), + from_wkt("MULTIPOLYGON(((0 0,1 0,0 1)),((2 0,3 0,2 1)))"), + true); +} + +template +inline void test_multipoint_box() +{ + typedef test_disjoint tester; + typedef bg::model::multi_point

MP; + typedef bg::model::box

B; + + tester::apply("mp-b-01", + from_wkt("MULTIPOINT(0 0,1 1)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("mp-b-02", + from_wkt("MULTIPOINT(1 1,3 3)"), + from_wkt("BOX(0 0,2 2)"), + false); + + tester::apply("mp-b-03", + from_wkt("MULTIPOINT(3 3,4 4)"), + from_wkt("BOX(0 0,2 2)"), + true); + + tester::apply("mp-b-04", + from_wkt("MULTIPOINT()"), + from_wkt("BOX(0 0,2 2)"), + true); +} + +template +inline void test_multipoint_ring() +{ + typedef bg::model::multi_point

MP; + typedef bg::model::ring R; // ccw, open + + typedef test_disjoint tester; + + tester::apply("mp-r-01", + from_wkt("MULTIPOINT(0 0,1 0)"), + from_wkt("POLYGON((0 0,1 0,0 1))"), + false); + + tester::apply("mp-r-02", + from_wkt("MULTIPOINT(1 0,1 1)"), + from_wkt("POLYGON((0 0,1 0,0 1))"), + false); + + tester::apply("mp-r-03", + from_wkt("MULTIPOINT(1 1,2 2)"), + from_wkt("POLYGON((0 0,1 0,0 1))"), + true); +} + +template +inline void test_multipoint_polygon() +{ + typedef bg::model::multi_point

MP; + typedef bg::model::polygon PL; // ccw, open + + typedef test_disjoint tester; + + tester::apply("mp-pg-01", + from_wkt("MULTIPOINT(0 0,1 0)"), + from_wkt("POLYGON(((0 0,1 0,0 1)))"), + false); + + tester::apply("mp-pg-02", + from_wkt("MULTIPOINT(0 0,2 0)"), + from_wkt("POLYGON(((0 0,1 0,0 1)))"), + false); + + tester::apply("mp-pg-03", + from_wkt("MULTIPOINT(1 1,2 0)"), + from_wkt("POLYGON(((0 0,1 0,0 1)))"), + true); + + tester::apply("mp-pg-04", + from_wkt("MULTIPOINT(1 1,2 3)"), + from_wkt("POLYGON(((0 0,1 0,0 1)))"), + true); +} + +template +inline void test_multipoint_multipolygon() +{ + typedef bg::model::multi_point

MP; + typedef bg::model::polygon PL; // ccw, open + typedef bg::model::multi_polygon MPL; + + typedef test_disjoint tester; + + tester::apply("mp-mp-01", + from_wkt("MULTIPOINT(0 0,2 0)"), + from_wkt("MULTIPOLYGON((0 0,1 0,0 1)),(2 0,3 0,2 1))"), + false); + + tester::apply("mp-mp-02", + from_wkt("MULTIPOINT(0 0,1 0)"), + from_wkt("MULTIPOLYGON((0 0,1 0,0 1)),(2 0,3 0,2 1))"), + false); + + tester::apply("mp-mp-03", + from_wkt("MULTIPOINT(1 1,2 0)"), + from_wkt("MULTIPOLYGON((0 0,1 0,0 1)),(2 0,3 0,2 1))"), + false); + + tester::apply("mp-mp-04", + from_wkt("MULTIPOINT(1 1,2 3)"), + from_wkt("MULTIPOLYGON((0 0,1 0,0 1)),(2 0,3 0,2 1))"), + true); +} + +//============================================================================ + +template +inline void test_pointlike_areal() +{ + typedef bg::model::point point_type; + + test_point_polygon(); + test_point_multipolygon(); + test_point_ring(); + test_point_box(); + + // not implemented yet + // test_multipoint_polygon(); + // test_multipoint_multipolygon(); + // test_multipoint_ring(); + test_multipoint_box(); +} + +//============================================================================ + +BOOST_AUTO_TEST_CASE( test_pointlike_areal_all ) +{ + test_pointlike_areal(); + test_pointlike_areal(); +#ifdef HAVE_TTMATH + test_pointlike_areal(); +#endif +} diff --git a/test/algorithms/relational_operations/disjoint/disjoint_coverage_p_l.cpp b/test/algorithms/relational_operations/disjoint/disjoint_coverage_p_l.cpp new file mode 100644 index 000000000..ab4b8839a --- /dev/null +++ b/test/algorithms/relational_operations/disjoint/disjoint_coverage_p_l.cpp @@ -0,0 +1,391 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014-2015, Oracle and/or its affiliates. + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_disjoint_coverage +#endif + +// unit test to test disjoint for all geometry combinations + +#include + +#include + +#include +#include + +#include + +#include +#include + +#include + +#include + +#include + + +#ifdef HAVE_TTMATH +#include +#endif + +namespace bg = ::boost::geometry; + +//============================================================================ + +struct test_disjoint +{ + template + static inline void apply(std::string const& case_id, + Geometry1 const& geometry1, + Geometry2 const& geometry2, + bool expected_result) + { + bool result = bg::disjoint(geometry1, geometry2); + BOOST_CHECK_MESSAGE(result == expected_result, + "case ID: " << case_id << ", G1: " << bg::wkt(geometry1) + << ", G2: " << bg::wkt(geometry2) << " -> Expected: " + << expected_result << ", detected: " << result); + + result = bg::disjoint(geometry2, geometry1); + BOOST_CHECK_MESSAGE(result == expected_result, + "case ID: " << case_id << ", G1: " << bg::wkt(geometry2) + << ", G2: " << bg::wkt(geometry1) << " -> Expected: " + << expected_result << ", detected: " << result); + +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << "case ID: " << case_id << "; G1 - G2: "; + std::cout << bg::wkt(geometry1) << " - "; + std::cout << bg::wkt(geometry2) << std::endl; + std::cout << std::boolalpha; + std::cout << "expected/computed result: " + << expected_result << " / " << result << std::endl; + std::cout << std::endl; + std::cout << std::noboolalpha; +#endif + } +}; + +//============================================================================ + +// pointlike-linear geometries +template +inline void test_point_segment() +{ + typedef test_disjoint tester; + typedef bg::model::segment

S; + + tester::apply("p-s-01", + from_wkt

("POINT(0 0)"), + from_wkt("SEGMENT(0 0,2 0)"), + false); + + tester::apply("p-s-02", + from_wkt

("POINT(2 0)"), + from_wkt("SEGMENT(0 0,2 0)"), + false); + + tester::apply("p-s-03", + from_wkt

("POINT(1 0)"), + from_wkt("SEGMENT(0 0,2 0)"), + false); + + tester::apply("p-s-04", + from_wkt

("POINT(1 1)"), + from_wkt("SEGMENT(0 0,2 0)"), + true); + + tester::apply("p-s-05", + from_wkt

("POINT(3 0)"), + from_wkt("SEGMENT(0 0,2 0)"), + true); + + tester::apply("p-s-06", + from_wkt

("POINT(-1 0)"), + from_wkt("SEGMENT(0 0,2 0)"), + true); + + // degenerate segment + tester::apply("p-s-07", + from_wkt

("POINT(-1 0)"), + from_wkt("SEGMENT(2 0,2 0)"), + true); + + // degenerate segment + tester::apply("p-s-08", + from_wkt

("POINT(2 0)"), + from_wkt("SEGMENT(2 0,2 0)"), + false); + + // degenerate segment + tester::apply("p-s-09", + from_wkt

("POINT(3 0)"), + from_wkt("SEGMENT(2 0,2 0)"), + true); + + // degenerate segment + tester::apply("p-s-10", + from_wkt

("POINT(1 1)"), + from_wkt("SEGMENT(2 0,2 0)"), + true); +} + +template +inline void test_point_linestring() +{ + typedef bg::model::linestring

L; + + typedef test_disjoint tester; + + tester::apply("p-l-01", + from_wkt

("POINT(0 0)"), + from_wkt("LINESTRING(0 0,2 2,4 4)"), + false); + + tester::apply("p-l-02", + from_wkt

("POINT(1 1)"), + from_wkt("LINESTRING(0 0,2 2,4 4)"), + false); + + tester::apply("p-l-03", + from_wkt

("POINT(3 3)"), + from_wkt("LINESTRING(0 0,2 2,4 4)"), + false); + + tester::apply("p-l-04", + from_wkt

("POINT(1 0)"), + from_wkt("LINESTRING(0 0,2 2,4 4)"), + true); + + tester::apply("p-l-05", + from_wkt

("POINT(5 5)"), + from_wkt("LINESTRING(0 0,2 2,4 4)"), + true); + + tester::apply("p-l-06", + from_wkt

("POINT(5 5)"), + from_wkt("LINESTRING(0 0,2 2)"), + true); +} + +template +inline void test_point_multilinestring() +{ + typedef bg::model::linestring

L; + typedef bg::model::multi_linestring ML; + + typedef test_disjoint tester; + + tester::apply("p-ml-01", + from_wkt

("POINT(0 1)"), + from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), + true); + + tester::apply("p-ml-02", + from_wkt

("POINT(0 0)"), + from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), + false); + + tester::apply("p-ml-03", + from_wkt

("POINT(1 1)"), + from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), + false); + + tester::apply("p-ml-04", + from_wkt

("POINT(1 0)"), + from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), + false); + + tester::apply("p-ml-05", + from_wkt

("POINT(0 0)"), + from_wkt("MULTILINESTRING((1 1,2 2,4 4),(3 0,4 0))"), + true); + + tester::apply("p-ml-06", + from_wkt

("POINT(0 0)"), + from_wkt("MULTILINESTRING((1 1,2 2,4 4),(0 0,4 0))"), + false); + + tester::apply("p-ml-07", + from_wkt

("POINT(0 0)"), + from_wkt("MULTILINESTRING((1 1,2 2,4 4),(-1 0,4 0))"), + false); +} + +template +inline void test_multipoint_segment() +{ + typedef test_disjoint tester; + typedef bg::model::multi_point

MP; + typedef bg::model::segment

S; + + tester::apply("mp-s-01", + from_wkt("MULTIPOINT(0 0,1 1)"), + from_wkt("SEGMENT(0 0,2 0)"), + false); + + tester::apply("mp-s-02", + from_wkt("MULTIPOINT(1 0,1 1)"), + from_wkt("SEGMENT(0 0,2 0)"), + false); + + tester::apply("mp-s-03", + from_wkt("MULTIPOINT(1 1,2 2)"), + from_wkt("SEGMENT(0 0,2 0)"), + true); + + tester::apply("mp-s-04", + from_wkt("MULTIPOINT()"), + from_wkt("SEGMENT(0 0,2 0)"), + true); + + tester::apply("mp-s-05", + from_wkt("MULTIPOINT(3 0,4 0)"), + from_wkt("SEGMENT(0 0,2 0)"), + true); + + tester::apply("mp-s-06", + from_wkt("MULTIPOINT(1 0,4 0)"), + from_wkt("SEGMENT(0 0,2 0)"), + false); + + // segments that degenerate to a point + tester::apply("mp-s-07", + from_wkt("MULTIPOINT(1 1,2 2)"), + from_wkt("SEGMENT(0 0,0 0)"), + true); + + tester::apply("mp-s-08", + from_wkt("MULTIPOINT(1 1,2 2)"), + from_wkt("SEGMENT(1 1,1 1)"), + false); +} + +template +inline void test_multipoint_linestring() +{ + typedef bg::model::multi_point

MP; + typedef bg::model::linestring

L; + + typedef test_disjoint tester; + + tester::apply("mp-l-01", + from_wkt("MULTIPOINT(0 0,1 0)"), + from_wkt("LINESTRING(0 0,2 2,4 4)"), + false); + + tester::apply("mp-l-02", + from_wkt("MULTIPOINT(1 0,1 1)"), + from_wkt("LINESTRING(0 0,2 2,4 4)"), + false); + + tester::apply("mp-l-03", + from_wkt("MULTIPOINT(1 0,3 3)"), + from_wkt("LINESTRING(0 0,2 2,4 4)"), + false); + + tester::apply("mp-l-04", + from_wkt("MULTIPOINT(1 0,2 0)"), + from_wkt("LINESTRING(0 0,2 2,4 4)"), + true); + + tester::apply("mp-l-05", + from_wkt("MULTIPOINT(-1 -1,2 0)"), + from_wkt("LINESTRING(0 0,2 2,4 4)"), + true); + + tester::apply("mp-l-06", + from_wkt("MULTIPOINT(-1 -1,2 0)"), + from_wkt("LINESTRING(1 0,3 0)"), + false); + + tester::apply("mp-l-07", + from_wkt("MULTIPOINT(-1 -1,2 0,-1 -1,2 0)"), + from_wkt("LINESTRING(1 0,3 0)"), + false); + + tester::apply("mp-l-08", + from_wkt("MULTIPOINT(2 0)"), + from_wkt("LINESTRING(1 0)"), + true); + + tester::apply("mp-l-09", + from_wkt("MULTIPOINT(3 0,0 0,3 0)"), + from_wkt("LINESTRING(1 0,2 0)"), + true); +} + +template +inline void test_multipoint_multilinestring() +{ + typedef bg::model::multi_point

MP; + typedef bg::model::linestring

L; + typedef bg::model::multi_linestring ML; + + typedef test_disjoint tester; + + tester::apply("mp-ml-01", + from_wkt("MULTIPOINT(0 1,0 2)"), + from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), + true); + + tester::apply("mp-ml-02", + from_wkt("MULTIPOINT(0 0,1 0)"), + from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), + false); + + tester::apply("mp-ml-03", + from_wkt("MULTIPOINT(0 1,1 1)"), + from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), + false); + + tester::apply("mp-ml-04", + from_wkt("MULTIPOINT(0 1,1 0)"), + from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), + false); + + tester::apply("mp-ml-05", + from_wkt("MULTIPOINT(0 0,10 0)"), + from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), + false); + + tester::apply("mp-ml-06", + from_wkt("MULTIPOINT(-1 0,3 0)"), + from_wkt("MULTILINESTRING((0 0,2 2,4 4),(0 0,2 0,4 0))"), + false); +} + +//============================================================================ + +template +inline void test_pointlike_linear() +{ + typedef bg::model::point point_type; + + test_point_linestring(); + test_point_multilinestring(); + test_point_segment(); + + test_multipoint_linestring(); + test_multipoint_multilinestring(); + test_multipoint_segment(); +} + +//============================================================================ + +BOOST_AUTO_TEST_CASE( test_pointlike_linear_all ) +{ + test_pointlike_linear(); + test_pointlike_linear(); +#ifdef HAVE_TTMATH + test_pointlike_linear(); +#endif +} diff --git a/test/algorithms/relational_operations/disjoint/disjoint_coverage_p_p.cpp b/test/algorithms/relational_operations/disjoint/disjoint_coverage_p_p.cpp new file mode 100644 index 000000000..9121e0f02 --- /dev/null +++ b/test/algorithms/relational_operations/disjoint/disjoint_coverage_p_p.cpp @@ -0,0 +1,169 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2014-2015, Oracle and/or its affiliates. + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_disjoint_coverage +#endif + +// unit test to test disjoint for all geometry combinations + +#include + +#include + +#include +#include + +#include + +#include +#include + +#include + +#include + +#include + + +#ifdef HAVE_TTMATH +#include +#endif + +namespace bg = ::boost::geometry; + +//============================================================================ + +struct test_disjoint +{ + template + static inline void apply(std::string const& case_id, + Geometry1 const& geometry1, + Geometry2 const& geometry2, + bool expected_result) + { + bool result = bg::disjoint(geometry1, geometry2); + BOOST_CHECK_MESSAGE(result == expected_result, + "case ID: " << case_id << ", G1: " << bg::wkt(geometry1) + << ", G2: " << bg::wkt(geometry2) << " -> Expected: " + << expected_result << ", detected: " << result); + + result = bg::disjoint(geometry2, geometry1); + BOOST_CHECK_MESSAGE(result == expected_result, + "case ID: " << case_id << ", G1: " << bg::wkt(geometry2) + << ", G2: " << bg::wkt(geometry1) << " -> Expected: " + << expected_result << ", detected: " << result); + +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << "case ID: " << case_id << "; G1 - G2: "; + std::cout << bg::wkt(geometry1) << " - "; + std::cout << bg::wkt(geometry2) << std::endl; + std::cout << std::boolalpha; + std::cout << "expected/computed result: " + << expected_result << " / " << result << std::endl; + std::cout << std::endl; + std::cout << std::noboolalpha; +#endif + } +}; + +//============================================================================ + +// pointlike-pointlike geometries +template +inline void test_point_point() +{ + typedef test_disjoint tester; + + tester::apply("p-p-01", + from_wkt

("POINT(0 0)"), + from_wkt

("POINT(0 0)"), + false); + + tester::apply("p-p-02", + from_wkt

("POINT(0 0)"), + from_wkt

("POINT(1 1)"), + true); +} + +template +inline void test_point_multipoint() +{ + typedef bg::model::multi_point

MP; + + typedef test_disjoint tester; + + tester::apply("p-mp-01", + from_wkt

("POINT(0 0)"), + from_wkt("MULTIPOINT(0 0,1 1)"), + false); + + tester::apply("p-mp-02", + from_wkt

("POINT(0 0)"), + from_wkt("MULTIPOINT(1 1,2 2)"), + true); + + tester::apply("p-mp-03", + from_wkt

("POINT(0 0)"), + from_wkt("MULTIPOINT()"), + true); +} + +template +inline void test_multipoint_multipoint() +{ + typedef bg::model::multi_point

MP; + + typedef test_disjoint tester; + + tester::apply("mp-mp-01", + from_wkt("MULTIPOINT(0 0,1 0)"), + from_wkt("MULTIPOINT(0 0,1 1)"), + false); + + tester::apply("mp-mp-02", + from_wkt("MULTIPOINT(0 0,1 0)"), + from_wkt("MULTIPOINT(1 1,2 2)"), + true); + + tester::apply("mp-mp-03", + from_wkt("MULTIPOINT()"), + from_wkt("MULTIPOINT(1 1,2 2)"), + true); + + tester::apply("mp-mp-04", + from_wkt("MULTIPOINT(0 0,1 0)"), + from_wkt("MULTIPOINT()"), + true); +} + +//============================================================================ + +template +inline void test_pointlike_pointlike() +{ + typedef bg::model::point point_type; + + test_point_point(); + test_point_multipoint(); + + test_multipoint_multipoint(); +} + +//============================================================================ + +BOOST_AUTO_TEST_CASE( test_pointlike_pointlike_all ) +{ + test_pointlike_pointlike(); + test_pointlike_pointlike(); +#ifdef HAVE_TTMATH + test_pointlike_pointlike(); +#endif +} diff --git a/test/algorithms/relational_operations/disjoint/disjoint_point_box_geometry.cpp b/test/algorithms/relational_operations/disjoint/disjoint_point_box_geometry.cpp new file mode 100644 index 000000000..f1de2de0e --- /dev/null +++ b/test/algorithms/relational_operations/disjoint/disjoint_point_box_geometry.cpp @@ -0,0 +1,127 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// 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 2015. +// Modifications copyright (c) 2015, Oracle and/or its affiliates. + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// 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_disjoint.hpp" + +#include +#include +#include + +#include + +#include + +#include + + +template +void test_all() +{ + typedef bg::model::box

box; + + test_disjoint("pp1", "point(1 1)", "point(1 1)", false); + test_disjoint("pp2", "point(1 1)", "point(1.001 1)", true); + + // left-right + test_disjoint("bb1", "box(1 1, 2 2)", "box(3 1, 4 2)", true); + test_disjoint("bb2", "box(1 1, 2 2)", "box(2 1, 3 2)", false); + test_disjoint("bb3", "box(1 1, 2 2)", "box(2 2, 3 3)", false); + test_disjoint("bb4", "box(1 1, 2 2)", "box(2.001 2, 3 3)", true); + + // up-down + test_disjoint("bb5", "box(1 1, 2 2)", "box(1 3, 2 4)", true); + test_disjoint("bb6", "box(1 1, 2 2)", "box(1 2, 2 3)", false); + // right-left + test_disjoint("bb7", "box(1 1, 2 2)", "box(0 1, 1 2)", false); + test_disjoint("bb8", "box(1 1, 2 2)", "box(0 1, 1 2)", false); + + // point-box + test_disjoint("pb1", "point(1 1)", "box(0 0, 2 2)", false); + test_disjoint("pb2", "point(2 2)", "box(0 0, 2 2)", false); + test_disjoint("pb3", "point(2.0001 2)", "box(1 1, 2 2)", true); + test_disjoint("pb4", "point(0.9999 2)", "box(1 1, 2 2)", true); + + // box-point (to test reverse compiling) + test_disjoint("bp1", "box(1 1, 2 2)", "point(2 2)", false); + + // Test triangles for polygons/rings, boxes + // Note that intersections are tested elsewhere, they don't need + // thorough test at this place + typedef bg::model::polygon

polygon; + typedef bg::model::ring

ring; + + // Testing overlap (and test compiling with box) + test_disjoint("overlaps_box_pp", overlaps_box[0], overlaps_box[1], false); + test_disjoint("overlaps_box_bp", overlaps_box[0], overlaps_box[1], false); + test_disjoint("overlaps_box_br", overlaps_box[0], overlaps_box[1], false); + test_disjoint("overlaps_box_pb", overlaps_box[1], overlaps_box[0], false); + test_disjoint("overlaps_box_rb", overlaps_box[1], overlaps_box[0], false); + + test_disjoint("point_ring1", "POINT(0 0)", "POLYGON((0 0,3 3,6 0,0 0))", false); + test_disjoint("point_ring2", "POINT(3 1)", "POLYGON((0 0,3 3,6 0,0 0))", false); + test_disjoint("point_ring3", "POINT(0 3)", "POLYGON((0 0,3 3,6 0,0 0))", true); + test_disjoint("point_polygon1", "POINT(0 0)", "POLYGON((0 0,3 3,6 0,0 0))", false); + test_disjoint("point_polygon2", "POINT(3 1)", "POLYGON((0 0,3 3,6 0,0 0))", false); + test_disjoint("point_polygon3", "POINT(0 3)", "POLYGON((0 0,3 3,6 0,0 0))", true); + + test_disjoint("point_ring2", "POLYGON((0 0,3 3,6 0,0 0))", "POINT(0 0)", false); + test_disjoint("point_polygon2", "POLYGON((0 0,3 3,6 0,0 0))", "POINT(0 0)", false); + + + // Problem described by Volker/Albert 2012-06-01 + test_disjoint("volker_albert_1", + "POLYGON((1992 3240,1992 1440,3792 1800,3792 3240,1992 3240))", + "BOX(1941 2066, 2055 2166)", false); + + test_disjoint("volker_albert_2", + "POLYGON((1941 2066,2055 2066,2055 2166,1941 2166))", + "BOX(1941 2066, 2055 2166)", false); +} + + +template +void test_3d() +{ + typedef bg::model::box

box; + + test_disjoint("pp 3d 1", "point(1 1 1)", "point(1 1 1)", false); + test_disjoint("pp 3d 2", "point(1 1 1)", "point(1.001 1 1)", true); + + test_disjoint("bb1", "box(1 1 1, 2 2 2)", "box(3 1 1, 4 2 1)", true); + test_disjoint("bb2", "box(1 1 1, 2 2 2)", "box(2 1 1, 3 2 1)", false); + test_disjoint("bb3", "box(1 1 1, 2 2 2)", "box(2 2 1, 3 3 1)", false); + test_disjoint("bb4", "box(1 1 1, 2 2 2)", "box(2.001 2 1, 3 3 1)", true); + +} + +int test_main(int, char* []) +{ + test_all >(); + test_all >(); + +#ifdef HAVE_TTMATH + test_all >(); +#endif + + test_3d >(); + + + return 0; +} From ff9ba7fe3cb42f1c2e340044e1f7fb557968a69f Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Wed, 17 Jun 2015 19:20:50 +0300 Subject: [PATCH 09/18] [test][iterators][point iterator] delete dynamically allocated memory (fixes memory leak error reported in regression matrix of the develop branch) --- test/iterators/point_iterator.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/iterators/point_iterator.cpp b/test/iterators/point_iterator.cpp index 3fa888212..7eaee6af0 100644 --- a/test/iterators/point_iterator.cpp +++ b/test/iterators/point_iterator.cpp @@ -742,6 +742,7 @@ BOOST_AUTO_TEST_CASE( test_multipoint_of_point_pointers ) { delete multipoint[i]; } + delete zero; } @@ -783,6 +784,7 @@ BOOST_AUTO_TEST_CASE( test_linestring_of_point_pointers ) { delete linestring[i]; } + delete zero; } From 42a5a091f7a703f5b0823eda6e661249962b1ba4 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Wed, 17 Jun 2015 19:27:12 +0300 Subject: [PATCH 10/18] [test][algorithms][envelope] remove duplicate test case; increase tolerance in test case (to avoid unit test failures on certain platforms/compilers, such as MSVC, qcc and quite a few others) --- test/algorithms/envelope_on_spheroid.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/test/algorithms/envelope_on_spheroid.cpp b/test/algorithms/envelope_on_spheroid.cpp index 1f3aa4114..3938418ed 100644 --- a/test/algorithms/envelope_on_spheroid.cpp +++ b/test/algorithms/envelope_on_spheroid.cpp @@ -998,15 +998,11 @@ BOOST_AUTO_TEST_CASE( envelope_linestring ) from_wkt("LINESTRING(10 10,20 20,10 30)"), 10, 10, 20, 30); - // linestring that circles most of the globe - tester::apply("l03", - from_wkt("LINESTRING(-170 25,-50 10,10 10,20 20,100 5,180 15)"), - -170, 5, 180, 25.15036418555258); - // linestring that circles the entire globe tester::apply("l03", from_wkt("LINESTRING(-185 0,-170 25,-50 10,10 10,20 20,100 5,180 15)"), - -180, 0, 180, 25.15036418555258); + -180, 0, 180, 25.15036418555258, + 4.0 * std::numeric_limits::epsilon()); // linestring that crosses the antimeridian but staying close to it tester::apply("l04", From 362aec8aa185ecbb28f71dda330c0863b0fdf20c Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 18 Jun 2015 08:40:32 +0300 Subject: [PATCH 11/18] [test][algorithms][expand] increase precision tolerance for a test case (to account for failing unit tests for some platforms) --- test/algorithms/expand_on_spheroid.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/algorithms/expand_on_spheroid.cpp b/test/algorithms/expand_on_spheroid.cpp index 8199fe842..98db446ad 100644 --- a/test/algorithms/expand_on_spheroid.cpp +++ b/test/algorithms/expand_on_spheroid.cpp @@ -616,7 +616,8 @@ BOOST_AUTO_TEST_CASE( expand_segment ) tester::apply("s03", from_wkt("BOX(5 5,50 10)"), from_wkt("SEGMENT(40 10,10 10)"), - 5, 5, 50, 10.34527004614999); + 5, 5, 50, 10.34527004614999, + 4.0 * std::numeric_limits::epsilon()); // segment ending at the north pole tester::apply("s04", From 098ca1e0386e0716363600c1d276aed1ba0e0223 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Mon, 15 Jun 2015 16:54:36 +0200 Subject: [PATCH 12/18] [geometry] Add CircleCI and Coveralls integration, add test results to the README. --- README.md | 10 +++- circle.yml | 147 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 circle.yml diff --git a/README.md b/README.md index 27ba8cdad..de0e359eb 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,15 @@ Boost.Geometry, part of collection of the [Boost C++ Libraries](http://github.co * **index** - examples and tests for the Spatial Index * **test** - Boost.Geometry unit tests +### Test results + +@ | Build | Coverage | Regression +------------|---------------|----------------|------------ +**master** | [![status](https://circleci.com/gh/awulkiew/geometry/tree/master.png?style=shield)](https://circleci.com/gh/awulkiew/geometry/tree/master) | [![status](https://coveralls.io/repos/awulkiew/geometry/badge.png?branch=master%0A)](https://coveralls.io/r/awulkiew/geometry?branch=master) | [![geometry](https://img.shields.io/badge/-geometry-4480cc.png?style=plastic)](http://www.boost.org/development/tests/master/developer/geometry.html) [![index](https://img.shields.io/badge/-index-4480cc.png?style=plastic)](http://www.boost.org/development/tests/master/developer/geometry-index.html) +**develop** | [![status](https://circleci.com/gh/awulkiew/geometry/tree/develop.png?style=shield)](https://circleci.com/gh/awulkiew/geometry/tree/develop) | [![status](https://coveralls.io/repos/awulkiew/geometry/badge.png?branch=develop%0A)](https://coveralls.io/r/awulkiew/geometry?branch=develop) | [![geometry](https://img.shields.io/badge/-geometry-4480cc.png?style=plastic)](http://www.boost.org/development/tests/develop/developer/geometry.html) [![index](https://img.shields.io/badge/-index-4480cc.png?style=plastic)](http://www.boost.org/development/tests/develop/developer/geometry-index.html) [![extensions](https://img.shields.io/badge/-extensions-4480cc.png?style=plastic)](http://www.boost.org/development/tests/develop/developer/geometry-extensions.html) + ### More information -* [Wiki](http://github.com/boostorg/geometry/wiki) * [Documentation](http://boost.org/libs/geometry) +* [Wiki](http://github.com/boostorg/geometry/wiki) + diff --git a/circle.yml b/circle.yml new file mode 100644 index 000000000..46f5e36e9 --- /dev/null +++ b/circle.yml @@ -0,0 +1,147 @@ +# Use, modification, and distribution are +# 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) +# +# Copyright Antony Polukhin 2014. +# Copyright Adam Wulkiewicz 2015. + +general: + branches: + only: + - master + - develop + +machine: + environment: + # required directories + BOOST_DIR: boost-local + COVERAGE_DIR: coverage-local + PROJECT_ROOT: $HOME/$CIRCLE_PROJECT_REPONAME + BOOST_ROOT: $PROJECT_ROOT/$BOOST_DIR + COVERAGE_ROOT: $PROJECT_ROOT/$COVERAGE_DIR + #COVERAGE_ROOT: $CIRCLE_ARTIFACTS + + # set TravisCI variabls because various tools uses them + #TRAVIS_BRANCH: $CIRCLE_BRANCH + #TRAVIS_BUILD_DIR: $HOME/$CIRCLE_PROJECT_REPONAME + #TRAVIS_COMMIT: $CIRCLE_SHA1 + #TRAVIS_COMMIT_RANGE: $CIRCLE_SHA1 + #TRAVIS_BUILD_ID: $CIRCLE_BUILD_NUM + #TRAVIS_BUILD_NUMBER: $CIRCLE_BUILD_NUM + #TRAVIS_JOB_ID: $((CIRCLE_NODE_INDEX+1)) + #TRAVIS_JOB_NUMBER: $TRAVIS_BUILD_NUMBER.$TRAVIS_JOB_ID + #TRAVIS_PULL_REQUEST: $CI_PULL_REQUEST + +dependencies: + pre: + - sudo apt-get update + - sudo apt-get install gcc-4.8 g++-4.8 build-essential + - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 10 + - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 10 + - sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-4.8 10 + - sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 20 + - sudo update-alternatives --set cc /usr/bin/gcc + - sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 20 + - sudo update-alternatives --set c++ /usr/bin/g++ + - sudo update-alternatives --config gcc + - sudo update-alternatives --config g++ + - sudo update-alternatives --config gcov + #- sudo apt-get install clang + #- sudo ln -s /usr/lib/llvm-3.0/lib/libprofile_rt.a /usr/lib/libprofile_rt.a + - sudo apt-get install python-yaml + + - pwd + + - mkdir $BOOST_ROOT + - cd $BOOST_ROOT && git init . + - cd $BOOST_ROOT && git remote add --no-tags -t $CIRCLE_BRANCH origin https://github.com/boostorg/boost.git + - cd $BOOST_ROOT && git fetch --depth=1 + - cd $BOOST_ROOT && git checkout $CIRCLE_BRANCH + - cd $BOOST_ROOT && git submodule update --init --merge + - cd $BOOST_ROOT && git remote set-branches --add origin $CIRCLE_BRANCH + - cd $BOOST_ROOT && git pull --recurse-submodules + - cd $BOOST_ROOT && git submodule update --init + - cd $BOOST_ROOT && git checkout $CIRCLE_BRANCH + - cd $BOOST_ROOT && git submodule foreach "git reset --quiet --hard; git clean -fxd" + - cd $BOOST_ROOT && git reset --hard; git clean -fxd + - cd $BOOST_ROOT && git status + - cd $BOOST_ROOT && rm -rf libs/geometry/ + - mkdir $BOOST_ROOT/libs/geometry + - cp -R `ls -A | grep -v $BOOST_DIR` $BOOST_ROOT/libs/geometry/ + - cd $BOOST_ROOT && ./bootstrap.sh + - cd $BOOST_ROOT && ./b2 headers + + # wait with the further modifications of the project directory until now + # to avoid copying into the $BOOST_ROOT/libs/geometry/ + + - wget http://downloads.sourceforge.net/ltp/lcov-1.11.tar.gz + - tar xvzf lcov-1.11.tar.gz + - cd lcov-1.11 && sudo make install + - gem install coveralls-lcov + + - if [ ! -d $COVERAGE_ROOT ]; then mkdir $COVERAGE_ROOT; fi + +test: + override: + # `--coverage` flags required to generate coverage info for Coveralls + # temporary for test purposes + #- cd $BOOST_ROOT/libs/geometry && ../../b2 cxxflags="--coverage" linkflags="--coverage" test/algorithms + #- cd $BOOST_ROOT/libs/geometry && ../../b2 cxxflags="--coverage" linkflags="--coverage" test/algorithms/detail + #- cd $BOOST_ROOT/libs/geometry && ../../b2 cxxflags="--coverage" linkflags="--coverage" test/algorithms/relational_operations + - cd $BOOST_ROOT/libs/geometry && ../../b2 cxxflags="--coverage" linkflags="--coverage" test + - cd $BOOST_ROOT/libs/geometry && ../../b2 cxxflags="--coverage" linkflags="--coverage" index/test/algorithms + - cd $BOOST_ROOT/libs/geometry && ../../b2 cxxflags="--coverage" linkflags="--coverage" index/test/rtree/exceptions + post: + ## Preparing Coveralls data by + + ## ... changind data format to a readable one + + + ## VERSION 1 + ## Copying Coveralls data to a separate folder + #- find $BOOST_ROOT/bin.v2/ -name "*.gcda" -exec cp "{}" $COVERAGE_ROOT \; + #- find $BOOST_ROOT/bin.v2/ -name "*.gcno" -exec cp "{}" $COVERAGE_ROOT \; + # upgraded version - change the file name if exists + - find $BOOST_ROOT/bin.v2/ -name "*.gcda" -exec bash -c 'filen=$(basename $1) ; filen=${filen%.*} ; dirn=$(dirname $1) ; srcgcda=$dirn/$filen.gcda ; srcgcno=$dirn/$filen.gcno ; if [ -f $COVERAGE_ROOT/$(basename $1) ]; then randn=$RANDOM ; cp $srcgcda $COVERAGE_ROOT/$filen.$randn.gcda ; cp $srcgcno $COVERAGE_ROOT/$filen.$randn.gcno ; else cp $srcgcda $COVERAGE_ROOT/ ; cp $srcgcno $COVERAGE_ROOT/ ; fi' bash "{}" \; + + - cd $BOOST_ROOT/libs/geometry && lcov --directory $COVERAGE_ROOT --base-directory ./ --capture --output-file $COVERAGE_ROOT/coverage.info + + ## ... erasing /usr and unneeded directories data + - lcov --remove $COVERAGE_ROOT/coverage.info "/usr*" "*/libs/geometry/*" -o $COVERAGE_ROOT/coverage.info + + ## ... erasing data that is not related to this project directly + - ls $BOOST_ROOT/boost | sed -r '/(geometry.*)/d' | sed -r 's/(.+)/"*\/boost\/\1\/*"/g' | sed -r 's/(.+\.hpp)\/\*/\1/g' | sed ':a;N;$!ba;s/\n/ /g' | xargs lcov --remove $COVERAGE_ROOT/coverage.info -o $COVERAGE_ROOT/coverage.info + + + ## VERSION 2 - remove unneeded data per test to not generate a huge *.info file + #- find $BOOST_ROOT/bin.v2/ \( -name "*.gcda" -o -name "*.gcno" \) -exec ls "{}" \; # TEST + + ## ... for each found *.gcda file generate a $COVERAGE_ROOT/*.gcda.info file +# - find $BOOST_ROOT/bin.v2/ -name "*.gcda" -exec bash -c 'cd $BOOST_ROOT/libs/geometry && lcov --directory $HOME/geometry/$(dirname "$1") --base-directory ./ --capture --output-file $COVERAGE_ROOT/$(basename "$1").info' bash "{}" \; + + ## ... save the space + #- rm -rf $BOOST_ROOT/bin.v2/ + + ## ... erasing /usr /test/ /example/ folder data +# - for f in $COVERAGE_ROOT/*.info ; do lcov --remove "$f" "/usr*" "*/geometry/test/*" "*/geometry/example/*" "*/geometry/index/*" "*/geometry/extensions/*" -o "$f"; done + + ## ... erasing data that is not related to this project directly +# - for f in $COVERAGE_ROOT/*.info ; do ls $HOME/geometry/$BOOST_ROOT/boost | sed -r '/(geometry.*)/d' | sed -r 's/(.+)/"*\/boost\/\1\/*"/g' | sed -r 's/(.+\.hpp)\/\*/\1/g' | sed ':a;N;$!ba;s/\n/ /g' | xargs lcov --remove "$f" -o "$f" ; done + + ## ... remove empty files since the next command can fail for them +# - for f in $COVERAGE_ROOT/*.info ; do if [ ! -s "$f" ]; then rm -f "$f"; fi ; done + + ## ... generate one coverage.info file +# - lcov -o $COVERAGE_ROOT/coverage.info `find $COVERAGE_ROOT/ -maxdepth 1 -name "*.info" | sed -r 's/(.+)/--add-tracefile \1/g' | sed ':a;N;$!ba;s/\n/ /g'` + + + ## ... sanity check + - ls -lah $COVERAGE_ROOT + + ## Sending data to Coveralls + + ## ... convert data with coveralls-lcov + #- coveralls-lcov -v -n $COVERAGE_ROOT/coverage.info > $COVERAGE_ROOT/coverage.json # TEST + + ## ... send + - coveralls-lcov --repo-token=$COVERALLS_REPO_TOKEN $COVERAGE_ROOT/coverage.info From c598934d4ed44e50adef46cdc9d448898f1637a7 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Fri, 19 Jun 2015 20:56:14 +0200 Subject: [PATCH 13/18] [geometry] Manually alter the JSON result file and send it to Coveralls. - use circle branch name (without newline) - use circleci service_name - set job_id (even if it's not used) --- circle.yml | 92 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 48 insertions(+), 44 deletions(-) diff --git a/circle.yml b/circle.yml index 46f5e36e9..ec26741d8 100644 --- a/circle.yml +++ b/circle.yml @@ -10,6 +10,7 @@ general: only: - master - develop + - test machine: environment: @@ -32,6 +33,11 @@ machine: #TRAVIS_JOB_NUMBER: $TRAVIS_BUILD_NUMBER.$TRAVIS_JOB_ID #TRAVIS_PULL_REQUEST: $CI_PULL_REQUEST + # this is not fully bulletproof, ideally one should check + # if the current branch originates in master or develop + # but it's good enough + BOOST_BRANCH: $([[ "$CIRCLE_BRANCH" = "master" ]] && echo master || echo develop) + dependencies: pre: - sudo apt-get update @@ -49,19 +55,18 @@ dependencies: #- sudo apt-get install clang #- sudo ln -s /usr/lib/llvm-3.0/lib/libprofile_rt.a /usr/lib/libprofile_rt.a - sudo apt-get install python-yaml - - - pwd + - sudo apt-get install jq - mkdir $BOOST_ROOT - cd $BOOST_ROOT && git init . - - cd $BOOST_ROOT && git remote add --no-tags -t $CIRCLE_BRANCH origin https://github.com/boostorg/boost.git + - cd $BOOST_ROOT && git remote add --no-tags -t $BOOST_BRANCH origin https://github.com/boostorg/boost.git - cd $BOOST_ROOT && git fetch --depth=1 - - cd $BOOST_ROOT && git checkout $CIRCLE_BRANCH + - cd $BOOST_ROOT && git checkout $BOOST_BRANCH - cd $BOOST_ROOT && git submodule update --init --merge - - cd $BOOST_ROOT && git remote set-branches --add origin $CIRCLE_BRANCH + - cd $BOOST_ROOT && git remote set-branches --add origin $BOOST_BRANCH - cd $BOOST_ROOT && git pull --recurse-submodules - cd $BOOST_ROOT && git submodule update --init - - cd $BOOST_ROOT && git checkout $CIRCLE_BRANCH + - cd $BOOST_ROOT && git checkout $BOOST_BRANCH - cd $BOOST_ROOT && git submodule foreach "git reset --quiet --hard; git clean -fxd" - cd $BOOST_ROOT && git reset --hard; git clean -fxd - cd $BOOST_ROOT && git status @@ -91,57 +96,56 @@ test: - cd $BOOST_ROOT/libs/geometry && ../../b2 cxxflags="--coverage" linkflags="--coverage" test - cd $BOOST_ROOT/libs/geometry && ../../b2 cxxflags="--coverage" linkflags="--coverage" index/test/algorithms - cd $BOOST_ROOT/libs/geometry && ../../b2 cxxflags="--coverage" linkflags="--coverage" index/test/rtree/exceptions + # run the tests in parallel - actually for now not in parallel + # the problem is that first the upper-level dir is handled + # then the tests from lower dir are run are executed and they're overlapping + #- cd $BOOST_ROOT/libs/geometry && index=0 ; run_tests() { for i in "$1"/* ; do if [ -f "$i"/Jamfile* ] ; then ((index++)) ; echo "$index - $i" ; ../../b2 cxxflags="--coverage" linkflags="--coverage" "$i" ; run_tests "$i" ; fi ; done } ; run_tests test + # so first try manually + #- cd $BOOST_ROOT/libs/geometry && case $CIRCLE_NODE_INDEX in 0) ../../b2 cxxflags="--coverage" linkflags="--coverage" test/io ;; 1) ../../b2 cxxflags="--coverage" linkflags="--coverage" test/views ;; esac: + # parallel: true + post: - ## Preparing Coveralls data by - - ## ... changind data format to a readable one - - - ## VERSION 1 ## Copying Coveralls data to a separate folder #- find $BOOST_ROOT/bin.v2/ -name "*.gcda" -exec cp "{}" $COVERAGE_ROOT \; #- find $BOOST_ROOT/bin.v2/ -name "*.gcno" -exec cp "{}" $COVERAGE_ROOT \; # upgraded version - change the file name if exists - - find $BOOST_ROOT/bin.v2/ -name "*.gcda" -exec bash -c 'filen=$(basename $1) ; filen=${filen%.*} ; dirn=$(dirname $1) ; srcgcda=$dirn/$filen.gcda ; srcgcno=$dirn/$filen.gcno ; if [ -f $COVERAGE_ROOT/$(basename $1) ]; then randn=$RANDOM ; cp $srcgcda $COVERAGE_ROOT/$filen.$randn.gcda ; cp $srcgcno $COVERAGE_ROOT/$filen.$randn.gcno ; else cp $srcgcda $COVERAGE_ROOT/ ; cp $srcgcno $COVERAGE_ROOT/ ; fi' bash "{}" \; + - find $BOOST_ROOT/bin.v2/ -name "*.gcda" -exec bash -c 'filen=$(basename $1) ; filen=${filen%.*} ; dirn=$(dirname $1) ; srcgcda=$dirn/$filen.gcda ; srcgcno=$dirn/$filen.gcno ; echo "$srcgcda" ; if [ -f $COVERAGE_ROOT/$(basename $1) ]; then randn=$RANDOM ; cp $srcgcda $COVERAGE_ROOT/$filen.$randn.gcda ; cp $srcgcno $COVERAGE_ROOT/$filen.$randn.gcno ; else cp $srcgcda $COVERAGE_ROOT/ ; cp $srcgcno $COVERAGE_ROOT/ ; fi' bash "{}" \; #: + #parallel: true - - cd $BOOST_ROOT/libs/geometry && lcov --directory $COVERAGE_ROOT --base-directory ./ --capture --output-file $COVERAGE_ROOT/coverage.info + ## Preparing Coveralls data by + + ## ... changind data format to a readable one + + - cd $BOOST_ROOT/libs/geometry && lcov --directory $COVERAGE_ROOT --base-directory ./ --capture --output-file $COVERAGE_ROOT/coverage.info #: + #parallel: true ## ... erasing /usr and unneeded directories data - - lcov --remove $COVERAGE_ROOT/coverage.info "/usr*" "*/libs/geometry/*" -o $COVERAGE_ROOT/coverage.info + - lcov --remove $COVERAGE_ROOT/coverage.info "/usr*" "*/libs/geometry/*" -o $COVERAGE_ROOT/coverage.info #: + #parallel: true ## ... erasing data that is not related to this project directly - - ls $BOOST_ROOT/boost | sed -r '/(geometry.*)/d' | sed -r 's/(.+)/"*\/boost\/\1\/*"/g' | sed -r 's/(.+\.hpp)\/\*/\1/g' | sed ':a;N;$!ba;s/\n/ /g' | xargs lcov --remove $COVERAGE_ROOT/coverage.info -o $COVERAGE_ROOT/coverage.info - - - ## VERSION 2 - remove unneeded data per test to not generate a huge *.info file - #- find $BOOST_ROOT/bin.v2/ \( -name "*.gcda" -o -name "*.gcno" \) -exec ls "{}" \; # TEST - - ## ... for each found *.gcda file generate a $COVERAGE_ROOT/*.gcda.info file -# - find $BOOST_ROOT/bin.v2/ -name "*.gcda" -exec bash -c 'cd $BOOST_ROOT/libs/geometry && lcov --directory $HOME/geometry/$(dirname "$1") --base-directory ./ --capture --output-file $COVERAGE_ROOT/$(basename "$1").info' bash "{}" \; - - ## ... save the space - #- rm -rf $BOOST_ROOT/bin.v2/ - - ## ... erasing /usr /test/ /example/ folder data -# - for f in $COVERAGE_ROOT/*.info ; do lcov --remove "$f" "/usr*" "*/geometry/test/*" "*/geometry/example/*" "*/geometry/index/*" "*/geometry/extensions/*" -o "$f"; done - - ## ... erasing data that is not related to this project directly -# - for f in $COVERAGE_ROOT/*.info ; do ls $HOME/geometry/$BOOST_ROOT/boost | sed -r '/(geometry.*)/d' | sed -r 's/(.+)/"*\/boost\/\1\/*"/g' | sed -r 's/(.+\.hpp)\/\*/\1/g' | sed ':a;N;$!ba;s/\n/ /g' | xargs lcov --remove "$f" -o "$f" ; done - - ## ... remove empty files since the next command can fail for them -# - for f in $COVERAGE_ROOT/*.info ; do if [ ! -s "$f" ]; then rm -f "$f"; fi ; done - - ## ... generate one coverage.info file -# - lcov -o $COVERAGE_ROOT/coverage.info `find $COVERAGE_ROOT/ -maxdepth 1 -name "*.info" | sed -r 's/(.+)/--add-tracefile \1/g' | sed ':a;N;$!ba;s/\n/ /g'` - + - ls $BOOST_ROOT/boost | sed -r '/(geometry.*)/d' | sed -r 's/(.+)/"*\/boost\/\1\/*"/g' | sed -r 's/(.+\.hpp)\/\*/\1/g' | sed ':a;N;$!ba;s/\n/ /g' | xargs lcov --remove $COVERAGE_ROOT/coverage.info -o $COVERAGE_ROOT/coverage.info #: + #parallel: true ## ... sanity check - - ls -lah $COVERAGE_ROOT + - ls -lah $COVERAGE_ROOT #: + #parallel: true ## Sending data to Coveralls - ## ... convert data with coveralls-lcov - #- coveralls-lcov -v -n $COVERAGE_ROOT/coverage.info > $COVERAGE_ROOT/coverage.json # TEST - ## ... send - - coveralls-lcov --repo-token=$COVERALLS_REPO_TOKEN $COVERAGE_ROOT/coverage.info + #- coveralls-lcov --repo-token=$COVERALLS_REPO_TOKEN $COVERAGE_ROOT/coverage.info : + # parallel: true + + ## ... or handle sending manually + ## ... convert data with coveralls-lcov + - coveralls-lcov --repo-token=$COVERALLS_REPO_TOKEN -v -n $COVERAGE_ROOT/coverage.info > $COVERAGE_ROOT/coverage.json #: + #parallel: true + + ## ... alter the json file + - jq -c ".service_name = \"circleci\" | .service_job_id = \"$CIRCLE_BUILD_NUM.$((CIRCLE_NODE_INDEX+1))\" | .git .branch =\"$CIRCLE_BRANCH\"" $COVERAGE_ROOT/coverage.json > $COVERAGE_ROOT/processed.json #: + #parallel: true + + ## ... send it to Coveralls + - curl --retry 3 -F "json_file=@$COVERAGE_ROOT/processed.json" 'https://coveralls.io/api/v1/jobs' #: + #parallel: true From bcc03065b42d0a1d87193d20ec91f526fa256db1 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sat, 20 Jun 2015 03:56:54 +0200 Subject: [PATCH 14/18] [geometry][ci] Enable parallel testing of geometry and index. Gather test results in each CircleCI container, then send all of them to the first one and there merge and send. --- circle.yml | 55 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/circle.yml b/circle.yml index ec26741d8..d7618f2b6 100644 --- a/circle.yml +++ b/circle.yml @@ -82,6 +82,7 @@ dependencies: - wget http://downloads.sourceforge.net/ltp/lcov-1.11.tar.gz - tar xvzf lcov-1.11.tar.gz - cd lcov-1.11 && sudo make install + - gem install coveralls-lcov - if [ ! -d $COVERAGE_ROOT ]; then mkdir $COVERAGE_ROOT; fi @@ -93,59 +94,73 @@ test: #- cd $BOOST_ROOT/libs/geometry && ../../b2 cxxflags="--coverage" linkflags="--coverage" test/algorithms #- cd $BOOST_ROOT/libs/geometry && ../../b2 cxxflags="--coverage" linkflags="--coverage" test/algorithms/detail #- cd $BOOST_ROOT/libs/geometry && ../../b2 cxxflags="--coverage" linkflags="--coverage" test/algorithms/relational_operations - - cd $BOOST_ROOT/libs/geometry && ../../b2 cxxflags="--coverage" linkflags="--coverage" test - - cd $BOOST_ROOT/libs/geometry && ../../b2 cxxflags="--coverage" linkflags="--coverage" index/test/algorithms - - cd $BOOST_ROOT/libs/geometry && ../../b2 cxxflags="--coverage" linkflags="--coverage" index/test/rtree/exceptions + #- cd $BOOST_ROOT/libs/geometry && ../../b2 cxxflags="--coverage" linkflags="--coverage" test + #- cd $BOOST_ROOT/libs/geometry && ../../b2 cxxflags="--coverage" linkflags="--coverage" index/test/algorithms + #- cd $BOOST_ROOT/libs/geometry && ../../b2 cxxflags="--coverage" linkflags="--coverage" index/test/rtree/exceptions # run the tests in parallel - actually for now not in parallel # the problem is that first the upper-level dir is handled # then the tests from lower dir are run are executed and they're overlapping #- cd $BOOST_ROOT/libs/geometry && index=0 ; run_tests() { for i in "$1"/* ; do if [ -f "$i"/Jamfile* ] ; then ((index++)) ; echo "$index - $i" ; ../../b2 cxxflags="--coverage" linkflags="--coverage" "$i" ; run_tests "$i" ; fi ; done } ; run_tests test # so first try manually - #- cd $BOOST_ROOT/libs/geometry && case $CIRCLE_NODE_INDEX in 0) ../../b2 cxxflags="--coverage" linkflags="--coverage" test/io ;; 1) ../../b2 cxxflags="--coverage" linkflags="--coverage" test/views ;; esac: - # parallel: true + - cd $BOOST_ROOT/libs/geometry && case $CIRCLE_NODE_INDEX in 0) ../../b2 cxxflags="--coverage" linkflags="--coverage" test ;; 1) ../../b2 cxxflags="--coverage" linkflags="--coverage" index/test ;; esac: + parallel: true post: ## Copying Coveralls data to a separate folder #- find $BOOST_ROOT/bin.v2/ -name "*.gcda" -exec cp "{}" $COVERAGE_ROOT \; #- find $BOOST_ROOT/bin.v2/ -name "*.gcno" -exec cp "{}" $COVERAGE_ROOT \; # upgraded version - change the file name if exists - - find $BOOST_ROOT/bin.v2/ -name "*.gcda" -exec bash -c 'filen=$(basename $1) ; filen=${filen%.*} ; dirn=$(dirname $1) ; srcgcda=$dirn/$filen.gcda ; srcgcno=$dirn/$filen.gcno ; echo "$srcgcda" ; if [ -f $COVERAGE_ROOT/$(basename $1) ]; then randn=$RANDOM ; cp $srcgcda $COVERAGE_ROOT/$filen.$randn.gcda ; cp $srcgcno $COVERAGE_ROOT/$filen.$randn.gcno ; else cp $srcgcda $COVERAGE_ROOT/ ; cp $srcgcno $COVERAGE_ROOT/ ; fi' bash "{}" \; #: - #parallel: true + - find $BOOST_ROOT/bin.v2/ -name "*.gcda" -exec bash -c 'filen=$(basename $1) ; filen=${filen%.*} ; dirn=$(dirname $1) ; srcgcda=$dirn/$filen.gcda ; srcgcno=$dirn/$filen.gcno ; echo "$srcgcda" ; if [ -f $COVERAGE_ROOT/$(basename $1) ]; then randn=$RANDOM ; cp $srcgcda $COVERAGE_ROOT/$filen.$randn.gcda ; cp $srcgcno $COVERAGE_ROOT/$filen.$randn.gcno ; else cp $srcgcda $COVERAGE_ROOT/ ; cp $srcgcno $COVERAGE_ROOT/ ; fi' bash "{}" \; : + parallel: true ## Preparing Coveralls data by ## ... changind data format to a readable one - - cd $BOOST_ROOT/libs/geometry && lcov --directory $COVERAGE_ROOT --base-directory ./ --capture --output-file $COVERAGE_ROOT/coverage.info #: - #parallel: true + - cd $BOOST_ROOT/libs/geometry && lcov --directory $COVERAGE_ROOT --base-directory ./ --capture --output-file $COVERAGE_ROOT/coverage.info : + parallel: true ## ... erasing /usr and unneeded directories data - - lcov --remove $COVERAGE_ROOT/coverage.info "/usr*" "*/libs/geometry/*" -o $COVERAGE_ROOT/coverage.info #: - #parallel: true + - lcov --remove $COVERAGE_ROOT/coverage.info "/usr*" "*/libs/geometry/*" -o $COVERAGE_ROOT/coverage.info : + parallel: true ## ... erasing data that is not related to this project directly - - ls $BOOST_ROOT/boost | sed -r '/(geometry.*)/d' | sed -r 's/(.+)/"*\/boost\/\1\/*"/g' | sed -r 's/(.+\.hpp)\/\*/\1/g' | sed ':a;N;$!ba;s/\n/ /g' | xargs lcov --remove $COVERAGE_ROOT/coverage.info -o $COVERAGE_ROOT/coverage.info #: - #parallel: true + - ls $BOOST_ROOT/boost | sed -r '/(geometry.*)/d' | sed -r 's/(.+)/"*\/boost\/\1\/*"/g' | sed -r 's/(.+\.hpp)\/\*/\1/g' | sed ':a;N;$!ba;s/\n/ /g' | xargs lcov --remove $COVERAGE_ROOT/coverage.info -o $COVERAGE_ROOT/coverage.info : + parallel: true ## ... sanity check - - ls -lah $COVERAGE_ROOT #: - #parallel: true + - ls -lah $COVERAGE_ROOT : + parallel: true ## Sending data to Coveralls - ## ... send - #- coveralls-lcov --repo-token=$COVERALLS_REPO_TOKEN $COVERAGE_ROOT/coverage.info : - # parallel: true + ## ... approach 1 + ## ... gather all files in one container + - if [ $CIRCLE_NODE_INDEX = 0 ]; then mv $COVERAGE_ROOT/coverage.info $COVERAGE_ROOT/coverage0.info ; else scp $COVERAGE_ROOT/coverage.info node0:$COVERAGE_ROOT/coverage$CIRCLE_NODE_INDEX.info ; fi : + parallel: true + # merge files (currently only 1 additional file) + - lcov --add-tracefile $COVERAGE_ROOT/coverage0.info --add-tracefile $COVERAGE_ROOT/coverage1.info -o $COVERAGE_ROOT/coverage.info - ## ... or handle sending manually + ## ... handle sending manually ## ... convert data with coveralls-lcov - coveralls-lcov --repo-token=$COVERALLS_REPO_TOKEN -v -n $COVERAGE_ROOT/coverage.info > $COVERAGE_ROOT/coverage.json #: #parallel: true ## ... alter the json file - - jq -c ".service_name = \"circleci\" | .service_job_id = \"$CIRCLE_BUILD_NUM.$((CIRCLE_NODE_INDEX+1))\" | .git .branch =\"$CIRCLE_BRANCH\"" $COVERAGE_ROOT/coverage.json > $COVERAGE_ROOT/processed.json #: + - jq -c ".service_name = \"circle-ci\" | .service_job_id = \"$CIRCLE_BUILD_NUM\" | .git .branch =\"$CIRCLE_BRANCH\"" $COVERAGE_ROOT/coverage.json > $COVERAGE_ROOT/processed.json + #- jq -c ".service_name = \"circle-ci\" | .service_job_id = \"$CIRCLE_BUILD_NUM\" | .parallel = true | .git .branch =\"$CIRCLE_BRANCH\"" $COVERAGE_ROOT/coverage.json > $COVERAGE_ROOT/processed.json #: #parallel: true ## ... send it to Coveralls - curl --retry 3 -F "json_file=@$COVERAGE_ROOT/processed.json" 'https://coveralls.io/api/v1/jobs' #: #parallel: true + + ## ... notify Coveralls that the parallel build has ended + # this doesn't work - Coveralls returns an error + #- echo "{\"payload\":{\"build_num\":\"$CIRCLE_BUILD_NUM\",\"status\":\"done\"}}" > $COVERAGE_ROOT/payload.json && curl --retry 3 -F "json_file=@$COVERAGE_ROOT/payload.json" "https://coveralls.io/webhook?repo_token=$COVERALLS_REPO_TOKEN" + +## This doesn't work - Coveralls returns an error +#notify: +# webhooks: + # Notify Coveralls that the build has ended + #- url: https://coveralls.io/webhook?repo_token=$COVERALLS_REPO_TOKEN From 514251c7feb1bde17edbed1fdcde2bbe11106b6b Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sat, 20 Jun 2015 05:35:09 +0200 Subject: [PATCH 15/18] [geometry][readme] Use consistent, flat badges from shields.io --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index de0e359eb..bbba7d46f 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,8 @@ Boost.Geometry, part of collection of the [Boost C++ Libraries](http://github.co @ | Build | Coverage | Regression ------------|---------------|----------------|------------ -**master** | [![status](https://circleci.com/gh/awulkiew/geometry/tree/master.png?style=shield)](https://circleci.com/gh/awulkiew/geometry/tree/master) | [![status](https://coveralls.io/repos/awulkiew/geometry/badge.png?branch=master%0A)](https://coveralls.io/r/awulkiew/geometry?branch=master) | [![geometry](https://img.shields.io/badge/-geometry-4480cc.png?style=plastic)](http://www.boost.org/development/tests/master/developer/geometry.html) [![index](https://img.shields.io/badge/-index-4480cc.png?style=plastic)](http://www.boost.org/development/tests/master/developer/geometry-index.html) -**develop** | [![status](https://circleci.com/gh/awulkiew/geometry/tree/develop.png?style=shield)](https://circleci.com/gh/awulkiew/geometry/tree/develop) | [![status](https://coveralls.io/repos/awulkiew/geometry/badge.png?branch=develop%0A)](https://coveralls.io/r/awulkiew/geometry?branch=develop) | [![geometry](https://img.shields.io/badge/-geometry-4480cc.png?style=plastic)](http://www.boost.org/development/tests/develop/developer/geometry.html) [![index](https://img.shields.io/badge/-index-4480cc.png?style=plastic)](http://www.boost.org/development/tests/develop/developer/geometry-index.html) [![extensions](https://img.shields.io/badge/-extensions-4480cc.png?style=plastic)](http://www.boost.org/development/tests/develop/developer/geometry-extensions.html) +**master** | [![status](https://img.shields.io/circleci/project/awulkiew/geometry/master.png)](https://circleci.com/gh/awulkiew/geometry/tree/master) | [![status](https://img.shields.io/coveralls/awulkiew/geometry/master.png)](https://coveralls.io/r/awulkiew/geometry?branch=master) | [![geometry](https://img.shields.io/badge/-geometry-4480cc.png)](http://www.boost.org/development/tests/master/developer/geometry.html) [![index](https://img.shields.io/badge/-index-4480cc.png)](http://www.boost.org/development/tests/master/developer/geometry-index.html) +**develop** | [![status](https://img.shields.io/circleci/project/awulkiew/geometry/develop.png)](https://circleci.com/gh/awulkiew/geometry/tree/develop) | [![status](https://img.shields.io/coveralls/awulkiew/geometry/develop.png)](https://coveralls.io/r/awulkiew/geometry?branch=develop) | [![geometry](https://img.shields.io/badge/-geometry-4480cc.png)](http://www.boost.org/development/tests/develop/developer/geometry.html) [![index](https://img.shields.io/badge/-index-4480cc.png)](http://www.boost.org/development/tests/develop/developer/geometry-index.html) [![extensions](https://img.shields.io/badge/-extensions-4480cc.png)](http://www.boost.org/development/tests/develop/developer/geometry-extensions.html) ### More information From 583354cbae834a23e27a243fc7b3d62ebaea870e Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sat, 20 Jun 2015 05:47:55 +0200 Subject: [PATCH 16/18] [test][intersects] Suppress unused local typedef warnings. --- .../intersects/intersects.cpp | 8 ++-- .../intersects/intersects_self.cpp | 42 ++++++++++--------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/test/algorithms/relational_operations/intersects/intersects.cpp b/test/algorithms/relational_operations/intersects/intersects.cpp index 876d6bb29..5ef71ba00 100644 --- a/test/algorithms/relational_operations/intersects/intersects.cpp +++ b/test/algorithms/relational_operations/intersects/intersects.cpp @@ -176,20 +176,20 @@ void test_all() test_multi_linestring_polygon

(); test_multi_polygon_polygon

(); - test_geometry >( + test_geometry( "POINT(0 0)", "POLYGON((0 0,3 3,3 3,4 1))", true); - test_geometry >( + test_geometry( "POINT(0 0)", "POLYGON((0 0,3 3,3 3,4 1))", true); - test_geometry, P>( + test_geometry( "POLYGON((0 0,3 3,3 3,4 1))", "POINT(0 0)", true); - test_geometry, P>( + test_geometry( "POLYGON((0 0,3 3,3 3,4 1))", "POINT(0 0)", true); diff --git a/test/algorithms/relational_operations/intersects/intersects_self.cpp b/test/algorithms/relational_operations/intersects/intersects_self.cpp index 5bfb79b5a..6d6c4172a 100644 --- a/test/algorithms/relational_operations/intersects/intersects_self.cpp +++ b/test/algorithms/relational_operations/intersects/intersects_self.cpp @@ -22,8 +22,10 @@ template void test_all() { + typedef bg::model::linestring

linestring; typedef bg::model::polygon

polygon; typedef bg::model::ring

ring; + typedef bg::model::ring ring_open; // self-intersecting is not tested in disjoint, so that is done here. @@ -64,54 +66,54 @@ void test_all() "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 >( + test_self_intersects( "LINESTRING(0 0,0 4,4 4,2 2,2 5)", true); - test_self_intersects >( + test_self_intersects( "LINESTRING(0 4,4 4,2 2,2 5)", true); // Test self-intersections at last segment in close/open rings: - test_self_intersects >( + test_self_intersects( "POLYGON((0 0,3 3,4 1,0 0))", false); - test_self_intersects >( + test_self_intersects( "POLYGON((0 0,3 3,4 1))", false); - test_self_intersects >( + test_self_intersects( "POLYGON((0 0,3 3,4 1,0 1,0 0))", true); - test_self_intersects >( + test_self_intersects( "POLYGON((0 0,3 3,4 1,0 1))", true); // Duplicates in first or last - test_self_intersects >( + test_self_intersects( "POLYGON((0 0,3 3,4 1,0 1,0 1,0 0))", true); - test_self_intersects >( + test_self_intersects( "POLYGON((0 0,3 3,4 1,0 1,0 0,0 0))", true); - test_self_intersects >( + test_self_intersects( "POLYGON((0 0,3 3,4 1,0 1,0 1))", true); - test_self_intersects >( + test_self_intersects( "POLYGON((0 0,0 0,3 3,4 1,0 1,0 1,0 0))", true); - test_self_intersects >( + test_self_intersects( "POLYGON((0 0,0 0,3 3,4 1,0 1,0 1))", true); - test_self_intersects >( + test_self_intersects( "POLYGON((0 0,3 3,3 3,4 1,0 1,0 1,0 0))", true); - test_self_intersects >( + test_self_intersects( "POLYGON((0 0,3 3,3 3,4 1,0 1,0 1))", true); - test_self_intersects >( + test_self_intersects( "POLYGON((0 0,3 3,4 1,0 0,0 0))", false); - test_self_intersects >( + test_self_intersects( "POLYGON((0 0,3 3,4 1,4 1,0 0))", false); - test_self_intersects >( + test_self_intersects( "POLYGON((0 0,3 3,4 1,4 1))", false); - test_self_intersects >( + test_self_intersects( "POLYGON((0 0,0 0,3 3,4 1,0 0))", false); - test_self_intersects >( + test_self_intersects( "POLYGON((0 0,0 0,3 3,4 1))", false); - test_self_intersects >( + test_self_intersects( "POLYGON((0 0,3 3,3 3,4 1,0 0))", false); - test_self_intersects >( + test_self_intersects( "POLYGON((0 0,3 3,3 3,4 1))", false); } From 2e0cfd631a3cb1877435ec11815b5da82a852e53 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sat, 20 Jun 2015 05:55:40 +0200 Subject: [PATCH 17/18] [geometry][ci] Move *.gcda and *.gcno coverage files instead of copy. --- circle.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/circle.yml b/circle.yml index d7618f2b6..ee3f55752 100644 --- a/circle.yml +++ b/circle.yml @@ -107,10 +107,10 @@ test: post: ## Copying Coveralls data to a separate folder - #- find $BOOST_ROOT/bin.v2/ -name "*.gcda" -exec cp "{}" $COVERAGE_ROOT \; - #- find $BOOST_ROOT/bin.v2/ -name "*.gcno" -exec cp "{}" $COVERAGE_ROOT \; + #- find $BOOST_ROOT/bin.v2/ -name "*.gcda" -exec mv "{}" $COVERAGE_ROOT \; + #- find $BOOST_ROOT/bin.v2/ -name "*.gcno" -exec mv "{}" $COVERAGE_ROOT \; # upgraded version - change the file name if exists - - find $BOOST_ROOT/bin.v2/ -name "*.gcda" -exec bash -c 'filen=$(basename $1) ; filen=${filen%.*} ; dirn=$(dirname $1) ; srcgcda=$dirn/$filen.gcda ; srcgcno=$dirn/$filen.gcno ; echo "$srcgcda" ; if [ -f $COVERAGE_ROOT/$(basename $1) ]; then randn=$RANDOM ; cp $srcgcda $COVERAGE_ROOT/$filen.$randn.gcda ; cp $srcgcno $COVERAGE_ROOT/$filen.$randn.gcno ; else cp $srcgcda $COVERAGE_ROOT/ ; cp $srcgcno $COVERAGE_ROOT/ ; fi' bash "{}" \; : + - find $BOOST_ROOT/bin.v2/ -name "*.gcda" -exec bash -c 'filen=$(basename $1) ; filen=${filen%.*} ; dirn=$(dirname $1) ; srcgcda=$dirn/$filen.gcda ; srcgcno=$dirn/$filen.gcno ; echo "$srcgcda" ; if [ -f $COVERAGE_ROOT/$(basename $1) ]; then randn=$RANDOM ; mv $srcgcda $COVERAGE_ROOT/$filen.$randn.gcda ; mv $srcgcno $COVERAGE_ROOT/$filen.$randn.gcno ; else mv $srcgcda $COVERAGE_ROOT/ ; mv $srcgcno $COVERAGE_ROOT/ ; fi' bash "{}" \; : parallel: true ## Preparing Coveralls data by From 9804911dd15e55f1fd46acc5a4225f1eef5c14d5 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sat, 20 Jun 2015 18:48:10 +0200 Subject: [PATCH 18/18] [geometry][ci] Improve the CircleCI script. - define the tests as a list stored in the environment variable - when moving the coverage results keep picking test names until a unique name is found. - after the info files from different containers are gathered automatically merge all of them into one. - improve/add comments --- circle.yml | 70 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/circle.yml b/circle.yml index ee3f55752..4a421267a 100644 --- a/circle.yml +++ b/circle.yml @@ -14,33 +14,30 @@ general: machine: environment: + # define tests list, if parallelism is enabled they are run in parallel + TESTS: test index/test + + # this is not fully bulletproof, ideally one should check + # if the current branch originates in master or develop + # but it's good enough + # test library using corresponding branch of Boost repository + BOOST_BRANCH: $([[ "$CIRCLE_BRANCH" = "master" ]] && echo master || echo develop) + # required directories BOOST_DIR: boost-local COVERAGE_DIR: coverage-local + + # helper variables PROJECT_ROOT: $HOME/$CIRCLE_PROJECT_REPONAME BOOST_ROOT: $PROJECT_ROOT/$BOOST_DIR COVERAGE_ROOT: $PROJECT_ROOT/$COVERAGE_DIR #COVERAGE_ROOT: $CIRCLE_ARTIFACTS - # set TravisCI variabls because various tools uses them - #TRAVIS_BRANCH: $CIRCLE_BRANCH - #TRAVIS_BUILD_DIR: $HOME/$CIRCLE_PROJECT_REPONAME - #TRAVIS_COMMIT: $CIRCLE_SHA1 - #TRAVIS_COMMIT_RANGE: $CIRCLE_SHA1 - #TRAVIS_BUILD_ID: $CIRCLE_BUILD_NUM - #TRAVIS_BUILD_NUMBER: $CIRCLE_BUILD_NUM - #TRAVIS_JOB_ID: $((CIRCLE_NODE_INDEX+1)) - #TRAVIS_JOB_NUMBER: $TRAVIS_BUILD_NUMBER.$TRAVIS_JOB_ID - #TRAVIS_PULL_REQUEST: $CI_PULL_REQUEST - - # this is not fully bulletproof, ideally one should check - # if the current branch originates in master or develop - # but it's good enough - BOOST_BRANCH: $([[ "$CIRCLE_BRANCH" = "master" ]] && echo master || echo develop) - dependencies: pre: - sudo apt-get update + + # gcc, g++, gcov - sudo apt-get install gcc-4.8 g++-4.8 build-essential - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 10 - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 10 @@ -52,11 +49,17 @@ dependencies: - sudo update-alternatives --config gcc - sudo update-alternatives --config g++ - sudo update-alternatives --config gcov - #- sudo apt-get install clang - #- sudo ln -s /usr/lib/llvm-3.0/lib/libprofile_rt.a /usr/lib/libprofile_rt.a - - sudo apt-get install python-yaml + + # coveralls-lcov for lcov *.info to JSON conversion + - gem install coveralls-lcov + + # jq for JSON handling - sudo apt-get install jq + # curl for HTTP + - sudo apt-get install curl + + # clone boost repository - mkdir $BOOST_ROOT - cd $BOOST_ROOT && git init . - cd $BOOST_ROOT && git remote add --no-tags -t $BOOST_BRANCH origin https://github.com/boostorg/boost.git @@ -70,21 +73,24 @@ dependencies: - cd $BOOST_ROOT && git submodule foreach "git reset --quiet --hard; git clean -fxd" - cd $BOOST_ROOT && git reset --hard; git clean -fxd - cd $BOOST_ROOT && git status + # replace the content of the library with the currently tested repo - cd $BOOST_ROOT && rm -rf libs/geometry/ - mkdir $BOOST_ROOT/libs/geometry - cp -R `ls -A | grep -v $BOOST_DIR` $BOOST_ROOT/libs/geometry/ + # build b2 and create headers - cd $BOOST_ROOT && ./bootstrap.sh - cd $BOOST_ROOT && ./b2 headers - # wait with the further modifications of the project directory until now + # wait with the modifications of the project directory until now # to avoid copying into the $BOOST_ROOT/libs/geometry/ + # download and install the latest lcov + # do not use the old one from sources - wget http://downloads.sourceforge.net/ltp/lcov-1.11.tar.gz - tar xvzf lcov-1.11.tar.gz - cd lcov-1.11 && sudo make install - - gem install coveralls-lcov - + # create a direcotry for temporary coverage data - if [ ! -d $COVERAGE_ROOT ]; then mkdir $COVERAGE_ROOT; fi test: @@ -97,12 +103,13 @@ test: #- cd $BOOST_ROOT/libs/geometry && ../../b2 cxxflags="--coverage" linkflags="--coverage" test #- cd $BOOST_ROOT/libs/geometry && ../../b2 cxxflags="--coverage" linkflags="--coverage" index/test/algorithms #- cd $BOOST_ROOT/libs/geometry && ../../b2 cxxflags="--coverage" linkflags="--coverage" index/test/rtree/exceptions - # run the tests in parallel - actually for now not in parallel + # this is the first step of the first approach to automatic balancing # the problem is that first the upper-level dir is handled - # then the tests from lower dir are run are executed and they're overlapping + # then the tests from lower dir are executed, so the tests in various containers overlap #- cd $BOOST_ROOT/libs/geometry && index=0 ; run_tests() { for i in "$1"/* ; do if [ -f "$i"/Jamfile* ] ; then ((index++)) ; echo "$index - $i" ; ../../b2 cxxflags="--coverage" linkflags="--coverage" "$i" ; run_tests "$i" ; fi ; done } ; run_tests test - # so first try manually - - cd $BOOST_ROOT/libs/geometry && case $CIRCLE_NODE_INDEX in 0) ../../b2 cxxflags="--coverage" linkflags="--coverage" test ;; 1) ../../b2 cxxflags="--coverage" linkflags="--coverage" index/test ;; esac: + + # so for now just run the tests from the list + - cd $BOOST_ROOT/libs/geometry && index=0 ; for t in ${TESTS[@]} ; do if [ $((index%CIRCLE_NODE_TOTAL)) -eq $CIRCLE_NODE_INDEX ] ; then ../../b2 cxxflags="--coverage" linkflags="--coverage" $t ; fi ; ((index++)) ; done : parallel: true post: @@ -110,7 +117,7 @@ test: #- find $BOOST_ROOT/bin.v2/ -name "*.gcda" -exec mv "{}" $COVERAGE_ROOT \; #- find $BOOST_ROOT/bin.v2/ -name "*.gcno" -exec mv "{}" $COVERAGE_ROOT \; # upgraded version - change the file name if exists - - find $BOOST_ROOT/bin.v2/ -name "*.gcda" -exec bash -c 'filen=$(basename $1) ; filen=${filen%.*} ; dirn=$(dirname $1) ; srcgcda=$dirn/$filen.gcda ; srcgcno=$dirn/$filen.gcno ; echo "$srcgcda" ; if [ -f $COVERAGE_ROOT/$(basename $1) ]; then randn=$RANDOM ; mv $srcgcda $COVERAGE_ROOT/$filen.$randn.gcda ; mv $srcgcno $COVERAGE_ROOT/$filen.$randn.gcno ; else mv $srcgcda $COVERAGE_ROOT/ ; mv $srcgcno $COVERAGE_ROOT/ ; fi' bash "{}" \; : + - find $BOOST_ROOT/bin.v2/ -name "*.gcda" -exec bash -c 'filen=$(basename $1) ; filen=${filen%.*} ; dirn=$(dirname $1) ; dstfilen=$filen ; while [ -f $COVERAGE_ROOT/$dstfilen.gcda ]; do dstfilen=$filen.$RANDOM ; done ; mv $dirn/$filen.gcda $COVERAGE_ROOT/$dstfilen.gcda ; mv $dirn/$filen.gcno $COVERAGE_ROOT/$dstfilen.gcno ; echo $dstfilen' bash "{}" \; : parallel: true ## Preparing Coveralls data by @@ -134,12 +141,12 @@ test: ## Sending data to Coveralls - ## ... approach 1 ## ... gather all files in one container - if [ $CIRCLE_NODE_INDEX = 0 ]; then mv $COVERAGE_ROOT/coverage.info $COVERAGE_ROOT/coverage0.info ; else scp $COVERAGE_ROOT/coverage.info node0:$COVERAGE_ROOT/coverage$CIRCLE_NODE_INDEX.info ; fi : parallel: true - # merge files (currently only 1 additional file) - - lcov --add-tracefile $COVERAGE_ROOT/coverage0.info --add-tracefile $COVERAGE_ROOT/coverage1.info -o $COVERAGE_ROOT/coverage.info + + ## ... merge info files + - lcov `ls $COVERAGE_ROOT/coverage*.info | sed -r 's/(.+)/--add-tracefile \1/g'` -o $COVERAGE_ROOT/coverage.info ## ... handle sending manually ## ... convert data with coveralls-lcov @@ -158,8 +165,9 @@ test: ## ... notify Coveralls that the parallel build has ended # this doesn't work - Coveralls returns an error #- echo "{\"payload\":{\"build_num\":\"$CIRCLE_BUILD_NUM\",\"status\":\"done\"}}" > $COVERAGE_ROOT/payload.json && curl --retry 3 -F "json_file=@$COVERAGE_ROOT/payload.json" "https://coveralls.io/webhook?repo_token=$COVERALLS_REPO_TOKEN" + #- echo "{\"payload\":{\"build_num\":\"$CIRCLE_BUILD_NUM\",\"status\":\"done\"}}" > $COVERAGE_ROOT/payload.json && curl --retry 3 -d "@$COVERAGE_ROOT/payload.json" "https://coveralls.io/webhook?repo_token=$COVERALLS_REPO_TOKEN" -## This doesn't work - Coveralls returns an error +## This doesn't work - no effect #notify: # webhooks: # Notify Coveralls that the build has ended