File indexing completed on 2025-01-05 03:59:33
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2007 Inge Wallin <ingwa@kde.org> 0004 // SPDX-FileCopyrightText: 2007-2012 Torsten Rahn <rahn@kde.org> 0005 // 0006 0007 0008 #ifndef MARBLE_MERCATORPROJECTION_H 0009 #define MARBLE_MERCATORPROJECTION_H 0010 0011 0012 /** @file 0013 * This file contains the headers for MercatorProjection. 0014 * 0015 * @author Inge Wallin <inge@lysator.liu.se> 0016 * @author Torsten Rahn <rahn@kde.org> 0017 */ 0018 0019 0020 #include "CylindricalProjection.h" 0021 0022 namespace Marble 0023 { 0024 0025 /** 0026 * @short A class to implement the Mercator projection. 0027 */ 0028 0029 class MercatorProjection : public CylindricalProjection 0030 { 0031 // Not a QObject so far because we don't need to send signals. 0032 public: 0033 0034 /** 0035 * @brief Construct a new MercatorProjection. 0036 */ 0037 MercatorProjection(); 0038 0039 ~MercatorProjection() override; 0040 0041 /** 0042 * @brief Returns the user-visible name of the projection. 0043 */ 0044 QString name() const override; 0045 0046 /** 0047 * @brief Returns a short user description of the projection 0048 * that can be used in tooltips or dialogs. 0049 */ 0050 QString description() const override; 0051 0052 /** 0053 * @brief Returns an icon for the projection. 0054 */ 0055 QIcon icon() const override; 0056 0057 qreal maxValidLat() const override; 0058 qreal minValidLat() const override; 0059 0060 PreservationType preservationType() const override { return Conformal; } 0061 0062 /** 0063 * @brief Get the screen coordinates corresponding to geographical coordinates in the map. 0064 * @param coordinates the coordinates of the requested pixel position 0065 * @param params the viewport parameters 0066 * @param x the x coordinate of the pixel is returned through this parameter 0067 * @param y the y coordinate of the pixel is returned through this parameter 0068 * @param globeHidesPoint whether the globe hides the point 0069 * @return @c true if the geographical coordinates are visible on the screen 0070 * @c false if the geographical coordinates are not visible on the screen 0071 */ 0072 bool screenCoordinates( const GeoDataCoordinates &coordinates, 0073 const ViewportParams *params, 0074 qreal &x, qreal &y, bool &globeHidesPoint ) const override; 0075 0076 bool screenCoordinates( const GeoDataCoordinates &coordinates, 0077 const ViewportParams * viewport, 0078 qreal *x, qreal &y, int &pointRepeatNum, 0079 const QSizeF& size, 0080 bool &globeHidesPoint ) const override; 0081 0082 using CylindricalProjection::screenCoordinates; 0083 0084 /** 0085 * @brief Get the earth coordinates corresponding to a pixel in the map. 0086 * 0087 * If the pixel (x, y) is outside the globe, only @p lon will be calculated, 0088 * and lat will be unchanged. 0089 * 0090 * @param x the x coordinate of the pixel 0091 * @param y the y coordinate of the pixel 0092 * @param params the viewport parameters 0093 * @param lon the longitude angle is returned through this parameter 0094 * @param lat the latitude angle is returned through this parameter 0095 * @param unit the unit 0096 * @return @c true if the pixel (x, y) is within the globe 0097 * @c false if the pixel (x, y) is outside the globe, i.e. in space. 0098 */ 0099 bool geoCoordinates( const int x, const int y, 0100 const ViewportParams *params, 0101 qreal& lon, qreal& lat, 0102 GeoDataCoordinates::Unit = GeoDataCoordinates::Degree ) const override; 0103 0104 GeoDataLatLonAltBox latLonAltBox( const QRect &screenRect, 0105 const ViewportParams *viewport ) const override; 0106 0107 bool mapCoversViewport( const ViewportParams *viewport ) const override; 0108 0109 private: 0110 mutable qreal m_lastCenterLat; 0111 mutable qreal m_lastCenterLatInv; 0112 0113 Q_DISABLE_COPY( MercatorProjection ) 0114 }; 0115 0116 } 0117 0118 #endif