|
|
|
@ -37,13 +37,13 @@ namespace core {
@@ -37,13 +37,13 @@ namespace core {
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// timeout for map connections
|
|
|
|
|
/// </summary>
|
|
|
|
|
QNetworkProxyFactory::setUseSystemConfiguration(true); |
|
|
|
|
QNetworkProxyFactory::setUseSystemConfiguration(true); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the value of the User-agent HTTP header.
|
|
|
|
|
/// </summary>
|
|
|
|
|
UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7"; |
|
|
|
|
UserAgent = QString("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:%1.0) Gecko/%2%3%4 Firefox/%5.0.%6").arg(QString::number(Random(3,14)), QString::number(Random(QDate().currentDate().year() - 4, QDate().currentDate().year())), QString::number(Random(11,12)), QString::number(Random(10,30)), QString::number(Random(3,14)), QString::number(Random(1,10))).toLatin1(); |
|
|
|
|
|
|
|
|
|
Timeout = 5 * 1000; |
|
|
|
|
CorrectGoogleVersions=true; |
|
|
|
@ -54,6 +54,10 @@ namespace core {
@@ -54,6 +54,10 @@ namespace core {
|
|
|
|
|
UrlFactory::~UrlFactory() |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
int UrlFactory::Random(int low, int high) |
|
|
|
|
{ |
|
|
|
|
return low + qrand() % (high - low); |
|
|
|
|
} |
|
|
|
|
QString UrlFactory::TileXYToQuadKey(const int &tileX,const int &tileY,const int &levelOfDetail) const |
|
|
|
|
{ |
|
|
|
|
QString quadKey; |
|
|
|
@ -112,7 +116,7 @@ namespace core {
@@ -112,7 +116,7 @@ namespace core {
|
|
|
|
|
#ifdef DEBUG_URLFACTORY |
|
|
|
|
qDebug()<<"Correct GoogleVersion"; |
|
|
|
|
#endif //DEBUG_URLFACTORY
|
|
|
|
|
//setIsCorrectGoogleVersions(true);
|
|
|
|
|
setIsCorrectGoogleVersions(true); |
|
|
|
|
QString url = "https://maps.google.com"; |
|
|
|
|
|
|
|
|
|
qheader.setUrl(QUrl(url)); |
|
|
|
@ -131,7 +135,7 @@ namespace core {
@@ -131,7 +135,7 @@ namespace core {
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
QString html=QString(reply->readAll()); |
|
|
|
|
QRegExp reg("\"*https://mts0.google.com/vt/lyrs=m@(\\d*)",Qt::CaseInsensitive); |
|
|
|
|
QRegExp reg("\"*https://mt0.google.com/vt/lyrs=m@(\\d*)",Qt::CaseInsensitive); |
|
|
|
|
if(reg.indexIn(html)!=-1) |
|
|
|
|
{ |
|
|
|
|
QStringList gc=reg.capturedTexts(); |
|
|
|
@ -143,7 +147,7 @@ namespace core {
@@ -143,7 +147,7 @@ namespace core {
|
|
|
|
|
#endif //DEBUG_URLFACTORY
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
reg = QRegExp("\"*https://mts0.google.com/vt/lyrs=h@(\\d*)",Qt::CaseInsensitive); |
|
|
|
|
reg=QRegExp("\"*https://mt0.google.com/vt/lyrs=h@(\\d*)",Qt::CaseInsensitive); |
|
|
|
|
if(reg.indexIn(html)!=-1) |
|
|
|
|
{ |
|
|
|
|
QStringList gc=reg.capturedTexts(); |
|
|
|
@ -153,7 +157,7 @@ namespace core {
@@ -153,7 +157,7 @@ namespace core {
|
|
|
|
|
qDebug()<<"TryCorrectGoogleVersions, VersionGoogleLabels: "<<VersionGoogleLabels; |
|
|
|
|
#endif //DEBUG_URLFACTORY
|
|
|
|
|
} |
|
|
|
|
reg=QRegExp("\"*https://khms0.google.com/kh/v=(\\d*)",Qt::CaseInsensitive); |
|
|
|
|
reg=QRegExp("\"*https://khm\\D?\\d.google.com/kh/v=(\\d*)",Qt::CaseInsensitive); |
|
|
|
|
if(reg.indexIn(html)!=-1) |
|
|
|
|
{ |
|
|
|
|
QStringList gc=reg.capturedTexts(); |
|
|
|
@ -163,7 +167,7 @@ namespace core {
@@ -163,7 +167,7 @@ namespace core {
|
|
|
|
|
qDebug()<<"TryCorrectGoogleVersions, VersionGoogleSatellite: "<<VersionGoogleSatellite; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
reg=QRegExp("\"*https://mts0.google.com/vt/lyrs=t@(\\d*),r@(\\d*)",Qt::CaseInsensitive); |
|
|
|
|
reg=QRegExp("\"*https://mt0.google.com/vt/lyrs=t@(\\d*),r@(\\d*)",Qt::CaseInsensitive); |
|
|
|
|
if(reg.indexIn(html)!=-1) |
|
|
|
|
{ |
|
|
|
|
QStringList gc=reg.capturedTexts(); |
|
|
|
@ -206,7 +210,6 @@ namespace core {
@@ -206,7 +210,6 @@ namespace core {
|
|
|
|
|
QString sec2 = ""; // after &zoom=...
|
|
|
|
|
GetSecGoogleWords(pos, sec1, sec2); |
|
|
|
|
TryCorrectGoogleVersions(); |
|
|
|
|
|
|
|
|
|
return QString("https://%1%2.google.com/%3/v=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleSatellite).arg(language).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
@ -230,7 +233,6 @@ namespace core {
@@ -230,7 +233,6 @@ namespace core {
|
|
|
|
|
QString sec2 = ""; // after &zoom=...
|
|
|
|
|
GetSecGoogleWords(pos, sec1, sec2); |
|
|
|
|
TryCorrectGoogleVersions(); |
|
|
|
|
|
|
|
|
|
return QString("https://%1%2.google.com/%3/v=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleTerrain).arg(language).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
@ -244,7 +246,7 @@ namespace core {
@@ -244,7 +246,7 @@ namespace core {
|
|
|
|
|
TryCorrectGoogleVersions(); |
|
|
|
|
// http://mt0.google.cn/vt/v=w2.101&hl=zh-CN&gl=cn&x=12&y=6&z=4&s=Ga
|
|
|
|
|
|
|
|
|
|
return QString("http://%1%2.google.cn/%3/lyrs=%4&hl=%5&gl=cn&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleMapChina).arg("zh-CN").arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); |
|
|
|
|
return QString("https://%1%2.google.cn/%3/lyrs=%4&hl=%5&gl=cn&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleMapChina).arg("zh-CN").arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case MapType::GoogleSatelliteChina: |
|
|
|
@ -255,9 +257,9 @@ namespace core {
@@ -255,9 +257,9 @@ namespace core {
|
|
|
|
|
QString sec2 = ""; // after &zoom=...
|
|
|
|
|
GetSecGoogleWords(pos, sec1, sec2); |
|
|
|
|
// TryCorrectGoogleVersions();
|
|
|
|
|
// http://khm0.google.cn/kh/v=46&x=12&y=6&z=4&s=Ga
|
|
|
|
|
// https://khm0.google.cn/kh/v=46&x=12&y=6&z=4&s=Ga
|
|
|
|
|
|
|
|
|
|
return QString("http://%1%2.google.cn/%3/lyrs=%4&gl=cn&x=%5%6&y=%7&z=%8&s=%9").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleSatelliteChina).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); |
|
|
|
|
return QString("https://%1%2.google.cn/%3/lyrs=%4&gl=cn&x=%5%6&y=%7&z=%8&s=%9").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleSatelliteChina).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case MapType::GoogleLabelsChina: |
|
|
|
@ -270,7 +272,7 @@ namespace core {
@@ -270,7 +272,7 @@ namespace core {
|
|
|
|
|
TryCorrectGoogleVersions(); |
|
|
|
|
// http://mt0.google.cn/vt/v=w2t.110&hl=zh-CN&gl=cn&x=12&y=6&z=4&s=Ga
|
|
|
|
|
|
|
|
|
|
return QString("http://%1%2.google.cn/%3/imgtp=png32&lyrs=%4&hl=%5&gl=cn&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleLabelsChina).arg("zh-CN").arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); |
|
|
|
|
return QString("https://%1%2.google.cn/%3/imgtp=png32&lyrs=%4&hl=%5&gl=cn&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleLabelsChina).arg("zh-CN").arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case MapType::GoogleTerrainChina: |
|
|
|
@ -284,7 +286,7 @@ namespace core {
@@ -284,7 +286,7 @@ namespace core {
|
|
|
|
|
|
|
|
|
|
// http://mt0.google.cn/vt/v=w2p.110&hl=zh-CN&gl=cn&x=12&y=6&z=4&s=Ga
|
|
|
|
|
|
|
|
|
|
return QString("http://%1%2.google.com/%3/lyrs=%4&hl=%5&gl=cn&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleTerrainChina).arg("zh-CN").arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); |
|
|
|
|
return QString("https://%1%2.google.com/%3/lyrs=%4&hl=%5&gl=cn&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleTerrainChina).arg("zh-CN").arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case MapType::GoogleMapKorea: |
|
|
|
@ -311,7 +313,7 @@ namespace core {
@@ -311,7 +313,7 @@ namespace core {
|
|
|
|
|
|
|
|
|
|
// http://khm1.google.co.kr/kh/v=54&x=109&y=49&z=7&s=
|
|
|
|
|
|
|
|
|
|
return QString("http://%1%2.google.co.kr/%3/v=%4&x=%5%6&y=%7&z=%8&s=%9").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleSatelliteKorea).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); |
|
|
|
|
return QString("https://%1%2.google.co.kr/%3/v=%4&x=%5%6&y=%7&z=%8&s=%9").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleSatelliteKorea).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case MapType::GoogleLabelsKorea: |
|
|
|
@ -502,12 +504,12 @@ namespace core {
@@ -502,12 +504,12 @@ namespace core {
|
|
|
|
|
QString UrlFactory::MakeGeocoderUrl(QString keywords) |
|
|
|
|
{ |
|
|
|
|
QString key = keywords.replace(' ', '+'); |
|
|
|
|
return QString("http://maps.google.com/maps/geo?q=%1&output=csv&key=%2").arg(key).arg(GoogleMapsAPIKey); |
|
|
|
|
return QString("https://maps.google.com/maps/geo?q=%1&output=csv&key=%2").arg(key).arg(GoogleMapsAPIKey); |
|
|
|
|
} |
|
|
|
|
QString UrlFactory::MakeReverseGeocoderUrl(internals::PointLatLng &pt,const QString &language) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
return QString("http://maps.google.com/maps/geo?hl=%1&ll=%2,%3&output=csv&key=%4").arg(language).arg(QString::number(pt.Lat())).arg(QString::number(pt.Lng())).arg(GoogleMapsAPIKey); |
|
|
|
|
return QString("https://maps.google.com/maps/geo?hl=%1&ll=%2,%3&output=csv&key=%4").arg(language).arg(QString::number(pt.Lat())).arg(QString::number(pt.Lng())).arg(GoogleMapsAPIKey); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
internals::PointLatLng UrlFactory::GetLatLngFromGeodecoder(const QString &keywords, GeoCoderStatusCode::Types &status) |
|
|
|
|