GeoDataLineString_p.h 3.17 KB
Newer Older
1
//
2
// This file is part of the Marble Virtual Globe.
3 4 5 6 7 8 9 10
//
// This program is free software licensed under the GNU LGPL. You can
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
// Copyright 2009      Patrick Spendrin <ps_ml@gmx.de>
//

11 12
#ifndef MARBLE_GEODATALINESTRINGPRIVATE_H
#define MARBLE_GEODATALINESTRINGPRIVATE_H
13 14 15

#include "GeoDataGeometry_p.h"

16 17
#include "GeoDataTypes.h"

18 19 20
namespace Marble
{

21
class GeoDataLineStringPrivate : public GeoDataGeometryPrivate
22 23
{
  public:
Benjamin Kaiser's avatar
Benjamin Kaiser committed
24
    explicit GeoDataLineStringPrivate( TessellationFlags f )
25 26
        :  m_rangeCorrected( 0 ),
           m_dirtyRange( true ),
Torsten Rahn's avatar
 
Torsten Rahn committed
27
           m_dirtyBox( true ),
28 29 30
           m_tessellationFlags( f ),
           m_previousResolution( -1 ),
           m_level( -1 )
31 32 33 34
    {
    }

    GeoDataLineStringPrivate()
35 36
         : m_rangeCorrected( 0 ),
           m_dirtyRange( true ),
Torsten Rahn's avatar
 
Torsten Rahn committed
37
           m_dirtyBox( true )
38 39 40
    {
    }

Michael Jansen's avatar
Michael Jansen committed
41 42
    ~GeoDataLineStringPrivate()
    {
43
        delete m_rangeCorrected;
Michael Jansen's avatar
Michael Jansen committed
44 45
    }

46
    GeoDataLineStringPrivate& operator=( const GeoDataLineStringPrivate &other)
47 48 49
    {
        GeoDataGeometryPrivate::operator=( other );
        m_vector = other.m_vector;
50 51
        m_rangeCorrected = 0;
        m_dirtyRange = true;
52 53
        m_dirtyBox = other.m_dirtyBox;
        m_tessellationFlags = other.m_tessellationFlags;
54
        return *this;
55 56 57
    }


Patrick Spendrin's avatar
Patrick Spendrin committed
58
    virtual GeoDataGeometryPrivate* copy()
59
    { 
60 61 62
        GeoDataLineStringPrivate* copy = new GeoDataLineStringPrivate;
        *copy = *this;
        return copy;
63 64
    }

65
    virtual const char* nodeType() const
66 67 68 69
    {
        return GeoDataTypes::GeoDataLineStringType;
    }

70 71 72 73
    virtual EnumGeometryId geometryId() const 
    {
        return GeoDataLineStringId;
    }
74

75
    void toPoleCorrected( const GeoDataLineString & q, GeoDataLineString & poleCorrected ) const;
76 77

    void toDateLineCorrected( const GeoDataLineString & q,
78
                              QVector<GeoDataLineString*> & lineStrings ) const;
79

80 81 82 83
    void interpolateDateLine( const GeoDataCoordinates & previousCoords,
                              const GeoDataCoordinates & currentCoords,
                              GeoDataCoordinates & previousAtDateline,
                              GeoDataCoordinates & currentAtDateline,
84
                              TessellationFlags f ) const;
85 86 87

    GeoDataCoordinates findDateLine( const GeoDataCoordinates & previousCoords,
                       const GeoDataCoordinates & currentCoords,
88
                       int recursionCounter ) const;
89

90
    quint8 levelForResolution(qreal resolution) const;
91 92 93
    qreal resolutionForLevel(int level) const;
    void optimize(GeoDataLineString& lineString) const;

94
    QVector<GeoDataCoordinates> m_vector;
Torsten Rahn's avatar
Torsten Rahn committed
95

96 97
    mutable GeoDataLineString*  m_rangeCorrected;
    mutable bool                m_dirtyRange;
Torsten Rahn's avatar
Torsten Rahn committed
98

99
    mutable bool                m_dirtyBox; // tells whether there have been changes to the
100 101 102
                                            // GeoDataPoints since the LatLonAltBox has 
                                            // been calculated. Saves performance. 
    TessellationFlags           m_tessellationFlags;
103
    mutable qreal  m_previousResolution;
104 105 106
    mutable quint8 m_level;

};
107 108 109

} // namespace Marble

110
#endif