[geos-commits] r3773 - in trunk: src/algorithm tests/xmltester tests/xmltester/tests/ticket

svn_geos at osgeo.org svn_geos at osgeo.org
Thu Feb 28 01:40:55 PST 2013


Author: strk
Date: 2013-02-28 01:40:54 -0800 (Thu, 28 Feb 2013)
New Revision: 3773

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

Fixes bug #582

Modified: trunk/src/algorithm/CentroidArea.cpp
===================================================================
--- trunk/src/algorithm/CentroidArea.cpp	2013-02-25 11:41:19 UTC (rev 3772)
+++ trunk/src/algorithm/CentroidArea.cpp	2013-02-28 09:40:54 UTC (rev 3773)
@@ -37,7 +37,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: trunk/tests/xmltester/Makefile.am
===================================================================
--- trunk/tests/xmltester/Makefile.am	2013-02-25 11:41:19 UTC (rev 3772)
+++ trunk/tests/xmltester/Makefile.am	2013-02-28 09:40:54 UTC (rev 3773)
@@ -33,6 +33,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/bug605.xml \

Added: trunk/tests/xmltester/tests/ticket/bug582.xml
===================================================================
--- trunk/tests/xmltester/tests/ticket/bug582.xml	                        (rev 0)
+++ trunk/tests/xmltester/tests/ticket/bug582.xml	2013-02-28 09:40:54 UTC (rev 3773)
@@ -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