File: VectorTileModel.h

package info (click to toggle)
marble 4%3A17.08.3-3.2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 141,596 kB
  • sloc: cpp: 189,322; xml: 39,420; ansic: 7,204; python: 2,244; sh: 1,137; makefile: 236; perl: 222; ruby: 97; java: 66
file content (120 lines) | stat: -rw-r--r-- 2,971 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
 This file is part of the Marble Virtual Globe.

 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 2012 Ander Pijoan <ander.pijoan@deusto.es>
 Copyright 2013      Bernhard Beschow <bbeschow@cs.tu-berlin.de>
*/

#ifndef MARBLE_VECTORTILEMODEL_H
#define MARBLE_VECTORTILEMODEL_H

#include <QObject>
#include <QRunnable>

#include <QMap>

#include "TileId.h"
#include "GeoDataLatLonBox.h"

class QThreadPool;

namespace Marble
{

class GeoDataDocument;
class GeoDataTreeModel;
class GeoSceneVectorTileDataset;
class GeoDataObject;
class TileLoader;

class TileRunner : public QObject, public QRunnable
{
    Q_OBJECT

public:
    TileRunner( TileLoader *loader, const GeoSceneVectorTileDataset *texture, const TileId &id );
    void run() override;

Q_SIGNALS:
    void documentLoaded( const TileId &id, GeoDataDocument *document );

private:
    TileLoader *const m_loader;
    const GeoSceneVectorTileDataset *const m_tileDataset;
    const TileId m_id;
};

class VectorTileModel : public QObject
{
    Q_OBJECT

public:
    explicit VectorTileModel( TileLoader *loader, const GeoSceneVectorTileDataset *layer, GeoDataTreeModel *treeModel, QThreadPool *threadPool );

    void setViewport(const GeoDataLatLonBox &bbox);

    QString name() const;

    void removeTile(GeoDataDocument* document);

    int tileZoomLevel() const;

    int cachedDocuments() const;

    void reload();

public Q_SLOTS:
    void updateTile( const TileId &id, GeoDataDocument *document );

    void clear();

Q_SIGNALS:
    void tileCompleted( const TileId &tileId );
    void tileAdded(GeoDataDocument *document);
    void tileRemoved(GeoDataDocument *document);

private Q_SLOTS:
    void cleanupTile(GeoDataObject* feature);

private:
    void removeTilesOutOfView(const GeoDataLatLonBox &boundingBox);
    void queryTiles(int tileZoomLevel, const QRect &rect);

private:
    struct CacheDocument
    {
        /** The CacheDocument takes ownership of doc */
        CacheDocument(GeoDataDocument *doc, VectorTileModel* vectorTileModel, const GeoDataLatLonBox &boundingBox);

        /** Remove the document from the tree and delete the document */
        ~CacheDocument();

        GeoDataLatLonBox latLonBox() const { return m_boundingBox; }

    private:
        Q_DISABLE_COPY( CacheDocument )

        GeoDataDocument *const m_document;
        VectorTileModel *const m_vectorTileModel;
        GeoDataLatLonBox m_boundingBox;
    };

    TileLoader *const m_loader;
    const GeoSceneVectorTileDataset *const m_layer;
    GeoDataTreeModel *const m_treeModel;
    QThreadPool *const m_threadPool;
    int m_tileLoadLevel;
    int m_tileZoomLevel;
    QList<TileId> m_pendingDocuments;
    QList<GeoDataDocument*> m_garbageQueue;
    QMap<TileId, QSharedPointer<CacheDocument> > m_documents;
    bool m_deleteDocumentsLater;
};

}

#endif // MARBLE_VECTORTILEMODEL_H