[geos-commits] r3750 - in branches/3.3: . include/geos/geom tests/xmltester tests/xmltester/tests/ticket

svn_geos at osgeo.org svn_geos at osgeo.org
Thu Jan 17 04:04:01 PST 2013


Author: strk
Date: 2013-01-17 04:04:00 -0800 (Thu, 17 Jan 2013)
New Revision: 3750

Added:
   branches/3.3/tests/xmltester/tests/ticket/bug615.xml
Modified:
   branches/3.3/NEWS
   branches/3.3/include/geos/geom/BinaryOp.h
   branches/3.3/tests/xmltester/Makefile.am
Log:
Only attempt to fix self-intersection between multiple components

Doing this reduces the likelyhood of entering an infinite recursion
whereas UnaryUnion (meant to fix that) would enter the self-intersection
attempt again. Fixes #615 for which a test is added.

This also gives us back an exception with the input of ticket #488,
which is the same behavior JTS exposes. The (bogus) test for it
is disabled by this commit.

Modified: branches/3.3/NEWS
===================================================================
--- branches/3.3/NEWS	2013-01-14 16:15:37 UTC (rev 3749)
+++ branches/3.3/NEWS	2013-01-17 12:04:00 UTC (rev 3750)
@@ -7,6 +7,7 @@
       while trying to obtain a valid Buffer output (#605)
     - Fix GEOSPointOnSurface with zero-length linestring (#609)
     - Fix EMPTY return from zero-area polygon (#613)
+    - Segfault from symdifference (#615)
 
 Changes in 3.3.6
 2012-11-15 -- that's Post-GIS day !

Modified: branches/3.3/include/geos/geom/BinaryOp.h
===================================================================
--- branches/3.3/include/geos/geom/BinaryOp.h	2013-01-14 16:15:37 UTC (rev 3749)
+++ branches/3.3/include/geos/geom/BinaryOp.h	2013-01-17 12:04:00 UTC (rev 3750)
@@ -4,6 +4,7 @@
  * GEOS - Geometry Engine Open Source
  * http://geos.refractions.net
  *
+ * Copyright (C) 2013 Sandro Santilli <strk at keybit.net>
  * Copyright (C) 2006 Refractions Research Inc.
  *
  * This is free software; you can redistribute and/or modify it under
@@ -50,6 +51,8 @@
 #define GEOS_GEOM_BINARYOP_H
 
 #include <geos/geom/Geometry.h>
+#include <geos/geom/GeometryCollection.h>
+#include <geos/geom/Polygon.h>
 #include <geos/geom/PrecisionModel.h>
 #include <geos/precision/CommonBitsRemover.h>
 #include <geos/precision/SimpleGeometryPrecisionReducer.h>
@@ -152,16 +155,52 @@
 	return true;
 }
 
-/* A single component may become a multi component */
+/*
+ * Attempt to fix noding of multilines and
+ * self-intersection of multipolygons 
+ *
+ * May return the input untouched.
+ */
 inline std::auto_ptr<Geometry>
 fix_self_intersections(std::auto_ptr<Geometry> g, const std::string& label)
 {
 #ifdef GEOS_DEBUG_BINARYOP
 	std::cerr << label << " fix_self_intersection (UnaryUnion)" << std::endl;
 #endif
-  // TODO: check for the sole self-intersections case ?
-  if ( ! check_valid(*g, label) ) return g->Union();
-  else return std::auto_ptr<Geometry>(g->clone());
+
+  // Only multi-components can be fixed by UnaryUnion
+  if ( ! dynamic_cast<const GeometryCollection*>(g.get()) ) return g;
+
+  using operation::valid::IsValidOp;
+
+  IsValidOp ivo(g.get());
+
+  // Polygon is valid, nothing to do
+  if ( ivo.isValid() ) return g;
+
+  // Not all invalidities can be fixed by this code
+
+  using operation::valid::TopologyValidationError;
+  TopologyValidationError* err = ivo.getValidationError();
+  switch ( err->getErrorType() ) {
+    case TopologyValidationError::eRingSelfIntersection:
+    case TopologyValidationError::eTooFewPoints: // collapsed lines
+#ifdef GEOS_DEBUG_BINARYOP
+	    std::cerr << label << " ATTEMPT_TO_FIX: " << err->getErrorType() << ": " << *g << std::endl;
+#endif
+      g = g->Union();
+#ifdef GEOS_DEBUG_BINARYOP
+	    std::cerr << label << " ATTEMPT_TO_FIX succeeded.. " << std::endl;
+#endif
+      return g;
+    case TopologyValidationError::eSelfIntersection:
+      // this one is within a single component, won't be fixed
+    default:
+#ifdef GEOS_DEBUG_BINARYOP
+	    std::cerr << label << " invalidity is: " << err->getErrorType() << std::endl;
+#endif
+      return g;
+  }
 }
 
 
@@ -270,11 +309,11 @@
 #endif
 	}
 
-//#if GEOS_DEBUG_BINARYOP
+#if GEOS_DEBUG_BINARYOP
   // Should we just give up here ?
   check_valid(*g0, "Input geom 0");
   check_valid(*g1, "Input geom 1");
-//#endif
+#endif
 
 #endif // USE_ORIGINAL_INPUT
 

Modified: branches/3.3/tests/xmltester/Makefile.am
===================================================================
--- branches/3.3/tests/xmltester/Makefile.am	2013-01-14 16:15:37 UTC (rev 3749)
+++ branches/3.3/tests/xmltester/Makefile.am	2013-01-17 12:04:00 UTC (rev 3750)
@@ -33,10 +33,10 @@
 	$(srcdir)/tests/ticket/bug392.xml \
 	$(srcdir)/tests/ticket/bug398.xml \
 	$(srcdir)/tests/ticket/bug434.xml \
-	$(srcdir)/tests/ticket/bug488.xml \
 	$(srcdir)/tests/ticket/bug527.xml \
 	$(srcdir)/tests/ticket/bug586.xml \
 	$(srcdir)/tests/ticket/bug599.xml \
+	$(srcdir)/tests/ticket/bug615.xml \
 	$(srcdir)/tests/general/TestBoundary.xml \
 	$(srcdir)/tests/general/TestBuffer.xml \
 	$(srcdir)/tests/general/TestBufferMitredJoin.xml \
@@ -90,7 +90,8 @@
 INVALID_OUTPUT_XMLTESTS = 
 
 FAILING_XMLTESTS = \
-	$(srcdir)/tests/failure/TestOverlay.xml
+	$(srcdir)/tests/failure/TestOverlay.xml \
+	$(srcdir)/tests/ticket/bug488.xml 
 
 XMLTESTS=$(SAFE_XMLTESTS) $(INVALID_OUTPUT_XMLTESTS) $(FAILING_XMLTESTS)
 

Added: branches/3.3/tests/xmltester/tests/ticket/bug615.xml
===================================================================
--- branches/3.3/tests/xmltester/tests/ticket/bug615.xml	                        (rev 0)
+++ branches/3.3/tests/xmltester/tests/ticket/bug615.xml	2013-01-17 12:04:00 UTC (rev 3750)
@@ -0,0 +1,22 @@
+
+<run>
+  <precisionModel type="FLOATING" />
+
+  <case>
+    <desc>
+See http://trac.osgeo.org/geos/ticket/615
+    </desc>
+    <a>
+01060000000500000001030000000100000004000000239CFA9F7F9230401ABADB203141474018601F9DBA92304062D68BA19C40474027361FD7869230408D62B9A5D5404740239CFA9F7F9230401ABADB203141474001030000000100000004000000125901C0739230408653A0054F41474043CA4FAA7D923040DB5548F949414740239CFA9F7F9230401ABADB2031414740125901C0739230408653A0054F4147400103000000010000000B0000005EA791E509923040D3DDAD7E594247408BFD65F7E4913040CBA65CE15D4247406F2F698CD69130400A850838844247401A34F44F70913040D947A7AE7C424740B745990D329130400AA2EE0390424740454C89247A913040D8817346944247407E74EACA679130406E3997E2AA424740A81DFE9AAC913040CA8E8D40BC4247400C410E4A9891304074EFE192E342474036B05582C5913040E5ED08A7054347405EA791E509923040D3DDAD7E5942474001030000000100000005000000125901C0739230408653A0054F4147400DAB7823F3903040FD1873D712424740A73FFB9122923040367BA01518424740773A98D22192304096FAA9431D424740125901C0739230408653A0054F414740010300000001000000040000005EA791E509923040D3DDAD7E59424740C4D32B651992304027C286A757424740773A98D22
 192304096FAA9431D4247405EA791E509923040D3DDAD7E59424740
+    </a>
+    <b>
+0106000000050000000103000000010000000800000019C9CCC7889230401D2A92141A41474018601F9DBA92304062D68BA19C40474026361FD7869230408D62B9A5D5404740B48EAA26889230408CB96B09F9404740C3D8429083923040B0AC34290541474098DD938785923040C5387F130A41474026361FD786923040704221020E41474019C9CCC7889230401D2A92141A4147400103000000010000000700000035F1A79473923040BDB5C0724F41474043CA4FAA7D923040DA5548F94941474098DD938785923040F0C4AC174341474018EC866D8B9230400C59DDEA39414740A64412BD8C923040FEF15EB53241474019C9CCC7889230401D2A92141A41474035F1A79473923040BDB5C0724F414740010300000001000000130000005EA791E509923040D3DDAD7E594247408BFD65F7E4913040CAA65CE15D4247406F2F698CD69130400A85083884424740D252793BC29130401FF46C567D4247409A999999999130402D5BEB8B844247401A34F44F70913040D847A7AE7C424740B745990D329130400AA2EE0390424740459E245D33913040D881734694424740378E588B4F91304018096D3997424740444C89247A913040D8817346944247407E74EACA679130406D3997E2AA424740A81DFE9AAC913040C98E8D40BC424740E17F2BD9B19130406D73637AC2424
 7400B410E4A9891304074EFE192E3424740280F0BB5A691304097E2AAB2EF424740D252793BC29130402D6002B7EE424740A81DFE9AAC9130400282397AFC42474036B05582C5913040E5ED08A7054347405EA791E509923040D3DDAD7E594247400103000000010000000E00000035F1A79473923040BDB5C0724F4147408A3C49BA66923040211FF46C5641474036CD3B4ED1913040C4B12E6EA3414740C47762D68B91304076374F75C8414740D3BCE3141D913040EE940ED6FF4147408CF337A110913040042159C0044247402979758E01913040F5D6C05609424740450DA661F8903040A0E062450D4247400DAB7823F3903040FC1873D71242474029965B5A0D91304020EF552B1342474099F04BFDBC913040834C327216424740A73FFB9122923040357BA01518424740773A98D22192304097FAA9431D42474035F1A79473923040BDB5C0724F414740010300000001000000040000005EA791E509923040D3DDAD7E59424740C3D32B651992304027C286A757424740773A98D22192304097FAA9431D4247405EA791E509923040D3DDAD7E59424740
+    </b>
+    <test>
+      <op name='symdifference' arg1='A' arg2='B' >
+01060000000C0000000103000000010000000C00000043CA4FAA7D923040DA5548F94941474098DD938785923040F0C4AC174341474018EC866D8B9230400C59DDEA39414740A64412BD8C923040FEF15EB53241474019C9CCC7889230401D2A92141A41474026361FD786923040704221020E41474098DD938785923040C5387F130A414740C3D8429083923040B0AC342905414740B48EAA26889230408CB96B09F940474026361FD7869230408D62B9A5D5404740239CFA9F7F9230401ABADB203141474043CA4FAA7D923040DA5548F9494147400103000000010000000A00000071D9271D0C91304001823120064247408CF337A110913040042159C004424740D3BCE3141D913040EE940ED6FF414740C47762D68B91304076374F75C841474036CD3B4ED1913040C4B12E6EA34147408A3C49BA66923040211FF46C5641474035F1A79473923040BDB5C0724F41474043CA4FAA7D923040DA5548F949414740125901C0739230408653A0054F41474071D9271D0C913040018231200642474001030000000100000005000000B745990D329130400AA2EE0390424740459E245D33913040D881734694424740378E588B4F91304018096D3997424740444C89247A913040D881734694424740B745990D329130400AA2EE0390424740010300000001000000050000000DA
 B7823F3903040FC1873D71242474071D9271D0C91304001823120064247402979758E01913040F5D6C05609424740450DA661F8903040A0E062450D4247400DAB7823F3903040FC1873D7124247400103000000010000000400000077459ECBAC91304054D11324814247406F2F698CD69130400A85083884424740D252793BC29130401FF46C567D42474077459ECBAC91304054D113248142474001030000000100000004000000A81DFE9AAC9130400282397AFC42474036B05582C5913040E5ED08A705434740B0C6C481B391304014A2E915F8424740A81DFE9AAC9130400282397AFC42474001030000000100000004000000D675324DA8913040353117A4EF424740B0C6C481B391304014A2E915F8424740D252793BC29130402D6002B7EE424740D675324DA8913040353117A4EF424740010300000001000000040000000B410E4A9891304074EFE192E3424740E17F2BD9B19130406D73637AC2424740A81DFE9AAC913040C98E8D40BC4247400B410E4A9891304074EFE192E3424740010300000001000000040000000B410E4A9891304074EFE192E3424740280F0BB5A691304097E2AAB2EF424740D675324DA8913040353117A4EF4247400B410E4A9891304074EFE192E3424740010300000001000000040000001A34F44F70913040D847A7AE7C4247409A99
 9999999130402D5BEB8B8442474077459ECBAC91304054D11324814247401A34F44F70913040D847A7AE7C424740010300000001000000040000003893A64068913040B2A17BDD1442474099F04BFDBC913040834C327216424740A73FFB9122923040357BA015184247403893A64068913040B2A17BDD14424740010300000001000000040000000DAB7823F3903040FC1873D7124247403893A64068913040B2A17BDD1442474029965B5A0D91304020EF552B134247400DAB7823F3903040FC1873D712424740
+      </op>
+    </test>
+  </case>
+
+</run>



More information about the geos-commits mailing list