~ubuntu-branches/ubuntu/wily/marble/wily

« back to all changes in this revision

Viewing changes to src/lib/marble/geodata/data/GeoDataLatLonBox.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell, José Manuel Santamaría Lema, Jonathan Riddell, Philip Muškovac
  • Date: 2015-08-13 11:44:25 UTC
  • mfrom: (1.5.12)
  • Revision ID: package-import@ubuntu.com-20150813114425-kdwa08ijv9p1f1rt
Tags: 4:15.08.0-0ubuntu1
[ José Manuel Santamaría Lema ]
* Update symbols: mark as optional symbols gone after building with
  GCC 5

[ Jonathan Riddell ]
* New upstream release
* Port to frameworks 5
* new upstream beta release

[ Philip Muškovac ]
* Add upstream_fix-vtable-linking.diff to fix vtable linking

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
#include "GeoDataTypes.h"
20
20
 
 
21
#include <QDataStream>
 
22
 
21
23
namespace Marble
22
24
{
23
25
 
235
237
 
236
238
qreal GeoDataLatLonBox::width( GeoDataCoordinates::Unit unit ) const
237
239
{
238
 
    qreal width = fabs( (qreal)( crossesDateLine() 
239
 
                                     ? 2 * M_PI - d->m_west + d->m_east
240
 
                                     : d->m_east - d->m_west ) );
 
240
    return GeoDataLatLonBox::width( d->m_east, d->m_west, unit );
 
241
}
 
242
 
 
243
qreal GeoDataLatLonBox::width( qreal east, qreal west, GeoDataCoordinates::Unit unit )
 
244
{
 
245
    qreal width = fabs( (qreal)( GeoDataLatLonBox::crossesDateLine(east, west)
 
246
                                     ? 2 * M_PI - west + east
 
247
                                     : east - west ) );
241
248
 
242
249
    // This also covers the case where this bounding box covers the whole
243
250
    // longitude range ( -180 <= lon <= + 180 ).
254
261
 
255
262
qreal GeoDataLatLonBox::height( GeoDataCoordinates::Unit unit ) const
256
263
{
257
 
    qreal height = fabs( (qreal)( d->m_south - d->m_north ) );
 
264
    return GeoDataLatLonBox::height(d->m_north, d->m_south, unit);
 
265
}
 
266
 
 
267
qreal GeoDataLatLonBox::height(qreal north, qreal south, GeoDataCoordinates::Unit unit)
 
268
{
 
269
    qreal height = fabs( (qreal)( south - north ) );
258
270
 
259
271
    if ( unit == GeoDataCoordinates::Degree ) {
260
272
        return height * RAD2DEG;
265
277
 
266
278
bool GeoDataLatLonBox::crossesDateLine() const
267
279
{
268
 
    if ( d->m_east < d->m_west ||
269
 
         ( d->m_east == M_PI && d->m_west == -M_PI ) ) {
 
280
    return GeoDataLatLonBox::crossesDateLine(d->m_east, d->m_west);
 
281
}
 
282
 
 
283
bool GeoDataLatLonBox::crossesDateLine(qreal east, qreal west)
 
284
{
 
285
    if ( east < west || ( east == M_PI && west == -M_PI ) ) {
270
286
        return true;
271
287
    }
272
 
 
273
288
    return false;
274
289
}
275
290
 
306
321
    return false;
307
322
}
308
323
 
309
 
bool GeoDataLatLonBox::contains( const GeoDataCoordinates &point ) const
 
324
bool GeoDataLatLonBox::contains(qreal lon, qreal lat) const
310
325
{
311
 
    qreal lon, lat;
312
 
 
313
 
    point.geoCoordinates( lon, lat );
314
 
 
315
326
    // We need to take care of the normal case ...
316
327
    if ( ( ( lon < d->m_west || lon > d->m_east ) && ( d->m_west < d->m_east ) ) ||
317
328
    // ... and the case where the bounding box crosses the date line:
318
329
         ( ( lon < d->m_west && lon > d->m_east ) && ( d->m_west > d->m_east ) ) )
319
330
        return false;
320
 
    
 
331
 
321
332
    if ( lat < d->m_south || lat > d->m_north )
322
333
        return false;
323
334
 
324
335
    return true;
325
336
}
326
337
 
 
338
bool GeoDataLatLonBox::contains( const GeoDataCoordinates &point ) const
 
339
{
 
340
    qreal lon, lat;
 
341
 
 
342
    point.geoCoordinates( lon, lat );
 
343
 
 
344
    return contains(lon, lat);
 
345
}
 
346
 
327
347
bool GeoDataLatLonBox::contains( const GeoDataLatLonBox &other ) const
328
348
{
329
349
    // check the contain criterion for the latitude first as this is trivial: