File indexing completed on 2024-05-12 03:50:12

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2007 Andrew Manson <g.real.ate@gmail.com>
0004 // SPDX-FileCopyrightText: 2008 Torsten Rahn <rahn@kde.org>
0005 //
0006 
0007 
0008 #ifndef MARBLE_GEODATALATLONALTBOX_H
0009 #define MARBLE_GEODATALATLONALTBOX_H
0010 
0011 
0012 #include "MarbleGlobal.h"
0013 
0014 #include "geodata_export.h"
0015 
0016 #include "GeoDataLatLonBox.h"
0017 
0018 #include <QHash>
0019 
0020 namespace Marble
0021 {
0022 
0023 class GeoDataLatLonAltBoxPrivate;
0024 
0025 class GeoDataLineString;
0026 
0027 
0028 /**
0029  * @short A class that defines a 3D bounding box for geographic data.
0030  *
0031  * GeoDataLatLonAltBox is a 3D bounding box that describes a geographic area
0032  * in terms of latitude, longitude and altitude.
0033  *
0034  * The bounding box gets described by assigning the northern, southern, 
0035  * eastern and western boundary.
0036  * So usually the value of the eastern boundary is bigger than the
0037  * value of the western boundary. Only if the bounding box crosses the
0038  * date line then the eastern boundary has got a smaller value than 
0039  * the western one.
0040  */
0041 
0042 class GEODATA_EXPORT GeoDataLatLonAltBox : public GeoDataLatLonBox
0043 {
0044     friend bool GEODATA_EXPORT operator==( GeoDataLatLonAltBox const& lhs, GeoDataLatLonAltBox const& rhs );
0045 
0046  public:
0047     GeoDataLatLonAltBox();
0048     GeoDataLatLonAltBox( const GeoDataLatLonAltBox & other );
0049     GeoDataLatLonAltBox( const GeoDataLatLonBox &other, qreal minAltitude, qreal maxAltitude );
0050     /**
0051      * @brief A LatLonAltBox with the data from a GeoDataCoordinate
0052      * This way of creating a GeoDataLatLonAltBox sets the north and south
0053      * values of this box to the Latitude value in the GeoDataCoordinate,
0054      * resulting in a Box that has a 0 Area. This is useful for building
0055      * LatLonAltBoxes from GeoDataCoordinates.
0056      */
0057     explicit GeoDataLatLonAltBox( const GeoDataCoordinates & coordinates );
0058     
0059     ~GeoDataLatLonAltBox() override;
0060 
0061     GeoDataLatLonAltBox& operator=( const GeoDataLatLonAltBox& other );
0062     GeoDataLatLonAltBox& operator=( const GeoDataCoordinates& other );
0063 
0064     /// Provides type information for downcasting a GeoData
0065     const char* nodeType() const override;
0066 
0067     /**
0068      * @brief qHash, for using GeoDataLatLonAltBox in a QCache as Key
0069      * @return the hash of the GeoDataLatLonAltBox
0070      */
0071     uint qHash(const GeoDataLatLonAltBox &);
0072 
0073     /**
0074      * @brief Get the lower altitude boundary of the bounding box.
0075      * @return the height of the lower altitude boundary in meters.
0076      */
0077     qreal minAltitude() const;
0078     void setMinAltitude( const qreal minAltitude );
0079 
0080     /**
0081      * @brief Get the upper altitude boundary of the bounding box.
0082      * @return the height of the upper altitude boundary in meters.
0083      */
0084     qreal maxAltitude() const;
0085     void setMaxAltitude( const qreal maxAltitude );
0086 
0087     /**
0088      * @brief Get the reference system for the altitude.
0089      * @return the point of reference which marks the origin 
0090      * for measuring the altitude.
0091      */
0092     AltitudeMode altitudeMode() const;
0093     void setAltitudeMode( const AltitudeMode altitudeMode );
0094 
0095     bool contains( const GeoDataCoordinates & ) const override;
0096     bool     contains( const GeoDataLatLonAltBox & ) const;
0097 
0098     /**
0099      * @brief Check if this GeoDataLatLonAltBox intersects with the given one.
0100      */
0101     virtual bool intersects( const GeoDataLatLonAltBox & ) const;
0102 
0103     using GeoDataLatLonBox::intersects;
0104 
0105     /**
0106      * @brief Create the smallest bounding box from a line string.
0107      * @return the smallest bounding box that contains the linestring.
0108      */
0109     static GeoDataLatLonAltBox fromLineString( const GeoDataLineString& lineString );
0110 
0111     /**
0112      * @brief Indicates whether the bounding box only contains a single 2D point ("singularity").
0113      * @return Return value is true if the height and the width of the bounding box equal zero.
0114      */
0115     bool isNull() const override;
0116 
0117     /**
0118      * @brief Resets the bounding box to its uninitialised state (and thus contains nothing).
0119      */
0120     void clear() override;
0121 
0122     /**
0123      * @brief returns the center of this box
0124      * @return a coordinate, body-center of the box
0125      */
0126     GeoDataCoordinates center() const override;
0127 
0128     /// Serialize the contents of the feature to @p stream.
0129     void pack( QDataStream& stream ) const override;
0130     /// Unserialize the contents of the feature from @p stream.
0131     void unpack( QDataStream& stream ) override;
0132 
0133  private:
0134     GeoDataLatLonAltBoxPrivate  * const d;
0135 };
0136 
0137 uint GEODATA_EXPORT qHash(const GeoDataLatLonAltBox &box, uint seed = 0);
0138 
0139 bool GEODATA_EXPORT operator==( GeoDataLatLonAltBox const& lhs, GeoDataLatLonAltBox const& rhs );
0140 
0141 }
0142 
0143 Q_DECLARE_METATYPE( Marble::GeoDataLatLonAltBox )
0144 
0145 #endif