• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List

WKBWriter.h

00001 /**********************************************************************
00002  * $Id: WKBWriter.h 2579 2009-06-15 14:03:52Z strk $
00003  *
00004  * GEOS - Geometry Engine Open Source
00005  * http://geos.refractions.net
00006  *
00007  * Copyright (C) 2005-2006 Refractions Research Inc.
00008  * Copyright (C) 2001-2002 Vivid Solutions Inc.
00009  *
00010  * This is free software; you can redistribute and/or modify it under
00011  * the terms of the GNU Lesser General Public Licence as published
00012  * by the Free Software Foundation. 
00013  * See the COPYING file for more information.
00014  *
00015  **********************************************************************
00016  *
00017  * Last port: io/WKBWriter.java rev. 1.1 (JTS-1.7)
00018  *
00019  **********************************************************************/
00020 
00021 #ifndef GEOS_IO_WKBWRITER_H
00022 #define GEOS_IO_WKBWRITER_H
00023 
00024 #include <geos/export.h>
00025 
00026 #include <geos/platform.h> // for getMachineByteOrder
00027 #include <iosfwd>
00028 
00029 // Forward declarations
00030 namespace geos {
00031         namespace geom {
00032 
00033                 class CoordinateSequence;
00034                 class Geometry;
00035                 class GeometryCollection;
00036                 class Point;
00037                 class LineString;
00038                 class LinearRing;
00039                 class Polygon;
00040                 class MultiPoint;
00041                 class MultiLineString;
00042                 class MultiPolygon;
00043                 class PrecisionModel;
00044 
00045         } // namespace geom
00046 } // namespace geos
00047 
00048 namespace geos {
00049 namespace io {
00050 
00073 class GEOS_DLL WKBWriter {
00074 
00075 public:
00076         /*
00077          * \brief
00078          * Initializes writer with target coordinate dimention, endianness flag
00079      * and SRID value.
00080          * <code>WKBWriter</code>.
00081      */
00082         WKBWriter(int dims=2, int bo=getMachineByteOrder(), bool includeSRID=false);
00083 
00084     /*
00085      * \brief
00086      * Destructor.
00087      */
00088     virtual ~WKBWriter();
00089 
00090         /*
00091          * \brief
00092          * Returns the output dimension used by the
00093          * <code>WKBWriter</code>.
00094          */
00095         virtual int getOutputDimension() const { return outputDimension; }
00096 
00097         /*
00098          * Sets the output dimension used by the
00099          * <code>WKBWriter</code>.
00100          */
00101         virtual void setOutputDimension(int newOutputDimension) { outputDimension=newOutputDimension; }
00102         
00103         /*
00104          * \brief
00105          * Returns the byte order used by the
00106          * <code>WKBWriter</code>.
00107          */
00108         virtual int getByteOrder() const { return byteOrder; }
00109 
00110         /*
00111          * Sets the byte order used by the
00112          * <code>WKBWriter</code>.
00113          */
00114         virtual void setByteOrder(int newByteOrder) { byteOrder=newByteOrder; }
00115 
00116         /*
00117          * \brief
00118          * Returns whether SRID values are output by the
00119          * <code>WKBWriter</code>.
00120          */
00121         virtual int getIncludeSRID() const { return includeSRID; }
00122 
00123         /*
00124          * Sets whether SRID values should be output by the
00125          * <code>WKBWriter</code>.
00126          */
00127     virtual void setIncludeSRID(int newIncludeSRID) { includeSRID = (0 == newIncludeSRID ? false : true); }
00128 
00136         void write(const geom::Geometry &g, std::ostream &os);
00137                 // throws IOException, ParseException
00138 
00146         void writeHEX(const geom::Geometry &g, std::ostream &os);
00147                 // throws IOException, ParseException
00148 
00149 private:
00150 
00151         int outputDimension;
00152 
00153         int byteOrder;
00154         
00155         bool includeSRID;
00156 
00157         std::ostream *outStream;
00158 
00159         unsigned char buf[8];
00160 
00161         void writePoint(const geom::Point &p);
00162                 // throws IOException
00163 
00164         void writeLineString(const geom::LineString &ls);
00165                 // throws IOException
00166 
00167         void writePolygon(const geom::Polygon &p);
00168                 // throws IOException
00169 
00170         void writeGeometryCollection(const geom::GeometryCollection &c, int wkbtype);
00171                 // throws IOException, ParseException
00172 
00173         void writeCoordinateSequence(const geom::CoordinateSequence &cs, bool sized);
00174                 // throws IOException
00175 
00176         void writeCoordinate(const geom::CoordinateSequence &cs, int idx, bool is3d);
00177                 // throws IOException
00178 
00179         void writeGeometryType(int geometryType, int SRID);
00180                 // throws IOException
00181 
00182         void writeSRID(int SRID);
00183                 // throws IOException
00184 
00185         void writeByteOrder();
00186                 // throws IOException
00187 
00188         void writeInt(int intValue);
00189                 // throws IOException
00190 
00191 };
00192 
00193 } // namespace io
00194 } // namespace geos
00195 
00196 #endif // #ifndef GEOS_IO_WKBWRITER_H
00197 
00198 /**********************************************************************
00199  * $Log$
00200  * Revision 1.2  2006/03/28 11:26:13  strk
00201  * ByteOrderDataInStream inlines moved to .inl file, updated
00202  * implementation files includes.
00203  *
00204  * Revision 1.1  2006/03/20 18:18:14  strk
00205  * io.h header split
00206  *
00207  **********************************************************************/

Generated on Thu Jul 22 2010 for GEOS by  doxygen 1.7.1