2
// This file is part of the Marble Virtual Globe.
4
// This program is free software licensed under the GNU LGPL. You can
5
// find a copy of this license in LICENSE.txt in the top directory of
8
// Copyright 2007 Andrew Manson <g.real.ate@gmail.com>
9
// Copyright 2008-2009 Torsten Rahn <rahn@kde.org>
13
#ifndef MARBLE_GEODATALATLONBOX_H
14
#define MARBLE_GEODATALATLONBOX_H
19
#include "GeoDataObject.h"
20
#include "GeoDataPoint.h"
22
#include "geodata_export.h"
27
class GeoDataLatLonBoxPrivate;
29
class GeoDataLineString;
32
* @short A class that defines a 2D bounding box for geographic data.
34
* GeoDataLatLonBox is a 2D bounding box that describes a geographic area
35
* in terms of latitude and longitude.
37
* The bounding box gets described by assigning the northern, southern,
38
* eastern and western boundary.
39
* So usually the value of the eastern boundary is bigger than the
40
* value of the western boundary.
42
* This is also true if the GeoDataLatLonBox covers the whole longitude
43
* range from 180 deg West to 180 deg East. Notably in this case
44
* the bounding box crosses the date line.
46
* If the GeoDataLatLonBox does not cover the whole longitude range but still
47
* crosses the date line then the eastern boundary has got a smaller value than
51
class GEODATA_EXPORT GeoDataLatLonBox : public GeoDataObject
53
friend bool operator==( GeoDataLatLonBox const& lhs, GeoDataLatLonBox const& rhs );
57
GeoDataLatLonBox( qreal north, qreal south, qreal east, qreal west, GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian );
58
GeoDataLatLonBox( const GeoDataLatLonBox & );
59
virtual ~GeoDataLatLonBox();
61
GeoDataLatLonBox& operator=( const GeoDataLatLonBox& other );
63
/// Provides type information for downcasting a GeoData
64
virtual const char* nodeType() const;
67
* @brief Get the northern boundary of the bounding box.
68
* @return the latitude of the northern boundary.
70
qreal north( GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian ) const;
71
void setNorth( const qreal north, GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian );
74
* @brief Get the southern boundary of the bounding box.
75
* @return the latitude of the southern boundary.
77
qreal south( GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian ) const;
78
void setSouth( const qreal south, GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian );
81
* @brief Get the eastern boundary of the bounding box.
82
* @return the longitude of the eastern boundary.
84
qreal east( GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian ) const;
85
void setEast( const qreal east, GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian );
88
* @brief Get the western boundary of the bounding box.
89
* @return the longitude of the western boundary.
91
qreal west( GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian ) const;
92
void setWest( const qreal west, GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian );
95
* @brief Get the rotation of the bounding box.
96
* @return the rotation of the bounding box.
98
qreal rotation( GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian ) const;
99
void setRotation( const qreal rotation, GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian );
101
void boundaries( qreal &north, qreal &south, qreal &east, qreal &west, GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian ) const;
102
void setBoundaries( qreal north, qreal south, qreal east, qreal west, GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian );
105
* @brief Get the width of the longitude interval
106
* @return the angle covered by the longitude range.
108
qreal width( GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian ) const;
111
* @brief Get the height of the latitude interval
112
* @return the angle covered by the latitude range.
114
qreal height( GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian ) const;
117
* @brief Detect whether the bounding box crosses the IDL.
118
* @return @c true the bounding box crosses the +/-180 deg longitude.
119
* @c false the bounding box doesn't cross the +/-180 deg longitude.
121
bool crossesDateLine() const;
124
* @brief returns the center of this box
125
* @return a coordinate, face-center of the box
127
virtual GeoDataCoordinates center() const;
130
* @brief Detect whether the bounding box contains one of the poles.
131
* @return @c true the bounding box contains one of the poles.
132
* @c false the bounding box doesn't contain one of the poles.
134
bool containsPole( Pole pole = AnyPole ) const;
136
virtual bool contains( const GeoDataPoint & ) const; // NOTE: Why do we need this one?
137
virtual bool contains( const GeoDataCoordinates & ) const;
138
bool contains( const GeoDataLatLonBox & ) const;
140
virtual bool intersects( const GeoDataLatLonBox & ) const;
143
* @brief Returns the bounding LatLonBox of this box with the given one.
145
GeoDataLatLonBox united( const GeoDataLatLonBox& other) const;
148
* @brief Create the smallest bounding box from a line string.
149
* @return the smallest bounding box that contains the linestring.
151
static GeoDataLatLonBox fromLineString( const GeoDataLineString& lineString );
154
* @brief Creates a text string of the bounding box
156
virtual QString toString( GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian ) const;
159
* @brief Indicates whether the bounding box only contains a single 2D point ("singularity").
160
* @return Return value is true if the height and the width of the bounding box equal zero.
162
virtual bool isNull() const;
165
* @brief Indicates whether the bounding box is not initialised (and contains all).
166
* @return Return value is true if bounding box is not initialised.
168
virtual bool isEmpty() const;
170
GeoDataLatLonBox operator|( const GeoDataLatLonBox& other ) const;
173
* @brief Unites this bounding box with the given one.
174
* @return Returns a reference to self.
176
GeoDataLatLonBox& operator |=( const GeoDataLatLonBox& other) ;
178
/// Serialize the contents of the feature to @p stream.
179
virtual void pack( QDataStream& stream ) const;
180
/// Unserialize the contents of the feature from @p stream.
181
virtual void unpack( QDataStream& stream );
184
GeoDataLatLonBoxPrivate * const d;