[geos-commits] r3065 - in trunk: include/geos/io src/io

svn_geos at osgeo.org svn_geos at osgeo.org
Thu Jun 24 04:27:16 EDT 2010


Author: strk
Date: 2010-06-24 08:27:16 +0000 (Thu, 24 Jun 2010)
New Revision: 3065

Modified:
   trunk/include/geos/io/WKBWriter.h
   trunk/include/geos/io/WKTWriter.h
   trunk/src/io/WKBWriter.cpp
   trunk/src/io/WKTWriter.cpp
Log:
Make WKTWriter::setOutputDimensions check parameter validity (must be 2 or 3) to be consistent with WKBWriter already doing so in constructor; make WKBWriter::setOutputDimensions perform the check as well (like the constructor); Drop virtual methods from WKTWriter class, which wasn't meant to be a virtual class (no virtual dtor anyway)


Modified: trunk/include/geos/io/WKBWriter.h
===================================================================
--- trunk/include/geos/io/WKBWriter.h	2010-06-23 09:48:03 UTC (rev 3064)
+++ trunk/include/geos/io/WKBWriter.h	2010-06-24 08:27:16 UTC (rev 3065)
@@ -106,7 +106,7 @@
      * @param newOutputDimension Supported values are 2 or 3.  Note that 3 indicates
      * up to 3 dimensions will be written but 2D WKB is still produced for 2D geometries.
 	 */
-	virtual void setOutputDimension(int newOutputDimension) { defaultOutputDimension=newOutputDimension; }
+	virtual void setOutputDimension(int newOutputDimension);
 	
 	/*
 	 * \brief

Modified: trunk/include/geos/io/WKTWriter.h
===================================================================
--- trunk/include/geos/io/WKTWriter.h	2010-06-23 09:48:03 UTC (rev 3064)
+++ trunk/include/geos/io/WKTWriter.h	2010-06-24 08:27:16 UTC (rev 3065)
@@ -141,11 +141,12 @@
 
 	/**
 	 * Enable old style 3D/4D WKT generation.
-     *
-     * By default the WKBWriter produces new style 3D/4D WKT (ie. "POINT Z (10 20 30)")
-     * but if this method is used to turn on old style WKT production then the WKT will
-     * be formatted in the style "POINT (10 20 30)".
 	 *
+	 * By default the WKBWriter produces new style 3D/4D WKT
+	 * (ie. "POINT Z (10 20 30)") but if this method is used
+	 * to turn on old style WKT production then the WKT will
+	 * be formatted in the style "POINT (10 20 30)".
+	 *
 	 * @param useOld3D true or false
 	 */
 	void setOld3D(bool useOld3D ) { old3D = useOld3D; }
@@ -155,15 +156,16 @@
 	 * Returns the output dimension used by the
 	 * <code>WKBWriter</code>.
 	 */
-	virtual int getOutputDimension() const { return defaultOutputDimension; }
+	int getOutputDimension() const { return defaultOutputDimension; }
 
 	/*
 	 * Sets the output dimension used by the <code>WKBWriter</code>.  
-     *
-     * @param newOutputDimension Supported values are 2 or 3.  Note that 3 indicates
-     * up to 3 dimensions will be written but 2D WKB is still produced for 2D geometries.
+	 *
+	 * @param newOutputDimension Supported values are 2 or 3. 
+	 *        Note that 3 indicates up to 3 dimensions will be
+	 *        written but 2D WKB is still produced for 2D geometries.
 	 */
-	virtual void setOutputDimension(int newOutputDimension) { defaultOutputDimension=newOutputDimension; }
+	void setOutputDimension(int newOutputDimension);
 	
 protected:
 

Modified: trunk/src/io/WKBWriter.cpp
===================================================================
--- trunk/src/io/WKBWriter.cpp	2010-06-23 09:48:03 UTC (rev 3064)
+++ trunk/src/io/WKBWriter.cpp	2010-06-24 08:27:16 UTC (rev 3065)
@@ -53,6 +53,16 @@
     outputDimension = defaultOutputDimension;
 }
 
+/* public */
+void
+WKBWriter::setOutputDimension(int dims)
+{
+	if ( dims < 2 || dims > 3 )
+		throw util::IllegalArgumentException("WKB output dimension must be 2 or 3");
+
+    defaultOutputDimension = dims;
+}
+
 WKBWriter::~WKBWriter()
 {
 }

Modified: trunk/src/io/WKTWriter.cpp
===================================================================
--- trunk/src/io/WKTWriter.cpp	2010-06-23 09:48:03 UTC (rev 3064)
+++ trunk/src/io/WKTWriter.cpp	2010-06-24 08:27:16 UTC (rev 3065)
@@ -31,6 +31,7 @@
 #include <geos/geom/MultiPolygon.h>
 #include <geos/geom/CoordinateSequence.h>
 #include <geos/geom/PrecisionModel.h>
+#include <geos/util/IllegalArgumentException.h>
 
 #include <typeinfo>
 #include <cstdio> // should avoid this
@@ -45,16 +46,26 @@
 namespace geos {
 namespace io { // geos.io
 
-WKTWriter::WKTWriter() {
-	isFormatted=false;
-	roundingPrecision=-1;
-	trim = false;
-	level=0;
-	formatter="%f";
-    defaultOutputDimension = 2;
-    old3D = false;
+WKTWriter::WKTWriter():
+	formatter("%f"),
+	isFormatted(false),
+	roundingPrecision(-1),
+	trim(false),
+	level(0),
+	defaultOutputDimension(2),
+	old3D(false)
+{
 }
 
+/* public */
+void
+WKTWriter::setOutputDimension(int dims)
+{
+	if ( dims < 2 || dims > 3 )
+		throw util::IllegalArgumentException("WKT output dimension must be 2 or 3");
+	defaultOutputDimension = dims;
+}
+
 WKTWriter::~WKTWriter() {}
 
 /*static*/



More information about the geos-commits mailing list