Marble

GeoDataPolygon.h
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2008-2009 Patrick Spendrin <[email protected]>
4 // SPDX-FileCopyrightText: 2008 Inge Wallin <[email protected]>
5 //
6 
7 
8 #ifndef MARBLE_GEODATAPOLYGON_H
9 #define MARBLE_GEODATAPOLYGON_H
10 
11 #include <QVector>
12 
13 #include "MarbleGlobal.h"
14 
15 #include "geodata_export.h"
16 #include "GeoDataGeometry.h"
17 
18 namespace Marble
19 {
20 
21 class GeoDataPolygonPrivate;
22 class GeoDataLinearRing;
23 class GeoDataCoordinates;
24 
25 /*!
26  \class GeoDataPolygon
27  \brief A polygon that can have "holes".
28 
29  GeoDataPolygon is a tool class that implements the Polygon tag/class
30  of the Open Geospatial Consortium standard KML 2.2.
31 
32  GeoDataPolygon extends GeoDataGeometry to store and edit
33  Polygons.
34 
35  In the QPainter API "pure" Polygons would represent polygons with
36  "holes" inside. However QPolygon doesn't provide this feature directly.
37 
38  Whenever a Polygon is painted GeoDataLineStyle should be used to assign a
39  color and line width.
40 
41  The polygon consists of
42  \li a single outer boundary and
43  \li optionally a set of inner boundaries.
44 
45  All boundaries are LinearRings.
46 
47  The boundaries of a GeoDataPolygon consist of several (geodetic) nodes which
48  are each connected through line segments. The nodes are stored as
49  GeoDataCoordinates objects.
50 
51 
52  The API which provides access to the nodes is similar to the API of
53  QVector.
54 
55  GeoDataPolygon allows Polygons to be tessellated in order to make them
56  follow the terrain and the curvature of the earth. The tessellation options
57  allow for different ways of visualization:
58 
59  \li Not tessellated: A Polygon that connects each two nodes directly and
60  straight in screen coordinate space.
61  \li A tessellated line: Each line segment is bent so that the Polygon
62  follows the curvature of the earth and its terrain. A tessellated
63  line segment connects two nodes at the shortest possible distance
64  ("along great circles").
65  \li A tessellated line that follows latitude circles whenever possible:
66  In this case Latitude circles are followed as soon as two subsequent
67  nodes have exactly the same amount of latitude. In all other places the
68  line segments follow great circles.
69 
70  Some convenience methods have been added that allow to calculate the
71  geodesic bounding box or the length of a Polygon.
72 
73  \see GeoDataLinearRing
74 */
75 
76 class GEODATA_EXPORT GeoDataPolygon : public GeoDataGeometry
77 {
78  public:
79 /*!
80  \brief Creates a new Polygon.
81 */
82  explicit GeoDataPolygon( TessellationFlags f = NoTessellation );
83 
84 
85 /*!
86  \brief Creates a Polygon from an existing geometry object.
87 */
88  explicit GeoDataPolygon( const GeoDataGeometry &other );
89 
90 /*!
91  \brief Destroys a Polygon.
92 */
93  ~GeoDataPolygon() override;
94 
95  const char *nodeType() const override;
96 
97  EnumGeometryId geometryId() const override;
98 
99  GeoDataGeometry *copy() const override;
100 
101 /*!
102  \brief Returns true/false depending on whether this and other are/are not equal.
103 */
104  bool operator==( const GeoDataPolygon &other ) const;
105  bool operator!=( const GeoDataPolygon &other ) const;
106 
107 
108 /*!
109  \brief Returns whether a Polygon is a closed polygon.
110 
111  \return <code>true</code> for a Polygon.
112 */
113  virtual bool isClosed() const;
114 
115 
116 /*!
117  \brief Returns whether the Polygon follows the earth's surface.
118 
119  \return <code>true</code> if the Polygon's line segments follow the
120  earth's surface and terrain along great circles.
121 */
122  bool tessellate() const;
123 
124 
125 /*!
126  \brief Sets the tessellation property for the Polygon.
127 
128  If \a tessellate is <code>true</code> then the Polygon's line segments
129  are bent and follow the earth's surface and terrain along great circles.
130  If \a tessellate is <code>false</code> then the Polygon's line segments
131  are rendered as straight lines in screen coordinate space.
132 */
133  void setTessellate( bool tessellate );
134 
135 
136 /*!
137  \brief Returns the tessellation flags for a Polygon.
138 */
139  TessellationFlags tessellationFlags() const;
140 
141 
142 /*!
143  \brief Sets the given tessellation flags for a Polygon.
144 */
145  void setTessellationFlags( TessellationFlags f );
146 
147 
148 /*!
149  \brief Returns the smallest latLonAltBox that contains the Polygon.
150 
151  \see GeoDataLatLonAltBox
152 */
153  const GeoDataLatLonAltBox& latLonAltBox() const override;
154 
155 /*!
156  \brief Returns the outer boundary that is represented as a LinearRing.
157 
158  \see GeoDataLinearRing
159 */
160  GeoDataLinearRing &outerBoundary();
161 
162 /*!
163  \brief Returns the outer boundary that is represented as a LinearRing.
164 
165  \see GeoDataLinearRing
166 */
167  const GeoDataLinearRing &outerBoundary() const;
168 
169 /*!
170  \brief Sets the given LinearRing as an outer boundary of the Polygon.
171 
172  \see GeoDataLinearRing
173 */
174  void setOuterBoundary( const GeoDataLinearRing& boundary );
175 
176 /*!
177  \brief Returns a set of inner boundaries which are represented as LinearRings.
178 
179  \see GeoDataLinearRing
180 */
181  QVector<GeoDataLinearRing>& innerBoundaries();
182 
183 /*!
184  \brief Returns a set of inner boundaries which are represented as LinearRings.
185 
186  \see GeoDataLinearRing
187 */
188  const QVector<GeoDataLinearRing>& innerBoundaries() const;
189 
190 /*!
191  \brief Appends a given LinearRing as an inner boundary of the Polygon.
192 
193  \see GeoDataLinearRing
194 */
195  void appendInnerBoundary( const GeoDataLinearRing& boundary );
196 
197 /*!
198  \brief Returns whether the given coordinates lie within the polygon.
199 
200  \return <code>true</code> if the coordinates lie within the polygon
201  (and not in its holes), false otherwise.
202 */
203  virtual bool contains( const GeoDataCoordinates &coordinates ) const;
204 
205  // Serialization
206 /*!
207  \brief Serialize the Polygon to a stream.
208  \param stream the stream.
209 */
210  void pack( QDataStream& stream ) const override;
211 
212 
213 /*!
214  \brief Unserialize the Polygon from a stream.
215  \param stream the stream.
216 */
217  void unpack( QDataStream& stream ) override;
218 
219  int renderOrder() const;
220  void setRenderOrder(int);
221 
222  private:
223  Q_DECLARE_PRIVATE(GeoDataPolygon)
224 };
225 
226 class GEODATA_EXPORT GeoDataOuterBoundary : public GeoDataPolygon
227 {
228 };
229 
230 class GEODATA_EXPORT GeoDataInnerBoundary : public GeoDataPolygon
231 {
232 };
233 
234 }
235 
236 #endif // GEODATAPOLYGON_H
A 3d point representation.
A LinearRing that allows to store a closed, contiguous set of line segments.
Binds a QML item to a specific geodetic location in screen coordinates.
A base class for all geodata features.
A polygon that can have "holes".
A class that defines a 3D bounding box for geographic data.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Nov 26 2021 23:23:27 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.