EWKBWriter.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/sqlite/EWKBWriter.h
22 
23  \brief A class that serializes a geometry to the SpatiaLite EWKB format.
24 */
25 
26 #ifndef __TERRALIB_SQLITE_INTERNAL_EWKBWRITER_H
27 #define __TERRALIB_SQLITE_INTERNAL_EWKBWRITER_H
28 
29 // TerraLib
30 #include "../common/Enums.h"
31 #include "../geometry/Visitor.h"
32 
33 #ifdef TE_ENABLE_SPATIALITE
34 
35 namespace te
36 {
37  namespace sqlite
38  {
39  /*!
40  \class EWKBWriter
41 
42  \brief A class that serializes a geometry to the SpatiaLite EWKB format.
43 
44  \sa EWKBReader
45  */
46  class EWKBWriter : public te::gm::Visitor
47  {
48  public:
49 
50  EWKBWriter(unsigned char* ewkb, te::common::MachineByteOrder byteOrder = te::common::NDR);
51 
52  ~EWKBWriter();
53 
54  void write(const te::gm::Geometry* geom);
55 
56  static void write(const te::gm::Geometry* geom, unsigned char* ewkb, te::common::MachineByteOrder byteOrder = te::common::NDR);
57 
58  void reset(unsigned char* ewkb, te::common::MachineByteOrder byteOrder = te::common::NDR);
59 
60  protected:
61 
62  void visit(const te::gm::Curve& /*visited*/) {}
63  void visit(const te::gm::Geometry& /*visited*/) {}
64  void visit(const te::gm::GeometryCollection& visited);
65  void visit(const te::gm::LinearRing& visited);
66  void visit(const te::gm::LineString& visited);
67  void visit(const te::gm::MultiCurve& /*visited*/) {}
68  void visit(const te::gm::MultiLineString& visited);
69  void visit(const te::gm::MultiPoint& visited);
70  void visit(const te::gm::MultiPolygon& visited);
71  void visit(const te::gm::MultiSurface& /*visited*/) {}
72  void visit(const te::gm::AbstractPoint& /*visited*/) {}
73  void visit(const te::gm::Point& visited);
74  void visit(const te::gm::PointM& visited);
75  void visit(const te::gm::PointZ& visited);
76  void visit(const te::gm::PointZM& visited);
77  void visit(const te::gm::PointKd& /*visited*/) {}
78  void visit(const te::gm::Polygon& visited);
79  void visit(const te::gm::PolyhedralSurface& /*visited*/) {}
80  void visit(const te::gm::Surface& /*visited*/) {}
81  void visit(const te::gm::TIN& /*visited*/) {}
82  void visit(const te::gm::Triangle& /*visited*/) {}
83  void visit(const te::gm::CircularString& /*visited*/) {}
84  void visit(const te::gm::CompoundCurve& /*visited*/) {}
85  void visit(const te::gm::CurvePolygon& /*visited*/) {}
86 
87  private:
88 
89  unsigned char* m_ewkb;
90  te::common::MachineByteOrder m_byteOrder;
91  };
92 
93  } // namespace sqlite
94 } // namespace te
95 
96 #endif // TE_ENABLE_SPATIALITE
97 
98 #endif // __TERRALIB_SQLITE_INTERNAL_EWKBWRITER_H
PolyhedralSurface is a contiguous collection of polygons, which share common boundary segments...
MultiPolygon is a MultiSurface whose elements are Polygons.
Definition: MultiPolygon.h:50
Curve is an abstract class that represents 1-dimensional geometric objects stored as a sequence of co...
Definition: Curve.h:58
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
TIN (triangulated irregular network) is a PolyhedralSurface consisting only of Triangle patches...
Definition: TIN.h:50
A LinearRing is a LineString that is both closed and simple.
Definition: LinearRing.h:53
A k-dimensional point.
Definition: PointKd.h:53
MultiPoint is a GeometryCollection whose elements are restricted to points.
Definition: MultiPoint.h:50
A point with z-coordinate value.
Definition: PointZ.h:51
LineString is a curve with linear interpolation between points.
Definition: LineString.h:62
Triangle is a polygon with 3 distinct, non-collinear vertices and no interior boundary.
Definition: Triangle.h:50
A point with x and y coordinate values.
Definition: Point.h:50
URI C++ Library.
CompoundCurve is a curve that may have circular and linear segments.
Definition: CompoundCurve.h:53
CurvePolygon is a planar surface defined by 1 exterior boundary and 0 or more interior boundaries...
Definition: CurvePolygon.h:57
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
MultiLineString is a MultiCurve whose elements are LineStrings.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
MultiSurface is a class that represents a 2-dimensional GeometryCollection whose elements are surface...
Definition: MultiSurface.h:54
MultiCurve is a class that represents a 1-dimensional GeometryCollection whose elements are curves...
Definition: MultiCurve.h:50
It is a collection of other geometric objects.
A base abstract class for 0-dimensional geometric objects that represents a single location in coordi...
Definition: AbstractPoint.h:50
CircularString is a curve with circular interpolation between points.
Surface is an abstract class that represents a 2-dimensional geometric objects.
Definition: Surface.h:54
A visitor interface for the Geometry hierarchy.
Definition: Visitor.h:44