GenericMapProvider.cpp 5.09 KB
Newer Older
Cosmin Marc's avatar
Cosmin Marc committed
1 2
/****************************************************************************
 *
Gus Grubba's avatar
Gus Grubba committed
3
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
Cosmin Marc's avatar
Cosmin Marc committed
4 5 6 7 8
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
9
#include "GenericMapProvider.h"
Pierre TILAK's avatar
Pierre TILAK committed
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
static const QString JapanStdMapUrl = QStringLiteral("https://cyberjapandata.gsi.go.jp/xyz/std/%1/%2/%3.png");

QString JapanStdMapProvider::_getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) {
    Q_UNUSED(networkManager)
    return JapanStdMapUrl.arg(zoom).arg(x).arg(y);
}

static const QString JapanSeamlessMapUrl = QStringLiteral("https://cyberjapandata.gsi.go.jp/xyz/seamlessphoto/%1/%2/%3.jpg");

QString JapanSeamlessMapProvider::_getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) {
    Q_UNUSED(networkManager)
    return JapanSeamlessMapUrl.arg(zoom).arg(x).arg(y);
}

static const QString JapanAnaglyphMapUrl = QStringLiteral("https://cyberjapandata.gsi.go.jp/xyz/anaglyphmap_color/%1/%2/%3.png");

QString JapanAnaglyphMapProvider::_getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) {
    Q_UNUSED(networkManager)
    return JapanAnaglyphMapUrl.arg(zoom).arg(x).arg(y);
}

static const QString JapanSlopeMapUrl = QStringLiteral("https://cyberjapandata.gsi.go.jp/xyz/slopemap/%1/%2/%3.png");

QString JapanSlopeMapProvider::_getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) {
    Q_UNUSED(networkManager)
    return JapanSlopeMapUrl.arg(zoom).arg(x).arg(y);
}

static const QString JapanReliefMapUrl = QStringLiteral("https://cyberjapandata.gsi.go.jp/xyz/relief/%1/%2/%3.png");

QString JapanReliefMapProvider::_getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) {
    Q_UNUSED(networkManager)
    return JapanReliefMapUrl.arg(zoom).arg(x).arg(y);
}

Cosmin Marc's avatar
Cosmin Marc committed
46 47 48 49 50
static const QString StatkartMapUrl = QStringLiteral("http://opencache.statkart.no/gatekeeper/gk/gk.open_gmaps?layers=topo4&zoom=%1&x=%2&y=%3");

QString StatkartMapProvider::_getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) {
    Q_UNUSED(networkManager)
    return StatkartMapUrl.arg(zoom).arg(x).arg(y);
Pierre TILAK's avatar
Pierre TILAK committed
51 52
}

Cosmin Marc's avatar
Cosmin Marc committed
53 54 55 56 57
static const QString EniroMapUrl = QStringLiteral("http://map.eniro.com/geowebcache/service/tms1.0.0/map/%1/%2/%3.png");

QString EniroMapProvider::_getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) {
    Q_UNUSED(networkManager)
    return EniroMapUrl.arg(zoom).arg(x).arg((1 << zoom) - 1 - y);
58
}
59

Cosmin Marc's avatar
Cosmin Marc committed
60 61 62 63 64
static const QString MapQuestMapUrl = QStringLiteral("http://otile%1.mqcdn.com/tiles/1.0.0/map/%2/%3/%4.jpg");

QString MapQuestMapMapProvider::_getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) {
    Q_UNUSED(networkManager)
    return MapQuestMapUrl.arg(_getServerNum(x, y, 4)).arg(zoom).arg(x).arg(y);
65 66
}

Cosmin Marc's avatar
Cosmin Marc committed
67 68 69 70 71
static const QString MapQuestSatUrl = QStringLiteral("http://otile%1.mqcdn.com/tiles/1.0.0/sat/%2/%3/%4.jpg");

QString MapQuestSatMapProvider::_getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) {
    Q_UNUSED(networkManager)
    return MapQuestSatUrl.arg(_getServerNum(x, y, 4)).arg(zoom).arg(x).arg(y);
72 73
}

Cosmin Marc's avatar
Cosmin Marc committed
74 75 76 77 78 79 80
QString VWorldStreetMapProvider::_getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) {
    Q_UNUSED(networkManager)
    const int gap   = zoom - 6;
    const int x_min = int(53 * pow(2, gap));
    const int x_max = int(55 * pow(2, gap) + (2 * gap - 1));
    const int y_min = int(22 * pow(2, gap));
    const int y_max = int(26 * pow(2, gap) + (2 * gap - 1));
81 82

    if (zoom > 19) {
Cosmin Marc's avatar
Cosmin Marc committed
83 84 85
        return QString();
    } else if (zoom > 5 && x >= x_min && x <= x_max && y >= y_min && y <= y_max) {
        return QString(QStringLiteral("http://xdworld.vworld.kr:8080/2d/Base/service/%1/%2/%3.png")).arg(zoom, x, y);
86
    } else {
Cosmin Marc's avatar
Cosmin Marc committed
87 88 89
        const QString key = _tileXYToQuadKey(x, y, zoom);
        return QString(QStringLiteral("http://ecn.t%1.tiles.virtualearth.net/tiles/r%2.png?g=%3&mkt=%4"))
            .arg(_getServerNum(x, y, 4)).arg(key, _versionBingMaps, _language);
90 91 92
    }
}

Cosmin Marc's avatar
Cosmin Marc committed
93 94 95 96 97 98 99
QString VWorldSatMapProvider::_getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) {
    Q_UNUSED(networkManager)
    const int gap   = zoom - 6;
    const int x_min = int(53 * pow(2, gap));
    const int x_max = int(55 * pow(2, gap) + (2 * gap - 1));
    const int y_min = int(22 * pow(2, gap));
    const int y_max = int(26 * pow(2, gap) + (2 * gap - 1));
100 101

    if (zoom > 19) {
Cosmin Marc's avatar
Cosmin Marc committed
102 103 104
        return QString();
    } else if (zoom > 5 && x >= x_min && x <= x_max && y >= y_min && y <= y_max) {
        return QString("http://xdworld.vworld.kr:8080/2d/Satellite/service/%1/%2/%3.jpeg").arg(zoom, x, y);
105
    } else {
Cosmin Marc's avatar
Cosmin Marc committed
106 107 108
        const QString key = _tileXYToQuadKey(x, y, zoom);
        return QString("http://ecn.t%1.tiles.virtualearth.net/tiles/a%2.jpeg?g=%3&mkt=%4")
            .arg(_getServerNum(x, y, 4)).arg(key, _versionBingMaps, _language);
109 110
    }
}