Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r82019 - in trunk/libs/geometry/test: algorithms multi/algorithms multi/algorithms/overlay
From: barend.gehrels_at_[hidden]
Date: 2012-12-16 07:18:45


Author: barendgehrels
Date: 2012-12-16 07:18:44 EST (Sun, 16 Dec 2012)
New Revision: 82019
URL: http://svn.boost.org/trac/boost/changeset/82019

Log:
[geometry] updated testsuite for difference, added test which checks convert_ring on inner-ring point-count
Text files modified:
   trunk/libs/geometry/test/algorithms/difference.cpp | 118 ++++++++++++++++++++-------------------
   trunk/libs/geometry/test/algorithms/test_difference.hpp | 31 ++++++----
   trunk/libs/geometry/test/multi/algorithms/multi_difference.cpp | 34 ++++++----
   trunk/libs/geometry/test/multi/algorithms/overlay/multi_overlay_cases.hpp | 8 ++
   4 files changed, 107 insertions(+), 84 deletions(-)

Modified: trunk/libs/geometry/test/algorithms/difference.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/difference.cpp (original)
+++ trunk/libs/geometry/test/algorithms/difference.cpp 2012-12-16 07:18:44 EST (Sun, 16 Dec 2012)
@@ -9,6 +9,8 @@
 
 // #define TEST_ISOVIST
 
+//#define HAVE_TTMATH
+
 //#define BOOST_GEOMETRY_CHECK_WITH_POSTGIS
 
 //#define BOOST_GEOMETRY_DEBUG_SEGMENT_IDENTIFIER
@@ -111,8 +113,8 @@
 
     test_one<polygon, polygon, polygon>("simplex_normal",
         simplex_normal[0], simplex_normal[1],
- 3, 3, 2.52636706856656,
- 3, 3, 3.52636706856656);
+ 3, 12, 2.52636706856656,
+ 3, 12, 3.52636706856656);
 
     test_one<polygon, polygon, polygon>("simplex_with_empty",
         simplex_normal[0], polygon_empty,
@@ -126,24 +128,24 @@
 
     test_one<polygon, polygon, polygon>("two_bends",
         two_bends[0], two_bends[1],
- 1, 7, 8.0,
- 1, 7, 8.0);
+ 1, 5, 8.0,
+ 1, 5, 8.0);
 
     test_one<polygon, polygon, polygon>("star_comb_15",
         star_comb_15[0], star_comb_15[1],
- 30, 150, 227.658275102812,
- 30, 150, 480.485775259312);
+ 30, 160, 227.658275102812,
+ 30, 198, 480.485775259312);
 
     test_one<polygon, polygon, polygon>("new_hole",
         new_hole[0], new_hole[1],
- 1, 10, 7.0,
- 1, 10, 14.0);
+ 1, 9, 7.0,
+ 1, 13, 14.0);
 
 
     test_one<polygon, polygon, polygon>("crossed",
         crossed[0], crossed[1],
- 1, 0, 19.5,
- 1, 0, 2.5);
+ 1, 18, 19.5,
+ 1, 7, 2.5);
 
     test_one<polygon, polygon, polygon>("disjoint",
         disjoint[0], disjoint[1],
@@ -152,35 +154,35 @@
 
     test_one<polygon, polygon, polygon>("distance_zero",
         distance_zero[0], distance_zero[1],
- 2, 0, 8.7048386,
+ 2, -1, 8.7048386,
         if_typed<ct, float>(1, 2), // The too small one is discarded for floating point
- 0, 0.0098387);
+ -1, 0.0098387);
 
 
     test_one<polygon, polygon, polygon>("equal_holes_disjoint",
         equal_holes_disjoint[0], equal_holes_disjoint[1],
- 1, 0, 9.0,
- 1, 0, 9.0);
+ 1, 5, 9.0,
+ 1, 5, 9.0);
 
     test_one<polygon, polygon, polygon>("only_hole_intersections1",
         only_hole_intersections[0], only_hole_intersections[1],
- 2, 0, 1.9090909,
- 4, 0, 10.9090909);
+ 2, 10, 1.9090909,
+ 4, 16, 10.9090909);
 
     test_one<polygon, polygon, polygon>("only_hole_intersection2",
         only_hole_intersections[0], only_hole_intersections[2],
- 3, 0, 30.9090909,
- 4, 0, 10.9090909);
+ 3, 20, 30.9090909,
+ 4, 16, 10.9090909);
 
     test_one<polygon, polygon, polygon>("first_within_second",
         first_within_second[1], first_within_second[0],
- 1, 1, 24,
+ 1, 10, 24,
         0, 0, 0);
 
     test_one<polygon, polygon, polygon>("fitting",
         fitting[0], fitting[1],
- 1, 0, 21.0,
- 1, 0, 4.0);
+ 1, 9, 21.0,
+ 1, 4, 4.0);
 
     test_one<polygon, polygon, polygon>("identical",
         identical[0], identical[1],
@@ -189,63 +191,63 @@
 
     test_one<polygon, polygon, polygon>("intersect_exterior_and_interiors_winded",
         intersect_exterior_and_interiors_winded[0], intersect_exterior_and_interiors_winded[1],
- 4, 0, 11.533333,
- 5, 0, 29.783333);
+ 4, 20, 11.533333,
+ 5, 26, 29.783333);
 
     test_one<polygon, polygon, polygon>("intersect_holes_intersect_and_disjoint",
         intersect_holes_intersect_and_disjoint[0], intersect_holes_intersect_and_disjoint[1],
- 2, 0, 15.75,
- 3, 0, 6.75);
+ 2, 16, 15.75,
+ 3, 17, 6.75);
 
     test_one<polygon, polygon, polygon>("intersect_holes_intersect_and_touch",
         intersect_holes_intersect_and_touch[0], intersect_holes_intersect_and_touch[1],
- 3, 0, 16.25,
- 3, 0, 6.25);
+ 3, 21, 16.25,
+ 3, 17, 6.25);
 
     test_one<polygon, polygon, polygon>("intersect_holes_new_ring",
         intersect_holes_new_ring[0], intersect_holes_new_ring[1],
- 3, 0, 9.8961,
- 4, 0, 121.8961, 0.01);
+ 3, 15, 9.8961,
+ 4, 25, 121.8961, 0.01);
 
     test_one<polygon, polygon, polygon>("first_within_hole_of_second",
         first_within_hole_of_second[0], first_within_hole_of_second[1],
- 1, -1, 1,
- 1, -1, 16);
+ 1, 5, 1,
+ 1, 10, 16);
 
     test_one<polygon, polygon, polygon>("intersect_holes_disjoint",
         intersect_holes_disjoint[0], intersect_holes_disjoint[1],
- 2, 15, 16.0,
- 2, 15, 6.0);
+ 2, 14, 16.0,
+ 2, 10, 6.0);
 
     test_one<polygon, polygon, polygon>("intersect_holes_intersect",
         intersect_holes_intersect[0], intersect_holes_intersect[1],
- 2, 14, 15.75,
- 2, 14, 5.75);
+ 2, 16, 15.75,
+ 2, 12, 5.75);
 
     test_one<polygon, polygon, polygon>(
             "case4", case_4[0], case_4[1],
- 6, 22, 2.77878787878788,
- 4, 27, 4.77878787878788);
+ 6, 28, 2.77878787878788,
+ 4, 22, 4.77878787878788);
 
     test_one<polygon, polygon, polygon>(
             "case5", case_5[0], case_5[1],
- 8, 22, 2.43452380952381,
- 7, 27, 3.18452380952381);
+ 8, 36, 2.43452380952381,
+ 7, 33, 3.18452380952381);
 
     test_one<polygon, polygon, polygon>("winded",
         winded[0], winded[1],
- 3, 1, 61,
- 1, 0, 13);
+ 3, 37, 61,
+ 1, 15, 13);
 
     test_one<polygon, polygon, polygon>("within_holes_disjoint",
         within_holes_disjoint[0], within_holes_disjoint[1],
- 2, 1, 25,
- 1, 0, 1);
+ 2, 15, 25,
+ 1, 5, 1);
 
     test_one<polygon, polygon, polygon>("side_side",
         side_side[0], side_side[1],
- 1, 0, 1,
- 1, 0, 1);
+ 1, 5, 1,
+ 1, 5, 1);
 
     /*** TODO: self-tangencies for difference
     test_one<polygon, polygon, polygon>("wrapped_a",
@@ -274,29 +276,29 @@
 
     test_one<polygon, polygon, polygon>("ggl_list_20110306_javier",
         ggl_list_20110306_javier[0], ggl_list_20110306_javier[1],
- 1, 0, 71495.3331,
- 2, 0, 8960.49049);
+ 1, -1, 71495.3331,
+ 2, -1, 8960.49049);
 #endif
         
     test_one<polygon, polygon, polygon>("ggl_list_20110307_javier",
         ggl_list_20110307_javier[0], ggl_list_20110307_javier[1],
- 1, 0, 16815.6,
- 1, 0, 3200.4,
+ 1, 13, 16815.6,
+ 1, 4, 3200.4,
         0.01);
 
     if (! boost::is_same<ct, float>::value)
     {
         test_one<polygon, polygon, polygon>("ggl_list_20110716_enrico",
             ggl_list_20110716_enrico[0], ggl_list_20110716_enrico[1],
- 3, 0, 35723.8506317139,
- 1, 0, 58456.4964294434
+ 3, -1, 35723.8506317139,
+ 1, -1, 58456.4964294434
             );
     }
 
     test_one<polygon, polygon, polygon>("ggl_list_20110820_christophe",
         ggl_list_20110820_christophe[0], ggl_list_20110820_christophe[1],
- 1, 0, 2.8570121719168924,
- 1, 0, 64.498061986388564);
+ 1, -1, 2.8570121719168924,
+ 1, -1, 64.498061986388564);
 
     test_one<polygon, polygon, polygon>("ggl_list_20120717_volker",
         ggl_list_20120717_volker[0], ggl_list_20120717_volker[1],
@@ -313,9 +315,9 @@
     // Because we cannot predict this, we only test for MSVC
     test_one<polygon, polygon, polygon>("ggl_list_20110627_phillip",
         ggl_list_20110627_phillip[0], ggl_list_20110627_phillip[1],
- if_typed_tt<ct>(1, 0), 0,
+ if_typed_tt<ct>(1, 0), -1,
             if_typed_tt<ct>(0.0000000000001105367, 0.0),
- 1, 0, 3577.40960816756,
+ 1, -1, 3577.40960816756,
         0.01
         );
 #endif
@@ -328,17 +330,17 @@
 
         test_one<polygon, ring, polygon>(
                 "ring_star_ring", example_ring, example_star,
- 5, 22, 1.6701714, 5, 27, 1.1901714);
+ 5, 27, 1.6701714, 5, 22, 1.1901714);
 
         static std::string const clip = "POLYGON((2.5 0.5,5.5 2.5))";
 
         test_one<polygon, box, ring>("star_box",
             clip, example_star,
- 4, 11, 2.833333, 4, 11, 0.833333);
+ 4, 20, 2.833333, 4, 16, 0.833333);
 
         test_one<polygon, ring, box>("box_star",
             example_star, clip,
- 4, 11, 0.833333, 4, 11, 2.833333);
+ 4, 16, 0.833333, 4, 20, 2.833333);
     }
 
     // Counter clockwise

Modified: trunk/libs/geometry/test/algorithms/test_difference.hpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/test_difference.hpp (original)
+++ trunk/libs/geometry/test/algorithms/test_difference.hpp 2012-12-16 07:18:44 EST (Sun, 16 Dec 2012)
@@ -38,7 +38,10 @@
 
 
 #if defined(TEST_WITH_SVG)
+# define BOOST_GEOMETRY_DEBUG_SEGMENT_IDENTIFIER
+# define BOOST_GEOMETRY_DEBUG_IDENTIFIER
 # include <boost/geometry/extensions/io/svg/svg_mapper.hpp>
+# include <boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp>
 #endif
 
 
@@ -79,7 +82,7 @@
 
 template <typename OutputType, typename G1, typename G2>
 void test_difference(std::string const& caseid, G1 const& g1, G2 const& g2,
- std::size_t expected_count, std::size_t expected_point_count,
+ std::size_t expected_count, int expected_point_count,
         double expected_area,
         double percentage = 0.0001,
         bool sym = false)
@@ -103,7 +106,7 @@
             it != clip.end();
             ++it)
     {
- if (expected_point_count > 0)
+ if (expected_point_count >= 0)
         {
             n += bg::num_points(*it);
         }
@@ -135,15 +138,15 @@
 
 
 #if ! defined(BOOST_GEOMETRY_NO_BOOST_TEST)
- /*if (expected_point_count > 0)
+ if (expected_point_count >= 0)
     {
- BOOST_CHECK_MESSAGE(n == expected_point_count,
+ BOOST_CHECK_MESSAGE(n == std::size_t(expected_point_count),
                 "difference: " << caseid
                 << " #points expected: " << expected_point_count
                 << " detected: " << n
                 << " type: " << string_from_type<coordinate_type>::name()
                 );
- }*/
+ }
 
     if (expected_count > 0)
     {
@@ -171,11 +174,11 @@
 void test_one(std::string const& caseid,
         std::string const& wkt1, std::string const& wkt2,
         std::size_t expected_count1,
- std::size_t expected_point_count1,
+ int expected_point_count1,
         double expected_area1,
 
         std::size_t expected_count2,
- std::size_t expected_point_count2,
+ int expected_point_count2,
         double expected_area2,
 
         double percentage = 0.0001)
@@ -256,7 +259,7 @@
 void test_one_lp(std::string const& caseid,
         std::string const& wkt1, std::string const& wkt2,
         std::size_t expected_count,
- std::size_t expected_point_count,
+ int expected_point_count,
         double expected_length)
 {
     G1 g1;
@@ -272,25 +275,29 @@
 
     typename bg::default_length_result<G1>::type length = 0;
     std::size_t n = 0;
+ std::size_t piece_count = 0;
     for (typename std::vector<OutputType>::iterator it = pieces.begin();
             it != pieces.end();
             ++it)
     {
- if (expected_point_count > 0)
+ if (expected_point_count >= 0)
         {
             n += bg::num_points(*it);
         }
-
+ piece_count++;
         length += bg::length(*it);
     }
 
- BOOST_CHECK_MESSAGE(pieces.size() == expected_count,
+ BOOST_CHECK_MESSAGE(piece_count == expected_count,
             "difference: " << caseid
             << " #outputs expected: " << expected_count
             << " detected: " << pieces.size()
             );
 
- BOOST_CHECK_EQUAL(n, expected_point_count);
+ if (expected_point_count >= 0)
+ {
+ BOOST_CHECK_EQUAL(n, std::size_t(expected_point_count));
+ }
 
     BOOST_CHECK_CLOSE(length, expected_length, 0.001);
 

Modified: trunk/libs/geometry/test/multi/algorithms/multi_difference.cpp
==============================================================================
--- trunk/libs/geometry/test/multi/algorithms/multi_difference.cpp (original)
+++ trunk/libs/geometry/test/multi/algorithms/multi_difference.cpp 2012-12-16 07:18:44 EST (Sun, 16 Dec 2012)
@@ -10,7 +10,8 @@
 #include <iostream>
 #include <string>
 
- // #define BOOST_GEOMETRY_DEBUG_ASSEMBLE
+//#define HAVE_TTMATH
+//#define BOOST_GEOMETRY_DEBUG_ASSEMBLE
 //#define BOOST_GEOMETRY_CHECK_WITH_SQLSERVER
 
 //#define BOOST_GEOMETRY_DEBUG_SEGMENT_IDENTIFIER
@@ -38,7 +39,7 @@
 {
     test_one<Polygon, MultiPolygon, MultiPolygon>("simplex_multi",
             case_multi_simplex[0], case_multi_simplex[1],
- 5, 12, 5.58, 4, 12, 2.58);
+ 5, 21, 5.58, 4, 17, 2.58);
 
     test_one<Polygon, MultiPolygon, MultiPolygon>("case_multi_no_ip",
             case_multi_no_ip[0], case_multi_no_ip[1],
@@ -49,13 +50,13 @@
 
     test_one<Polygon, MultiPolygon, Polygon>("simplex_multi_mp_p",
             case_multi_simplex[0], case_single_simplex,
- 5, 22, 5.58, 4, 17, 2.58);
+ 5, 21, 5.58, 4, 17, 2.58);
     test_one<Polygon, Ring, MultiPolygon>("simplex_multi_r_mp",
             case_single_simplex, case_multi_simplex[0],
- 4, 17, 2.58, 5, 22, 5.58);
+ 4, 17, 2.58, 5, 21, 5.58);
     test_one<Ring, MultiPolygon, Polygon>("simplex_multi_mp_r",
             case_multi_simplex[0], case_single_simplex,
- 5, 22, 5.58, 4, 17, 2.58);
+ 5, 21, 5.58, 4, 17, 2.58);
 
     // Constructed cases for multi/touch/equal/etc
     test_one<Polygon, MultiPolygon, MultiPolygon>("case_61_multi",
@@ -69,7 +70,7 @@
             0, 0, 0, 1, 5, 1);
     test_one<Polygon, MultiPolygon, MultiPolygon>("case_64_multi",
         case_64_multi[0], case_64_multi[1],
- 1, 1, 1, 1, 1, 1);
+ 1, 5, 1, 1, 5, 1);
     test_one<Polygon, MultiPolygon, MultiPolygon>("case_65_multi",
         case_65_multi[0], case_65_multi[1],
             0, 0, 0, 2, 10, 3);
@@ -84,22 +85,22 @@
 
     test_one<Polygon, MultiPolygon, MultiPolygon>("case_78_multi",
         case_78_multi[0], case_78_multi[1],
- 1, 1, 1.0, 1, 1, 1.0);
+ 1, 5, 1.0, 1, 5, 1.0);
 
     // Ticket on GGL list 2011/10/25
     // to mix polygon/multipolygon in call to difference
     test_one<Polygon, Polygon, Polygon>("ggl_list_20111025_vd_pp",
         ggl_list_20111025_vd[0], ggl_list_20111025_vd[1],
- 1, -999, 8.0, 1, -999, 12.5);
+ 1, 4, 8.0, 1, 4, 12.5);
     test_one<Polygon, Polygon, MultiPolygon>("ggl_list_20111025_vd_pm",
         ggl_list_20111025_vd[0], ggl_list_20111025_vd[3],
- 1, -999, 8.0, 1, -999, 12.5);
+ 1, 4, 8.0, 1, 4, 12.5);
     test_one<Polygon, MultiPolygon, Polygon>("ggl_list_20111025_vd_mp",
         ggl_list_20111025_vd[2], ggl_list_20111025_vd[1],
- 1, -999, 8.0, 1, -999, 12.5);
+ 1, 4, 8.0, 1, 4, 12.5);
     test_one<Polygon, MultiPolygon, MultiPolygon>("ggl_list_20111025_vd_mm",
         ggl_list_20111025_vd[2], ggl_list_20111025_vd[3],
- 1, -999, 8.0, 1, -999, 12.5);
+ 1, 4, 8.0, 1, 4, 12.5);
 
     // Second case
     // This can be tested with this SQL for SQL-Server
@@ -120,14 +121,19 @@
 
     test_one<Polygon, Polygon, MultiPolygon>("ggl_list_20111025_vd_2",
         ggl_list_20111025_vd_2[0], ggl_list_20111025_vd_2[1],
- 1, -999, 10.0, 2, -999, 6.0);
+ 1, 7, 10.0, 2, 10, 6.0);
 
     test_one<Polygon, MultiPolygon, MultiPolygon>("ggl_list_20120915_h2_a",
         ggl_list_20120915_h2[0], ggl_list_20120915_h2[1],
- 2, -999, 17.0, 0, -999, 0.0);
+ 2, 13, 17.0, 0, 0, 0.0);
     test_one<Polygon, MultiPolygon, MultiPolygon>("ggl_list_20120915_h2_b",
         ggl_list_20120915_h2[0], ggl_list_20120915_h2[2],
- 2, -999, 17.0, 0, -999, 0.0);
+ 2, 13, 17.0, 0, 0, 0.0);
+
+ test_one<Polygon, MultiPolygon, MultiPolygon>("ggl_list_20120221_volker",
+ ggl_list_20120221_volker[0], ggl_list_20120221_volker[1],
+ 2, 12, 7962.66, 1, 18, 2775258.93,
+ 0.001);
 
 
     /* TODO: fix

Modified: trunk/libs/geometry/test/multi/algorithms/overlay/multi_overlay_cases.hpp
==============================================================================
--- trunk/libs/geometry/test/multi/algorithms/overlay/multi_overlay_cases.hpp (original)
+++ trunk/libs/geometry/test/multi/algorithms/overlay/multi_overlay_cases.hpp 2012-12-16 07:18:44 EST (Sun, 16 Dec 2012)
@@ -434,5 +434,13 @@
         "MULTIPOLYGON(((-1 5, 0 5, 0 0, -1 0, -1 5)), ((0 0, 1 0, 1 -1, 0 -1, 0 0)))"
     };
 
+// Mail of volker, about another problem, but this specific example is causing two-point inner rings polygons which should be discarded
+// (condition of num_points in detail/overlay/convert_ring.hpp)
+static std::string ggl_list_20120221_volker[2] =
+ {
+ "MULTIPOLYGON(((1032 2130,1032 1764,2052 2712,1032 2130)),((3234 2580,2558 2690,3234 2532,3234 2580)),((2558 2690,2136 2790,2052 2712,2136 2760,2558 2690)))",
+ "MULTIPOLYGON(((3232 2532.469945355191,2136 2790,1032 1764,1032 1458,1032 1212,2136 2328,3232 2220.196721311475,3232 1056,1031 1056,1031 2856,3232 2856,3232 2532.469945355191),(3232 2412.426229508197,2136 2646,3232 2412.426229508197)))"
+ };
+
 
 #endif // BOOST_GEOMETRY_TEST_MULTI_OVERLAY_CASES_HPP


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