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
00072
00073
00074
00075
00076 WKBWriter(int dims=2, int bo=getMachineByteOrder(), bool includeSRID=false);
00077
00078
00079
00080
00081
00082 virtual ~WKBWriter();
00083
00084
00085
00086
00087
00088
00089 virtual int getOutputDimension() const { return outputDimension; }
00090
00091
00092
00093
00094
00095 virtual void setOutputDimension(int newOutputDimension) { outputDimension=newOutputDimension; }
00096
00097
00098
00099
00100
00101
00102 virtual int getByteOrder() const { return byteOrder; }
00103
00104
00105
00106
00107
00108 virtual void setByteOrder(int newByteOrder) { byteOrder=newByteOrder; }
00109
00110
00111
00112
00113
00114
00115 virtual int getIncludeSRID() const { return includeSRID; }
00116
00117
00118
00119
00120
00121 virtual void setIncludeSRID(int newIncludeSRID) { includeSRID = (0 == newIncludeSRID ? false : true); }
00122
00130 void write(const geom::Geometry &g, std::ostream &os);
00131
00132
00140 void writeHEX(const geom::Geometry &g, std::ostream &os);
00141
00142
00143 private:
00144
00145 int outputDimension;
00146
00147 int byteOrder;
00148
00149 bool includeSRID;
00150
00151 std::ostream *outStream;
00152
00153 unsigned char buf[8];
00154
00155 void writePoint(const geom::Point &p);
00156
00157
00158 void writeLineString(const geom::LineString &ls);
00159
00160
00161 void writePolygon(const geom::Polygon &p);
00162
00163
00164 void writeGeometryCollection(const geom::GeometryCollection &c, int wkbtype);
00165
00166
00167 void writeCoordinateSequence(const geom::CoordinateSequence &cs, bool sized);
00168
00169
00170 void writeCoordinate(const geom::CoordinateSequence &cs, int idx, bool is3d);
00171
00172
00173 void writeGeometryType(int geometryType, int SRID);
00174
00175
00176 void writeSRID(int SRID);
00177
00178
00179 void writeByteOrder();
00180
00181
00182 void writeInt(int intValue);
00183
00184
00185 };
00186
00187 }
00188 }
00189
00190 #endif // #ifndef GEOS_IO_WKBWRITER_H
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201