WKBReader.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/geometry/WKBReader.h
22 
23  \brief A class that deserializes a geometry from a valid WKB.
24 */
25 
26 #ifndef __TERRALIB_GEOMETRY_INTERNAL_WKBREADER_H
27 #define __TERRALIB_GEOMETRY_INTERNAL_WKBREADER_H
28 
29 // TerraLib
30 #include "../common/Enums.h"
31 #include "../common/Static.h"
32 #include "Config.h"
33 #include "Enums.h"
34 
35 namespace te
36 {
37  namespace gm
38  {
39 // Forward declaration
40  class Geometry;
41  class GeometryCollection;
42  class LinearRing;
43  class LineString;
44  class MultiLineString;
45  class MultiPoint;
46  class MultiPolygon;
47  class Point;
48  class PointM;
49  class PointZ;
50  class PointZM;
51  class Polygon;
52  class PolyhedralSurface;
53 
54  /*!
55  \class WKBReader
56 
57  \brief A class that deserializes a geometry from a valid WKB.
58 
59  \ingroup geometry
60 
61  \sa WKBWriter
62  */
64  {
65  public:
66 
67  /*!
68  \brief It returns a valid geometry from a given WKB.
69 
70  \param wkb A valid WKB geometry.
71 
72  \return A geometry created from reading the WKB. The caller of this method will take the ownership of the returned geometry.
73  */
74  static Geometry* read(const char* wkb);
75 
76  /*!
77  \brief It returns a valid geometry from a given hex-encoded WKB.
78 
79  \param hwkb An hex-encoded WKB geometry.
80 
81  \return A geometry created from reading the HWKB. The caller of this method will take the ownership of the returned geometry.
82  */
83  static Geometry* readHex(const char* hwkb);
84 
85  private:
86 
87  static te::gm::Geometry* getGeometry(const char* wkb, const char** endptr);
88 
89  static te::gm::Point* getPoint(const char* wkb, const char** endptr);
90 
91  static te::gm::PointZ* getPointZ(const char* wkb, const char** endptr);
92 
93  static te::gm::PointM* getPointM(const char* wkb, const char** endptr);
94 
95  static te::gm::PointZM* getPointZM(const char* wkb, const char** endptr);
96 
97  static te::gm::LineString* getLineString(const char* wkb, const char** endptr);
98 
99  static te::gm::LinearRing* getLinearRing(const char* wkb, const char** endptr, te::common::MachineByteOrder byteOrder, GeomType gType);
100 
101  static te::gm::Polygon* getPolygon(const char* wkb, const char** endptr);
102 
103  static te::gm::GeometryCollection* getGeometryCollection(const char* wkb, const char** endptr);
104 
105  static te::gm::PolyhedralSurface* getPolyhedralSurface(const char* wkb, const char** endptr);
106  };
107 
108  } // namespace gm
109 } // namespace te
110 
111 #endif // __TERRALIB_GEOMETRY_INTERNAL_WKBREADER_H
PolyhedralSurface is a contiguous collection of polygons, which share common boundary segments...
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:41
A point with a z-coordinate value and an associated measurement.
Definition: PointZM.h:51
A point with an associated measure.
Definition: PointM.h:51
#define TEGEOMEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:76
A LinearRing is a LineString that is both closed and simple.
Definition: LinearRing.h:53
A point with z-coordinate value.
Definition: PointZ.h:51
LineString is a curve with linear interpolation between points.
Definition: LineString.h:62
A point with x and y coordinate values.
Definition: Point.h:50
URI C++ Library.
General enumerations.
MachineByteOrder
Endianness.
Definition: Enums.h:116
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
Configuration flags for the Vector Geometry Model of TerraLib.
It is a collection of other geometric objects.
A base type for static classes.
Definition: Static.h:43
A class that deserializes a geometry from a valid WKB.
Definition: WKBReader.h:63