$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r74170 - in trunk: boost/geometry/policies/relate libs/geometry/test/algorithms libs/geometry/test/algorithms/overlay
From: barend.gehrels_at_[hidden]
Date: 2011-08-30 17:16:51
Author: barendgehrels
Date: 2011-08-30 17:16:50 EDT (Tue, 30 Aug 2011)
New Revision: 74170
URL: http://svn.boost.org/trac/boost/changeset/74170
Log:
Bugfix (robustness issue) based on ticket ggl-list by Christophe, dated Aug 20, 2011
Phase 1, it still has to be reworked
Text files modified: 
   trunk/boost/geometry/policies/relate/intersection_points.hpp  |    11 ++++++++++-                             
   trunk/libs/geometry/test/algorithms/difference.cpp            |     6 ++++++                                  
   trunk/libs/geometry/test/algorithms/intersection.cpp          |     4 ++--                                    
   trunk/libs/geometry/test/algorithms/overlay/overlay_cases.hpp |     7 +++++++                                 
   trunk/libs/geometry/test/algorithms/union.cpp                 |     2 +-                                      
   5 files changed, 26 insertions(+), 4 deletions(-)
Modified: trunk/boost/geometry/policies/relate/intersection_points.hpp
==============================================================================
--- trunk/boost/geometry/policies/relate/intersection_points.hpp	(original)
+++ trunk/boost/geometry/policies/relate/intersection_points.hpp	2011-08-30 17:16:50 EDT (Tue, 30 Aug 2011)
@@ -70,7 +70,16 @@
         promoted_type const da = (promoted_type(dx2) * wy) - (promoted_type(dy2) * wx);
 
         // r: ratio 0-1 where intersection divides A/B
-        promoted_type const r = da / d;
+        promoted_type r = da / d;
+		// Handle robustness issues
+		if (r < 0)
+		{
+			r = 0;
+		}
+		else if (r > 1)
+		{
+			r = 1;
+		}
 
         result.count = 1;
         set<0>(result.intersections[0],
Modified: trunk/libs/geometry/test/algorithms/difference.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/difference.cpp	(original)
+++ trunk/libs/geometry/test/algorithms/difference.cpp	2011-08-30 17:16:50 EDT (Tue, 30 Aug 2011)
@@ -224,6 +224,12 @@
         1, 0, 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); 
+
+
 
 #ifdef _MSC_VER
     // 2011-07-02
Modified: trunk/libs/geometry/test/algorithms/intersection.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/intersection.cpp	(original)
+++ trunk/libs/geometry/test/algorithms/intersection.cpp	2011-08-30 17:16:50 EDT (Tue, 30 Aug 2011)
@@ -166,7 +166,7 @@
     test_one<Polygon, Polygon, Polygon>("isovist",
         isovist1[0], isovist1[1],
         1,
-        if_typed<ct, float>(19, if_typed<ct, double>(22, 20)),
+        if_typed<ct, float>(19, if_typed<ct, double>(20, 20)),
         88.19203,
         if_typed<ct, float>(0.5, if_typed<ct, double>(0.1, 0.01)));
 #endif
@@ -191,7 +191,7 @@
     test_one<Polygon, Polygon, Polygon>("ggl_list_20110716_enrico",
         ggl_list_20110716_enrico[0], ggl_list_20110716_enrico[1],
         3, 
-        if_typed<ct, float>(20, 22), 
+        if_typed<ct, float>(19, if_typed<ct, double>(22, 21)),
         35723.8506317139);
 #endif
 
Modified: trunk/libs/geometry/test/algorithms/overlay/overlay_cases.hpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/overlay/overlay_cases.hpp	(original)
+++ trunk/libs/geometry/test/algorithms/overlay/overlay_cases.hpp	2011-08-30 17:16:50 EDT (Tue, 30 Aug 2011)
@@ -512,6 +512,13 @@
     };
 
 
+static std::string ggl_list_20110820_christophe[2] = 
+{
+    "POLYGON((17.763942722600319 32.23605727739968,19.192448808558737 30.807551191441263,16.000000000000000 30.000000000000000,17.763942722600319 32.236057277399681))",
+    "POLYGON((0.24806946917841693 26.015444246572663,31.751930530821582 33.984555753427337,32.248069469178418 30.015444246572663,0.24806946917841693 26.015444246572663))" 
+};
+
+
 // GEOS "TestOverlay" test.
 // Note that the first one WAS invalid and is made valid using SQL Server 2008 Spatial MakeValid() function
 static std::string geos_1_test_overlay[2] =
Modified: trunk/libs/geometry/test/algorithms/union.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/union.cpp	(original)
+++ trunk/libs/geometry/test/algorithms/union.cpp	2011-08-30 17:16:50 EDT (Tue, 30 Aug 2011)
@@ -244,7 +244,7 @@
         1,
         0,
         if_typed<ct, float>(71, 
-            if_typed<ct, double>(72, 73)),
+            if_typed<ct, double>(70, 73)),
         313.36036462);
 #endif
 }