Loading...
Searching...
No Matches
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
38namespace 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. */
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 Point& visited);
115 void visit(const Polygon& visited);
116 void visit(const PolyhedralSurface& visited);
117 virtual void visit(const Surface& /*visited*/) {}
118 void visit(const TIN& visited);
119 void visit(const Triangle& visited);
120 void visit(const CircularString& /*visited*/) {}
121 void visit(const CompoundCurve& /*visited*/) {}
122 void visit(const CurvePolygon& /*visited*/) {}
123
124 private:
125
126 std::ostream& m_ostream; //!< The output stream used to serialize the geometry to WKT.
127 bool m_tagged; //!< This flag controls how geometry are write to the output stream.
128 };
129
130 } // namespace gm
131} // namespace te
132
133#endif // __TERRALIB_GEOMETRY_INTERNAL_WKTWRITER_H
CircularString is a curve with circular interpolation between points.
CompoundCurve is a curve that may have circular and linear segments.
Definition: CompoundCurve.h:54
CurvePolygon is a planar surface defined by 1 exterior boundary and 0 or more interior boundaries.
Definition: CurvePolygon.h:58
Curve is an abstract class that represents 1-dimensional geometric objects stored as a sequence of co...
Definition: Curve.h:59
It is a collection of other geometric objects.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:78
LineString is a curve with linear interpolation between points.
Definition: LineString.h:65
A LinearRing is a LineString that is both closed and simple.
Definition: LinearRing.h:54
MultiCurve is a class that represents a 1-dimensional GeometryCollection whose elements are curves.
Definition: MultiCurve.h:51
MultiLineString is a MultiCurve whose elements are LineStrings.
MultiPoint is a GeometryCollection whose elements are restricted to points.
Definition: MultiPoint.h:54
MultiPolygon is a MultiSurface whose elements are Polygons.
Definition: MultiPolygon.h:51
MultiSurface is a class that represents a 2-dimensional GeometryCollection whose elements are surface...
Definition: MultiSurface.h:55
A point with x and y coordinate values.
Definition: Point.h:51
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:51
PolyhedralSurface is a contiguous collection of polygons, which share common boundary segments.
Surface is an abstract class that represents a 2-dimensional geometric objects.
Definition: Surface.h:55
TIN (triangulated irregular network) is a PolyhedralSurface consisting only of Triangle patches.
Definition: TIN.h:51
Triangle is a polygon with 3 distinct, non-collinear vertices and no interior boundary.
Definition: Triangle.h:51
A visitor interface for the Geometry hierarchy.
Definition: Visitor.h:45
A class that serializes a geometry to the WKT format.
Definition: WKTWriter.h:55
void visit(const TIN &visited)
void visit(const MultiPoint &visited)
virtual void visit(const Curve &)
Definition: WKTWriter.h:104
bool m_tagged
This flag controls how geometry are write to the output stream.
Definition: WKTWriter.h:127
void visit(const LineString &visited)
void visit(const Point &visited)
virtual void visit(const MultiSurface &)
Definition: WKTWriter.h:113
void visit(const CircularString &)
Definition: WKTWriter.h:120
virtual void visit(const MultiCurve &)
Definition: WKTWriter.h:109
void visit(const Polygon &visited)
void visit(const CurvePolygon &)
Definition: WKTWriter.h:122
virtual void visit(const Surface &)
Definition: WKTWriter.h:117
void write(const Geometry *geom)
It serializes the geometry to a WKT representation.
void visit(const PolyhedralSurface &visited)
void visit(const LinearRing &visited)
~WKTWriter()
Destructor.
static void write(const Geometry &geom, std::ostream &o)
It serializes the geometry to a WKT representation.
void visit(const MultiPolygon &visited)
std::ostream & m_ostream
The output stream used to serialize the geometry to WKT.
Definition: WKTWriter.h:126
void visit(const GeometryCollection &visited)
void visit(const CompoundCurve &)
Definition: WKTWriter.h:121
void visit(const MultiLineString &visited)
virtual void visit(const Geometry &)
Definition: WKTWriter.h:105
void visit(const Triangle &visited)
void write(const Geometry &geom)
It serializes the geometry to a WKT representation.
static void write(const Geometry *geom, std::ostream &o)
It serializes the geometry to a WKT representation.
WKTWriter(std::ostream &o)
It constructs a new WKT writer.
TerraLib.
A visitor interface for the SymbologyEncoding hierarchy.
#define TEGEOMEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:76