- Main Page
- Namespaces
- Classes
- Files
- Related Pages

# WKBWriter.h

    00001 /**********************************************************************
    00002  * $Id: WKBWriter.h 2032 2007-11-23 02:33:41Z mloskot $
    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 #ifndef GEOS_IO_WKBWRITER_H
    00018 #define GEOS_IO_WKBWRITER_H
    00019
    00020 #include <geos/platform.h> // for getMachineByteOrder
    00021 #include <iosfwd>
    00022
    00023 // Forward declarations
    00024 namespace geos {
    00025         namespace geom {
    00026
    00027                 class CoordinateSequence;
    00028                 class Geometry;
    00029                 class GeometryCollection;
    00030                 class Point;
    00031                 class LineString;
    00032                 class LinearRing;
    00033                 class Polygon;
    00034                 class MultiPoint;
    00035                 class MultiLineString;
    00036                 class MultiPolygon;
    00037                 class PrecisionModel;
    00038
    00039         } // namespace geom
    00040 } // namespace geos
    00041
    00042 namespace geos {
    00043 namespace io {
    00044
    00067 class WKBWriter {
    00068
    00069 public:
    00070
    00071         WKBWriter(int dims=2, int bo=getMachineByteOrder(), bool includeSRID=false);
    00072
    00073         /*
    00074          * \brief
    00075          * Returns the output dimension used by the
    00076          * <code>WKBWriter</code>.
    00077          */
    00078         virtual int getOutputDimension() const { return outputDimension; }
    00079
    00080         /*
    00081          * Sets the output dimension used by the
    00082          * <code>WKBWriter</code>.
    00083          */
    00084         virtual void setOutputDimension(int newOutputDimension) { outputDimension=newOutputDimension; }
    00085
    00086         /*
    00087          * \brief
    00088          * Returns the byte order used by the
    00089          * <code>WKBWriter</code>.
    00090          */
    00091         virtual int getByteOrder() const { return byteOrder; }
    00092
    00093         /*
    00094          * Sets the byte order used by the
    00095          * <code>WKBWriter</code>.
    00096          */
    00097         virtual void setByteOrder(int newByteOrder) { byteOrder=newByteOrder; }
    00098
    00099         /*
    00100          * \brief
    00101          * Returns whether SRID values are output by the
    00102          * <code>WKBWriter</code>.
    00103          */
    00104         virtual int getIncludeSRID() const { return includeSRID; }
    00105
    00106         /*
    00107          * Sets whether SRID values should be output by the
    00108          * <code>WKBWriter</code>.
    00109          */
    00110         virtual void setIncludeSRID(int newIncludeSRID) { includeSRID=static_cast<bool>(newIncludeSRID); }
    00111
    00119         void write(const geom::Geometry &g, std::ostream &os);
    00120                 // throws IOException, ParseException
    00121
    00129         void writeHEX(const geom::Geometry &g, std::ostream &os);
    00130                 // throws IOException, ParseException
    00131
    00132 private:
    00133
    00134         int outputDimension;
    00135
    00136         int byteOrder;
    00137
    00138         bool includeSRID;
    00139
    00140         std::ostream *outStream;
    00141
    00142         unsigned char buf[8];
    00143
    00144         void writePoint(const geom::Point &p);
    00145                 // throws IOException
    00146
    00147         void writeLineString(const geom::LineString &ls);
    00148                 // throws IOException
    00149
    00150         void writePolygon(const geom::Polygon &p);
    00151                 // throws IOException
    00152
    00153         void writeGeometryCollection(const geom::GeometryCollection &c, int wkbtype);
    00154                 // throws IOException, ParseException
    00155
    00156         void writeCoordinateSequence(const geom::CoordinateSequence &cs, bool sized);
    00157                 // throws IOException
    00158
    00159         void writeCoordinate(const geom::CoordinateSequence &cs, int idx, bool is3d);
    00160                 // throws IOException
    00161
    00162         void writeGeometryType(int geometryType, int SRID);
    00163                 // throws IOException
    00164
    00165         void writeSRID(int SRID);
    00166                 // throws IOException
    00167
    00168         void writeByteOrder();
    00169                 // throws IOException
    00170
    00171         void writeInt(int intValue);
    00172                 // throws IOException
    00173
    00174 };
    00175
    00176 } // namespace io
    00177 } // namespace geos
    00178
    00179 #endif // #ifndef GEOS_IO_WKBWRITER_H
    00180
    00181 /**********************************************************************
    00182  * $Log$
    00183  * Revision 1.2  2006/03/28 11:26:13  strk
    00184  * ByteOrderDataInStream inlines moved to .inl file, updated
    00185  * implementation files includes.
    00186  *
    00187  * Revision 1.1  2006/03/20 18:18:14  strk
    00188  * io.h header split
    00189  *
    00190  **********************************************************************/