[geos-commits] r3513 - in branches/3.3: . src/operation/union tests/unit/operation/union tests/xmltester/tests/general

svn_geos at osgeo.org svn_geos at osgeo.org
Fri Nov 4 13:45:43 EDT 2011


Author: strk
Date: 2011-11-04 10:45:43 -0700 (Fri, 04 Nov 2011)
New Revision: 3513

Modified:
   branches/3.3/NEWS
   branches/3.3/src/operation/union/UnaryUnionOp.cpp
   branches/3.3/tests/unit/operation/union/UnaryUnionOpTest.cpp
   branches/3.3/tests/xmltester/tests/general/TestUnaryUnion.xml
Log:
Fix noding of self-intersecting lines through UnaryUnion (#482)

Includes updated tests from JTS

Modified: branches/3.3/NEWS
===================================================================
--- branches/3.3/NEWS	2011-11-04 15:00:15 UTC (rev 3512)
+++ branches/3.3/NEWS	2011-11-04 17:45:43 UTC (rev 3513)
@@ -4,6 +4,7 @@
 - Bug fixes / improvements
     - Fixed CMAKE_CXX_FLAGS overridind -std=gnu++0x (#489)
     - Missing versions update in CMake configuration (#490)
+    - Fix noding of self-intersecting lines through UnaryUnion (#482)
 
 Changes in 3.3.1
 2011-09-27

Modified: branches/3.3/src/operation/union/UnaryUnionOp.cpp
===================================================================
--- branches/3.3/src/operation/union/UnaryUnionOp.cpp	2011-11-04 15:00:15 UTC (rev 3512)
+++ branches/3.3/src/operation/union/UnaryUnionOp.cpp	2011-11-04 17:45:43 UTC (rev 3513)
@@ -83,13 +83,18 @@
 
   GeomAutoPtr unionLines;
   if (!lines.empty()) {
-#if 0
-      GeomAutoPtr lineGeom = geomFact->buildGeometry( lines.begin(),
-                                                      lines.end()    );
-      unionLines = unionNoOpt(*lineGeom);
-#endif
+      /* JTS compatibility NOTE:
+       * we use cascaded here for robustness [1]
+       * but also add a final unionNoOpt step to deal with
+       * self-intersecting lines [2]
+       *
+       * [1](http://trac.osgeo.org/geos/ticket/392
+       * [2](http://trac.osgeo.org/geos/ticket/482
+       *
+       */
       unionLines.reset( CascadedUnion::Union( lines.begin(),
                                               lines.end()   ) );
+      unionLines = unionNoOpt(*unionLines);
   }
 
   GeomAutoPtr unionPolygons;

Modified: branches/3.3/tests/unit/operation/union/UnaryUnionOpTest.cpp
===================================================================
--- branches/3.3/tests/unit/operation/union/UnaryUnionOpTest.cpp	2011-11-04 15:00:15 UTC (rev 3512)
+++ branches/3.3/tests/unit/operation/union/UnaryUnionOpTest.cpp	2011-11-04 17:45:43 UTC (rev 3513)
@@ -1,6 +1,6 @@
 // $Id$
 // 
-// Test Suite for geos::operation::geounion::CascadedPolygonUnion class.
+// Test Suite for geos::operation::geounion::UnaryUnionOp class.
 
 // tut
 #include <tut.hpp>
@@ -167,5 +167,17 @@
         doTest(geoms, "GEOMETRYCOLLECTION (POINT (80 50), POINT (100 70), LINESTRING (40 60, 120 110))");
     }
 
+    template<>
+    template<>
+    void object::test<6>()
+    {
+        static char const* const geoms[] = 
+        {
+            "LINESTRING (0 0, 10 0, 5 -5, 5 5)",
+            NULL
+        };
+        doTest(geoms, "MULTILINESTRING ((0 0, 5 0), (5 0, 10 0, 5 -5, 5 0), (5 0, 5 5))");
+    }
+
 } // namespace tut
 

Modified: branches/3.3/tests/xmltester/tests/general/TestUnaryUnion.xml
===================================================================
--- branches/3.3/tests/xmltester/tests/general/TestUnaryUnion.xml	2011-11-04 15:00:15 UTC (rev 3512)
+++ branches/3.3/tests/xmltester/tests/general/TestUnaryUnion.xml	2011-11-04 17:45:43 UTC (rev 3513)
@@ -27,6 +27,18 @@
 </case>
 
 <case>
+  <desc>L - LineString (showing noding)</desc>
+  <a>
+    LINESTRING (0 0, 10 0, 5 -5, 5 5)
+  </a>
+<test>
+  <op name="union" arg1="A">
+    MULTILINESTRING ((0 0, 5 0), (5 0, 10 0, 5 -5, 5 0), (5 0, 5 5))
+  </op>
+</test>
+</case>
+
+<case>
   <desc>mL - multiLineString (showing noding)</desc>
   <a>
     MULTILINESTRING((0 0, 10 10), (0 10, 10 0))



More information about the geos-commits mailing list