00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef GEOS_IO_WKBWRITER_H
00018 #define GEOS_IO_WKBWRITER_H
00019
00020 #include <geos/platform.h>
00021 #include <iosfwd>
00022
00023
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 }
00040 }
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
00075
00076
00077
00078 virtual int getOutputDimension() const { return outputDimension; }
00079
00080
00081
00082
00083
00084 virtual void setOutputDimension(int newOutputDimension) { outputDimension=newOutputDimension; }
00085
00086
00087
00088
00089
00090
00091 virtual int getByteOrder() const { return byteOrder; }
00092
00093
00094
00095
00096
00097 virtual void setByteOrder(int newByteOrder) { byteOrder=newByteOrder; }
00098
00099
00100
00101
00102
00103
00104 virtual int getIncludeSRID() const { return includeSRID; }
00105
00106
00107
00108
00109
00110 virtual void setIncludeSRID(int newIncludeSRID) { includeSRID=static_cast<bool>(newIncludeSRID); }
00111
00119 void write(const geom::Geometry &g, std::ostream &os);
00120
00121
00129 void writeHEX(const geom::Geometry &g, std::ostream &os);
00130
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
00146
00147 void writeLineString(const geom::LineString &ls);
00148
00149
00150 void writePolygon(const geom::Polygon &p);
00151
00152
00153 void writeGeometryCollection(const geom::GeometryCollection &c, int wkbtype);
00154
00155
00156 void writeCoordinateSequence(const geom::CoordinateSequence &cs, bool sized);
00157
00158
00159 void writeCoordinate(const geom::CoordinateSequence &cs, int idx, bool is3d);
00160
00161
00162 void writeGeometryType(int geometryType, int SRID);
00163
00164
00165 void writeSRID(int SRID);
00166
00167
00168 void writeByteOrder();
00169
00170
00171 void writeInt(int intValue);
00172
00173
00174 };
00175
00176 }
00177 }
00178
00179 #endif // #ifndef GEOS_IO_WKBWRITER_H
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190