00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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>
00027 #include <iosfwd>
00028
00029
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 }
00046 }
00047
00048 namespace geos {
00049 namespace io {
00050
00073 class GEOS_DLL WKBWriter {
00074
00075 public:
00076
00077
00078
00079
00080
00081
00082 WKBWriter(int dims=2, int bo=getMachineByteOrder(), bool includeSRID=false);
00083
00084
00085
00086
00087
00088 virtual ~WKBWriter();
00089
00090
00091
00092
00093
00094
00095 virtual int getOutputDimension() const { return outputDimension; }
00096
00097
00098
00099
00100
00101 virtual void setOutputDimension(int newOutputDimension) { outputDimension=newOutputDimension; }
00102
00103
00104
00105
00106
00107
00108 virtual int getByteOrder() const { return byteOrder; }
00109
00110
00111
00112
00113
00114 virtual void setByteOrder(int newByteOrder) { byteOrder=newByteOrder; }
00115
00116
00117
00118
00119
00120
00121 virtual int getIncludeSRID() const { return includeSRID; }
00122
00123
00124
00125
00126
00127 virtual void setIncludeSRID(int newIncludeSRID) { includeSRID = (0 == newIncludeSRID ? false : true); }
00128
00136 void write(const geom::Geometry &g, std::ostream &os);
00137
00138
00146 void writeHEX(const geom::Geometry &g, std::ostream &os);
00147
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
00163
00164 void writeLineString(const geom::LineString &ls);
00165
00166
00167 void writePolygon(const geom::Polygon &p);
00168
00169
00170 void writeGeometryCollection(const geom::GeometryCollection &c, int wkbtype);
00171
00172
00173 void writeCoordinateSequence(const geom::CoordinateSequence &cs, bool sized);
00174
00175
00176 void writeCoordinate(const geom::CoordinateSequence &cs, int idx, bool is3d);
00177
00178
00179 void writeGeometryType(int geometryType, int SRID);
00180
00181
00182 void writeSRID(int SRID);
00183
00184
00185 void writeByteOrder();
00186
00187
00188 void writeInt(int intValue);
00189
00190
00191 };
00192
00193 }
00194 }
00195
00196 #endif // #ifndef GEOS_IO_WKBWRITER_H
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207