diff --git a/src/FlightMap/FlightMap.qml b/src/FlightMap/FlightMap.qml index 051f7f6118940a04f3cd04a2cb6a031e949d4083..4959a88cb6305c002dac1b8492d1bfdaa9a14f6f 100644 --- a/src/FlightMap/FlightMap.qml +++ b/src/FlightMap/FlightMap.qml @@ -97,7 +97,6 @@ Map { var settings = QGroundControl.settingsManager.flightMapSettings var fullMapName = settings.mapProvider.value + " " + settings.mapType.value - console.log("updateActiveMapType",fullMapName) for (var i = 0; i < _map.supportedMapTypes.length; i++) { if (fullMapName === _map.supportedMapTypes[i].name) { _map.activeMapType = _map.supportedMapTypes[i] diff --git a/src/QtLocationPlugin/GenericMapProvider.cpp b/src/QtLocationPlugin/GenericMapProvider.cpp index abfe3487684c11be4297e177e14721a0132a10cb..dfacb5f791b75ed18a849e391c875959f22056f1 100644 --- a/src/QtLocationPlugin/GenericMapProvider.cpp +++ b/src/QtLocationPlugin/GenericMapProvider.cpp @@ -20,3 +20,84 @@ QString EniroMapProvider::_getURL(int x, int y, int zoom, .arg(x) .arg((1 << zoom) - 1 - y); } + +QString MapQuestMapMapProvider::_getURL(int x, int y, int zoom, + QNetworkAccessManager* networkManager) { + Q_UNUSED(networkManager); + char letter = "1234"[_getServerNum(x, y, 4)]; + return QString("http://otile%1.mqcdn.com/tiles/1.0.0/map/%2/%3/%4.jpg") + .arg(letter) + .arg(zoom) + .arg(x) + .arg(y); +} + +QString MapQuestSatMapProvider::_getURL(int x, int y, int zoom, + QNetworkAccessManager* networkManager) { + Q_UNUSED(networkManager); + char letter = "1234"[_getServerNum(x, y, 4)]; + return QString("http://otile%1.mqcdn.com/tiles/1.0.0/sat/%2/%3/%4.jpg") + .arg(letter) + .arg(zoom) + .arg(x) + .arg(y); +} + +QString +VWorldStreetMapProvider::_getURL(int x, int y, int zoom, + QNetworkAccessManager* networkManager) { + Q_UNUSED(networkManager); + int gap = zoom - 6; + int x_min = 53 * pow(2, gap); + int x_max = 55 * pow(2, gap) + (2 * gap - 1); + int y_min = 22 * pow(2, gap); + int y_max = 26 * pow(2, gap) + (2 * gap - 1); + + if (zoom > 19) { + return {}; + } else if (zoom > 5 && x >= x_min && x <= x_max && y >= y_min && + y <= y_max) { + return QString( + "http://xdworld.vworld.kr:8080/2d/Base/service/%1/%2/%3.png") + .arg(zoom) + .arg(x) + .arg(y); + } else { + QString key = _tileXYToQuadKey(x, y, zoom); + return QString("http://ecn.t%1.tiles.virtualearth.net/tiles/" + "r%2.png?g=%3&mkt=%4") + .arg(_getServerNum(x, y, 4)) + .arg(key) + .arg(_versionBingMaps) + .arg(_language); + } +} + +QString VWorldSatMapProvider::_getURL(int x, int y, int zoom, + QNetworkAccessManager* networkManager) { + Q_UNUSED(networkManager); + int gap = zoom - 6; + int x_min = 53 * pow(2, gap); + int x_max = 55 * pow(2, gap) + (2 * gap - 1); + int y_min = 22 * pow(2, gap); + int y_max = 26 * pow(2, gap) + (2 * gap - 1); + + if (zoom > 19) { + return {}; + } 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) + .arg(x) + .arg(y); + } else { + 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) + .arg(_versionBingMaps) + .arg(_language); + } +} diff --git a/src/QtLocationPlugin/GenericMapProvider.h b/src/QtLocationPlugin/GenericMapProvider.h index 7750420d303dd81ceaa767271b13a7c364139cbc..1953e5653d27122c40a63a7b36828df490bac835 100644 --- a/src/QtLocationPlugin/GenericMapProvider.h +++ b/src/QtLocationPlugin/GenericMapProvider.h @@ -30,3 +30,55 @@ class EniroMapProvider : public MapProvider { QString _getURL(int x, int y, int zoom, QNetworkAccessManager* networkManager); }; + +class MapQuestMapMapProvider : public MapProvider { + Q_OBJECT + public: + MapQuestMapMapProvider(QObject* parent) + : MapProvider(QString("https://mapquest.com"), QString("jpg"), + AVERAGE_TILE_SIZE, QGeoMapType::StreetMap, parent) {} + + QString _getURL(int x, int y, int zoom, + QNetworkAccessManager* networkManager); +}; + +class MapQuestSatMapProvider : public MapProvider { + Q_OBJECT + public: + MapQuestSatMapProvider(QObject* parent) + : MapProvider(QString("https://mapquest.com"), QString("jpg"), + AVERAGE_TILE_SIZE, QGeoMapType::SatelliteMapDay, parent) { + } + + QString _getURL(int x, int y, int zoom, + QNetworkAccessManager* networkManager); +}; + +class VWorldStreetMapProvider : public MapProvider { + Q_OBJECT + public: + VWorldStreetMapProvider(QObject* parent) + : MapProvider(QString("www.vworld.kr"), QString("png"), + AVERAGE_TILE_SIZE, QGeoMapType::StreetMap, parent) {} + + QString _getURL(int x, int y, int zoom, + QNetworkAccessManager* networkManager); + + private: + const QString _versionBingMaps = "563"; +}; + +class VWorldSatMapProvider : public MapProvider { + Q_OBJECT + public: + VWorldSatMapProvider(QObject* parent) + : MapProvider(QString("www.vworld.kr"), QString("jpg"), + AVERAGE_TILE_SIZE, QGeoMapType::SatelliteMapDay, parent) { + } + + QString _getURL(int x, int y, int zoom, + QNetworkAccessManager* networkManager); + + private: + const QString _versionBingMaps = "563"; +}; diff --git a/src/QtLocationPlugin/QGCMapUrlEngine.cpp b/src/QtLocationPlugin/QGCMapUrlEngine.cpp index 45f13962605fa65def101e8703339b889d96994e..b4d4c0bf4de62c6340242669dec57b9da46a94af 100644 --- a/src/QtLocationPlugin/QGCMapUrlEngine.cpp +++ b/src/QtLocationPlugin/QGCMapUrlEngine.cpp @@ -69,6 +69,12 @@ UrlFactory::UrlFactory() : _timeout(5 * 1000) { _providersTable["Mapbox Outdoors"] = new MapboxOutdoorsMapProvider(this); _providersTable["Mapbox RunBikeHike"] = new MapboxRunBikeHikeMapProvider(this); _providersTable["Mapbox HighContrast"] = new MapboxHighContrastMapProvider(this); + + //_providersTable["MapQuest Map"] = new MapQuestMapMapProvider(this); + //_providersTable["MapQuest Sat"] = new MapQuestSatMapProvider(this); + + _providersTable["VWorld Street Map"] = new VWorldStreetMapProvider(this); + _providersTable["VWorld Satellite Map"] = new VWorldSatMapProvider(this); } void UrlFactory::registerProvider(QString name, MapProvider* provider) { @@ -432,7 +438,7 @@ quint32 UrlFactory::averageSizeForType(QString type) { return _providersTable[type]->getAverageSize(); } qCDebug(QGCMapUrlEngineLog) << "UrlFactory::averageSizeForType " << type - << " Not registeret"; + << " Not registered"; // case AirmapElevation: // return AVERAGE_AIRMAP_ELEV_SIZE;