[geos-commits] r3774 - in branches/3.3: . src/algorithm tests/xmltester tests/xmltester/tests/ticket

svn_geos at osgeo.org svn_geos at osgeo.org
Thu Feb 28 01:45:21 PST 2013


Author: strk
Date: 2013-02-28 01:45:21 -0800 (Thu, 28 Feb 2013)
New Revision: 3774

Added:
   branches/3.3/tests/xmltester/tests/ticket/bug582.xml
Modified:
   branches/3.3/NEWS
   branches/3.3/src/algorithm/CentroidArea.cpp
   branches/3.3/tests/xmltester/Makefile.am
Log:
Fix centroid computation for collections with empty components

Fixes bug #582

Modified: branches/3.3/NEWS
===================================================================
--- branches/3.3/NEWS	2013-02-28 09:40:54 UTC (rev 3773)
+++ branches/3.3/NEWS	2013-02-28 09:45:21 UTC (rev 3774)
@@ -5,6 +5,7 @@
     - IsValidOp: throw proper error on nested shells (#608)
     - Fix header guards (#617, #618, #619)
     - WKTWriter::appendCoordinate optimisation
+    - Fix centroid computation for collections with empty components (#582)
 
 Changes in 3.3.7
 2013-01-22 

Modified: branches/3.3/src/algorithm/CentroidArea.cpp
===================================================================
--- branches/3.3/src/algorithm/CentroidArea.cpp	2013-02-28 09:40:54 UTC (rev 3773)
+++ branches/3.3/src/algorithm/CentroidArea.cpp	2013-02-28 09:45:21 UTC (rev 3774)
@@ -38,7 +38,8 @@
 void
 CentroidArea::add(const Geometry *geom)
 {
-	if(const Polygon *poly=dynamic_cast<const Polygon*>(geom)) {
+  if(geom->isEmpty()) return;
+	else if(const Polygon *poly=dynamic_cast<const Polygon*>(geom)) {
 		setBasePoint(poly->getExteriorRing()->getCoordinateN(0));
 		add(poly);
 	}

Modified: branches/3.3/tests/xmltester/Makefile.am
===================================================================
--- branches/3.3/tests/xmltester/Makefile.am	2013-02-28 09:40:54 UTC (rev 3773)
+++ branches/3.3/tests/xmltester/Makefile.am	2013-02-28 09:45:21 UTC (rev 3774)
@@ -34,6 +34,7 @@
 	$(srcdir)/tests/ticket/bug398.xml \
 	$(srcdir)/tests/ticket/bug434.xml \
 	$(srcdir)/tests/ticket/bug527.xml \
+	$(srcdir)/tests/ticket/bug582.xml \
 	$(srcdir)/tests/ticket/bug586.xml \
 	$(srcdir)/tests/ticket/bug599.xml \
 	$(srcdir)/tests/ticket/bug615.xml \

Added: branches/3.3/tests/xmltester/tests/ticket/bug582.xml
===================================================================
--- branches/3.3/tests/xmltester/tests/ticket/bug582.xml	                        (rev 0)
+++ branches/3.3/tests/xmltester/tests/ticket/bug582.xml	2013-02-28 09:45:21 UTC (rev 3774)
@@ -0,0 +1,13 @@
+<run>
+  <precisionModel scale="1.0" offsetx="0.0" offsety="0.0"/>
+
+<case>
+  <desc>GC - overlapping polygons </desc>
+  <a>
+  MULTIPOLYGON(EMPTY,((0 0,1 0,1 1,0 1, 0 0)))
+	</a>
+<test><op name="getCentroid" arg1="A" >    POINT (0.5 0.5)   </op></test>
+</case>
+
+
+</run>



More information about the geos-commits mailing list