GEOS  3.9.1dev
WKBReader.h
Go to the documentation of this file.
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/io/ByteOrderDataInStream.h> // for composition
26 
27 #include <iosfwd> // ostream, istream
28 #include <memory>
29 // #include <vector>
30 #include <array>
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 class CoordinateSequence;
56 
57 } // namespace geom
58 } // namespace geos
59 
60 
61 namespace geos {
62 namespace io {
63 
81 
82 public:
83 
85 
87  WKBReader();
88 
97  std::unique_ptr<geom::Geometry> read(std::istream& is);
98 
107  std::unique_ptr<geom::Geometry> readHEX(std::istream& is);
108 
115  static std::ostream& printHEX(std::istream& is, std::ostream& os);
116 
117 private:
118 
120 
121  // for now support the WKB standard only - may be generalized later
122  unsigned int inputDimension;
123  bool hasZ;
124  bool hasM;
125 
127 
128  std::array<double, 4> ordValues;
129 
130  std::unique_ptr<geom::Geometry> readGeometry();
131 
132  std::unique_ptr<geom::Point> readPoint();
133 
134  std::unique_ptr<geom::LineString> readLineString();
135 
136  std::unique_ptr<geom::LinearRing> readLinearRing();
137 
138  std::unique_ptr<geom::Polygon> readPolygon();
139 
140  std::unique_ptr<geom::MultiPoint> readMultiPoint();
141 
142  std::unique_ptr<geom::MultiLineString> readMultiLineString();
143 
144  std::unique_ptr<geom::MultiPolygon> readMultiPolygon();
145 
146  std::unique_ptr<geom::GeometryCollection> readGeometryCollection();
147 
148  std::unique_ptr<geom::CoordinateSequence> readCoordinateSequence(int); // throws IOException
149 
150  void readCoordinate(); // throws IOException
151 
152  // Declare type as noncopyable
153  WKBReader(const WKBReader& other) = delete;
154  WKBReader& operator=(const WKBReader& rhs) = delete;
155 };
156 
157 } // namespace io
158 } // namespace geos
159 
160 #ifdef _MSC_VER
161 #pragma warning(pop)
162 #endif
163 
164 #endif // #ifndef GEOS_IO_WKBREADER_H
std::array< double, 4 > ordValues
Definition: WKBReader.h:128
unsigned int inputDimension
Definition: WKBReader.h:122
#define GEOS_DLL
Definition: export.h:28
Reads a Geometry from Well-Known Binary format.
Definition: WKBReader.h:80
ByteOrderDataInStream dis
Definition: WKBReader.h:126
Allows reading an stream of primitive datatypes from an underlying istream, with the representation b...
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Basic namespace for all GEOS functionalities.
const geom::GeometryFactory & factory
Definition: WKBReader.h:119