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

svn_geos at osgeo.org svn_geos at osgeo.org
Thu Jun 24 05:01:54 EDT 2010


Author: strk
Date: 2010-06-24 09:01:54 +0000 (Thu, 24 Jun 2010)
New Revision: 3068

Modified:
   trunk/capi/geos_ts_c.cpp
   trunk/include/geos/io/WKBWriter.h
   trunk/src/io/WKBWriter.cpp
Log:
Make WKBWriter::setByteOrder check for argument and throw IllegalArgumentException when appropriate. Make sure C-API wrapper catches those.


Modified: trunk/capi/geos_ts_c.cpp
===================================================================
--- trunk/capi/geos_ts_c.cpp	2010-06-24 08:28:41 UTC (rev 3067)
+++ trunk/capi/geos_ts_c.cpp	2010-06-24 09:01:54 UTC (rev 3068)
@@ -4576,6 +4576,10 @@
         {
             writer->setByteOrder(newByteOrder);
         }
+        catch (const std::exception &e)
+        {
+            handle->ERROR_MESSAGE("%s", e.what());
+        }
         catch (...)
         {
             handle->ERROR_MESSAGE("Unknown exception thrown");

Modified: trunk/include/geos/io/WKBWriter.h
===================================================================
--- trunk/include/geos/io/WKBWriter.h	2010-06-24 08:28:41 UTC (rev 3067)
+++ trunk/include/geos/io/WKBWriter.h	2010-06-24 09:01:54 UTC (rev 3068)
@@ -102,9 +102,10 @@
 
 	/*
 	 * 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);
 	
@@ -119,7 +120,7 @@
 	 * Sets the byte order used by the
 	 * <code>WKBWriter</code>.
 	 */
-	virtual void setByteOrder(int newByteOrder) { byteOrder=newByteOrder; }
+	virtual void setByteOrder(int newByteOrder);
 
 	/*
 	 * \brief

Modified: trunk/src/io/WKBWriter.cpp
===================================================================
--- trunk/src/io/WKBWriter.cpp	2010-06-24 08:28:41 UTC (rev 3067)
+++ trunk/src/io/WKBWriter.cpp	2010-06-24 09:01:54 UTC (rev 3068)
@@ -206,7 +206,7 @@
 	{
 		buf[0] = WKBConstants::wkbNDR;
 	}
-	else
+	else 
 	{
 		buf[0] = WKBConstants::wkbXDR;
 	}
@@ -215,7 +215,24 @@
 	outStream->write(reinterpret_cast<char*>(buf), 1);
 }
 
+/* public */
 void
+WKBWriter::setByteOrder(int bo)
+{
+	if (bo != ByteOrderValues::ENDIAN_LITTLE &&
+	    bo != ByteOrderValues::ENDIAN_BIG )
+	{
+	    std::ostringstream os;
+		os << "WKB output dimension must be LITTLE ("
+		   << ByteOrderValues::ENDIAN_LITTLE
+		   << ") or BIG (" << ByteOrderValues::ENDIAN_BIG << ")";
+		throw util::IllegalArgumentException(os.str());
+	}
+
+	byteOrder = bo;
+}
+
+void
 WKBWriter::writeGeometryType(int typeId, int SRID) 
 {
 	int flag3D = (outputDimension == 3) ? 0x80000000 : 0;



More information about the geos-commits mailing list