~ubuntu-branches/ubuntu/quantal/marble/quantal

« back to all changes in this revision

Viewing changes to src/lib/geodata/data/GeoDataLatLonBox.h

  • Committer: Bazaar Package Importer
  • Author(s): Philip Muškovac
  • Date: 2011-07-11 15:43:02 UTC
  • Revision ID: james.westby@ubuntu.com-20110711154302-lq69ftcx125g1jx5
Tags: upstream-4.6.90+repack
Import upstream version 4.6.90+repack

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// This file is part of the Marble Virtual Globe.
 
3
//
 
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
 
6
// the source code.
 
7
//
 
8
// Copyright 2007      Andrew Manson  <g.real.ate@gmail.com>
 
9
// Copyright 2008-2009 Torsten Rahn   <rahn@kde.org>
 
10
//
 
11
 
 
12
 
 
13
#ifndef MARBLE_GEODATALATLONBOX_H
 
14
#define MARBLE_GEODATALATLONBOX_H
 
15
 
 
16
 
 
17
#include "global.h"
 
18
 
 
19
#include "GeoDataObject.h"
 
20
#include "GeoDataPoint.h"
 
21
 
 
22
#include "geodata_export.h"
 
23
 
 
24
namespace Marble
 
25
{
 
26
 
 
27
class GeoDataLatLonBoxPrivate;
 
28
 
 
29
class GeoDataLineString;
 
30
 
 
31
/**
 
32
 * @short A class that defines a 2D bounding box for geographic data.
 
33
 *
 
34
 * GeoDataLatLonBox is a 2D bounding box that describes a geographic area
 
35
 * in terms of latitude and longitude.
 
36
 *
 
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.
 
41
 *
 
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.
 
45
 *
 
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
 
48
 * the western one.
 
49
 */
 
50
 
 
51
class GEODATA_EXPORT GeoDataLatLonBox : public GeoDataObject
 
52
{
 
53
    friend bool operator==( GeoDataLatLonBox const& lhs, GeoDataLatLonBox const& rhs );
 
54
 
 
55
 public:
 
56
    GeoDataLatLonBox();
 
57
    GeoDataLatLonBox( qreal north, qreal south, qreal east, qreal west, GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian );
 
58
    GeoDataLatLonBox( const GeoDataLatLonBox & );
 
59
    virtual ~GeoDataLatLonBox();
 
60
 
 
61
    GeoDataLatLonBox& operator=( const GeoDataLatLonBox& other );
 
62
 
 
63
    /// Provides type information for downcasting a GeoData
 
64
    virtual const char* nodeType() const;
 
65
 
 
66
    /**
 
67
     * @brief Get the northern boundary of the bounding box.
 
68
     * @return the latitude of the northern boundary.
 
69
     */
 
70
    qreal north( GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian ) const;
 
71
    void setNorth( const qreal north, GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian );
 
72
 
 
73
    /**
 
74
     * @brief Get the southern boundary of the bounding box.
 
75
     * @return the latitude of the southern boundary.
 
76
     */
 
77
    qreal south( GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian ) const;
 
78
    void setSouth( const qreal south, GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian );
 
79
 
 
80
    /**
 
81
     * @brief Get the eastern boundary of the bounding box.
 
82
     * @return the longitude of the eastern boundary.
 
83
     */
 
84
    qreal east( GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian ) const;
 
85
    void setEast( const qreal east, GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian );
 
86
 
 
87
    /**
 
88
     * @brief Get the western boundary of the bounding box.
 
89
     * @return the longitude of the western boundary.
 
90
     */
 
91
    qreal west( GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian ) const;
 
92
    void setWest( const qreal west, GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian );
 
93
 
 
94
    /**
 
95
     * @brief Get the rotation of the bounding box.
 
96
     * @return the rotation of the bounding box.
 
97
     */
 
98
    qreal rotation( GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian ) const;
 
99
    void setRotation( const qreal rotation, GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian );
 
100
 
 
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 );
 
103
 
 
104
    /**
 
105
     * @brief Get the width of the longitude interval
 
106
     * @return the angle covered by the longitude range.
 
107
     */
 
108
    qreal width( GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian ) const;
 
109
 
 
110
    /**
 
111
     * @brief Get the height of the latitude interval
 
112
     * @return the angle covered by the latitude range.
 
113
     */
 
114
    qreal height( GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian ) const;
 
115
 
 
116
    /**
 
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.
 
120
     */
 
121
    bool     crossesDateLine() const;
 
122
 
 
123
    /**
 
124
     * @brief returns the center of this box
 
125
     * @return a coordinate, face-center of the box
 
126
     */
 
127
    virtual GeoDataCoordinates center() const;
 
128
 
 
129
    /**
 
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.
 
133
     */
 
134
    bool containsPole( Pole pole = AnyPole ) const;
 
135
 
 
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;
 
139
 
 
140
    virtual bool intersects( const GeoDataLatLonBox & ) const;
 
141
 
 
142
    /**
 
143
     * @brief Returns the bounding LatLonBox of this box with the given one.
 
144
     */
 
145
    GeoDataLatLonBox united( const GeoDataLatLonBox& other) const;
 
146
 
 
147
    /**
 
148
     * @brief Create the smallest bounding box from a line string.
 
149
     * @return the smallest bounding box that contains the linestring.
 
150
     */
 
151
    static GeoDataLatLonBox fromLineString( const GeoDataLineString& lineString );
 
152
 
 
153
    /**
 
154
     * @brief Creates a text string of the bounding box
 
155
     */
 
156
    virtual QString toString( GeoDataCoordinates::Unit unit = GeoDataCoordinates::Radian ) const;
 
157
 
 
158
    /**
 
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.
 
161
     */
 
162
    virtual bool isNull() const;
 
163
 
 
164
    /**
 
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.
 
167
     */
 
168
    virtual bool isEmpty() const;
 
169
 
 
170
    GeoDataLatLonBox operator|( const GeoDataLatLonBox& other ) const;
 
171
 
 
172
    /**
 
173
     * @brief Unites this bounding box with the given one.
 
174
     * @return Returns a reference to self.
 
175
     */
 
176
    GeoDataLatLonBox& operator |=( const GeoDataLatLonBox& other) ;
 
177
 
 
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 );
 
182
 
 
183
 private:
 
184
    GeoDataLatLonBoxPrivate  * const d;
 
185
};
 
186
 
 
187
}
 
188
 
 
189
#endif