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/util/Machine.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
00083
00084
00085
00086
00087
00088 WKBWriter(int dims=2, int bo=getMachineByteOrder(), bool includeSRID=false);
00089
00090
00091
00092
00093
00094 virtual ~WKBWriter();
00095
00096
00097
00098
00099
00100
00101 virtual int getOutputDimension() const { return defaultOutputDimension; }
00102
00103
00104
00105
00106
00107
00108
00109
00110 virtual void setOutputDimension(int newOutputDimension);
00111
00112
00113
00114
00115
00116
00117 virtual int getByteOrder() const { return byteOrder; }
00118
00119
00120
00121
00122
00123 virtual void setByteOrder(int newByteOrder);
00124
00125
00126
00127
00128
00129
00130 virtual int getIncludeSRID() const { return includeSRID; }
00131
00132
00133
00134
00135
00136 virtual void setIncludeSRID(int newIncludeSRID) { includeSRID = (0 == newIncludeSRID ? false : true); }
00137
00145 void write(const geom::Geometry &g, std::ostream &os);
00146
00147
00155 void writeHEX(const geom::Geometry &g, std::ostream &os);
00156
00157
00158 private:
00159
00160 int defaultOutputDimension;
00161 int outputDimension;
00162
00163 int byteOrder;
00164
00165 bool includeSRID;
00166
00167 std::ostream *outStream;
00168
00169 unsigned char buf[8];
00170
00171 void writePoint(const geom::Point &p);
00172
00173
00174 void writeLineString(const geom::LineString &ls);
00175
00176
00177 void writePolygon(const geom::Polygon &p);
00178
00179
00180 void writeGeometryCollection(const geom::GeometryCollection &c, int wkbtype);
00181
00182
00183 void writeCoordinateSequence(const geom::CoordinateSequence &cs, bool sized);
00184
00185
00186 void writeCoordinate(const geom::CoordinateSequence &cs, int idx, bool is3d);
00187
00188
00189 void writeGeometryType(int geometryType, int SRID);
00190
00191
00192 void writeSRID(int SRID);
00193
00194
00195 void writeByteOrder();
00196
00197
00198 void writeInt(int intValue);
00199
00200
00201 };
00202
00203 }
00204 }
00205
00206 #endif // #ifndef GEOS_IO_WKBWRITER_H
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217