Marble

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

KDE's Doxygen guidelines are available online.