[geos-commits] r3173 - in trunk: include/geos/geom src/geom

svn_geos at osgeo.org svn_geos at osgeo.org
Wed Feb 2 14:23:52 EST 2011


Author: strk
Date: 2011-02-02 11:23:52 -0800 (Wed, 02 Feb 2011)
New Revision: 3173

Modified:
   trunk/include/geos/geom/GeometryFactory.h
   trunk/src/geom/GeometryFactory.cpp
Log:
Add interface to create MultiPoint from Coordinate vector

Modified: trunk/include/geos/geom/GeometryFactory.h
===================================================================
--- trunk/include/geos/geom/GeometryFactory.h	2011-02-02 17:57:11 UTC (rev 3172)
+++ trunk/include/geos/geom/GeometryFactory.h	2011-02-02 19:23:52 UTC (rev 3173)
@@ -4,6 +4,7 @@
  * GEOS - Geometry Engine Open Source
  * http://geos.refractions.net
  *
+ * Copyright (C) 2011 Sandro Santilli <strk at keybit.net>
  * Copyright (C) 2006 Refractions Research Inc.
  *
  * This is free software; you can redistribute and/or modify it under
@@ -13,7 +14,7 @@
  *
  **********************************************************************
  *
- * Last port: geom/GeometryFactory.java rev. 1.48
+ * Last port: geom/GeometryFactory.java r320 (JTS-1.12)
  *
  **********************************************************************/
 
@@ -224,6 +225,12 @@
 	MultiPoint* createMultiPoint(
 			const CoordinateSequence &fromCoords) const;
 
+	/// \brief
+	/// Construct a MultiPoint containing a Point geometry
+	/// for each Coordinate in the given vector.
+	MultiPoint* createMultiPoint(
+			const std::vector<Coordinate> &fromCoords) const;
+
 	/// Construct an EMPTY Polygon 
 	Polygon* createPolygon() const;
 

Modified: trunk/src/geom/GeometryFactory.cpp
===================================================================
--- trunk/src/geom/GeometryFactory.cpp	2011-02-02 17:57:11 UTC (rev 3172)
+++ trunk/src/geom/GeometryFactory.cpp	2011-02-02 19:23:52 UTC (rev 3173)
@@ -4,6 +4,7 @@
  * GEOS - Geometry Engine Open Source
  * http://geos.refractions.net
  *
+ * Copyright (C) 2011 Sandro Santilli <strk at keybit.net>
  * Copyright (C) 2001-2002 Vivid Solutions Inc.
  * Copyright (C) 2005 Refractions Research Inc.
  *
@@ -14,7 +15,7 @@
  *
  **********************************************************************
  *
- * Last port: geom/GeometryFactory.java rev. 1.48
+ * Last port: geom/GeometryFactory.java r320 (JTS-1.12)
  *
  **********************************************************************/
 
@@ -478,6 +479,28 @@
 }
 
 /*public*/
+MultiPoint*
+GeometryFactory::createMultiPoint(const std::vector<Coordinate> &fromCoords) const
+{
+	size_t npts=fromCoords.getSize();
+	vector<Geometry *> *pts=new vector<Geometry *>;
+	pts->reserve(npts);
+	for (size_t i=0; i<npts; ++i) {
+		Point *pt=createPoint(fromCoords.getAt(i));
+		pts->push_back(pt);
+	}
+	MultiPoint *mp = NULL;
+	try {
+		mp = createMultiPoint(pts);
+	} catch (...) {
+		for (size_t i=0; i<npts; ++i) delete (*pts)[i];
+		delete pts;
+		throw;
+	}
+	return mp;
+}
+
+/*public*/
 Polygon*
 GeometryFactory::createPolygon() const
 {



More information about the geos-commits mailing list