[geos-commits] r3862 - in trunk: include/geos/triangulate src/triangulate tests/unit/triangulate

svn_geos at osgeo.org svn_geos at osgeo.org
Sun Aug 4 04:58:32 PDT 2013


Author: strk
Date: 2013-08-04 04:58:32 -0700 (Sun, 04 Aug 2013)
New Revision: 3862

Modified:
   trunk/include/geos/triangulate/DelaunayTriangulationBuilder.h
   trunk/src/triangulate/DelaunayTriangulationBuilder.cpp
   trunk/tests/unit/triangulate/DelaunayTest.cpp
Log:
envelope() method added to DelaunayTriangulationBuilder class

Includes testcase. Patch by Vishal Tiwari

Modified: trunk/include/geos/triangulate/DelaunayTriangulationBuilder.h
===================================================================
--- trunk/include/geos/triangulate/DelaunayTriangulationBuilder.h	2013-08-03 15:37:46 UTC (rev 3861)
+++ trunk/include/geos/triangulate/DelaunayTriangulationBuilder.h	2013-08-04 11:58:32 UTC (rev 3862)
@@ -29,6 +29,7 @@
 	  class MultiLineString;
 	  class GeometryCollection;
 	  class GeometryFactory;
+	  class Envelope;
   }
   namespace triangulate { 
     namespace quadedge { 
@@ -139,6 +140,15 @@
 	 */
 	std::auto_ptr<geom::GeometryCollection> getTriangles(const geom::GeometryFactory& geomFact);
 
+	/** 
+	 * Computes the {@link Envelope} of a collection of {@link Coordinate}s.
+	 * 
+	 * @param coords a List of Coordinates
+	 * @return the envelope of the set of coordinates
+	 */
+
+	static geom::Envelope envelope(const geom::CoordinateSequence& coords);
+
 };
 
 } //namespace geos.triangulate

Modified: trunk/src/triangulate/DelaunayTriangulationBuilder.cpp
===================================================================
--- trunk/src/triangulate/DelaunayTriangulationBuilder.cpp	2013-08-03 15:37:46 UTC (rev 3861)
+++ trunk/src/triangulate/DelaunayTriangulationBuilder.cpp	2013-08-04 11:58:32 UTC (rev 3862)
@@ -134,6 +134,20 @@
 	return subdiv->getTriangles(geomFact);
 }
 
+geom::Envelope DelaunayTriangulationBuilder::envelope(const geom::CoordinateSequence& coords)
+{
+	Envelope env;
+	std::vector<Coordinate> coord_vector;
+	coords.toVector(coord_vector);
+	for(std::vector<Coordinate>::iterator it= coord_vector.begin() ; it!=coord_vector.end() ; ++it)
+	{   
+		Coordinate coord = *it;
+		env.expandToInclude(coord);
+	}   
+	return env;
+}
+
+
 } //namespace geos.triangulate
 } //namespace goes
 

Modified: trunk/tests/unit/triangulate/DelaunayTest.cpp
===================================================================
--- trunk/tests/unit/triangulate/DelaunayTest.cpp	2013-08-03 15:37:46 UTC (rev 3861)
+++ trunk/tests/unit/triangulate/DelaunayTest.cpp	2013-08-04 11:58:32 UTC (rev 3862)
@@ -13,7 +13,7 @@
 #include <geos/io/WKTReader.h>
 #include <geos/geom/GeometryCollection.h>
 #include <geos/geom/GeometryFactory.h>
-
+#include <geos/geom/CoordinateArraySequence.h>
 //#include <stdio.h>
 
 using namespace geos::triangulate;
@@ -172,5 +172,31 @@
 
 		runDelaunay(wkt, false, expectedEdges, 0.001);
 	}
+	// 9 - Test for DelaunayTriangulationBuilder::envelope
+	template<>
+	template<>
+	void object::test<9>()
+	{   
+		WKTReader reader;
+		Geometry* sites = reader.read("MULTIPOINT ((150 200), (180 270), (275 163))");
+		Coordinate a(150,200);
+		Coordinate b(180,270);
+		Coordinate c(275,163);
+		std::vector<Coordinate>* v = new std::vector<Coordinate>();
+		v->push_back(a);
+		v->push_back(b);
+		v->push_back(c);
+
+		geos::geom::CoordinateArraySequence *seq = new CoordinateArraySequence(v);
+
+		DelaunayTriangulationBuilder builder;
+		builder.setSites(*seq);
+		Envelope env = builder.envelope(*seq);
+
+		ensure_equals(env.getWidth() , 125);
+		ensure_equals(env.getHeight() , 107);
+
+	}
+
 } // namespace tut
 



More information about the geos-commits mailing list