00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef GEOS_IO_WKBWRITER_H
00021 #define GEOS_IO_WKBWRITER_H
00022
00023 #include <geos/export.h>
00024
00025 #include <geos/util/Machine.h>
00026 #include <iosfwd>
00027
00028
00029 namespace geos {
00030 namespace geom {
00031
00032 class CoordinateSequence;
00033 class Geometry;
00034 class GeometryCollection;
00035 class Point;
00036 class LineString;
00037 class LinearRing;
00038 class Polygon;
00039 class MultiPoint;
00040 class MultiLineString;
00041 class MultiPolygon;
00042 class PrecisionModel;
00043
00044 }
00045 }
00046
00047 namespace geos {
00048 namespace io {
00049
00072 class GEOS_DLL WKBWriter {
00073
00074 public:
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087 WKBWriter(int dims=2, int bo=getMachineByteOrder(), bool includeSRID=false);
00088
00089
00090
00091
00092
00093 virtual ~WKBWriter();
00094
00095
00096
00097
00098
00099
00100 virtual int getOutputDimension() const { return defaultOutputDimension; }
00101
00102
00103
00104
00105
00106
00107
00108
00109 virtual void setOutputDimension(int newOutputDimension);
00110
00111
00112
00113
00114
00115
00116 virtual int getByteOrder() const { return byteOrder; }
00117
00118
00119
00120
00121
00122 virtual void setByteOrder(int newByteOrder);
00123
00124
00125
00126
00127
00128
00129 virtual int getIncludeSRID() const { return includeSRID; }
00130
00131
00132
00133
00134
00135 virtual void setIncludeSRID(int newIncludeSRID) { includeSRID = (0 == newIncludeSRID ? false : true); }
00136
00144 void write(const geom::Geometry &g, std::ostream &os);
00145
00146
00154 void writeHEX(const geom::Geometry &g, std::ostream &os);
00155
00156
00157 private:
00158
00159 int defaultOutputDimension;
00160 int outputDimension;
00161
00162 int byteOrder;
00163
00164 bool includeSRID;
00165
00166 std::ostream *outStream;
00167
00168 unsigned char buf[8];
00169
00170 void writePoint(const geom::Point &p);
00171
00172
00173 void writeLineString(const geom::LineString &ls);
00174
00175
00176 void writePolygon(const geom::Polygon &p);
00177
00178
00179 void writeGeometryCollection(const geom::GeometryCollection &c, int wkbtype);
00180
00181
00182 void writeCoordinateSequence(const geom::CoordinateSequence &cs, bool sized);
00183
00184
00185 void writeCoordinate(const geom::CoordinateSequence &cs, int idx, bool is3d);
00186
00187
00188 void writeGeometryType(int geometryType, int SRID);
00189
00190
00191 void writeSRID(int SRID);
00192
00193
00194 void writeByteOrder();
00195
00196
00197 void writeInt(int intValue);
00198
00199
00200 };
00201
00202 }
00203 }
00204
00205 #endif // #ifndef GEOS_IO_WKBWRITER_H