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 Polygon;
49  class PolyhedralSurface;
50 
51  /*!
52  \class WKBReader
53 
54  \brief A class that deserializes a geometry from a valid WKB.
55 
56  \ingroup geometry
57 
58  \sa WKBWriter
59  */
61  {
62  public:
63 
64  /*!
65  \brief It returns a valid geometry from a given WKB.
66 
67  \param wkb A valid WKB geometry.
68 
69  \return A geometry created from reading the WKB. The caller of this method will take the ownership of the returned geometry.
70  */
71  static Geometry* read(const char* wkb);
72 
73  /*!
74  \brief It returns a valid geometry from a given hex-encoded WKB.
75 
76  \param hwkb An hex-encoded WKB geometry.
77 
78  \return A geometry created from reading the HWKB. The caller of this method will take the ownership of the returned geometry.
79  */
80  static Geometry* readHex(const char* hwkb);
81 
82  private:
83 
84  static te::gm::Geometry* getGeometry(const char* wkb, const char** endptr);
85 
86  static te::gm::Point* getPoint(const char* wkb, const char** endptr);
87 
88  static te::gm::Point* getPointZ(const char* wkb, const char** endptr);
89 
90  static te::gm::Point* getPointM(const char* wkb, const char** endptr);
91 
92  static te::gm::Point* getPointZM(const char* wkb, const char** endptr);
93 
94  static te::gm::LineString* getLineString(const char* wkb, const char** endptr);
95 
96  static te::gm::LinearRing* getLinearRing(const char* wkb, const char** endptr, te::common::MachineByteOrder byteOrder, GeomType gType);
97 
98  static te::gm::Polygon* getPolygon(const char* wkb, const char** endptr);
99 
100  static te::gm::GeometryCollection* getGeometryCollection(const char* wkb, const char** endptr);
101 
102  static te::gm::PolyhedralSurface* getPolyhedralSurface(const char* wkb, const char** endptr);
103  };
104 
105  } // namespace gm
106 } // namespace te
107 
108 #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
#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
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:122
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:74
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:60