GoogleMapProvider.h 3.34 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(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 43 44

    // 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;
    QString        _secGoogleWord;
};
Pierre TILAK's avatar
Pierre TILAK committed
45

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

59 60 61
const quint32 AVERAGE_GOOGLE_STREET_MAP  = 4913;
const quint32 AVERAGE_GOOGLE_SAT_MAP     = 56887;
const quint32 AVERAGE_GOOGLE_TERRAIN_MAP = 19391;
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80

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

class GoogleStreetMapProvider : public GoogleMapProvider {
    Q_OBJECT
  public:
    GoogleStreetMapProvider(QObject* parent)
        : GoogleMapProvider(AVERAGE_GOOGLE_STREET_MAP, QGeoMapType::StreetMap,
                            parent) {}

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

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

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

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

93 94 95
// -----------------------------------------------------------
// Google Labels Map

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

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

108 109 110
// -----------------------------------------------------------
// Google Terrain Map

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

Pierre TILAK's avatar
Pierre TILAK committed
118 119 120 121
  protected:
    QString _getURL(int x, int y, int zoom,
                    QNetworkAccessManager* networkManager);
};