-
Notifications
You must be signed in to change notification settings - Fork 3
/
tilecache.h
75 lines (73 loc) · 2.84 KB
/
tilecache.h
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
/************************************************************************************
* QSlippyMap - Tile based slippery map *
* Copyright (C) 2017 Michael Carpenter (malcom2073@gmail.com) *
* *
* This file is a part of QSlippyMap *
* *
* QSlippyMap is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation, version *
* 2.1 of the License. *
* *
* QSlippyMap is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
************************************************************************************/
#ifndef TILECACHE_H
#define TILECACHE_H
#include <QMap>
#include <QImage>
#include <QThread>
#include <QMutex>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
class TileCache : public QThread
{
Q_OBJECT
public:
TileCache();
void add(int x, int y, int z, QImage img);
void getTile(int x, int y, int z);
bool contains(int x, int y, int z);
void zoomLevelChanged();
void SetGoogle();
void SetMapbox();
private:
enum TileTypes
{
MAPBOX_TILES,
GOOGLE_TILES
};
TileTypes m_tileTypes;
int Random(int low, int high);
class TileReq
{
public:
int x;
int y;
int z;
};
QList<TileReq> m_tileQueue;
QMutex m_tileMutex;
QMutex m_networkQueueMutex;
QMap<int,QMap<int,QMap<int,bool> > > m_tileExistsMap;
QString m_cacheLocation;
void run();
QNetworkAccessManager *m_nam;
QMap<QNetworkReply*,QPair<QPair<int, int>, int> > m_tileIdList;
QByteArray UserAgent;
signals:
void tileRecv(int x,int y, int z, QImage tile);
void localTileUpdate(int count);
void networkTileUpdate(int count);
private slots:
void networkFinished();
void networkError(QNetworkReply::NetworkError err);
};
#endif // TILECACHE_H