GEOS 3.9.1
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/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
40namespace geos {
41namespace geom {
42
43class GeometryFactory;
44class Coordinate;
45class Geometry;
46class GeometryCollection;
47class Point;
48class LineString;
49class LinearRing;
50class Polygon;
51class MultiPoint;
52class MultiLineString;
53class MultiPolygon;
54class PrecisionModel;
55class CoordinateSequence;
56
57} // namespace geom
58} // namespace geos
59
60
61namespace geos {
62namespace io {
63
80class GEOS_DLL WKBReader {
81
82public:
83
85
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
117private:
118
119 const geom::GeometryFactory& factory;
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
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition GeometryFactory.h:68
Allows reading an stream of primitive datatypes from an underlying istream, with the representation b...
Definition ByteOrderDataInStream.h:41
Reads a Geometry from Well-Known Binary format.
Definition WKBReader.h:80
static std::ostream & printHEX(std::istream &is, std::ostream &os)
Print WKB in HEX form to out stream.
WKBReader()
Inizialize parser with default GeometryFactory.
std::unique_ptr< geom::Geometry > readHEX(std::istream &is)
Reads a Geometry from an istream in hex format.
std::unique_ptr< geom::Geometry > read(std::istream &is)
Reads a Geometry from an istream.
Basic namespace for all GEOS functionalities.
Definition IndexedNestedRingTester.h:26