GEOS  3.3.3
WKBReader.h
1 /**********************************************************************
2  * $Id: WKBReader.h 2958 2010-03-29 11:29:40Z mloskot $
3  *
4  * GEOS - Geometry Engine Open Source
5  * http://geos.refractions.net
6  *
7  * Copyright (C) 2005-2006 Refractions Research Inc.
8  * Copyright (C) 2001-2002 Vivid Solutions Inc.
9  *
10  * This is free software; you can redistribute and/or modify it under
11  * the terms of the GNU Lesser General Public Licence as published
12  * by the Free Software Foundation.
13  * See the COPYING file for more information.
14  *
15  **********************************************************************
16  *
17  * Last port: io/WKBReader.java rev. 1.1 (JTS-1.7)
18  *
19  **********************************************************************/
20 
21 #ifndef GEOS_IO_WKBREADER_H
22 #define GEOS_IO_WKBREADER_H
23 
24 #include <geos/export.h>
25 
26 #include <geos/geom/GeometryFactory.h>
27 #include <geos/io/ByteOrderDataInStream.h> // for composition
28 
29 #include <iosfwd> // ostream, istream
30 #include <vector>
31 #include <string>
32 
33 #define BAD_GEOM_TYPE_MSG "Bad geometry type encountered in"
34 
35 #ifdef _MSC_VER
36 #pragma warning(push)
37 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
38 #endif
39 
40 // Forward declarations
41 namespace geos {
42  namespace geom {
43 
44  //class GeometryFactory;
45  class Coordinate;
46  class Geometry;
47  class GeometryCollection;
48  class Point;
49  class LineString;
50  class LinearRing;
51  class Polygon;
52  class MultiPoint;
53  class MultiLineString;
54  class MultiPolygon;
55  class PrecisionModel;
56 
57  } // namespace geom
58 } // namespace geos
59 
60 
61 namespace geos {
62 namespace io {
63 
80 class GEOS_DLL WKBReader {
81 
82 public:
83 
84  WKBReader(geom::GeometryFactory const& f): factory(f) {};
85 
87  WKBReader();
88 
97  geom::Geometry* read(std::istream &is);
98  // throws IOException, ParseException
99 
108  geom::Geometry *readHEX(std::istream &is);
109  // throws IOException, ParseException
110 
117  static std::ostream &printHEX(std::istream &is, std::ostream &os);
118 
119 private:
120 
121  const geom::GeometryFactory &factory;
122 
123  // for now support the WKB standard only - may be generalized later
124  unsigned int inputDimension;
125 
126  ByteOrderDataInStream dis;
127 
128  std::vector<double> ordValues;
129 
130  geom::Geometry *readGeometry();
131  // throws IOException, ParseException
132 
133  geom::Point *readPoint();
134  // throws IOException
135 
136  geom::LineString *readLineString();
137  // throws IOException
138 
139  geom::LinearRing *readLinearRing();
140  // throws IOException
141 
142  geom::Polygon *readPolygon();
143  // throws IOException
144 
145  geom::MultiPoint *readMultiPoint();
146  // throws IOException, ParseException
147 
148  geom::MultiLineString *readMultiLineString();
149  // throws IOException, ParseException
150 
151  geom::MultiPolygon *readMultiPolygon();
152  // throws IOException, ParseException
153 
154  geom::GeometryCollection *readGeometryCollection();
155  // throws IOException, ParseException
156 
157  geom::CoordinateSequence *readCoordinateSequence(int); // throws IOException
158 
159  void readCoordinate(); // throws IOException
160 
161  // Declare type as noncopyable
162  WKBReader(const WKBReader& other);
163  WKBReader& operator=(const WKBReader& rhs);
164 };
165 
166 } // namespace io
167 } // namespace geos
168 
169 #ifdef _MSC_VER
170 #pragma warning(pop)
171 #endif
172 
173 #endif // #ifndef GEOS_IO_WKBREADER_H
174 
175 /**********************************************************************
176  * $Log$
177  * Revision 1.3 2006/06/01 11:49:36 strk
178  * Reduced installed headers form geomgraph namespace
179  *
180  * Revision 1.2 2006/04/12 10:57:19 strk
181  * Added WKBReader default ctor using default GeometryFactory instance
182  *
183  * Revision 1.1 2006/03/20 18:18:14 strk
184  * io.h header split
185  *
186  **********************************************************************/