GEOS  3.8.0dev
WKBReader.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2005-2006 Refractions Research Inc.
7  * Copyright (C) 2001-2002 Vivid Solutions Inc.
8  *
9  * This is free software; you can redistribute and/or modify it under
10  * the terms of the GNU Lesser General Public Licence as published
11  * by the Free Software Foundation.
12  * See the COPYING file for more information.
13  *
14  **********************************************************************
15  *
16  * Last port: io/WKBReader.java rev. 1.1 (JTS-1.7)
17  *
18  **********************************************************************/
19 
20 #ifndef GEOS_IO_WKBREADER_H
21 #define GEOS_IO_WKBREADER_H
22 
23 #include <geos/export.h>
24 
25 #include <geos/geom/GeometryFactory.h>
26 #include <geos/io/ByteOrderDataInStream.h> // for composition
27 
28 #include <iosfwd> // ostream, istream
29 #include <memory>
30 #include <vector>
31 
32 #define BAD_GEOM_TYPE_MSG "Bad geometry type encountered in"
33 
34 #ifdef _MSC_VER
35 #pragma warning(push)
36 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
37 #endif
38 
39 // Forward declarations
40 namespace geos {
41 namespace geom {
42 
43 //class GeometryFactory;
44 class Coordinate;
45 class Geometry;
46 class GeometryCollection;
47 class Point;
48 class LineString;
49 class LinearRing;
50 class Polygon;
51 class MultiPoint;
52 class MultiLineString;
53 class MultiPolygon;
54 class PrecisionModel;
55 
56 } // namespace geom
57 } // namespace geos
58 
59 
60 namespace geos {
61 namespace io {
62 
79 class GEOS_DLL WKBReader {
80 
81 public:
82 
83  WKBReader(geom::GeometryFactory const& f): factory(f) {}
84 
86  WKBReader();
87 
96  std::unique_ptr<geom::Geometry> read(std::istream& is);
97 
106  std::unique_ptr<geom::Geometry> readHEX(std::istream& is);
107 
114  static std::ostream& printHEX(std::istream& is, std::ostream& os);
115 
116 private:
117 
118  const geom::GeometryFactory& factory;
119 
120  // for now support the WKB standard only - may be generalized later
121  unsigned int inputDimension;
122 
123  ByteOrderDataInStream dis;
124 
125  std::vector<double> ordValues;
126 
127  std::unique_ptr<geom::Geometry> readGeometry();
128 
129  std::unique_ptr<geom::Point> readPoint();
130 
131  std::unique_ptr<geom::LineString> readLineString();
132 
133  std::unique_ptr<geom::LinearRing> readLinearRing();
134 
135  std::unique_ptr<geom::Polygon> readPolygon();
136 
137  std::unique_ptr<geom::MultiPoint> readMultiPoint();
138 
139  std::unique_ptr<geom::MultiLineString> readMultiLineString();
140 
141  std::unique_ptr<geom::MultiPolygon> readMultiPolygon();
142 
143  std::unique_ptr<geom::GeometryCollection> readGeometryCollection();
144 
145  std::unique_ptr<geom::CoordinateSequence> readCoordinateSequence(int); // throws IOException
146 
147  void readCoordinate(); // throws IOException
148 
149  // Declare type as noncopyable
150  WKBReader(const WKBReader& other) = delete;
151  WKBReader& operator=(const WKBReader& rhs) = delete;
152 };
153 
154 } // namespace io
155 } // namespace geos
156 
157 #ifdef _MSC_VER
158 #pragma warning(pop)
159 #endif
160 
161 #endif // #ifndef GEOS_IO_WKBREADER_H
Reads a Geometry from Well-Known Binary format.
Definition: WKBReader.h:79
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:66
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25