[geos-commits] r3604 - trunk/src/geom

svn_geos at osgeo.org svn_geos at osgeo.org
Fri Apr 6 15:04:01 EDT 2012


Author: strk
Date: 2012-04-06 12:04:01 -0700 (Fri, 06 Apr 2012)
New Revision: 3604

Modified:
   trunk/src/geom/GeometryFactory.cpp
Log:
Deep copy Geometry with GeometryFactory.createGeometry()

Uses the CoordinateSequenceFactory of the factory

Modified: trunk/src/geom/GeometryFactory.cpp
===================================================================
--- trunk/src/geom/GeometryFactory.cpp	2012-04-06 19:03:02 UTC (rev 3603)
+++ trunk/src/geom/GeometryFactory.cpp	2012-04-06 19:04:01 UTC (rev 3604)
@@ -32,6 +32,8 @@
 #include <geos/geom/GeometryCollection.h>
 #include <geos/geom/PrecisionModel.h>
 #include <geos/geom/Envelope.h>
+#include <geos/geom/util/CoordinateOperation.h>
+#include <geos/geom/util/GeometryEditor.h>
 #include <geos/util/IllegalArgumentException.h>
 
 #include <cassert>
@@ -56,17 +58,26 @@
 namespace geos {
 namespace geom { // geos::geom
 
-//namespace { 
-//	class gfCoordinateOperation: public CoordinateOperation {
-//	using CoordinateOperation::edit;
-//	public:
-//		virtual CoordinateSequence* edit(const CoordinateSequence *coordinates,
-//				const Geometry *geometry);
-//	};
-//}
+namespace { 
 
+class gfCoordinateOperation: public util::CoordinateOperation {
+using CoordinateOperation::edit;
+  const CoordinateSequenceFactory* _gsf;
+public:
+  gfCoordinateOperation(const CoordinateSequenceFactory* gsf)
+      : _gsf(gsf)
+  {}
+  CoordinateSequence* edit( const CoordinateSequence *coordSeq,
+                            const Geometry * )
+  {
+    return _gsf->create(*coordSeq);
+  }
+};
 
+} // anonymous namespace
 
+
+
 /*public*/
 GeometryFactory::GeometryFactory()
 	:
@@ -696,13 +707,11 @@
 GeometryFactory::createGeometry(const Geometry *g) const
 {
 	// could this be cached to make this more efficient? Or maybe it isn't enough overhead to bother
-	return g->clone();
-	//GeometryEditor *editor=new GeometryEditor(this);
-	//gfCoordinateOperation *coordOp = new gfCoordinateOperation();
-	//Geometry *ret=editor->edit(g, coordOp);
-	//delete coordOp;
-	//delete editor;
-	//return ret;
+	//return g->clone();
+	util::GeometryEditor editor(this);
+	gfCoordinateOperation coordOp(coordinateListFactory);
+	Geometry *ret = editor.edit(g, &coordOp);
+	return ret;
 }
 
 /*public*/



More information about the geos-commits mailing list