File indexing completed on 2024-05-05 03:49:52

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_EQUIRECTPROJECTION_H
0009 #define MARBLE_EQUIRECTPROJECTION_H
0010 
0011 
0012 /** @file
0013  * This file contains the headers for EquirectProjection.
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 
0023 namespace Marble
0024 {
0025 
0026 /**
0027  * @short A class to implement the Equirectangular projection used by the "Flat Map" view.
0028  */
0029 
0030 class EquirectProjection : public CylindricalProjection
0031 {
0032     // Not a QObject so far because we don't need to send signals.
0033  public:
0034 
0035     /**
0036      * @brief Construct a new EquirectProjection.
0037      */
0038     EquirectProjection();
0039 
0040     ~EquirectProjection() override;
0041 
0042     /**
0043      * @brief Returns the user-visible name of the projection.
0044      */
0045     QString name() const override;
0046 
0047     /**
0048      * @brief Returns a short user description of the projection
0049      * that can be used in tooltips or dialogs.
0050      */
0051     QString description() const override;
0052 
0053     /**
0054      * @brief Returns an icon for the projection.
0055      */
0056     QIcon icon() const override;
0057 
0058     PreservationType preservationType() const override { return NoPreservation; }
0059 
0060     /**
0061      * @brief Get the screen coordinates corresponding to geographical coordinates in the map.
0062      * @param coordinates  the coordinates of the requested pixel position
0063      * @param params the viewport parameters
0064      * @param x      the x coordinate of the pixel is returned through this parameter
0065      * @param y      the y coordinate of the pixel is returned through this parameter
0066      * @param globeHidesPoint whether the globe hides the point
0067      * @return @c true  if the geographical coordinates are visible on the screen
0068      *         @c false if the geographical coordinates are not visible on the screen
0069      */
0070     bool screenCoordinates( const GeoDataCoordinates &coordinates,
0071                             const ViewportParams *params,
0072                             qreal &x, qreal &y, bool &globeHidesPoint ) const override;
0073 
0074     bool screenCoordinates( const GeoDataCoordinates &coordinates,
0075                             const ViewportParams *viewport,
0076                             qreal *x, qreal &y, int &pointRepeatNum,
0077                             const QSizeF& size,
0078                             bool &globeHidesPoint ) const override;
0079 
0080     using CylindricalProjection::screenCoordinates;
0081 
0082     /**
0083      * @brief Get the earth coordinates corresponding to a pixel in the map.
0084      *
0085      * If the pixel (x, y) is outside the globe, only @p lon will be calculated,
0086      * and lat will be unchanged.
0087      *
0088      * @param x      the x coordinate of the pixel
0089      * @param y      the y coordinate of the pixel
0090      * @param params parameters of the viewport
0091      * @param lon    the longitude angle is returned through this parameter
0092      * @param lat    the latitude angle is returned through this parameter
0093      * @param unit   the unit
0094      * @return @c true  if the pixel (x, y) is within the map
0095      *         @c false if the pixel (x, y) is above or underneath the map
0096      */
0097     bool geoCoordinates( const int x, const int y,
0098                          const ViewportParams *params,
0099                          qreal& lon, qreal& lat,
0100                          GeoDataCoordinates::Unit unit = GeoDataCoordinates::Degree ) const override;
0101 
0102     GeoDataLatLonAltBox latLonAltBox( const QRect& screenRect,
0103                                       const ViewportParams *viewport ) const override;
0104 
0105     bool mapCoversViewport( const ViewportParams *viewport ) const override;
0106 
0107  private:
0108     Q_DISABLE_COPY( EquirectProjection )
0109 };
0110 
0111 }
0112 
0113 #endif