Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r81956 - trunk/libs/geometry/test/algorithms
From: barend.gehrels_at_[hidden]
Date: 2012-12-14 17:28:48


Author: barendgehrels
Date: 2012-12-14 17:28:48 EST (Fri, 14 Dec 2012)
New Revision: 81956
URL: http://svn.boost.org/trac/boost/changeset/81956

Log:
[geometry] added combinations point/ring, point/polygon, point/multi_polygon for disjoint and intersects (unit tests)
Text files modified:
   trunk/libs/geometry/test/algorithms/disjoint.cpp | 10 +++++++++
   trunk/libs/geometry/test/algorithms/intersects.cpp | 43 +++++++++++++++++++++++++++++++++++++--
   trunk/libs/geometry/test/algorithms/test_intersects.hpp | 6 +++++
   3 files changed, 56 insertions(+), 3 deletions(-)

Modified: trunk/libs/geometry/test/algorithms/disjoint.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/disjoint.cpp (original)
+++ trunk/libs/geometry/test/algorithms/disjoint.cpp 2012-12-14 17:28:48 EST (Fri, 14 Dec 2012)
@@ -105,6 +105,16 @@
     test_disjoint<ring, ring>("within_simplex_rr1", within_simplex[0], within_simplex[1], false);
     test_disjoint<ring, ring>("within_simplex_rr2", within_simplex[1], within_simplex[0], false);
 
+ test_disjoint<P, ring>("point_ring1", "POINT(0 0)", "POLYGON((0 0,3 3,6 0,0 0))", false);
+ test_disjoint<P, ring>("point_ring2", "POINT(3 1)", "POLYGON((0 0,3 3,6 0,0 0))", false);
+ test_disjoint<P, ring>("point_ring3", "POINT(0 3)", "POLYGON((0 0,3 3,6 0,0 0))", true);
+ test_disjoint<P, polygon>("point_polygon1", "POINT(0 0)", "POLYGON((0 0,3 3,6 0,0 0))", false);
+ test_disjoint<P, polygon>("point_polygon2", "POINT(3 1)", "POLYGON((0 0,3 3,6 0,0 0))", false);
+ test_disjoint<P, polygon>("point_polygon3", "POINT(0 3)", "POLYGON((0 0,3 3,6 0,0 0))", true);
+
+ test_disjoint<ring, P>("point_ring2", "POLYGON((0 0,3 3,6 0,0 0))", "POINT(0 0)", false);
+ test_disjoint<polygon, P>("point_polygon2", "POLYGON((0 0,3 3,6 0,0 0))", "POINT(0 0)", false);
+
     // Linear
     typedef bg::model::linestring<P> ls;
     typedef bg::model::segment<P> segment;

Modified: trunk/libs/geometry/test/algorithms/intersects.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/intersects.cpp (original)
+++ trunk/libs/geometry/test/algorithms/intersects.cpp 2012-12-14 17:28:48 EST (Fri, 14 Dec 2012)
@@ -17,13 +17,28 @@
 template <typename P>
 void test_all()
 {
- // intersect <=> ! disjoint
+ typedef bg::model::polygon<P> polygon;
+ typedef bg::model::ring<P> ring;
+
+ // intersect <=> ! disjoint (in most cases)
     // so most tests are done in disjoint test.
- // We only test compilation of one case.
+ // We only test compilation of a few cases.
     test_geometry<P, bg::model::box<P> >("POINT(1 1)", "BOX(0 0,2 2)", true);
 
+ test_geometry<polygon, bg::model::box<P> >(
+ "POLYGON((1992 3240,1992 1440,3792 1800,3792 3240,1992 3240))",
+ "BOX(1941 2066, 2055 2166)", true);
+
+ test_geometry<ring, bg::model::box<P> >(
+ "POLYGON((1992 3240,1992 1440,3792 1800,3792 3240,1992 3240))",
+ "BOX(1941 2066, 2055 2166)", true);
+
+ test_geometry<polygon, bg::model::box<P> >(
+ "POLYGON((1941 2066,2055 2066,2055 2166,1941 2166))",
+ "BOX(1941 2066, 2055 2166)", true);
+
+
     // self-intersecting is not tested in disjoint, so that is done here.
- typedef bg::model::polygon<P> polygon;
 
     // Just a normal polygon
     test_self_intersects<polygon>("POLYGON((0 0,0 4,1.5 2.5,2.5 1.5,4 0,0 0))", false);
@@ -111,6 +126,28 @@
         "POLYGON((0 0,3 3,3 3,4 1,0 0))", false);
     test_self_intersects<bg::model::ring<P, true, false> >(
         "POLYGON((0 0,3 3,3 3,4 1))", false);
+
+ test_geometry<P, bg::model::box<P> >(
+ "POINT(0 0)",
+ "BOX(0 0,4 4)",
+ true);
+ test_geometry<P, bg::model::ring<P> >(
+ "POINT(0 0)",
+ "POLYGON((0 0,3 3,3 3,4 1))",
+ true);
+ test_geometry<P, bg::model::polygon<P> >(
+ "POINT(0 0)",
+ "POLYGON((0 0,3 3,3 3,4 1))",
+ true);
+
+ test_geometry<bg::model::ring<P>, P>(
+ "POLYGON((0 0,3 3,3 3,4 1))",
+ "POINT(0 0)",
+ true);
+ test_geometry<bg::model::polygon<P>, P>(
+ "POLYGON((0 0,3 3,3 3,4 1))",
+ "POINT(0 0)",
+ true);
 }
 
 

Modified: trunk/libs/geometry/test/algorithms/test_intersects.hpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/test_intersects.hpp (original)
+++ trunk/libs/geometry/test/algorithms/test_intersects.hpp 2012-12-14 17:28:48 EST (Fri, 14 Dec 2012)
@@ -32,12 +32,18 @@
     bg::read_wkt(wkt2, geometry2);
 
     bool detected = bg::intersects(geometry1, geometry2);
+ bool detected2 = bg::intersects(geometry2, geometry1);
 
     BOOST_CHECK_MESSAGE(detected == expected,
         "intersects: " << wkt1
         << " with " << wkt2
         << " -> Expected: " << expected
         << " detected: " << detected);
+ BOOST_CHECK_MESSAGE(detected2 == expected,
+ "intersects: " << wkt1
+ << " with " << wkt2
+ << " -> Expected: " << expected
+ << " detected: " << detected2);
 }
 
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk