[geos-commits] [SCM] GEOS branch svn-3.6 updated. bcf347af99abc0f2c5064db9cb5b1e2e2ee4bebd

git at osgeo.org git at osgeo.org
Mon Jul 30 18:06:43 PDT 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GEOS".

The branch, svn-3.6 has been updated
       via  bcf347af99abc0f2c5064db9cb5b1e2e2ee4bebd (commit)
      from  d3adb9f0080731f0d8c7e546410ca330b446f446 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit bcf347af99abc0f2c5064db9cb5b1e2e2ee4bebd
Author: Daniel Baston <dbaston at gmail.com>
Date:   Mon Jul 30 21:04:41 2018 -0400

    Fix infinite loop in GEOSClipByRect
    
    Fixes #865
    Closes https://github.com/libgeos/geos/pull/110

diff --git a/src/operation/intersection/RectangleIntersection.cpp b/src/operation/intersection/RectangleIntersection.cpp
index dc0ee4f..25312a8 100644
--- a/src/operation/intersection/RectangleIntersection.cpp
+++ b/src/operation/intersection/RectangleIntersection.cpp
@@ -60,6 +60,11 @@ bool different(double x1, double y1, double x2, double y2)
 inline
 void clip_one_edge(double & x1, double & y1, double x2, double y2, double limit)
 {
+  if (x2 == limit) {
+  	y1 = y2;
+    x1 = x2;
+  }
+
   if(x1 != x2)
 	{
 	  y1 += (y2-y1)*(limit-x1)/(x2-x1);
diff --git a/src/operation/intersection/RectangleIntersectionBuilder.cpp b/src/operation/intersection/RectangleIntersectionBuilder.cpp
index 986c4aa..d9d269f 100644
--- a/src/operation/intersection/RectangleIntersectionBuilder.cpp
+++ b/src/operation/intersection/RectangleIntersectionBuilder.cpp
@@ -22,6 +22,7 @@
 #include <geos/geom/LineString.h>
 #include <geos/geom/LinearRing.h>
 #include <geos/algorithm/CGAlgorithms.h>
+#include <geos/util/IllegalArgumentException.h>
 
 #include <cmath> // for fabs()
 
@@ -184,6 +185,13 @@ double distance(const Rectangle & rect,
   Rectangle::Position pos = rect.position(x1,y1);
   Rectangle::Position endpos = rect.position(x2,y2);
 
+  if (pos & Rectangle::Position::Outside ||
+      endpos & Rectangle::Position::Outside ||
+	  pos & Rectangle::Position::Inside ||
+	  endpos & Rectangle::Position::Inside) {
+  	throw geos::util::IllegalArgumentException("Can't compute distance to non-boundary position.");
+  }
+
   while(true)
 	{
 	  // Close up when we have the same edge and the
diff --git a/tests/unit/operation/intersection/RectangleIntersectionTest.cpp b/tests/unit/operation/intersection/RectangleIntersectionTest.cpp
index 57ffb5c..24b7168 100644
--- a/tests/unit/operation/intersection/RectangleIntersectionTest.cpp
+++ b/tests/unit/operation/intersection/RectangleIntersectionTest.cpp
@@ -101,7 +101,6 @@ namespace tut
     typedef group::object object;
 
     group test_rectangleintersectiontest_group("geos::operation::intersection::RectangleIntersection");
-
     // inside
     template<> template<> void object::test<1>()
     {
@@ -1514,4 +1513,19 @@ namespace tut
         "POLYGON((0 0,0 10,10 10,10 0,0 0))";
       doClipTest(inp, exp, r);
     }
+
+    // PostGIS hanging unit test
+    template<> template<> void object::test<208>()
+    {
+      Rectangle r(3.0481343214686657e-14, -20000000.000000, 20000000.000000, -1.000000);
+      const char *clip =
+        "POLYGON((3.0481343214686657e-14 -20000000, 200000000 -20000000, 200000000 -1, 3.0481343214686657e-14 -1, 3.0481343214686657e-14 -20000000))";
+      const char *inp =
+        "POLYGON((3.0481343214686657e-14 -20000000, 3.0481343214686657e-14 -1, 1.570795680861262382313481289e-3 -0.999998766299703523152686557296, 3.141587485909849188081555127e-3 -0.999995065201858102099663483386, 3.0481343214686657e-14 -20000000))";
+
+      GeomPtr isect{readWKT(clip)->intersection(readWKT(inp).get())};
+      std::string exp = wktwriter.write(isect.get());
+
+      doClipTest(inp, exp, r, 1e-20);
+    }
 }

-----------------------------------------------------------------------

Summary of changes:
 src/operation/intersection/RectangleIntersection.cpp     |  5 +++++
 .../intersection/RectangleIntersectionBuilder.cpp        |  8 ++++++++
 .../operation/intersection/RectangleIntersectionTest.cpp | 16 +++++++++++++++-
 3 files changed, 28 insertions(+), 1 deletion(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list