Commit 4f5b188f authored by dogmaphobic's avatar dogmaphobic

Update map URLs

Remove spurious debug message.
parent 9bef0830
......@@ -63,7 +63,6 @@ Item {
smallFontPointSize = defaultFontPointSize * _screenTools.smallFontPointRatio
mediumFontPointSize = defaultFontPointSize * _screenTools.mediumFontPointRatio
largeFontPointSize = defaultFontPointSize * _screenTools.largeFontPointRatio
console.log("setBasePointSize", defaultFontPixelWidth)
}
Text {
......
......@@ -14,6 +14,8 @@
* Original work: The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
*/
//#define DEBUG_GOOGLE_MAPS
#include "QGCMapEngine.h"
#include <QRegExp>
......@@ -23,6 +25,11 @@
#include <QString>
#include <QByteArray>
#if defined(DEBUG_GOOGLE_MAPS)
#include <QFile>
#include <QStandardPaths>
#endif
//-----------------------------------------------------------------------------
UrlFactory::UrlFactory()
: _timeout(5 * 1000)
......@@ -36,10 +43,10 @@ UrlFactory::UrlFactory()
QNetworkProxyFactory::setUseSystemConfiguration(true);
// Google version strings
_versionGoogleMap = "m@336";
_versionGoogleSatellite = "194";
_versionGoogleMap = "m@338000000";
_versionGoogleSatellite = "198";
_versionGoogleLabels = "h@336";
_versionGoogleTerrain = "t@132,r@336";
_versionGoogleTerrain = "t@132,r@338000000";
_secGoogleWord = "Galileo";
// BingMaps
_versionBingMaps = "563";
......@@ -122,12 +129,12 @@ UrlFactory::getTileURL(MapType type, int x, int y, int zoom, QNetworkAccessManag
case GoogleLabels:
case GoogleTerrain:
case GoogleHybrid:
request.setRawHeader("Referrer", "http://maps.google.com/");
request.setRawHeader("Referrer", "https://www.google.com/maps/preview");
break;
case BingHybrid:
case BingMap:
case BingSatellite:
request.setRawHeader("Referrer", "http://www.bing.com/maps/");
request.setRawHeader("Referrer", "https://www.bing.com/maps/");
break;
/*
case OpenStreetMapSurfer:
......@@ -397,22 +404,29 @@ UrlFactory::_googleVersionCompleted()
return;
}
QString html = QString(_googleReply->readAll());
QRegExp reg("\"*http://mt0.google.com/vt/lyrs=m@(\\d*)",Qt::CaseInsensitive);
if (reg.indexIn(html) != -1) {
QStringList gc = reg.capturedTexts();
_versionGoogleMap = QString("m@%1").arg(gc[1]);
#if defined(DEBUG_GOOGLE_MAPS)
QString filename = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
filename += "/google.output";
QFile file(filename);
if (file.open(QIODevice::ReadWrite))
{
QTextStream stream( &file );
stream << html << endl;
}
reg = QRegExp("\"*http://mt0.google.com/vt/lyrs=h@(\\d*)",Qt::CaseInsensitive);
#endif
QRegExp reg("\"*https?://mt\\D?\\d..*/vt\\?lyrs=m@(\\d*)", Qt::CaseInsensitive);
if (reg.indexIn(html) != -1) {
QStringList gc = reg.capturedTexts();
_versionGoogleLabels = QString("h@%1").arg(gc[1]);
_versionGoogleMap = QString("m@%1").arg(gc[1]);
}
reg = QRegExp("\"*http://khm\\D?\\d.google.com/kh/v=(\\d*)",Qt::CaseInsensitive);
reg = QRegExp("\"*https?://khm\\D?\\d.googleapis.com/kh\\?v=(\\d*)", Qt::CaseInsensitive);
if (reg.indexIn(html) != -1) {
QStringList gc = reg.capturedTexts();
_versionGoogleSatellite = gc[1];
}
reg = QRegExp("\"*http://mt0.google.com/vt/lyrs=t@(\\d*),r@(\\d*)",Qt::CaseInsensitive);
reg = QRegExp("\"*https?://mt\\D?\\d..*/vt\\?lyrs=t@(\\d*),r@(\\d*)", Qt::CaseInsensitive);
if (reg.indexIn(html) != -1) {
QStringList gc = reg.capturedTexts();
_versionGoogleTerrain = QString("t@%1,r@%2").arg(gc[1]).arg(gc[2]);
......@@ -423,7 +437,7 @@ UrlFactory::_googleVersionCompleted()
//-----------------------------------------------------------------------------
void
UrlFactory::_tryCorrectGoogleVersions(QNetworkAccessManager* networkManager)
UrlFactory::_tryCorrectGoogleVersions(QNetworkAccessManager* networkManager)
{
QMutexLocker locker(&_googleVersionMutex);
if (_googleVersionRetrieved) {
......@@ -437,7 +451,10 @@ UrlFactory::_tryCorrectGoogleVersions(QNetworkAccessManager* networkManager)
QNetworkProxy tProxy;
tProxy.setType(QNetworkProxy::DefaultProxy);
networkManager->setProxy(tProxy);
QString url = "http://maps.google.com/maps";
QSslConfiguration conf = qheader.sslConfiguration();
conf.setPeerVerifyMode(QSslSocket::VerifyNone);
qheader.setSslConfiguration(conf);
QString url = "http://maps.google.com/maps/api/js?v=3.2&sensor=false";
qheader.setUrl(QUrl(url));
QByteArray ua;
ua.append(getQGCMapEngine()->userAgent());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment