Marble

AbstractProjection.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2007-2008 Inge Wallin <ingwa@kde.org>
4// SPDX-FileCopyrightText: 2007-2012 Torsten Rahn <rahn@kde.org>
5//
6
7#ifndef MARBLE_ABSTRACTPROJECTION_H
8#define MARBLE_ABSTRACTPROJECTION_H
9
10/** @file
11 * This file contains the headers for AbstractProjection.
12 *
13 * @author Inge Wallin <inge@lysator.liu.se>
14 * @author Torsten Rahn <rahn@kde.org>
15 */
16
17#include <QList>
18
19#include "GeoDataCoordinates.h"
20#include "marble_export.h"
21
22class QIcon;
23class QPainterPath;
24class QPolygonF;
25class QRect;
26class QString;
27
28namespace Marble
29{
30
31// The manhattan distance in pixels at which extra nodes get created for tessellation.
32static const int tessellationPrecision = 10;
33static const int latLonAltBoxSamplingRate = 4;
34
35class GeoDataLineString;
36class GeoDataLatLonAltBox;
37class ViewportParams;
38class AbstractProjectionPrivate;
39
40/**
41 * @short A base class for all projections in Marble.
42 */
43
44class MARBLE_EXPORT AbstractProjection
45{
46 // Not a QObject so far because we don't need to send signals.
47public:
48 enum SurfaceType {
49 Cylindrical,
50 Pseudocylindrical,
51 Hybrid,
52 Conical,
53 Pseudoconical,
54 Azimuthal
55 };
56
57 enum PreservationType {
58 NoPreservation,
59 Conformal,
60 EqualArea
61 };
62
63 /**
64 * @brief Construct a new AbstractProjection.
65 */
67
68 virtual ~AbstractProjection();
69
70 /**
71 * @brief Returns the user-visible name of the projection.
72 *
73 * Example: "Mercator"
74 */
75 virtual QString name() const = 0;
76
77 /**
78 * @brief Returns a short user description of the projection
79 * that can be used in tooltips or dialogs.
80 */
81 virtual QString description() const = 0;
82
83 /**
84 * @brief Returns an icon for the projection.
85 */
86 virtual QIcon icon() const = 0;
87
88 /**
89 * @brief Returns the maximum (northern) latitude that is mathematically defined and reasonable.
90 *
91 * Example: For many projections the value will represent +90 degrees in Radian.
92 * In the case of Mercator this value will equal +85.05113 degrees in Radian.
93 */
94 virtual qreal maxValidLat() const;
95
96 /**
97 * @brief Returns the arbitrarily chosen maximum (northern) latitude.
98 * By default this value is equal to the value defined inside maxValidLat().
99 * In general this value can only be smaller or equal to maxValidLat().
100 */
101 qreal maxLat() const;
102 void setMaxLat(qreal maxLat);
103
104 /**
105 * @brief Returns the minimum (southern) latitude that is mathematically defined and reasonable.
106 *
107 * Example: For many projections the value will represent -90 degrees in Radian.
108 * In the case of Mercator this value will equal -85.05113 degrees in Radian.
109 */
110 virtual qreal minValidLat() const;
111
112 /**
113 * @brief Returns the arbitrarily chosen minimum (southern) latitude.
114 * By default this value is equal to the value defined inside minValidLat().
115 * In general this value can only be larger or equal to minValidLat().
116 */
117 qreal minLat() const;
118 void setMinLat(qreal minLat);
119
120 /**
121 * @brief Returns whether the projection allows for wrapping in x direction (along the longitude scale).
122 *
123 * Example: Cylindrical projections allow for repeating.
124 */
125 virtual bool repeatableX() const;
126
127 /**
128 * @brief Returns whether the projection allows to navigate seamlessly "over" the pole.
129 *
130 * Example: Azimuthal projections.
131 */
132 virtual bool traversablePoles() const;
133 virtual bool traversableDateLine() const;
134
135 virtual SurfaceType surfaceType() const = 0;
136
137 virtual PreservationType preservationType() const;
138
139 // The projection surface can have different orientations:
140 // - normal: the surface's axis of symmetry matches the Earth's axis
141 // - transverse: orthogonally oriented compared to the Earth's axis
142 // - oblique: somewhere in between
143
144 virtual bool isOrientedNormal() const;
145
146 /**
147 * @brief Defines whether a projection is supposed to be clipped to a certain radius.
148 *
149 * Example: The Gnomonic projection is clipped to a circle of a certain clipping radius
150 * (although it's mathematically defined beyond that radius).
151 */
152 virtual bool isClippedToSphere() const;
153
154 virtual qreal clippingRadius() const;
155
156 /**
157 * @brief Get the screen coordinates corresponding to geographical coordinates in the map.
158 * @param lon the lon coordinate of the requested pixel position in radians
159 * @param lat the lat coordinate of the requested pixel position in radians
160 * @param viewport the viewport parameters
161 * @param x the x coordinate of the pixel is returned through this parameter
162 * @param y the y coordinate of the pixel is returned through this parameter
163 * @return @c true if the geographical coordinates are visible on the screen
164 * @c false if the geographical coordinates are not visible on the screen
165 *
166 * @see ViewportParams
167 */
168 bool screenCoordinates(const qreal lon, const qreal lat, const ViewportParams *viewport, qreal &x, qreal &y) const;
169
170 /**
171 * @brief Get the screen coordinates corresponding to geographical coordinates in the map.
172 *
173 * @param geopoint the point on earth, including altitude, that we want the coordinates for.
174 * @param viewport the viewport parameters
175 * @param x the x coordinate of the pixel is returned through this parameter
176 * @param y the y coordinate of the pixel is returned through this parameter
177 * @param globeHidesPoint whether the point gets hidden on the far side of the earth
178 *
179 * @return @c true if the geographical coordinates are visible on the screen
180 * @c false if the geographical coordinates are not visible on the screen
181 *
182 * @see ViewportParams
183 */
184 virtual bool screenCoordinates(const GeoDataCoordinates &geopoint, const ViewportParams *viewport, qreal &x, qreal &y, bool &globeHidesPoint) const = 0;
185
186 // Will just call the virtual version with a dummy globeHidesPoint.
187 bool screenCoordinates(const GeoDataCoordinates &geopoint, const ViewportParams *viewport, qreal &x, qreal &y) const;
188
189 /**
190 * @brief Get the coordinates of screen points for geographical coordinates in the map.
191 *
192 * @param coordinates the point on earth, including altitude, that we want the coordinates for.
193 * @param viewport the viewport parameters
194 * @param x the x coordinates of the pixels are returned through this parameter
195 * @param y the y coordinate of the pixel is returned through this parameter
196 * @param pointRepeatNum the amount of times that a single geographical
197 point gets represented on the map
198 * @param size the size
199 * @param globeHidesPoint whether the point gets hidden on the far side of the earth
200 *
201 * @return @c true if the geographical coordinates are visible on the screen
202 * @c false if the geographical coordinates are not visible on the screen
203 *
204 * @see ViewportParams
205 */
206 virtual bool screenCoordinates(const GeoDataCoordinates &coordinates,
207 const ViewportParams *viewport,
208 qreal *x,
209 qreal &y,
210 int &pointRepeatNum,
211 const QSizeF &size,
212 bool &globeHidesPoint) const = 0;
213
214 virtual bool screenCoordinates(const GeoDataLineString &lineString, const ViewportParams *viewport, QList<QPolygonF *> &polygons) const = 0;
215
216 /**
217 * @brief Get the earth coordinates corresponding to a pixel in the map.
218 * @param x the x coordinate of the pixel
219 * @param y the y coordinate of the pixel
220 * @param viewport the viewport parameters
221 * @param lon the longitude angle is returned through this parameter
222 * @param lat the latitude angle is returned through this parameter
223 * @param unit the unit of the angles for lon and lat.
224 * @return @c true if the pixel (x, y) is within the globe
225 * @c false if the pixel (x, y) is outside the globe, i.e. in space.
226 */
227 virtual bool geoCoordinates(const int x,
228 const int y,
229 const ViewportParams *viewport,
230 qreal &lon,
231 qreal &lat,
232 GeoDataCoordinates::Unit unit = GeoDataCoordinates::Degree) const = 0;
233
234 /**
235 * @brief Returns a GeoDataLatLonAltBox bounding box of the given screenrect inside the given viewport.
236 */
237 virtual GeoDataLatLonAltBox latLonAltBox(const QRect &screenRect, const ViewportParams *viewport) const;
238
239 /**
240 * @brief Returns whether the projected data fully obstructs the current viewport.
241 * In this case there are no black areas visible around the actual map.
242 * This case allows for performance optimizations.
243 */
244 virtual bool mapCoversViewport(const ViewportParams *viewport) const = 0;
245
246 /**
247 * @brief Returns the shape/outline of a map projection.
248 * This call allows e.g. to draw the default background color of the map itself.
249 *
250 * Example: For an azimuthal projection a circle is returned at low zoom values.
251 */
252 virtual QPainterPath mapShape(const ViewportParams *viewport) const = 0;
253
254 QRegion mapRegion(const ViewportParams *viewport) const;
255
256protected:
258 explicit AbstractProjection(AbstractProjectionPrivate *dd);
259
260private:
261 Q_DECLARE_PRIVATE(AbstractProjection)
262 Q_DISABLE_COPY(AbstractProjection)
263};
264
265}
266
267#endif
A base class for all projections in Marble.
virtual bool mapCoversViewport(const ViewportParams *viewport) const =0
Returns whether the projected data fully obstructs the current viewport.
virtual bool screenCoordinates(const GeoDataCoordinates &coordinates, const ViewportParams *viewport, qreal *x, qreal &y, int &pointRepeatNum, const QSizeF &size, bool &globeHidesPoint) const =0
Get the coordinates of screen points for geographical coordinates in the map.
virtual bool geoCoordinates(const int x, const int y, const ViewportParams *viewport, qreal &lon, qreal &lat, GeoDataCoordinates::Unit unit=GeoDataCoordinates::Degree) const =0
Get the earth coordinates corresponding to a pixel in the map.
virtual QPainterPath mapShape(const ViewportParams *viewport) const =0
Returns the shape/outline of a map projection.
virtual bool screenCoordinates(const GeoDataCoordinates &geopoint, const ViewportParams *viewport, qreal &x, qreal &y, bool &globeHidesPoint) const =0
Get the screen coordinates corresponding to geographical coordinates in the map.
virtual QIcon icon() const =0
Returns an icon for the projection.
virtual QString name() const =0
Returns the user-visible name of the projection.
virtual QString description() const =0
Returns a short user description of the projection that can be used in tooltips or dialogs.
A 3d point representation.
Unit
enum used constructor to specify the units used
A class that defines a 3D bounding box for geographic data.
A LineString that allows to store a contiguous set of line segments.
A public class that controls what is visible in the viewport of a Marble map.
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 Sat Dec 21 2024 17:04:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.