From 54de9f96a1b29d11e1a8044ac8fcc6accfa5201f Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Mon, 6 Jun 2016 21:14:00 +0200 Subject: [PATCH 1/3] [strategies] Support different RobustPoint types. --- .../strategies/cartesian/cart_intersect.hpp | 47 ++++++++++--------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/include/boost/geometry/strategies/cartesian/cart_intersect.hpp b/include/boost/geometry/strategies/cartesian/cart_intersect.hpp index 8a9857376..c72980f01 100644 --- a/include/boost/geometry/strategies/cartesian/cart_intersect.hpp +++ b/include/boost/geometry/strategies/cartesian/cart_intersect.hpp @@ -3,8 +3,8 @@ // Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2014. -// Modifications copyright (c) 2014, Oracle and/or its affiliates. +// This file was modified by Oracle on 2014, 2016. +// Modifications copyright (c) 2014-2016, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -108,17 +108,18 @@ struct relate_cartesian_segments } // The main entry-routine, calculating intersections of segments a / b - template + // NOTE: Robust* types may be the same as Segments' point types + template static inline return_type apply(Segment1 const& a, Segment2 const& b, - RobustPolicy const& robust_policy, - RobustPoint const& robust_a1, RobustPoint const& robust_a2, - RobustPoint const& robust_b1, RobustPoint const& robust_b2) + RobustPolicy const& /*robust_policy*/, + RobustPoint1 const& robust_a1, RobustPoint1 const& robust_a2, + RobustPoint2 const& robust_b1, RobustPoint2 const& robust_b2) { BOOST_CONCEPT_ASSERT( (concept::ConstSegment) ); BOOST_CONCEPT_ASSERT( (concept::ConstSegment) ); - boost::ignore_unused_variable_warning(robust_policy); - using geometry::detail::equals::equals_point_point; bool const a_is_point = equals_point_point(robust_a1, robust_a2); bool const b_is_point = equals_point_point(robust_b1, robust_b2); @@ -162,9 +163,10 @@ struct relate_cartesian_segments coordinate_type, double >::type promoted_type; - typedef typename geometry::coordinate_type + typedef typename select_most_precise < - RobustPoint + typename geometry::coordinate_type::type, + typename geometry::coordinate_type::type >::type robust_coordinate_type; typedef typename segment_ratio_type @@ -300,12 +302,13 @@ private: typename RatioType, typename Segment1, typename Segment2, - typename RobustPoint + typename RobustPoint1, + typename RobustPoint2 > static inline return_type relate_collinear(Segment1 const& a, Segment2 const& b, - RobustPoint const& robust_a1, RobustPoint const& robust_a2, - RobustPoint const& robust_b1, RobustPoint const& robust_b2, + RobustPoint1 const& robust_a1, RobustPoint1 const& robust_a2, + RobustPoint2 const& robust_b1, RobustPoint2 const& robust_b2, bool a_is_point, bool b_is_point) { if (a_is_point) @@ -335,12 +338,13 @@ private: typename RatioType, typename Segment1, typename Segment2, - typename RobustType + typename RobustType1, + typename RobustType2 > static inline return_type relate_collinear(Segment1 const& a , Segment2 const& b - , RobustType oa_1, RobustType oa_2 - , RobustType ob_1, RobustType ob_2 + , RobustType1 oa_1, RobustType1 oa_2 + , RobustType2 ob_1, RobustType2 ob_2 ) { // Calculate the ratios where a starts in b, b starts in a @@ -373,8 +377,8 @@ private: // b2 is located w.r.t. a at ratio: (5-2)/5=3/5 (on a) // a1 is located w.r.t. b at ratio: (2-8)/-3=6/3 (after b ends) // a2 is located w.r.t. b at ratio: (7-8)/-3=1/3 (on b) - RobustType const length_a = oa_2 - oa_1; // no abs, see above - RobustType const length_b = ob_2 - ob_1; + RobustType1 const length_a = oa_2 - oa_1; // no abs, see above + RobustType2 const length_b = ob_2 - ob_1; RatioType ra_from(oa_1 - ob_1, length_b); RatioType ra_to(oa_2 - ob_1, length_b); @@ -435,12 +439,13 @@ private: < typename RatioType, typename DegenerateSegment, - typename RobustType + typename RobustType1, + typename RobustType2 > static inline return_type relate_one_degenerate( DegenerateSegment const& degenerate_segment - , RobustType d - , RobustType s1, RobustType s2 + , RobustType1 d + , RobustType2 s1, RobustType2 s2 , bool a_degenerate ) { From 841f4699479995aebc1cf2fbce48496e62118983 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Mon, 6 Jun 2016 21:14:56 +0200 Subject: [PATCH 2/3] [test][intersects][within] Add test cases for geometries using different point types. --- .../intersects/intersects.cpp | 179 ++++++++++-------- .../intersects/intersects_box_geometry.cpp | 27 ++- .../intersects/intersects_multi.cpp | 23 ++- .../relational_operations/within/within.cpp | 103 +++++----- .../within/within_areal_areal.cpp | 102 +++++----- .../within/within_linear_areal.cpp | 25 ++- .../within/within_linear_linear.cpp | 90 +++++---- 7 files changed, 303 insertions(+), 246 deletions(-) diff --git a/test/algorithms/relational_operations/intersects/intersects.cpp b/test/algorithms/relational_operations/intersects/intersects.cpp index 5ef71ba00..1ded505e7 100644 --- a/test/algorithms/relational_operations/intersects/intersects.cpp +++ b/test/algorithms/relational_operations/intersects/intersects.cpp @@ -3,8 +3,9 @@ // 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. +// This file was modified by Oracle on 2013, 2015, 2016. +// Modifications copyright (c) 2013-2016, Oracle and/or its affiliates. +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -18,20 +19,21 @@ #include -template +template void test_intersects_polygon_polygon() { - typedef bg::model::polygon poly_ccw_o; - test_geometry("POLYGON((1 1, 3 3, 2 5))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", true); - test_geometry("POLYGON((6 6, 7 6, 7 7, 6 7))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", false); - test_geometry("POLYGON((7 7, 9 7, 9 9, 7 9))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", true); + typedef bg::model::polygon poly_ccw_o1; + typedef bg::model::polygon poly_ccw_o2; + test_geometry("POLYGON((1 1, 3 3, 2 5))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", true); + test_geometry("POLYGON((6 6, 7 6, 7 7, 6 7))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", false); + test_geometry("POLYGON((7 7, 9 7, 9 9, 7 9))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", true); } -template +template void test_intersects_linestring_segment() { - typedef bg::model::linestring

ls; - typedef bg::model::segment

seg; + typedef bg::model::linestring ls; + typedef bg::model::segment seg; test_geometry("LINESTRING(1 1, 3 3, 2 5)", "SEGMENT(2 0, 2 6)", true); test_geometry("LINESTRING(1 1, 3 3)", "SEGMENT(1 0, 1 1)", true); @@ -39,28 +41,29 @@ void test_intersects_linestring_segment() test_geometry("LINESTRING(1 1, 3 3)", "SEGMENT(3 0, 4 1)", false); } -template +template void test_intersects_linestring_linestring() { - typedef bg::model::linestring

ls; + typedef bg::model::linestring ls1; + typedef bg::model::linestring ls2; - test_geometry("LINESTRING(0 0,2 0,3 0)", "LINESTRING(0 0,1 1,2 2)", true); - test_geometry("LINESTRING(0 0,2 0,3 0)", "LINESTRING(2 2,1 1,0 0)", true); - test_geometry("LINESTRING(3 0,2 0,0 0)", "LINESTRING(0 0,1 1,2 2)", true); - test_geometry("LINESTRING(3 0,2 0,0 0)", "LINESTRING(2 2,1 1,0 0)", true); + test_geometry("LINESTRING(0 0,2 0,3 0)", "LINESTRING(0 0,1 1,2 2)", true); + test_geometry("LINESTRING(0 0,2 0,3 0)", "LINESTRING(2 2,1 1,0 0)", true); + test_geometry("LINESTRING(3 0,2 0,0 0)", "LINESTRING(0 0,1 1,2 2)", true); + test_geometry("LINESTRING(3 0,2 0,0 0)", "LINESTRING(2 2,1 1,0 0)", true); - test_geometry("LINESTRING(0 0,2 0,3 0)", "LINESTRING(1 0,4 0,5 0)", true); - test_geometry("LINESTRING(1 0,2 0)", "LINESTRING(1 0,0 0)", true); + test_geometry("LINESTRING(0 0,2 0,3 0)", "LINESTRING(1 0,4 0,5 0)", true); + test_geometry("LINESTRING(1 0,2 0)", "LINESTRING(1 0,0 0)", true); } -template +template void test_intersects_linestring_polygon() { - typedef bg::model::linestring

ls; + typedef bg::model::linestring ls; typedef bg::model::multi_linestring mls; - typedef bg::model::polygon

poly_cw_c; - typedef bg::model::polygon poly_ccw_c; - typedef bg::model::polygon poly_ccw_o; + typedef bg::model::polygon poly_cw_c; + typedef bg::model::polygon poly_ccw_c; + typedef bg::model::polygon poly_ccw_o; typedef bg::model::multi_polygon mpoly_ccw_c; test_geometry("LINESTRING(1 1,2 2)", "POLYGON((0 0,10 0,10 10,0 10,0 0))", true); @@ -81,12 +84,12 @@ void test_intersects_linestring_polygon() test_geometry("MULTILINESTRING((1 1,2 2))", "MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0)))", true); } -template +template void test_intersects_linestring_ring() { - typedef bg::model::linestring

ls; + typedef bg::model::linestring ls; typedef bg::model::multi_linestring mls; - typedef bg::model::ring ring_ccw_c; + typedef bg::model::ring ring_ccw_c; test_geometry("LINESTRING(1 1,2 2)", "POLYGON((0 0,10 0,10 10,0 10,0 0))", true); test_geometry("LINESTRING(1 0,2 2)", "POLYGON((0 0,10 0,10 10,0 10,0 0))", true); @@ -96,11 +99,11 @@ void test_intersects_linestring_ring() test_geometry("MULTILINESTRING((1 1,2 2))", "POLYGON((0 0,10 0,10 10,0 10,0 0))", true); } -template +template void test_intersects_ring_polygon() { - typedef bg::model::ring ring_ccw_o; - typedef bg::model::polygon poly_ccw_o; + typedef bg::model::ring ring_ccw_o; + typedef bg::model::polygon poly_ccw_o; test_geometry("POLYGON((1 1, 3 3, 2 5))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", true); test_geometry("POLYGON((6 6, 7 6, 7 7, 6 7))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", false); @@ -109,36 +112,36 @@ void test_intersects_ring_polygon() test_geometry("POLYGON((6 6,7 6,7 7,6 7))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", false); } -template +template void test_intersects_point_linestring() { - typedef bg::model::linestring

ls; + typedef bg::model::linestring ls; typedef bg::model::multi_linestring mls; - test_geometry("POINT(0 0)", "LINESTRING(0 0,2 2,4 0)", true); - test_geometry("POINT(1 1)", "LINESTRING(0 0,2 2,4 0)", true); - test_geometry("POINT(1 0)", "LINESTRING(0 0,2 2,4 0)", false); + test_geometry("POINT(0 0)", "LINESTRING(0 0,2 2,4 0)", true); + test_geometry("POINT(1 1)", "LINESTRING(0 0,2 2,4 0)", true); + test_geometry("POINT(1 0)", "LINESTRING(0 0,2 2,4 0)", false); // MULTI - test_geometry("POINT(0 0)", "MULTILINESTRING((0 0,2 2,4 0))", true); + test_geometry("POINT(0 0)", "MULTILINESTRING((0 0,2 2,4 0))", true); } -template +template void test_intersects_point_segment() { - typedef bg::model::segment

seg; + typedef bg::model::segment seg; - test_geometry("POINT(0 0)", "LINESTRING(0 0,2 2)", true); - test_geometry("POINT(1 1)", "LINESTRING(0 0,2 2)", true); - test_geometry("POINT(1 0)", "LINESTRING(0 0,2 2)", false); + test_geometry("POINT(0 0)", "LINESTRING(0 0,2 2)", true); + test_geometry("POINT(1 1)", "LINESTRING(0 0,2 2)", true); + test_geometry("POINT(1 0)", "LINESTRING(0 0,2 2)", false); } -template +template void test_multi_linestring_polygon() { - typedef bg::model::linestring

ls; + typedef bg::model::linestring ls; typedef bg::model::multi_linestring mls; - typedef bg::model::polygon

poly; + typedef bg::model::polygon poly; test_geometry("MULTILINESTRING((11 11, 20 20),(5 7, 4 1))", "POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 2,4 4,2 4,2 2))", @@ -148,56 +151,72 @@ void test_multi_linestring_polygon() true); } -template +template void test_multi_polygon_polygon() { - typedef bg::model::polygon

poly; - typedef bg::model::multi_polygon mpoly; + typedef bg::model::polygon poly1; + typedef bg::model::multi_polygon mpoly; + typedef bg::model::polygon poly2; - test_geometry("MULTIPOLYGON(((11 11,11 20,20 20,20 11,11 11)),((5 5,5 6,6 6,6 5,5 5)))", - "POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 2,4 4,2 4,2 2))", - true); + test_geometry("MULTIPOLYGON(((11 11,11 20,20 20,20 11,11 11)),((5 5,5 6,6 6,6 5,5 5)))", + "POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 2,4 4,2 4,2 2))", + true); +} + +template +void test_point_polygon() +{ + typedef bg::model::ring ring; + typedef bg::model::polygon poly; + + test_geometry( + "POINT(0 0)", + "POLYGON((0 0,3 3,3 3,4 1))", + true); + test_geometry( + "POINT(0 0)", + "POLYGON((0 0,3 3,3 3,4 1))", + true); + + test_geometry( + "POLYGON((0 0,3 3,3 3,4 1))", + "POINT(0 0)", + true); + test_geometry( + "POLYGON((0 0,3 3,3 3,4 1))", + "POINT(0 0)", + true); +} + +template +void test_all() +{ + typedef bg::model::polygon polygon; + typedef bg::model::ring ring; + + test_intersects_point_segment(); + test_intersects_point_linestring(); + test_intersects_polygon_polygon(); + test_intersects_linestring_polygon(); + test_intersects_linestring_ring(); + test_intersects_linestring_segment(); + test_intersects_linestring_linestring(); + test_intersects_ring_polygon(); + test_multi_linestring_polygon(); + test_multi_polygon_polygon(); + test_point_polygon(); } template void test_all() { - typedef bg::model::polygon

polygon; - typedef bg::model::ring

ring; - - test_intersects_point_segment

(); - test_intersects_point_linestring

(); - test_intersects_polygon_polygon

(); - test_intersects_linestring_polygon

(); - test_intersects_linestring_ring

(); - test_intersects_linestring_segment

(); - test_intersects_linestring_linestring

(); - test_intersects_ring_polygon

(); - test_multi_linestring_polygon

(); - test_multi_polygon_polygon

(); - - test_geometry( - "POINT(0 0)", - "POLYGON((0 0,3 3,3 3,4 1))", - true); - test_geometry( - "POINT(0 0)", - "POLYGON((0 0,3 3,3 3,4 1))", - true); - - test_geometry( - "POLYGON((0 0,3 3,3 3,4 1))", - "POINT(0 0)", - true); - test_geometry( - "POLYGON((0 0,3 3,3 3,4 1))", - "POINT(0 0)", - true); + test_all(); } int test_main( int , char* [] ) { test_all >(); + test_all, bg::model::point >(); #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 index 0aaf92ecb..692a0f691 100644 --- a/test/algorithms/relational_operations/intersects/intersects_box_geometry.cpp +++ b/test/algorithms/relational_operations/intersects/intersects_box_geometry.cpp @@ -3,8 +3,8 @@ // 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. +// This file was modified by Oracle on 2013, 2015, 2016. +// Modifications copyright (c) 2013-2016, Oracle and/or its affiliates. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -19,35 +19,41 @@ #include -template +template void test_all() { - typedef bg::model::polygon

polygon; - typedef bg::model::ring

ring; + 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 >("POINT(1 1)", "BOX(0 0,2 2)", true); - test_geometry >( + test_geometry >( "POLYGON((1992 3240,1992 1440,3792 1800,3792 3240,1992 3240))", "BOX(1941 2066, 2055 2166)", true); - test_geometry >( + test_geometry >( "POLYGON((1992 3240,1992 1440,3792 1800,3792 3240,1992 3240))", "BOX(1941 2066, 2055 2166)", true); - test_geometry >( + test_geometry >( "POLYGON((1941 2066,2055 2066,2055 2166,1941 2166))", "BOX(1941 2066, 2055 2166)", true); - test_geometry >( + test_geometry >( "POINT(0 0)", "BOX(0 0,4 4)", true); } +template +void test_all() +{ + test_all(); +} + // Those tests won't pass for rational<> because numeric_limits<> isn't specialized for this type template void test_additional() @@ -150,6 +156,7 @@ void test_additional() int test_main( int , char* [] ) { + test_all, bg::model::point >(); test_all >(); test_additional >(); diff --git a/test/algorithms/relational_operations/intersects/intersects_multi.cpp b/test/algorithms/relational_operations/intersects/intersects_multi.cpp index 6ed8b358f..d2c70d1f8 100644 --- a/test/algorithms/relational_operations/intersects/intersects_multi.cpp +++ b/test/algorithms/relational_operations/intersects/intersects_multi.cpp @@ -3,6 +3,10 @@ // Copyright (c) 2012-2015 Barend Gehrels, Amsterdam, the Netherlands. +// This file was modified by Oracle on 2016. +// Modifications copyright (c) 2016, Oracle and/or its affiliates. +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -20,26 +24,35 @@ #include #include -template +template void test_all() { - typedef bg::model::polygon

polygon; - typedef bg::model::multi_polygon mp; + typedef bg::model::polygon polygon1; + typedef bg::model::multi_polygon mp1; + typedef bg::model::polygon polygon2; + typedef bg::model::multi_polygon mp2; - test_geometry("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))", + test_geometry("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))", "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))", true); - test_geometry("POINT(0 0)", + test_geometry("POINT(0 0)", "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))", true); } +template +void test_all() +{ + test_all(); +} + int test_main(int, char* []) { //test_all >(); test_all >(); + test_all, bg::model::point >(); #ifdef HAVE_TTMATH test_all >(); diff --git a/test/algorithms/relational_operations/within/within.cpp b/test/algorithms/relational_operations/within/within.cpp index 51718154c..07cea8d58 100644 --- a/test/algorithms/relational_operations/within/within.cpp +++ b/test/algorithms/relational_operations/within/within.cpp @@ -21,22 +21,29 @@ #include #include -template -void test_all() +template +void test_point_box() { - typedef bg::model::box

box_type; + typedef bg::model::box box_type1; + typedef bg::model::box box_type2; - test_geometry("POINT(1 1)", "BOX(0 0,2 2)", true); - test_geometry("POINT(0 0)", "BOX(0 0,2 2)", false); - test_geometry("POINT(2 2)", "BOX(0 0,2 2)", false); - test_geometry("POINT(0 1)", "BOX(0 0,2 2)", false); - test_geometry("POINT(1 0)", "BOX(0 0,2 2)", false); + test_geometry("POINT(1 1)", "BOX(0 0,2 2)", true); + test_geometry("POINT(0 0)", "BOX(0 0,2 2)", false); + test_geometry("POINT(2 2)", "BOX(0 0,2 2)", false); + test_geometry("POINT(0 1)", "BOX(0 0,2 2)", false); + test_geometry("POINT(1 0)", "BOX(0 0,2 2)", false); - test_geometry("BOX(1 1,2 2)", "BOX(0 0,3 3)", true); - test_geometry("BOX(0 0,3 3)", "BOX(1 1,2 2)", false); + test_geometry("POINT(3 3)", "BOX(1 1,4 4)", true); + test_geometry("POINT(3 3)", "BOX(0 0,5 5)", true); - test_geometry("BOX(1 1,3 3)", "BOX(0 0,3 3)", true); - test_geometry("BOX(3 1,3 3)", "BOX(0 0,3 3)", false); + test_geometry("BOX(1 1,2 2)", "BOX(0 0,3 3)", true); + test_geometry("BOX(0 0,3 3)", "BOX(1 1,2 2)", false); + + test_geometry("BOX(1 1,3 3)", "BOX(0 0,3 3)", true); + test_geometry("BOX(3 1,3 3)", "BOX(0 0,3 3)", false); + + test_geometry("BOX(1 1,4 4)", "BOX(0 0,5 5)", true); + test_geometry("BOX(0 0,5 5)", "BOX(1 1,4 4)", false); /* test_within_code("POINT(1 1)", "BOX(0 0,2 2)", 1); @@ -54,7 +61,7 @@ void test_all() */ } -void test_3d() +void test_point_box_3d() { typedef boost::geometry::model::point point_type; typedef boost::geometry::model::box box_type; @@ -70,50 +77,26 @@ void test_3d() } template -void test_mixed_of() +void test_point_poly() { - typedef boost::geometry::model::polygon polygon_type1; - typedef boost::geometry::model::polygon polygon_type2; - typedef boost::geometry::model::box box_type1; - typedef boost::geometry::model::box box_type2; + typedef boost::geometry::model::polygon poly1; + typedef boost::geometry::model::polygon poly2; - polygon_type1 poly1; - polygon_type2 poly2; - boost::geometry::read_wkt("POLYGON((0 0,0 5,5 5,5 0,0 0))", poly1); - boost::geometry::read_wkt("POLYGON((0 0,0 5,5 5,5 0,0 0))", poly2); - - box_type1 box1(P1(1, 1), P1(4, 4)); - box_type2 box2(P2(0, 0), P2(5, 5)); - P1 p1(3, 3); - P2 p2(3, 3); - - BOOST_CHECK_EQUAL(bg::within(p1, poly2), true); - BOOST_CHECK_EQUAL(bg::within(p2, poly1), true); - BOOST_CHECK_EQUAL(bg::within(p2, box1), true); - BOOST_CHECK_EQUAL(bg::within(p1, box2), true); - BOOST_CHECK_EQUAL(bg::within(box1, box2), true); - BOOST_CHECK_EQUAL(bg::within(box2, box1), false); + test_geometry("POINT(3 3)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", true); + test_geometry("POINT(3 3)", "POLYGON((0 0,0 5,5 5,5 0,0 0))", true); } - -void test_mixed() +template +void test_all() { - // Mixing point types and coordinate types - test_mixed_of - < - boost::geometry::model::d2::point_xy, - boost::geometry::model::point - >(); - test_mixed_of - < - boost::geometry::model::d2::point_xy, - boost::geometry::model::point - >(); - test_mixed_of - < - boost::geometry::model::d2::point_xy, - boost::geometry::model::d2::point_xy - >(); + test_point_box(); + test_point_poly(); +} + +template +void test_all() +{ + test_all(); } void test_strategy() @@ -145,11 +128,19 @@ void test_strategy() int test_main( int , char* [] ) { - test_all >(); - test_all >(); + typedef boost::geometry::model::d2::point_xy xyd; + typedef boost::geometry::model::d2::point_xy xyf; + typedef boost::geometry::model::d2::point_xy xyi; + typedef boost::geometry::model::point p2d; + + test_all(); + test_all(); + test_all(); - test_mixed(); - test_3d(); + test_all(); + test_all(); + + test_point_box_3d(); test_strategy(); diff --git a/test/algorithms/relational_operations/within/within_areal_areal.cpp b/test/algorithms/relational_operations/within/within_areal_areal.cpp index 559543945..625be46d8 100644 --- a/test/algorithms/relational_operations/within/within_areal_areal.cpp +++ b/test/algorithms/relational_operations/within/within_areal_areal.cpp @@ -3,8 +3,8 @@ // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2014, 2015. -// Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. +// This file was modified by Oracle on 2014, 2015, 2016. +// Modifications copyright (c) 2014-2016 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -20,72 +20,82 @@ #include #include -template +template void test_a_a() { - typedef bg::model::polygon

poly; - typedef bg::model::ring

ring; - typedef bg::model::multi_polygon mpoly; + typedef bg::model::polygon poly1; + typedef bg::model::ring ring1; + typedef bg::model::multi_polygon mpoly1; + typedef bg::model::polygon poly2; + typedef bg::model::ring ring2; + typedef bg::model::multi_polygon mpoly2; - test_geometry("POLYGON((0 0,0 2,2 2,2 0,0 0))", "POLYGON((0 0,0 5,5 5,5 0,0 0))", true); - test_geometry("POLYGON((0 0,0 5,5 5,5 0,0 0))", "POLYGON((0 0,0 5,5 5,5 0,0 0))", true); - test_geometry("POLYGON((0 0,0 6,6 6,6 0,0 0))", "POLYGON((0 0,0 5,5 5,5 0,0 0))", false); + test_geometry("POLYGON((0 0,0 2,2 2,2 0,0 0))", "POLYGON((0 0,0 5,5 5,5 0,0 0))", true); + test_geometry("POLYGON((0 0,0 5,5 5,5 0,0 0))", "POLYGON((0 0,0 5,5 5,5 0,0 0))", true); + test_geometry("POLYGON((0 0,0 6,6 6,6 0,0 0))", "POLYGON((0 0,0 5,5 5,5 0,0 0))", false); - test_geometry("POLYGON((0 0,0 9,9 9,9 0,0 0),(3 3,6 3,6 6,3 6,3 3))", - "POLYGON((0 0,0 9,9 9,9 0,0 0),(3 3,6 3,6 6,3 6,3 3))", true); - test_geometry("POLYGON((0 0,0 9,9 9,9 0,0 0),(3 3,6 3,6 6,3 6,3 3))", - "POLYGON((0 0,0 9,9 9,9 0,0 0),(4 4,5 4,5 5,4 5,4 4))", true); - test_geometry("POLYGON((1 1,1 8,8 8,8 1,1 1),(3 3,6 3,6 6,3 6,3 3))", - "POLYGON((0 0,0 9,9 9,9 0,0 0),(3 3,6 3,6 6,3 6,3 3))", true); - test_geometry("POLYGON((1 1,1 8,8 8,8 1,1 1),(3 3,6 3,6 6,3 6,3 3))", - "POLYGON((0 0,0 9,9 9,9 0,0 0),(4 4,5 4,5 5,4 5,4 4))", true); + test_geometry("POLYGON((0 0,0 9,9 9,9 0,0 0),(3 3,6 3,6 6,3 6,3 3))", + "POLYGON((0 0,0 9,9 9,9 0,0 0),(3 3,6 3,6 6,3 6,3 3))", true); + test_geometry("POLYGON((0 0,0 9,9 9,9 0,0 0),(3 3,6 3,6 6,3 6,3 3))", + "POLYGON((0 0,0 9,9 9,9 0,0 0),(4 4,5 4,5 5,4 5,4 4))", true); + test_geometry("POLYGON((1 1,1 8,8 8,8 1,1 1),(3 3,6 3,6 6,3 6,3 3))", + "POLYGON((0 0,0 9,9 9,9 0,0 0),(3 3,6 3,6 6,3 6,3 3))", true); + test_geometry("POLYGON((1 1,1 8,8 8,8 1,1 1),(3 3,6 3,6 6,3 6,3 3))", + "POLYGON((0 0,0 9,9 9,9 0,0 0),(4 4,5 4,5 5,4 5,4 4))", true); - test_geometry("POLYGON((0 0,0 2,2 2,2 0,0 0))", - "MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)))", true); - test_geometry("POLYGON((0 0,0 2,2 2,2 0,0 0))", - "MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)))", true); + test_geometry("POLYGON((0 0,0 2,2 2,2 0,0 0))", + "MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)))", true); + test_geometry("POLYGON((0 0,0 2,2 2,2 0,0 0))", + "MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)))", true); - test_geometry("MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)))", - "POLYGON((0 0,0 10,10 10,10 0,0 0))", true); - test_geometry("MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((15 15,15 110,110 110,110 15,15 15)))", - "POLYGON((0 0,0 10,10 10,10 0,0 0))", false); + test_geometry("MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)))", + "POLYGON((0 0,0 10,10 10,10 0,0 0))", true); + test_geometry("MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((15 15,15 110,110 110,110 15,15 15)))", + "POLYGON((0 0,0 10,10 10,10 0,0 0))", false); - test_geometry("MULTIPOLYGON(((0 0,0 1,1 0,0 0)),((3 3,3 4,4 3,3 3)))", - "POLYGON((0 0,0 10,10 10,10 0,0 0),(3 3,4 3,4 4,3 4,3 3))", false); + test_geometry("MULTIPOLYGON(((0 0,0 1,1 0,0 0)),((3 3,3 4,4 3,3 3)))", + "POLYGON((0 0,0 10,10 10,10 0,0 0),(3 3,4 3,4 4,3 4,3 3))", false); - test_geometry("MULTIPOLYGON(((0 0,0 1,1 0,0 0)),((3 3,3 4,4 3,3 3)))", - "MULTIPOLYGON(((0 0,0 1,1 0,0 0)),((3 3,3 4,4 3,3 3)))", true); - test_geometry("MULTIPOLYGON(((0 0,0 1,1 0,0 0)),((3 3,3 4,4 3,3 3)))", - "MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)))", true); - test_geometry("MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)))", - "MULTIPOLYGON(((0 0,0 1,1 0,0 0)),((3 3,3 4,4 3,3 3)))", false); + test_geometry("MULTIPOLYGON(((0 0,0 1,1 0,0 0)),((3 3,3 4,4 3,3 3)))", + "MULTIPOLYGON(((0 0,0 1,1 0,0 0)),((3 3,3 4,4 3,3 3)))", true); + test_geometry("MULTIPOLYGON(((0 0,0 1,1 0,0 0)),((3 3,3 4,4 3,3 3)))", + "MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)))", true); + test_geometry("MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)))", + "MULTIPOLYGON(((0 0,0 1,1 0,0 0)),((3 3,3 4,4 3,3 3)))", false); // https://svn.boost.org/trac/boost/ticket/10912 - test_geometry("POLYGON((0 0,0 5,5 5,5 0,0 0))", - "POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 2,4 4,2 4,2 2),(6 6,8 6,8 8,6 8,6 6))", - false); - test_geometry("POLYGON((0 0,0 10,10 10,10 0,0 0))", - "POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,2 4,4 4,4 2,2 2))", - false); + test_geometry("POLYGON((0 0,0 5,5 5,5 0,0 0))", + "POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 2,4 4,2 4,2 2),(6 6,8 6,8 8,6 8,6 6))", + false); + test_geometry("POLYGON((0 0,0 10,10 10,10 0,0 0))", + "POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,2 4,4 4,4 2,2 2))", + false); - test_geometry("POLYGON((0 0,0 5,5 5,5 0,0 0))", - "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))", - true); - test_geometry("POLYGON((0 0,0 10,10 10,10 0,0 0))", - "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))", - true); + test_geometry("POLYGON((0 0,0 5,5 5,5 0,0 0))", + "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))", + true); + test_geometry("POLYGON((0 0,0 10,10 10,10 0,0 0))", + "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 0,0 -10,-10 -10,-10 0,0 0)))", + true); +} + +template +void test_all() +{ + test_a_a(); } template void test_all() { - test_a_a

(); + test_a_a(); } int test_main( int , char* [] ) { test_all >(); test_all >(); + test_all, bg::model::point >(); #if defined(HAVE_TTMATH) test_all >(); diff --git a/test/algorithms/relational_operations/within/within_linear_areal.cpp b/test/algorithms/relational_operations/within/within_linear_areal.cpp index 14e541d36..63bb0028a 100644 --- a/test/algorithms/relational_operations/within/within_linear_areal.cpp +++ b/test/algorithms/relational_operations/within/within_linear_areal.cpp @@ -3,15 +3,15 @@ // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2014, 2015. -// Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. +// This file was modified by Oracle on 2014, 2015, 2016. +// Modifications copyright (c) 2014-2016 Oracle and/or its affiliates. + +// Contributed and/or modified by 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_within.hpp" @@ -20,13 +20,13 @@ #include #include -template +template void test_l_a() { - typedef bg::model::linestring

ls; + typedef bg::model::linestring ls; typedef bg::model::multi_linestring mls; - typedef bg::model::polygon

poly; - typedef bg::model::ring

ring; + typedef bg::model::polygon poly; + typedef bg::model::ring ring; typedef bg::model::multi_polygon mpoly; // B,I @@ -100,16 +100,23 @@ void test_l_a() false); } +template +void test_all() +{ + test_l_a(); +} + template void test_all() { - test_l_a

(); + test_l_a(); } int test_main( int , char* [] ) { test_all >(); test_all >(); + test_all, bg::model::point >(); #if defined(HAVE_TTMATH) diff --git a/test/algorithms/relational_operations/within/within_linear_linear.cpp b/test/algorithms/relational_operations/within/within_linear_linear.cpp index f2e2876bf..c4d7d348d 100644 --- a/test/algorithms/relational_operations/within/within_linear_linear.cpp +++ b/test/algorithms/relational_operations/within/within_linear_linear.cpp @@ -3,14 +3,15 @@ // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2014, 2015. -// Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. +// This file was modified by Oracle on 2014, 2015, 2016. +// Modifications copyright (c) 2014-2016 Oracle and/or its affiliates. + +// Contributed and/or modified by 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_within.hpp" @@ -19,76 +20,85 @@ #include #include -template +template void test_l_l() { - typedef bg::model::linestring

ls; - typedef bg::model::multi_linestring mls; + typedef bg::model::linestring ls1; + typedef bg::model::multi_linestring mls1; + typedef bg::model::linestring ls2; + typedef bg::model::multi_linestring mls2; - test_geometry("LINESTRING(0 0, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 3 2)", true); + test_geometry("LINESTRING(0 0, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 3 2)", true); - test_geometry("LINESTRING(0 0, 1 1, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 3 2)", true); - test_geometry("LINESTRING(3 2, 2 2, 1 1, 0 0)", "LINESTRING(0 0, 2 2, 3 2)", true); - test_geometry("LINESTRING(0 0, 1 1, 2 2, 3 2)", "LINESTRING(3 2, 2 2, 0 0)", true); - test_geometry("LINESTRING(3 2, 2 2, 1 1, 0 0)", "LINESTRING(3 2, 2 2, 0 0)", true); + test_geometry("LINESTRING(0 0, 1 1, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 3 2)", true); + test_geometry("LINESTRING(3 2, 2 2, 1 1, 0 0)", "LINESTRING(0 0, 2 2, 3 2)", true); + test_geometry("LINESTRING(0 0, 1 1, 2 2, 3 2)", "LINESTRING(3 2, 2 2, 0 0)", true); + test_geometry("LINESTRING(3 2, 2 2, 1 1, 0 0)", "LINESTRING(3 2, 2 2, 0 0)", true); - test_geometry("LINESTRING(1 1, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", true); - test_geometry("LINESTRING(3 2, 2 2, 1 1)", "LINESTRING(0 0, 2 2, 4 2)", true); - test_geometry("LINESTRING(1 1, 2 2, 3 2)", "LINESTRING(4 2, 2 2, 0 0)", true); - test_geometry("LINESTRING(3 2, 2 2, 1 1)", "LINESTRING(4 2, 2 2, 0 0)", true); + test_geometry("LINESTRING(1 1, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", true); + test_geometry("LINESTRING(3 2, 2 2, 1 1)", "LINESTRING(0 0, 2 2, 4 2)", true); + test_geometry("LINESTRING(1 1, 2 2, 3 2)", "LINESTRING(4 2, 2 2, 0 0)", true); + test_geometry("LINESTRING(3 2, 2 2, 1 1)", "LINESTRING(4 2, 2 2, 0 0)", true); - test_geometry("LINESTRING(1 1, 2 2, 3 3)", "LINESTRING(0 0, 2 2, 4 2)", false); - test_geometry("LINESTRING(1 1, 2 2, 3 2, 3 3)", "LINESTRING(0 0, 2 2, 4 2)", false); - test_geometry("LINESTRING(1 1, 2 2, 3 1)", "LINESTRING(0 0, 2 2, 4 2)", false); - test_geometry("LINESTRING(1 1, 2 2, 3 2, 3 1)", "LINESTRING(0 0, 2 2, 4 2)", false); + test_geometry("LINESTRING(1 1, 2 2, 3 3)", "LINESTRING(0 0, 2 2, 4 2)", false); + test_geometry("LINESTRING(1 1, 2 2, 3 2, 3 3)", "LINESTRING(0 0, 2 2, 4 2)", false); + test_geometry("LINESTRING(1 1, 2 2, 3 1)", "LINESTRING(0 0, 2 2, 4 2)", false); + test_geometry("LINESTRING(1 1, 2 2, 3 2, 3 1)", "LINESTRING(0 0, 2 2, 4 2)", false); - test_geometry("LINESTRING(0 1, 1 1, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", false); - test_geometry("LINESTRING(0 1, 0 0, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", false); - test_geometry("LINESTRING(1 0, 1 1, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", false); - test_geometry("LINESTRING(1 0, 0 0, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", false); + test_geometry("LINESTRING(0 1, 1 1, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", false); + test_geometry("LINESTRING(0 1, 0 0, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", false); + test_geometry("LINESTRING(1 0, 1 1, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", false); + test_geometry("LINESTRING(1 0, 0 0, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 4 2)", false); // duplicated points - test_geometry("LINESTRING(1 1, 2 2, 2 2)", "LINESTRING(0 0, 2 2, 4 2)", true); - test_geometry("LINESTRING(1 1, 1 1, 2 2)", "LINESTRING(0 0, 2 2, 4 2)", true); + test_geometry("LINESTRING(1 1, 2 2, 2 2)", "LINESTRING(0 0, 2 2, 4 2)", true); + test_geometry("LINESTRING(1 1, 1 1, 2 2)", "LINESTRING(0 0, 2 2, 4 2)", true); - test_geometry("LINESTRING(0 0, 0 0, 0 0, 1 1, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 3 3)", + test_geometry("LINESTRING(0 0, 0 0, 0 0, 1 1, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 2 2, 3 3)", "LINESTRING(0 0, 2 2, 4 4)", true); // invalid linestrings -// test_geometry("LINESTRING(0 0)", "LINESTRING(0 0)", false); -// test_geometry("LINESTRING(1 1)", "LINESTRING(0 0, 2 2)", true); -// test_geometry("LINESTRING(0 0)", "LINESTRING(0 0, 2 2)", false); -// test_geometry("LINESTRING(0 0, 1 1)", "LINESTRING(0 0)", false); +// test_geometry("LINESTRING(0 0)", "LINESTRING(0 0)", false); +// test_geometry("LINESTRING(1 1)", "LINESTRING(0 0, 2 2)", true); +// test_geometry("LINESTRING(0 0)", "LINESTRING(0 0, 2 2)", false); +// test_geometry("LINESTRING(0 0, 1 1)", "LINESTRING(0 0)", false); // spikes // FOR NOW DISABLED - /*test_geometry("LINESTRING(0 0,5 0,3 0,6 0)", "LINESTRING(0 0,6 0)", true); + /*test_geometry("LINESTRING(0 0,5 0,3 0,6 0)", "LINESTRING(0 0,6 0)", true); - test_geometry("LINESTRING(0 0,2 2,3 3,1 1)", "LINESTRING(0 0,3 3,6 3)", true); - test_geometry("LINESTRING(0 0,3 3,6 3)", "LINESTRING(0 0,2 2,3 3,1 1)", false); - test_geometry("LINESTRING(0 0,2 2,3 3,1 1)", "LINESTRING(0 0,4 4,6 3)", true); - test_geometry("LINESTRING(0 0,4 4,6 3)", "LINESTRING(0 0,2 2,3 3,1 1)", false); + test_geometry("LINESTRING(0 0,2 2,3 3,1 1)", "LINESTRING(0 0,3 3,6 3)", true); + test_geometry("LINESTRING(0 0,3 3,6 3)", "LINESTRING(0 0,2 2,3 3,1 1)", false); + test_geometry("LINESTRING(0 0,2 2,3 3,1 1)", "LINESTRING(0 0,4 4,6 3)", true); + test_geometry("LINESTRING(0 0,4 4,6 3)", "LINESTRING(0 0,2 2,3 3,1 1)", false); - test_geometry("LINESTRING(0 0,2 2,3 3,1 1,5 3)", "LINESTRING(0 0,3 3,6 3)", false);*/ + test_geometry("LINESTRING(0 0,2 2,3 3,1 1,5 3)", "LINESTRING(0 0,3 3,6 3)", false);*/ - test_geometry("LINESTRING(1 1, 2 2)", "MULTILINESTRING((0 0, 2 2),(3 3, 4 4))", true); + test_geometry("LINESTRING(1 1, 2 2)", "MULTILINESTRING((0 0, 2 2),(3 3, 4 4))", true); - test_geometry("MULTILINESTRING((0 0, 2 2),(3 3, 4 4))", "LINESTRING(0 0, 5 5)", true); + test_geometry("MULTILINESTRING((0 0, 2 2),(3 3, 4 4))", "LINESTRING(0 0, 5 5)", true); - test_geometry("MULTILINESTRING((1 1, 2 2),(3 3, 4 4))", "MULTILINESTRING((1 1, 2 2),(2 2, 5 5))", true); + test_geometry("MULTILINESTRING((1 1, 2 2),(3 3, 4 4))", "MULTILINESTRING((1 1, 2 2),(2 2, 5 5))", true); +} + +template +void test_all() +{ + test_l_l(); } template void test_all() { - test_l_l

(); + test_l_l(); } int test_main( int , char* [] ) { test_all >(); test_all >(); + test_all, bg::model::point >(); #if defined(HAVE_TTMATH) test_all >(); From ccd671f5aca5813ac7ffc2494438182ad281c807 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Mon, 6 Jun 2016 21:16:27 +0200 Subject: [PATCH 3/3] [test][index] Test rtree intersects query with various geometries using point type different than rtree::bounds_type. --- index/test/rtree/Jamfile.v2 | 1 + index/test/rtree/rtree_intersects_geom.cpp | 55 ++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 index/test/rtree/rtree_intersects_geom.cpp diff --git a/index/test/rtree/Jamfile.v2 b/index/test/rtree/Jamfile.v2 index f5052de37..91b2c427b 100644 --- a/index/test/rtree/Jamfile.v2 +++ b/index/test/rtree/Jamfile.v2 @@ -14,6 +14,7 @@ test-suite boost-geometry-index-rtree : [ run rtree_epsilon.cpp ] [ run rtree_insert_remove.cpp ] + [ run rtree_intersects_geom.cpp ] [ run rtree_move_pack.cpp ] [ run rtree_non_cartesian.cpp ] [ run rtree_values.cpp ] diff --git a/index/test/rtree/rtree_intersects_geom.cpp b/index/test/rtree/rtree_intersects_geom.cpp new file mode 100644 index 000000000..973628cbb --- /dev/null +++ b/index/test/rtree/rtree_intersects_geom.cpp @@ -0,0 +1,55 @@ +// Boost.Geometry Index +// Unit Test + +// Copyright (c) 2016 Adam Wulkiewicz, Lodz, Poland. + +// 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 + +#include +#include + +template +void test_all() +{ + typedef bg::model::box Box; + typedef bg::model::segment Seg; + typedef bg::model::ring Ring; + typedef bg::model::polygon Poly; + typedef bg::model::multi_polygon MPoly; + typedef bg::model::linestring Ls; + typedef bg::model::multi_linestring MLs; + typedef bg::model::multi_point MPt; + + bgi::rtree rt; + std::vector found; + + rt.query(bgi::intersects(Point()), back_inserter(found)); + rt.query(bgi::intersects(Seg()), back_inserter(found)); + rt.query(bgi::intersects(Box()), back_inserter(found)); + rt.query(bgi::intersects(Ring()), back_inserter(found)); + rt.query(bgi::intersects(Poly()), back_inserter(found)); + rt.query(bgi::intersects(MPoly()), back_inserter(found)); + rt.query(bgi::intersects(Ls()), back_inserter(found)); + rt.query(bgi::intersects(MLs()), back_inserter(found)); + rt.query(bgi::intersects(MPt()), back_inserter(found)); +} + +int test_main(int, char* []) +{ + typedef bg::model::d2::point_xy Pt; + typedef bg::model::box Box; + + test_all< Pt, Pt, bgi::linear<16> >(); + test_all< Pt, Pt, bgi::quadratic<4> >(); + test_all< Pt, Pt, bgi::rstar<4> >(); + + test_all< Box, Pt, bgi::linear<16> >(); + test_all< Box, Pt, bgi::quadratic<4> >(); + test_all< Box, Pt, bgi::rstar<4> >(); + + return 0; +}