line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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 |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
#include |
26
|
|
|
|
|
|
|
#include // for composition |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
#include // ostream, istream |
29
|
|
|
|
|
|
|
#include |
30
|
|
|
|
|
|
|
#include |
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
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
/** |
64
|
|
|
|
|
|
|
* \class WKBReader io.h geos.h |
65
|
|
|
|
|
|
|
* |
66
|
|
|
|
|
|
|
* \brief Reads a Geometry from Well-Known Binary format. |
67
|
|
|
|
|
|
|
* |
68
|
|
|
|
|
|
|
* This class is designed to support reuse of a single instance to read |
69
|
|
|
|
|
|
|
* multiple geometries. This class is not thread-safe; each thread should |
70
|
|
|
|
|
|
|
* create its own instance. |
71
|
|
|
|
|
|
|
* |
72
|
|
|
|
|
|
|
* The Well-known Binary format is defined in the
|
73
|
|
|
|
|
|
|
* HREF="http://www.opengis.org/techno/specs.htm">OpenGIS Simple Features |
74
|
|
|
|
|
|
|
* Specification for SQL. |
75
|
|
|
|
|
|
|
* This implementation supports the extended WKB standard which allows |
76
|
|
|
|
|
|
|
* representing 3-dimensional coordinates. |
77
|
|
|
|
|
|
|
* |
78
|
|
|
|
|
|
|
*/ |
79
|
0
|
|
|
|
|
|
class GEOS_DLL WKBReader { |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
public: |
82
|
|
|
|
|
|
|
|
83
|
8
|
|
|
|
|
|
WKBReader(geom::GeometryFactory const& f): factory(f) {} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
/// Inizialize parser with default GeometryFactory. |
86
|
|
|
|
|
|
|
WKBReader(); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
/** |
89
|
|
|
|
|
|
|
* \brief Reads a Geometry from an istream. |
90
|
|
|
|
|
|
|
* |
91
|
|
|
|
|
|
|
* @param is the stream to read from |
92
|
|
|
|
|
|
|
* @return the Geometry read |
93
|
|
|
|
|
|
|
* @throws IOException |
94
|
|
|
|
|
|
|
* @throws ParseException |
95
|
|
|
|
|
|
|
*/ |
96
|
|
|
|
|
|
|
geom::Geometry* read(std::istream &is); |
97
|
|
|
|
|
|
|
// throws IOException, ParseException |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
/** |
100
|
|
|
|
|
|
|
* \brief Reads a Geometry from an istream in hex format. |
101
|
|
|
|
|
|
|
* |
102
|
|
|
|
|
|
|
* @param is the stream to read from |
103
|
|
|
|
|
|
|
* @return the Geometry read |
104
|
|
|
|
|
|
|
* @throws IOException |
105
|
|
|
|
|
|
|
* @throws ParseException |
106
|
|
|
|
|
|
|
*/ |
107
|
|
|
|
|
|
|
geom::Geometry *readHEX(std::istream &is); |
108
|
|
|
|
|
|
|
// throws IOException, ParseException |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
/** |
111
|
|
|
|
|
|
|
* \brief Print WKB in HEX form to out stream |
112
|
|
|
|
|
|
|
* |
113
|
|
|
|
|
|
|
* @param is is the stream to read from |
114
|
|
|
|
|
|
|
* @param os is the stream to write to |
115
|
|
|
|
|
|
|
*/ |
116
|
|
|
|
|
|
|
static std::ostream &printHEX(std::istream &is, std::ostream &os); |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
private: |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
const geom::GeometryFactory &factory; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
// for now support the WKB standard only - may be generalized later |
123
|
|
|
|
|
|
|
unsigned int inputDimension; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
ByteOrderDataInStream dis; |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
std::vector ordValues; |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
geom::Geometry *readGeometry(); |
130
|
|
|
|
|
|
|
// throws IOException, ParseException |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
geom::Point *readPoint(); |
133
|
|
|
|
|
|
|
// throws IOException |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
geom::LineString *readLineString(); |
136
|
|
|
|
|
|
|
// throws IOException |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
geom::LinearRing *readLinearRing(); |
139
|
|
|
|
|
|
|
// throws IOException |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
geom::Polygon *readPolygon(); |
142
|
|
|
|
|
|
|
// throws IOException |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
geom::MultiPoint *readMultiPoint(); |
145
|
|
|
|
|
|
|
// throws IOException, ParseException |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
geom::MultiLineString *readMultiLineString(); |
148
|
|
|
|
|
|
|
// throws IOException, ParseException |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
geom::MultiPolygon *readMultiPolygon(); |
151
|
|
|
|
|
|
|
// throws IOException, ParseException |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
geom::GeometryCollection *readGeometryCollection(); |
154
|
|
|
|
|
|
|
// throws IOException, ParseException |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
geom::CoordinateSequence *readCoordinateSequence(int); // throws IOException |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
void readCoordinate(); // throws IOException |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
// Declare type as noncopyable |
161
|
|
|
|
|
|
|
WKBReader(const WKBReader& other) = delete; |
162
|
|
|
|
|
|
|
WKBReader& operator=(const WKBReader& rhs) = delete; |
163
|
|
|
|
|
|
|
}; |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
} // namespace io |
166
|
|
|
|
|
|
|
} // namespace geos |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
#ifdef _MSC_VER |
169
|
|
|
|
|
|
|
#pragma warning(pop) |
170
|
|
|
|
|
|
|
#endif |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
#endif // #ifndef GEOS_IO_WKBREADER_H |