WKTWriter.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/WKTWriter.h
22 
23  \brief A class that serializes a geometry to the WKT format.
24 */
25 
26 #ifndef __TERRALIB_GEOMETRY_INTERNAL_WKTWRITER_H
27 #define __TERRALIB_GEOMETRY_INTERNAL_WKTWRITER_H
28 
29 // TerraLib
30 #include "Visitor.h"
31 
32 // STL
33 #include <iosfwd>
34 
35 // Boost
36 #include <boost/noncopyable.hpp>
37 
38 namespace te
39 {
40  namespace gm
41  {
42 // Forward declaration
43  class Geometry;
44 
45  /*!
46  \class WKTWriter
47 
48  \brief A class that serializes a geometry to the WKT format.
49 
50  \ingroup geometry
51 
52  \sa WKTReader
53  */
54  class TEGEOMEXPORT WKTWriter : public Visitor, public boost::noncopyable
55  {
56  public:
57 
58  /*!
59  \brief It constructs a new WKT writer.
60 
61  \param o An output stream where we will write the wkt.
62  */
63  WKTWriter(std::ostream& o);
64 
65  /*! \brief Destructor. */
66  ~WKTWriter();
67 
68  /*!
69  \brief It serializes the geometry to a WKT representation.
70 
71  \param geom The geometry to be serialized.
72 
73  \note You must call reset in successive calls to this method.
74  */
75  void write(const Geometry* geom);
76 
77  /*!
78  \brief It serializes the geometry to a WKT representation.
79 
80  \param geom The geometry to be serialized.
81 
82  \note You must call reset in successive calls to this method.
83  */
84  void write(const Geometry& geom);
85 
86  /*!
87  \brief It serializes the geometry to a WKT representation.
88 
89  \param geom The geometry to be serialized.
90  \param o An output stream where we will write the wkt.
91  */
92  static void write(const Geometry* geom, std::ostream& o);
93 
94  /*!
95  \brief It serializes the geometry to a WKT representation.
96 
97  \param geom The geometry to be serialized.
98  \param o An output stream where we will write the wkt.
99  */
100  static void write(const Geometry& geom, std::ostream& o);
101 
102  protected:
103 
104  virtual void visit(const Curve& /*visited*/) {}
105  virtual void visit(const Geometry& /*visited*/) {}
106  void visit(const GeometryCollection& visited);
107  void visit(const LinearRing& visited);
108  void visit(const LineString& visited);
109  virtual void visit(const MultiCurve& /*visited*/) {}
110  void visit(const MultiLineString& visited);
111  void visit(const MultiPoint& visited);
112  void visit(const MultiPolygon& visited);
113  virtual void visit(const MultiSurface& /*visited*/) {}
114  void visit(const AbstractPoint& /*visited*/) {}
115  void visit(const Point& visited);
116  void visit(const PointM& visited);
117  void visit(const PointZ& visited);
118  void visit(const PointZM& visited);
119  void visit(const PointKd& /*visited*/) {}
120  void visit(const Polygon& visited);
121  void visit(const PolyhedralSurface& visited);
122  virtual void visit(const Surface& /*visited*/) {}
123  void visit(const TIN& visited);
124  void visit(const Triangle& visited);
125  void visit(const CircularString& /*visited*/) {}
126  void visit(const CompoundCurve& /*visited*/) {}
127  void visit(const CurvePolygon& /*visited*/) {}
128 
129  private:
130 
131  std::ostream& m_ostream; //!< The output stream used to serialize the geometry to WKT.
132  bool m_tagged; //!< This flag controls how geometry are write to the output stream.
133  };
134 
135  } // namespace gm
136 } // namespace te
137 
138 #endif // __TERRALIB_GEOMETRY_INTERNAL_WKTWRITER_H
PolyhedralSurface is a contiguous collection of polygons, which share common boundary segments...
std::ostream & m_ostream
The output stream used to serialize the geometry to WKT.
Definition: WKTWriter.h:131
MultiPolygon is a MultiSurface whose elements are Polygons.
Definition: MultiPolygon.h:50
A class that serializes a geometry to the WKT format.
Definition: WKTWriter.h:54
void visit(const PointKd &)
Definition: WKTWriter.h:119
Curve is an abstract class that represents 1-dimensional geometric objects stored as a sequence of co...
Definition: Curve.h:58
virtual void visit(const Surface &)
Definition: WKTWriter.h:122
virtual void visit(const MultiCurve &)
Definition: WKTWriter.h:109
A point with a z-coordinate value and an associated measurement.
Definition: PointZM.h:51
virtual void visit(const Geometry &)
Definition: WKTWriter.h:105
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
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
virtual void visit(const Curve &)
Definition: WKTWriter.h:104
CurvePolygon is a planar surface defined by 1 exterior boundary and 0 or more interior boundaries...
Definition: CurvePolygon.h:57
void visit(const CurvePolygon &)
Definition: WKTWriter.h:127
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
void visit(const CircularString &)
Definition: WKTWriter.h:125
MultiLineString is a MultiCurve whose elements are LineStrings.
void visit(const CompoundCurve &)
Definition: WKTWriter.h:126
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
virtual void visit(const MultiSurface &)
Definition: WKTWriter.h:113
MultiCurve is a class that represents a 1-dimensional GeometryCollection whose elements are curves...
Definition: MultiCurve.h:50
void visit(const AbstractPoint &)
Definition: WKTWriter.h:114
It is a collection of other geometric objects.
bool m_tagged
This flag controls how geometry are write to the output stream.
Definition: WKTWriter.h:132
A base abstract class for 0-dimensional geometric objects that represents a single location in coordi...
Definition: AbstractPoint.h:50
A visitor interface for the Geometry hierarchy.
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