Marble

VectorTileModel.h
1/*
2 SPDX-License-Identifier: LGPL-2.1-or-later
3
4 SPDX-FileCopyrightText: 2012 Ander Pijoan <ander.pijoan@deusto.es>
5 SPDX-FileCopyrightText: 2013 Bernhard Beschow <bbeschow@cs.tu-berlin.de>
6*/
7
8#ifndef MARBLE_VECTORTILEMODEL_H
9#define MARBLE_VECTORTILEMODEL_H
10
11#include <QObject>
12#include <QRunnable>
13
14#include <QMap>
15
16#include "GeoDataLatLonBox.h"
17#include "TileId.h"
18
19class QThreadPool;
20
21namespace Marble
22{
23
24class GeoDataDocument;
25class GeoDataTreeModel;
26class GeoSceneVectorTileDataset;
27class GeoDataObject;
28class TileLoader;
29
30class TileRunner : public QObject, public QRunnable
31{
33
34public:
35 TileRunner(TileLoader *loader, const GeoSceneVectorTileDataset *texture, const TileId &id);
36 void run() override;
37
39 void documentLoaded(const TileId &id, GeoDataDocument *document);
40
41private:
42 TileLoader *const m_loader;
43 const GeoSceneVectorTileDataset *const m_tileDataset;
44 const TileId m_id;
45};
46
47class VectorTileModel : public QObject
48{
50
51public:
52 explicit VectorTileModel(TileLoader *loader, const GeoSceneVectorTileDataset *layer, GeoDataTreeModel *treeModel, QThreadPool *threadPool);
53
54 void setViewport(const GeoDataLatLonBox &bbox);
55
56 QString name() const;
57
58 const GeoSceneVectorTileDataset *layer() const;
59
60 void removeTile(GeoDataDocument *document);
61
62 int tileZoomLevel() const;
63
64 int cachedDocuments() const;
65
66 void reload();
67
68public Q_SLOTS:
69 void updateTile(const TileId &id, GeoDataDocument *document);
70
71 void clear();
72
74 void tileCompleted(const TileId &tileId);
75 void tileAdded(GeoDataDocument *document);
76 void tileRemoved(GeoDataDocument *document);
77
78private Q_SLOTS:
79 void cleanupTile(GeoDataObject *feature);
80
81private:
82 void removeTilesOutOfView(const GeoDataLatLonBox &boundingBox);
83 void queryTiles(int tileZoomLevel, const QRect &rect);
84
85private:
86 struct CacheDocument {
87 /** The CacheDocument takes ownership of doc */
88 CacheDocument(GeoDataDocument *doc, VectorTileModel *vectorTileModel, const GeoDataLatLonBox &boundingBox);
89
90 /** Remove the document from the tree and delete the document */
91 ~CacheDocument();
92
93 GeoDataLatLonBox latLonBox() const
94 {
95 return m_boundingBox;
96 }
97
98 private:
99 Q_DISABLE_COPY(CacheDocument)
100
101 GeoDataDocument *const m_document;
102 VectorTileModel *const m_vectorTileModel;
103 GeoDataLatLonBox m_boundingBox;
104 };
105
106 TileLoader *const m_loader;
107 const GeoSceneVectorTileDataset *const m_layer;
108 GeoDataTreeModel *const m_treeModel;
109 QThreadPool *const m_threadPool;
110 int m_tileLoadLevel;
111 int m_tileZoomLevel;
112 QList<TileId> m_pendingDocuments;
113 QList<GeoDataDocument *> m_garbageQueue;
115 bool m_deleteDocumentsLater;
116};
117
118}
119
120#endif // MARBLE_VECTORTILEMODEL_H
Binds a QML item to a specific geodetic location in screen coordinates.
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:37:04 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.