GoogleMapProvider.h 3.94 KB
Newer Older
1 2 3 4 5
#pragma once

#include "MapProvider.h"

#include <QByteArray>
6
#include <QMutex>
7 8 9
#include <QNetworkProxy>
#include <QNetworkReply>
#include <QPoint>
10
#include <QString>
11 12 13 14

class GoogleMapProvider : public MapProvider {
    Q_OBJECT
  public:
15 16
    GoogleMapProvider(QString imageFormat, quint32 averageSize,
                      QGeoMapType::MapStyle mapType, QObject* parent);
17 18 19 20 21 22 23 24 25

    ~GoogleMapProvider();

    // Google Specific private slots
  private slots:
    void _networkReplyError(QNetworkReply::NetworkError error);
    void _googleVersionCompleted();
    void _replyDestroyed();

Pierre TILAK's avatar
Pierre TILAK committed
26
  protected:
27
    // Define the url to Request
28 29
    virtual QString _getURL(int x, int y, int zoom,
                            QNetworkAccessManager* networkManager) = 0;
30 31 32 33 34 35 36 37 38 39 40 41 42

    // Google Specific private methods
    void _getSecGoogleWords(int x, int y, QString& sec1, QString& sec2);
    void _tryCorrectGoogleVersions(QNetworkAccessManager* networkManager);

    // Google Specific attributes
    bool           _googleVersionRetrieved;
    QNetworkReply* _googleReply;
    QMutex         _googleVersionMutex;
    QString        _versionGoogleMap;
    QString        _versionGoogleSatellite;
    QString        _versionGoogleLabels;
    QString        _versionGoogleTerrain;
Pierre TILAK's avatar
Pierre TILAK committed
43
    QString        _versionGoogleHybrid;
44 45
    QString        _secGoogleWord;
};
Pierre TILAK's avatar
Pierre TILAK committed
46

47 48 49 50 51 52 53 54 55 56 57 58 59
// NoMap = 0,
// StreetMap,
// SatelliteMapDay,
// SatelliteMapNight,
// TerrainMap,
// HybridMap,
// TransitMap,
// GrayStreetMap,
// PedestrianMap,
// CarNavigationMap,
// CycleMap,
// CustomMap = 100

60 61 62
const quint32 AVERAGE_GOOGLE_STREET_MAP  = 4913;
const quint32 AVERAGE_GOOGLE_SAT_MAP     = 56887;
const quint32 AVERAGE_GOOGLE_TERRAIN_MAP = 19391;
63 64 65 66 67 68 69 70

// -----------------------------------------------------------
// Google Street Map

class GoogleStreetMapProvider : public GoogleMapProvider {
    Q_OBJECT
  public:
    GoogleStreetMapProvider(QObject* parent)
71 72
        : GoogleMapProvider(QString("png"), AVERAGE_GOOGLE_STREET_MAP,
                            QGeoMapType::StreetMap, parent) {}
73 74 75 76 77 78 79 80 81

  protected:
    QString _getURL(int x, int y, int zoom,
                    QNetworkAccessManager* networkManager);
};

// -----------------------------------------------------------
// Google Street Map

Pierre TILAK's avatar
Pierre TILAK committed
82 83 84
class GoogleSatelliteMapProvider : public GoogleMapProvider {
    Q_OBJECT
  public:
85
    GoogleSatelliteMapProvider(QObject* parent)
86
        : GoogleMapProvider(QString("jpg"), AVERAGE_GOOGLE_SAT_MAP,
87 88
                            QGeoMapType::SatelliteMapDay, parent) {}

Pierre TILAK's avatar
Pierre TILAK committed
89 90 91 92
  protected:
    QString _getURL(int x, int y, int zoom,
                    QNetworkAccessManager* networkManager);
};
Pierre TILAK's avatar
Pierre TILAK committed
93

94 95 96
// -----------------------------------------------------------
// Google Labels Map

Pierre TILAK's avatar
Pierre TILAK committed
97 98 99
class GoogleLabelsMapProvider : public GoogleMapProvider {
    Q_OBJECT
  public:
100
    GoogleLabelsMapProvider(QObject* parent)
101 102
        : GoogleMapProvider(QString("png"), AVERAGE_TILE_SIZE,
                            QGeoMapType::CustomMap, parent) {}
103

Pierre TILAK's avatar
Pierre TILAK committed
104 105 106 107 108
  protected:
    QString _getURL(int x, int y, int zoom,
                    QNetworkAccessManager* networkManager);
};

109 110 111
// -----------------------------------------------------------
// Google Terrain Map

Pierre TILAK's avatar
Pierre TILAK committed
112 113 114
class GoogleTerrainMapProvider : public GoogleMapProvider {
    Q_OBJECT
  public:
115
    GoogleTerrainMapProvider(QObject* parent)
116 117
        : GoogleMapProvider(QString("png"), AVERAGE_GOOGLE_TERRAIN_MAP,
                            QGeoMapType::TerrainMap, parent) {}
118

Pierre TILAK's avatar
Pierre TILAK committed
119 120 121 122
  protected:
    QString _getURL(int x, int y, int zoom,
                    QNetworkAccessManager* networkManager);
};
Pierre TILAK's avatar
Pierre TILAK committed
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137

// -----------------------------------------------------------
// Google Hybrid Map

class GoogleHybridMapProvider : public GoogleMapProvider {
    Q_OBJECT
  public:
    GoogleHybridMapProvider(QObject* parent)
        : GoogleMapProvider(QString("png"), AVERAGE_GOOGLE_SAT_MAP,
                            QGeoMapType::HybridMap, parent) {}

  protected:
    QString _getURL(int x, int y, int zoom,
                    QNetworkAccessManager* networkManager);
};