[geos-commits] r2489 - in trunk: source/geomgraph tests/bigtest

svn_geos at osgeo.org svn_geos at osgeo.org
Thu May 7 11:57:28 EDT 2009


Author: strk
Date: 2009-05-07 11:57:28 -0400 (Thu, 07 May 2009)
New Revision: 2489

Added:
   trunk/tests/bigtest/README
   trunk/tests/bigtest/bug234.cpp
Modified:
   trunk/source/geomgraph/GeometryGraph.cpp
   trunk/tests/bigtest/Makefile.am
Log:
Skip empty components when building GeometryGraph. Fixes bug #234. Add non-automated test for it, and README file in the directory containing it...


Modified: trunk/source/geomgraph/GeometryGraph.cpp
===================================================================
--- trunk/source/geomgraph/GeometryGraph.cpp	2009-05-07 15:36:51 UTC (rev 2488)
+++ trunk/source/geomgraph/GeometryGraph.cpp	2009-05-07 15:57:28 UTC (rev 2489)
@@ -227,8 +227,11 @@
 GeometryGraph::addPolygonRing(const LinearRing *lr, int cwLeft, int cwRight)
 	// throw IllegalArgumentException (see below)
 {
-	const CoordinateSequence *lrcl;
-	lrcl = lr->getCoordinatesRO();
+	// skip empty component (see bug #234)
+	if ( lr->isEmpty() ) return;
+
+	const CoordinateSequence *lrcl = lr->getCoordinatesRO();
+
 	CoordinateSequence* coord=CoordinateSequence::removeRepeatedPoints(lrcl);
 	if (coord->getSize()<4) {
 		hasTooFewPointsVar=true;

Modified: trunk/tests/bigtest/Makefile.am
===================================================================
--- trunk/tests/bigtest/Makefile.am	2009-05-07 15:36:51 UTC (rev 2488)
+++ trunk/tests/bigtest/Makefile.am	2009-05-07 15:57:28 UTC (rev 2489)
@@ -2,7 +2,8 @@
 top_srcdir=@top_srcdir@
 top_builddir=@top_builddir@
 
-noinst_PROGRAMS = TestSweepLineSpeed
+check_PROGRAMS = bug234
+check_PROGRAMS += TestSweepLineSpeed
 
 LIBS = $(top_builddir)/source/libgeos.la
 # -lmpatrol -lbfd -lintl -liberty -limagehlp
@@ -10,6 +11,9 @@
 TestSweepLineSpeed_SOURCES = TestSweepLineSpeed.cpp GeometryTestFactory.cpp bigtest.h
 TestSweepLineSpeed_LDADD = $(LIBS)
 
+bug234_SOURCES = bug234.cpp
+bug234_LDADD = $(LIBS)
+
 INCLUDES = -I$(top_srcdir)/source/headers
 INCLUDES += -I$(top_srcdir)/source/io/markup
 

Added: trunk/tests/bigtest/README
===================================================================
--- trunk/tests/bigtest/README	                        (rev 0)
+++ trunk/tests/bigtest/README	2009-05-07 15:57:28 UTC (rev 2489)
@@ -0,0 +1,5 @@
+This directory is a mess, should be renamed to reflect that :)
+
+Now seriously, there's no automated test in this directory, but
+random tests intended for manual runs. They get built by 'make check'
+but not executed.

Added: trunk/tests/bigtest/bug234.cpp
===================================================================
--- trunk/tests/bigtest/bug234.cpp	                        (rev 0)
+++ trunk/tests/bigtest/bug234.cpp	2009-05-07 15:57:28 UTC (rev 2489)
@@ -0,0 +1,49 @@
+#include <vector>
+
+#include "geos/geom/GeometryFactory.h"
+#include "geos/geom/Geometry.h"
+#include "geos/geom/Coordinate.h"
+#include "geos/geom/CoordinateArraySequence.h"
+#include "geos/geom/LinearRing.h"
+#include "geos/geom/Polygon.h"
+#include "geos/geom/MultiPolygon.h"
+
+using namespace geos::geom;
+using namespace std;
+
+int main() {
+ GeometryFactory factory;
+
+ vector< Geometry * > *polys1 = new vector<Geometry*>();
+ vector< Geometry * > *polys2 = new vector<Geometry*>();
+ vector< Geometry * > *holes1 = new vector<Geometry*>();
+
+ CoordinateArraySequence coords1;
+ coords1.add(Coordinate(1, 1));
+ coords1.add(Coordinate(1, 5));
+ coords1.add(Coordinate(5, 5));
+ coords1.add(Coordinate(5, 1));
+ coords1.add(Coordinate(1, 1));
+ holes1->push_back( factory.createLinearRing() );
+ polys1->push_back( factory.createPolygon(factory.createLinearRing(coords1), holes1) );
+
+ CoordinateArraySequence coords2;
+ coords2.add(Coordinate(3, 3));
+ coords2.add(Coordinate(3, 4));
+ coords2.add(Coordinate(4, 4));
+ coords2.add(Coordinate(4, 3));
+ coords2.add(Coordinate(3, 3));
+ polys2->push_back( factory.createPolygon(factory.createLinearRing(coords2), new vector<Geometry*>) );
+
+ MultiPolygon *mpoly1 = factory.createMultiPolygon(polys1);
+ MultiPolygon *mpoly2 = factory.createMultiPolygon(polys2);
+
+ cout << mpoly1->toString() << endl;
+ cout << mpoly2->toString() << endl;
+ Geometry *intersection = mpoly1->intersection(mpoly2);
+ cout << intersection->toString() << endl;
+
+ delete mpoly1;
+ delete mpoly2;
+ delete intersection;
+} 



More information about the geos-commits mailing list