[geos-commits] r3716 - in trunk: . src/triangulate/quadedge tests/unit/triangulate

svn_geos at osgeo.org svn_geos at osgeo.org
Mon Sep 10 03:34:14 PDT 2012


Author: strk
Date: 2012-09-10 03:34:13 -0700 (Mon, 10 Sep 2012)
New Revision: 3716

Modified:
   trunk/NEWS
   trunk/src/triangulate/quadedge/QuadEdgeSubdivision.cpp
   trunk/tests/unit/triangulate/DelaunayTest.cpp
Log:
Add Z support in delaunay triangulation (#570)

Thanks Benjamin Campbell

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2012-09-10 09:23:47 UTC (rev 3715)
+++ trunk/NEWS	2012-09-10 10:34:13 UTC (rev 3716)
@@ -2,7 +2,7 @@
 ????-??-??
 
 - New things:
-  - Delaunay Triangulation API (#487, #565)
+  - Delaunay Triangulation API (#487, #565, #570)
   - Interruptibility API (C and C++)
   - CAPI: GEOSNode (#496) - PHP: Geometry->node
   - GeometryPrecisionReducer class

Modified: trunk/src/triangulate/quadedge/QuadEdgeSubdivision.cpp
===================================================================
--- trunk/src/triangulate/quadedge/QuadEdgeSubdivision.cpp	2012-09-10 09:23:47 UTC (rev 3715)
+++ trunk/src/triangulate/quadedge/QuadEdgeSubdivision.cpp	2012-09-10 10:34:13 UTC (rev 3716)
@@ -24,6 +24,7 @@
 #include <geos/geom/LineString.h>
 #include <geos/geom/CoordinateSequence.h>
 #include <geos/geom/CoordinateArraySequence.h>
+#include <geos/geom/CoordinateSequenceFactory.h>
 #include <geos/geom/CoordinateArraySequenceFactory.h>
 #include <geos/geom/GeometryCollection.h>
 #include <geos/geom/GeometryFactory.h>
@@ -379,7 +380,7 @@
 
 	void visit(QuadEdge* triEdges[3])
 	{
-		geom::CoordinateSequence *coordSeq = coordSeqFact.create(4,2);
+		geom::CoordinateSequence *coordSeq = coordSeqFact.create(4,0);
 		for (int i = 0; i < 3; i++) {
 			Vertex v = triEdges[i]->orig();
 			coordSeq->setAt(v.getCoordinate(), i);
@@ -422,12 +423,12 @@
 {
 	std::auto_ptr<QuadEdgeList> quadEdges(getPrimaryEdges(false));
 	std::vector<Geometry *> edges(quadEdges->size());
-	CoordinateArraySequenceFactory coordSeqFact;
+	const CoordinateSequenceFactory *coordSeqFact = geomFact.getCoordinateSequenceFactory();
 	int i = 0;
 	for (QuadEdgeSubdivision::QuadEdgeList::iterator it = quadEdges->begin(); it != quadEdges->end(); ++it)
 	{
 		QuadEdge *qe = *it;
-		CoordinateSequence *coordSeq = coordSeqFact.create((std::vector<geom::Coordinate>*)NULL, 2);;
+		CoordinateSequence *coordSeq = coordSeqFact->create((std::vector<geom::Coordinate>*)NULL);;
 
 		coordSeq->add(qe->orig().getCoordinate());
 		coordSeq->add(qe->dest().getCoordinate());

Modified: trunk/tests/unit/triangulate/DelaunayTest.cpp
===================================================================
--- trunk/tests/unit/triangulate/DelaunayTest.cpp	2012-09-10 09:23:47 UTC (rev 3715)
+++ trunk/tests/unit/triangulate/DelaunayTest.cpp	2012-09-10 10:34:13 UTC (rev 3716)
@@ -13,7 +13,7 @@
 #include <geos/geom/GeometryCollection.h>
 #include <geos/geom/GeometryFactory.h>
 
-#include <stdio.h>
+//#include <stdio.h>
 
 using namespace geos::triangulate;
 using namespace geos::triangulate::quadedge;
@@ -59,6 +59,7 @@
 		expected->normalize();
 			
 		ensure(results->equalsExact(expected, 1e-7));
+		ensure(results->getCoordinateDimension() == expected->getCoordinateDimension());
 
 		delete sites;
 		delete expected;
@@ -90,7 +91,7 @@
 	template<>
 	void object::test<2>()
 	{
-		const char * wkt = "MULTIPOINT ((10 10 1), (10 20 2), (20 20 3))";
+		const char * wkt = "MULTIPOINT ((10 10), (10 20), (20 20))";
 		const char* expectedEdges = "MULTILINESTRING ((10 20, 20 20), (10 10, 10 20), (10 10, 20 20))";
 		const char * expectedTri = "GEOMETRYCOLLECTION (POLYGON ((10 20, 10 10, 20 20, 10 20)))";
 
@@ -145,5 +146,18 @@
 
 		runDelaunay(wkt, false, expectedEdges);
 	}
+	
+	// 7 - Test grid (2.5d)
+	template<>
+	template<>
+	void object::test<7>()
+	{
+		const char * wkt = "MULTIPOINT ((10 10 1), (10 20 2), (20 20 3), (20 10 1.5), (20 0 2.5), (10 0 3.5), (0 0 0), (0 10 .5), (0 20 .25))";
+		const char* expectedEdges = "MULTILINESTRING ((10 20 2, 20 20 3), (0 20 .25, 10 20 2), (0 10 .5, 0 20 .25), (0 0 0, 0 10 .5), (0 0 0, 10 0 3.5), (10 0 3.5, 20 0 2.5), (20 0 2.5, 20 10 1.5), (20 10 1.5, 20 20 3), (10 20 2, 20 10 1.5), (10 10 1, 20 10 1.6), (10 10 1, 10 20 2), (10 10 1, 0 20 .25), (10 10 1, 0 10 .5), (10 0 3.5, 10 10 1), (0 10 .5, 10 0 3.5), (10 10 1, 20 0 2.5))";
+		const char * expectedTri = "GEOMETRYCOLLECTION (POLYGON ((0 20 .25, 0 10 .5, 10 10 1, 0 20 .25)), POLYGON ((0 20 .25, 10 10 1, 10 20 2, 0 20 .25)), POLYGON ((10 20 2, 10 10 1, 20 10 1.5, 10 20 2)), POLYGON ((10 20 2, 20 10 1.5, 20 20 3, 10 20 2)), POLYGON ((10 0 3.5, 20 0 2.5, 10 10 1, 10 0 3.5)), POLYGON ((10 0 3.5, 10 10 1, 0 10 .5, 10 0 3.5)), POLYGON ((10 0 3.5, 0 10 .5, 0 0 0, 10 0 3.5)), POLYGON ((10 10 1, 20 0 2.5, 20 10 1.5, 10 10 1)))";
+
+		runDelaunay(wkt, false, expectedEdges);
+		runDelaunay(wkt, true, expectedTri);
+	}
 } // namespace tut
 



More information about the geos-commits mailing list