1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

Merge branch 'rel-15.05' into rel-nano-15.05

This commit is contained in:
abeck70 2015-05-19 18:25:07 +10:00
commit 399bf0470a
13 changed files with 254 additions and 362 deletions

View File

@ -55,10 +55,10 @@ QVector<MapType::Types> AllLayersOfType::GetAllLayersOfType(const MapType::Types
}
break;
case MapType::ArcGIS_MapsLT_Map_Hybrid:
case MapType::OpenStreetMapSurferTerrain:
{
types.append(MapType::ArcGIS_MapsLT_OrtoFoto);
types.append(MapType::ArcGIS_MapsLT_Map_Labels);
types.append(MapType::OpenStreetMapSurfer);
types.append(MapType::OpenStreetMapSurferTerrain);
}
break;

View File

@ -9,5 +9,6 @@
// #define DEBUG_URLFACTORY
// #define DEBUG_MEMORY_CACHE
// #define DEBUG_GetGeocoderFromCache
// #define DEBUG_TIMINGS
// #define DEBUG_CORE
#endif // DEBUGHEADER_H

View File

@ -52,35 +52,15 @@ public:
OpenStreetMapSurfer = 34,
OpenStreetMapSurferTerrain = 35,
BingMap = 444,
BingSatellite = 555,
BingHybrid = 666,
BingMap = 444,
BingSatellite = 555,
BingHybrid = 666,
ArcGIS_Map = 777,
ArcGIS_Satellite = 788,
ArcGIS_ShadedRelief = 799,
ArcGIS_Terrain = 811,
ArcGIS_Map = 777,
ArcGIS_Satellite = 788,
ArcGIS_ShadedRelief = 799,
ArcGIS_Terrain = 811,
// use these numbers to clean up old stuff
// ArcGIS_MapsLT_Map_Old= 877,
// ArcGIS_MapsLT_OrtoFoto_Old = 888,
// ArcGIS_MapsLT_Map_Labels_Old = 890,
// ArcGIS_MapsLT_Map_Hybrid_Old = 899,
// ArcGIS_MapsLT_Map=977,
// ArcGIS_MapsLT_OrtoFoto=988,
// ArcGIS_MapsLT_Map_Labels=990,
// ArcGIS_MapsLT_Map_Hybrid=999,
// ArcGIS_MapsLT_Map=978,
// ArcGIS_MapsLT_OrtoFoto=989,
// ArcGIS_MapsLT_Map_Labels=991,
// ArcGIS_MapsLT_Map_Hybrid=998,
ArcGIS_MapsLT_Map = 1000,
ArcGIS_MapsLT_OrtoFoto = 1001,
ArcGIS_MapsLT_Map_Labels = 1002,
ArcGIS_MapsLT_Map_Hybrid = 1003,
PergoTurkeyMap = 2001,
SigPacSpainMap = 3001,
GoogleMapKorea = 4001,
@ -88,7 +68,7 @@ public:
GoogleLabelsKorea = 4003,
GoogleHybridKorea = 4005,
YandexMapRu = 5000
Statkart_Topo2 = 5500
};
static QString StrByType(Types const & value)
{

View File

@ -40,6 +40,7 @@ OPMaps *OPMaps::Instance()
OPMaps::OPMaps() : RetryLoadTile(2), useMemoryCache(true)
{
accessmode = AccessMode::ServerAndCache;
// Need to figure out why this is *fixed* to Portugese. This casues pt-PT to be sent with every Google request
Language = LanguageType::PortuguesePortugal;
LanguageStr = LanguageType().toShortString(Language);
Cache::Instance();
@ -100,15 +101,15 @@ QByteArray OPMaps::GetImageFrom(const MapType::Types &type, const Point &pos, co
}
}
if (accessmode != AccessMode::CacheOnly) {
QEventLoop q;
QNetworkReply *reply;
QNetworkRequest qheader;
QNetworkAccessManager network;
QTimer tT;
tT.setSingleShot(true);
connect(&network, SIGNAL(finished(QNetworkReply *)),
&q, SLOT(quit()));
connect(&tT, SIGNAL(timeout()), &q, SLOT(quit()));
// This SSL Hack is half assed... technically bad *security* joojoo.
// Required due to a QT5 bug on linux and Mac
//
QSslConfiguration conf = qheader.sslConfiguration();
conf.setPeerVerifyMode(QSslSocket::VerifyNone);
qheader.setSslConfiguration(conf);
network.setProxy(Proxy);
#ifdef DEBUG_GMAPS
qDebug() << "Try Tile from the Internet";
@ -119,8 +120,7 @@ QByteArray OPMaps::GetImageFrom(const MapType::Types &type, const Point &pos, co
QString url = MakeImageUrl(type, pos, zoom, LanguageStr);
#ifdef DEBUG_TIMINGS
qDebug() << "opmaps after make image url" << time.elapsed();
#endif // url "http://vec02.maps.yandex.ru/tiles?l=map&v=2.10.2&x=7&y=5&z=3" string
// "http://map3.pergo.com.tr/tile/02/000/000/007/000/000/002.png"
#endif // url can be hard coded for debugging purposes
qheader.setUrl(QUrl(url));
qheader.setRawHeader("User-Agent", UserAgent);
qheader.setRawHeader("Accept", "*/*");
@ -145,6 +145,14 @@ QByteArray OPMaps::GetImageFrom(const MapType::Types &type, const Point &pos, co
}
break;
case MapType::GoogleMapKorea:
case MapType::GoogleSatelliteKorea:
case MapType::GoogleLabelsKorea:
{
qheader.setRawHeader("Referrer", "http://maps.google.co.kr/");
}
break;
case MapType::BingHybrid:
case MapType::BingMap:
case MapType::BingSatellite:
@ -153,15 +161,6 @@ QByteArray OPMaps::GetImageFrom(const MapType::Types &type, const Point &pos, co
}
break;
case MapType::ArcGIS_MapsLT_Map_Labels:
case MapType::ArcGIS_MapsLT_Map:
case MapType::ArcGIS_MapsLT_OrtoFoto:
case MapType::ArcGIS_MapsLT_Map_Hybrid:
{
qheader.setRawHeader("Referrer", "http://www.maps.lt/map_beta/");
}
break;
case MapType::OpenStreetMapSurfer:
case MapType::OpenStreetMapSurferTerrain:
{
@ -175,35 +174,35 @@ QByteArray OPMaps::GetImageFrom(const MapType::Types &type, const Point &pos, co
qheader.setRawHeader("Referrer", "http://www.openstreetmap.org/");
}
break;
case MapType::YandexMapRu:
case MapType::Statkart_Topo2:
{
qheader.setRawHeader("Referrer", "http://maps.yandex.ru/");
qheader.setRawHeader("Referrer", "http://www.norgeskart.no/");
}
break;
default:
break;
}
qDebug() << "Timeout is " << Timeout;
reply = network.get(qheader);
tT.start(Timeout);
q.exec();
qDebug() << "reply " << reply;
if (!tT.isActive()) {
errorvars.lock();
++diag.timeouts;
errorvars.unlock();
return ret;
QTime time;
while ((!(reply->isFinished()) || (time.elapsed() > (6 * Timeout)))) {
QCoreApplication::processEvents(QEventLoop::AllEvents);
}
tT.stop();
if ((reply->error() != QNetworkReply::NoError)) {
errorvars.lock();
++diag.networkerrors;
errorvars.unlock();
reply->deleteLater();
qDebug() << "Finished?" << reply->error() << " abort?" << (time.elapsed() > Timeout * 6);
// If you are seeing Error 6 here you are dealing with a QT SSL Bug!!!
if ((reply->error() != QNetworkReply::NoError) | (time.elapsed() > Timeout * 6)) {
qDebug() << "reply error: " << reply->error() << " see table at - http://doc.qt.io/qt-5/qnetworkreply.html";
return ret;
}
ret = reply->readAll();
// qDebug() << "ret " << ret;
reply->deleteLater(); // TODO can't this be global??
if (ret.isEmpty()) {
#ifdef DEBUG_GMAPS
qDebug() << "Invalid Tile";

View File

@ -28,12 +28,14 @@
namespace core {
const QString ProviderStrings::levelsForSigPacSpainMap[] = { "0", "1", "2", "3", "4",
"MTNSIGPAC",
"MTN2000", "MTN2000", "MTN2000", "MTN2000", "MTN2000",
"MTN200", "MTN200", "MTN200",
"MTN25", "MTN25",
"ORTOFOTOS", "ORTOFOTOS", "ORTOFOTOS", "ORTOFOTOS" };
const QString ProviderStrings::levelsForSigPacSpainMap[] = {
// "0", "1", "2", "3", "4",
"MTNSIGPAC",
"MTN2000", "MTN2000", "MTN2000", "MTN2000", "MTN2000",
"MTN200", "MTN200", "MTN200",
"MTN25", "MTN25",
"ORTOFOTOS","ORTOFOTOS", "ORTOFOTOS", "ORTOFOTOS"
};
ProviderStrings::ProviderStrings()
{
@ -59,14 +61,11 @@ ProviderStrings::ProviderStrings()
/// Google Maps API generated using http://greatmaps.codeplex.com/
/// from http://code.google.com/intl/en-us/apis/maps/signup.html
/// </summary>
GoogleMapsAPIKey = "ABQIAAAAWaQgWiEBF3lW97ifKnAczhRAzBk5Igf8Z5n2W3hNnMT0j2TikxTLtVIGU7hCLLHMAuAMt-BO5UrEWA";
GoogleMapsAPIKey = "ABQIAAAAWaQgWiEBF3lW97ifKnAczhRAzBk5Igf8Z5n2W3hNnMT0j2TikxTLtVIGU7hCLLHMAuAMt-BO5UrEWA";
// BingMaps
VersionBingMaps = "563";
VersionBingMaps = "563";
// YandexMap
VersionYandexMap = "2.16.0";
// VersionYandexSatellite = "1.19.0";
////////////////////
/// <summary>

View File

@ -63,10 +63,6 @@ public:
// BingMaps
QString VersionBingMaps;
// YandexMap
QString VersionYandexMap;
/// <summary>
/// Bing Maps Customer Identification, more info here
/// http://msdn.microsoft.com/en-us/library/bb924353.aspx

View File

@ -73,6 +73,10 @@ QString UrlFactory::TileXYToQuadKey(const int &tileX, const int &tileY, const in
}
int UrlFactory::GetServerNum(const Point &pos, const int &max) const
{
#ifdef DEBUG_URLFACTORY
qDebug() << QString("%1").arg(pos.X());
qDebug() << QString("%1").arg(pos.Y());
#endif
return (pos.X() + 2 * pos.Y()) % max;
}
void UrlFactory::setIsCorrectGoogleVersions(bool value)
@ -98,12 +102,12 @@ void UrlFactory::TryCorrectGoogleVersions()
if (CorrectGoogleVersions && !IsCorrectGoogleVersions()) {
QNetworkReply *reply;
QNetworkRequest qheader;
// This SSL Hack is half assed... technically bad *security* joojoo.
// Required due to a QT5 bug on linux and Mac
//
QSslConfiguration conf = qheader.sslConfiguration();
conf.setPeerVerifyMode(QSslSocket::VerifyNone);
qheader.setSslConfiguration(conf);
// This SSL Hack is half assed... technically bad *security* joojoo.
// Required due to a QT5 bug on linux and Mac
//
QSslConfiguration conf = qheader.sslConfiguration();
conf.setPeerVerifyMode(QSslSocket::VerifyNone);
qheader.setSslConfiguration(conf);
QNetworkAccessManager network;
QEventLoop q;
QTimer tT;
@ -116,9 +120,9 @@ void UrlFactory::TryCorrectGoogleVersions()
qDebug() << "Correct GoogleVersion";
#endif // DEBUG_URLFACTORY
// setIsCorrectGoogleVersions(true);
// QString url = "https://www.google.com/maps/@0,-0,7z?dg=dbrw&newdg=1";
// We need to switch to the Above url... the /lochp method will be depreciated soon
// https://productforums.google.com/forum/#!category-topic/maps/navigation/k6EFrp7J7Jk
// QString url = "https://www.google.com/maps/@0,-0,7z?dg=dbrw&newdg=1";
// We need to switch to the Above url... the /lochp method will be depreciated soon
// https://productforums.google.com/forum/#!category-topic/maps/navigation/k6EFrp7J7Jk
QString url = "https://www.google.com/lochp";
qheader.setUrl(QUrl(url));
@ -139,7 +143,7 @@ void UrlFactory::TryCorrectGoogleVersions()
QString html = QString(reply->readAll());
#ifdef DEBUG_URLFACTORY
qDebug() << html;
qDebug() << html;
#endif // DEBUG_URLFACTORY
QRegExp reg("\"*https://mts0.google.com/vt/lyrs=m@(\\d*)", Qt::CaseInsensitive);
@ -171,7 +175,9 @@ void UrlFactory::TryCorrectGoogleVersions()
VersionGoogleSatelliteKorea = VersionGoogleSatellite;
VersionGoogleSatelliteChina = "s@" + VersionGoogleSatellite;
#ifdef DEBUG_URLFACTORY
qDebug() << "TryCorrectGoogleVersions, VersionGoogleSatellite: " << VersionGoogleSatellite;
#endif // DEBUG_URLFACTORY
}
reg = QRegExp("\"*https://mts0.google.com/vt/lyrs=t@(\\d*),r@(\\d*)", Qt::CaseInsensitive);
@ -225,7 +231,9 @@ QString UrlFactory::MakeImageUrl(const MapType::Types &type, const Point &pos, c
QString sec2 = ""; // after &zoom=...
GetSecGoogleWords(pos, sec1, sec2);
TryCorrectGoogleVersions();
#ifdef DEBUG_URLFACTORY
qDebug() << QString("http://%1%2.google.com/%3/lyrs=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleLabels).arg(language).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2);
#endif
return QString("http://%1%2.google.com/%3/lyrs=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleLabels).arg(language).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2);
}
break;
@ -276,7 +284,9 @@ QString UrlFactory::MakeImageUrl(const MapType::Types &type, const Point &pos, c
TryCorrectGoogleVersions();
// http://mt0.google.cn/vt/v=w2t.110&hl=zh-CN&gl=cn&x=12&y=6&z=4&s=Ga
#ifdef DEBUG_URLFACTORY
qDebug() << 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);
#endif
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);
}
break;
@ -290,7 +300,7 @@ QString UrlFactory::MakeImageUrl(const MapType::Types &type, const Point &pos, c
TryCorrectGoogleVersions();
// 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("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(VersionGoogleTerrainChina).arg("zh-CN").arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2);
}
break;
case MapType::GoogleMapKorea:
@ -304,10 +314,10 @@ QString UrlFactory::MakeImageUrl(const MapType::Types &type, const Point &pos, c
// https://mts0.google.com/vt/lyrs=m@224000000&hl=ko&gl=KR&src=app&x=107&y=50&z=7&s=Gal
// https://mts0.google.com/mt/v=kr1.11&hl=ko&x=109&y=49&z=7&s=
qDebug() << QString("https://%1%2.google.com/%3/lyrs=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleMapKorea).arg(language).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2);
QString ret = QString("https://%1%2.google.com/%3/lyrs=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleMapKorea).arg(language).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2);
return ret;
#ifdef DEBUG_URLFACTORY
qDebug() << QString("https://%1%2.google.com/%3/v=%4&hl=ko&gl=KR&x=%5%6&y=%7&z=%8&s=%9").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleMapKorea).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2);
#endif
return QString("https://%1%2.google.com/%3/v=%4&hl=ko&gl=KR&x=%5%6&y=%7&z=%8&s=%9").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleMapKorea).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2);
}
break;
case MapType::GoogleSatelliteKorea:
@ -320,20 +330,25 @@ QString UrlFactory::MakeImageUrl(const MapType::Types &type, const Point &pos, c
TryCorrectGoogleVersions();
// http://khm1.google.co.kr/kh/v=54&x=109&y=49&z=7&s=
#ifdef DEBUG_URLFACTORY
qDebug() << 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);
#endif
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:
{
QString server = "mts";
QString request = "mt";
QString request = "vt";
QString sec1 = ""; // after &x=...
QString sec2 = ""; // after &zoom=...
GetSecGoogleWords(pos, sec1, sec2);
TryCorrectGoogleVersions();
// https://mts1.gmaptiles.co.kr/mt/v=kr1t.11&hl=lt&x=109&y=50&z=7&s=G
return QString("https://%1%2.gmaptiles.co.kr/%3/v=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleLabelsKorea).arg(language).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2);
#ifdef DEBUG_URLFACTORY
qDebug() << QString("https://%1%2.google.com/%3/v=%4&hl=ko&gl=KR&x=%5%6&y=%7&z=%8&s=%9").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleLabelsKorea).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2);
#endif
return QString("https://%1%2.google.com/%3/v=%4&hl=ko&gl=KR&x=%5%6&y=%7&z=%8&s=%9").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleLabelsKorea).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2);
}
break;
// *.yimg.com has been depreciated. "Here" is what Yahoo uses now. https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/request-constructing.html
@ -347,24 +362,34 @@ QString UrlFactory::MakeImageUrl(const MapType::Types &type, const Point &pos, c
case MapType::OpenStreetOsm:
{
char letter = "abc"[GetServerNum(pos, 3)];
#ifdef DEBUG_URLFACTORY
qDebug() << QString("http://%1.tile.openstreetmap.org/%2/%3/%4.png").arg(letter).arg(zoom).arg(pos.X()).arg(pos.Y());
#endif
return QString("http://%1.tile.openstreetmap.org/%2/%3/%4.png").arg(letter).arg(zoom).arg(pos.X()).arg(pos.Y());
}
break;
case MapType::OpenStreetMapSurfer:
{
// http://tiles1.mapsurfer.net/tms_r.ashx?x=37378&y=20826&z=16
// http://wiki.openstreetmap.org/wiki/MapSurfer.NET -> Mapsurfernet.com -> dead
// http://wiki.openstreetmap.org/wiki/OpenMapSurfer mentions: http://korona.geog.uni-heidelberg.de
qDebug() << QString("http://tiles1.mapsurfer.net/tms_r.ashx?x=%1&y=%2&z=%3").arg(pos.X()).arg(pos.Y()).arg(zoom);
return QString("http://tiles1.mapsurfer.net/tms_r.ashx?x=%1&y=%2&z=%3").arg(pos.X()).arg(pos.Y()).arg(zoom);
// Searched Google for tms_r.ashx and found korona.geog.uni-heidelberg.de has a service on port 8001
// http://129.206.74.245:8001/tms_r.ashx?x=37378&y=20826&z=16
#ifdef DEBUG_URLFACTORY
qDebug() << QString("http://129.206.74.245:8001/tms_r.ashx?x=%1&y=%2&z=%3").arg(pos.X()).arg(pos.Y()).arg(zoom);
#endif
return QString("http://129.206.74.245:8001/tms_r.ashx?x=%1&y=%2&z=%3").arg(pos.X()).arg(pos.Y()).arg(zoom);
}
break;
case MapType::OpenStreetMapSurferTerrain:
{
// http://tiles2.mapsurfer.net/tms_t.ashx?x=9346&y=5209&z=14
// http://korona.geog.uni-heidelberg.de/tiles/asterh/x=501&y=388&z=10
qDebug() << QString("http://tiles2.mapsurfer.net/tms_t.ashx?x=%1&y=%2&z=%3").arg(pos.X()).arg(pos.Y()).arg(zoom);
return QString("http://tiles2.mapsurfer.net/tms_t.ashx?x=%1&y=%2&z=%3").arg(pos.X()).arg(pos.Y()).arg(zoom);
#ifdef DEBUG_URLFACTORY
qDebug() << QString("http://korona.geog.uni-heidelberg.de/tiles/asterh/x=%1&y=%2&z=%3").arg(pos.X()).arg(pos.Y()).arg(zoom);
#endif
return QString("http://korona.geog.uni-heidelberg.de/tiles/asterh/x=%1&y=%2&z=%3").arg(pos.X()).arg(pos.Y()).arg(zoom);
}
break;
case MapType::BingMap:
@ -403,7 +428,9 @@ QString UrlFactory::MakeImageUrl(const MapType::Types &type, const Point &pos, c
{
// http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_ShadedRelief_World_2D/MapServer/tile/1/0/1.jpg
#ifdef DEBUG_URLFACTORY
qDebug() << QString("http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/%1/%2/%3").arg(zoom).arg(pos.Y()).arg(pos.X());
#endif
return QString("http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/%1/%2/%3").arg(zoom).arg(pos.Y()).arg(pos.X());
}
break;
@ -414,87 +441,23 @@ QString UrlFactory::MakeImageUrl(const MapType::Types &type, const Point &pos, c
return QString("http://server.arcgisonline.com/ArcGIS/rest/services/NGS_Topo_US_2D/MapServer/tile/%1/%2/%3").arg(zoom).arg(pos.Y()).arg(pos.X());
}
break;
case MapType::ArcGIS_MapsLT_OrtoFoto:
{
// http://www.maps.lt/ortofoto/mapslt_ortofoto_vector_512/map/_alllayers/L02/R0000001b/C00000028.jpg
// http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto/MapServer/tile/0/9/13
// return string.Format("http://www.maps.lt/ortofoto/mapslt_ortofoto_vector_512/map/_alllayers/L{0:00}/R{1:x8}/C{2:x8}.jpg", zoom, pos.Y(), pos.X());
// http://dc1.maps.lt/cache/mapslt_ortofoto_512/map/_alllayers/L03/R0000001c/C00000029.jpg
// return string.Format("http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto/MapServer/tile/{0}/{1}/{2}", zoom, pos.Y(), pos.X());
// http://dc1.maps.lt/cache/mapslt_ortofoto_512/map/_alllayers/L03/R0000001d/C0000002a.jpg
// TODO verificar
qDebug() << QString("http://dc1.maps.lt/cache/mapslt_ortofoto/map/_alllayers/L%1/R%2/C%3.jpg").arg(zoom, 2, 10, (QChar)'0').arg(pos.Y(), 8, 16, (QChar)'0').arg(pos.X(), 8, 16, (QChar)'0');
return QString("http://dc1.maps.lt/cache/mapslt_ortofoto/map/_alllayers/L%1/R%2/C%3.jpg").arg(zoom, 2, 10, (QChar)'0').arg(pos.Y(), 8, 16, (QChar)'0').arg(pos.X(), 8, 16, (QChar)'0');
}
break;
case MapType::ArcGIS_MapsLT_Map:
{
// http://www.maps.lt/ortofoto/mapslt_ortofoto_vector_512/map/_alllayers/L02/R0000001b/C00000028.jpg
// http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto/MapServer/tile/0/9/13
// return string.Format("http://www.maps.lt/ortofoto/mapslt_ortofoto_vector_512/map/_alllayers/L{0:00}/R{1:x8}/C{2:x8}.jpg", zoom, pos.Y(), pos.X());
// http://arcgis.maps.lt/ArcGIS/rest/services/mapslt/MapServer/tile/7/1162/1684.png
// http://dc1.maps.lt/cache/mapslt_512/map/_alllayers/L03/R0000001b/C00000029.png
// TODO verificar
// http://dc1.maps.lt/cache/mapslt/map/_alllayers/L02/R0000001c/C00000029.png
qDebug() << QString("http://dc1.maps.lt/cache/mapslt/map/_alllayers/L%1/R%2/C%3.png").arg(zoom, 2, 10, (QChar)'0').arg(pos.Y(), 8, 16, (QChar)'0').arg(pos.X(), 8, 16, (QChar)'0');
return QString("http://dc1.maps.lt/cache/mapslt/map/_alllayers/L%1/R%2/C%3.png").arg(zoom, 2, 10, (QChar)'0').arg(pos.Y(), 8, 16, (QChar)'0').arg(pos.X(), 8, 16, (QChar)'0');
}
break;
case MapType::ArcGIS_MapsLT_Map_Labels:
{
// http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto_overlay/MapServer/tile/0/9/13
// return string.Format("http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto_overlay/MapServer/tile/{0}/{1}/{2}", zoom, pos.Y(), pos.X());
// http://dc1.maps.lt/cache/mapslt_ortofoto_overlay_512/map/_alllayers/L03/R0000001d/C00000029.png
// TODO verificar
qDebug() << QString("http://dc1.maps.lt/cache/mapslt_ortofoto_overlay/map/_alllayers/L%1/R%2/C%3.png").arg(zoom, 2, 10, (QChar)'0').arg(pos.Y(), 8, 16, (QChar)'0').arg(pos.X(), 8, 16, (QChar)'0');
return QString("http://dc1.maps.lt/cache/mapslt_ortofoto_overlay/map/_alllayers/L%1/R%2/C%3.png").arg(zoom, 2, 10, (QChar)'0').arg(pos.Y(), 8, 16, (QChar)'0').arg(pos.X(), 8, 16, (QChar)'0');
}
break;
case MapType::PergoTurkeyMap:
{
// http://{domain}/{layerName}/{zoomLevel}/{first3LetterOfTileX}/{second3LetterOfTileX}/{third3LetterOfTileX}/{first3LetterOfTileY}/{second3LetterOfTileY}/{third3LetterOfTileXY}.png
// http://map3.pergo.com.tr/tile/00/000/000/001/000/000/000.png
// That means: Zoom Level: 0 TileX: 1 TileY: 0
// http://domain/tile/14/000/019/371/000/011/825.png
// That means: Zoom Level: 14 TileX: 19371 TileY:11825
// string x = pos.X().ToString("000000000").Insert(3, "/").Insert(7, "/"); // - 000/000/001
// string y = pos.Y().ToString("000000000").Insert(3, "/").Insert(7, "/"); // - 000/000/000
QString x = QString("%1").arg(QString::number(pos.X()), 9, (QChar)'0');
x.insert(3, "/").insert(7, "/");
QString y = QString("%1").arg(QString::number(pos.Y()), 9, (QChar)'0');
y.insert(3, "/").insert(7, "/");
// "http://map03.pergo.com.tr/tile/2/000/000/003/000/000/002.png"
// This has changed map03 does not exist. (neither does map3) Servers have changed to map1 and map2?
return QString("http://map%1.pergo.com.tr/tile/%2/%3/%4.png").arg(GetServerNum(pos, 4)).arg(zoom, 2, 10, (QChar)'0').arg(x).arg(y);
}
break;
case MapType::SigPacSpainMap:
{
// http://sigpac.magrama.es/fega/h5visor/ is new server location
qDebug() << QString("http://sigpac.mapa.es/kmlserver/raster/%1@3785/%2.%3.%4.img").arg(levelsForSigPacSpainMap[zoom]).arg(zoom).arg(pos.X()).arg((2 << (zoom - 1)) - pos.Y() - 1);
return QString("http://sigpac.magrama.es/SDG/%1@3785/%2.%3.%4.img").arg(levelsForSigPacSpainMap[zoom]).arg(zoom).arg(pos.X()).arg((2 << (zoom - 1)) - pos.Y() - 1);
// http://sigpac.magrama.es/fega/h5visor/ is new server location
#ifdef DEBUG_URLFACTORY
qDebug() << QString("http://sigpac.magrama.es/SDG/raster/%1@3785/%2.%3.%4.img").arg(levelsForSigPacSpainMap[zoom]).arg(zoom).arg(pos.X()).arg((2 << (zoom - 1)) - pos.Y() - 1);
#endif
return QString("http://sigpac.magrama.es/SDG/raster/%1@3785/%2.%3.%4.img").arg(levelsForSigPacSpainMap[zoom]).arg(zoom).arg(pos.X()).arg((2 << (zoom - 1)) - pos.Y() - 1);
}
break;
case MapType::YandexMapRu:
case MapType::Statkart_Topo2:
{
/*
Used "oldmaps" to determine map types - https://old.maps.yandex.ru/?ll=-83.110960%2C40.091250&spn=7.745361%2C6.015476&z=7&l=map
map: 'https:\/\/vec0%d.maps.yandex.net\/tiles?l=map&%c&%l',
sat: 'https:\/\/sat0%d.maps.yandex.net\/tiles?l=sat&%c&%l',
skl: 'https:\/\/vec0%d.maps.yandex.net\/tiles?l=skl&%c&%l',
*/
QString server = "vec";
return QString("http://%1").arg(server) + QString("0%2.maps.yandex.net/tiles?l=map&v=%3&x=%4&y=%5&z=%6").arg(GetServerNum(pos, 4) + 1).arg(VersionYandexMap).arg(pos.X()).arg(pos.Y()).arg(zoom);
// Satllite maps are poor quality, but available.
// QString server = "sat";
// return QString("http://%1").arg(server) + QString("0%2.maps.yandex.net/tiles?l=sat&v=%3&x=%4&y=%5&z=%6").arg(GetServerNum(pos, 4) + 1).arg(VersionYandexMap).arg(pos.X()).arg(pos.Y()).arg(zoom);
#ifdef DEBUG_URLFACTORY
qDebug() << QString("http://opencache.statkart.no/gatekeeper/gk/gk.open_gmaps?layers=topo2&zoom=%1&x=%2&y=%3").arg(zoom).arg(pos.X()).arg(pos.Y());
#endif
return QString("http://opencache.statkart.no/gatekeeper/gk/gk.open_gmaps?layers=topo2&zoom=%1&x=%2&y=%3").arg(zoom).arg(pos.X()).arg(pos.Y());
}
break;
default:
break;
@ -515,12 +478,16 @@ void UrlFactory::GetSecGoogleWords(const Point &pos, QString &sec1, QString &sec
QString UrlFactory::MakeGeocoderUrl(QString keywords)
{
QString key = keywords.replace(' ', '+');
// CSV output has been depreciated. API key is no longer needed.
// CSV output has been depreciated. API key is no longer needed.
return QString("https://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address=%1").arg(key);
}
QString UrlFactory::MakeReverseGeocoderUrl(internals::PointLatLng &pt, const QString &language)
{
// CSV output has been depreciated. API key is no longer needed.
#ifdef DEBUG_URLFACTORY
qDebug() << "Language: " << language;
#endif
// CSV output has been depreciated. API key is no longer needed.
return QString("https://maps.googleapis.com/maps/api/geocode/xml?latlng=%1,%2").arg(QString::number(pt.Lat())).arg(QString::number(pt.Lng()));
}
internals::PointLatLng UrlFactory::GetLatLngFromGeodecoder(const QString &keywords, QString &status)
@ -530,7 +497,7 @@ internals::PointLatLng UrlFactory::GetLatLngFromGeodecoder(const QString &keywor
QString latxml;
QString lonxml;
//QString status;
// QString status;
internals::PointLatLng UrlFactory::GetLatLngFromGeocoderUrl(const QString &url, const bool &useCache, QString &status)
{
@ -588,83 +555,77 @@ internals::PointLatLng UrlFactory::GetLatLngFromGeocoderUrl(const QString &url,
geo = reply->readAll();
#ifdef DEBUG_URLFACTORY
qDebug() << "GetLatLngFromGeocoderUrl:Reply ok";
qDebug() << geo; // This is the response from the geocode request (no longer in CSV)
qDebug() << geo; // This is the response from the geocode request (no longer in CSV)
#endif // DEBUG_URLFACTORY
// This is SOOOO horribly hackish, code duplication needs to go. Needed a quick fix.
QXmlStreamReader reader(geo);
while(!reader.atEnd())
{
reader.readNext();
// This is SOOOO horribly hackish, code duplication needs to go. Needed a quick fix.
QXmlStreamReader reader(geo);
while (!reader.atEnd()) {
reader.readNext();
if(reader.isStartElement())
{
if(reader.name() == "lat")
{
reader.readNext();
if(reader.atEnd())
break;
if (reader.isStartElement()) {
if (reader.name() == "lat") {
reader.readNext();
if (reader.atEnd()) {
break;
}
if(reader.isCharacters())
{
QString text = reader.text().toString();
qDebug() << text;
latxml = text;
break;
}
}
}
if (reader.isCharacters()) {
QString text = reader.text().toString();
#ifdef DEBUG_URLFACTORY
qDebug() << text;
#endif
latxml = text;
break;
}
}
}
}
}
while (!reader.atEnd()) {
reader.readNext();
while(!reader.atEnd())
{
reader.readNext();
if (reader.isStartElement()) {
if (reader.name() == "lng") {
reader.readNext();
if (reader.atEnd()) {
break;
}
if(reader.isStartElement())
{
if(reader.name() == "lng")
{
reader.readNext();
if(reader.atEnd())
break;
if (reader.isCharacters()) {
QString text = reader.text().toString();
#ifdef DEBUG_URLFACTORY
qDebug() << text;
#endif
lonxml = text;
break;
}
}
}
}
if(reader.isCharacters())
{
QString text = reader.text().toString();
qDebug() << text;
lonxml = text;
break;
}
}
}
QXmlStreamReader reader2(geo);
while (!reader2.atEnd()) {
reader2.readNext();
}
if (reader2.isStartElement()) {
if (reader2.name() == "status") {
reader2.readNext();
if (reader2.atEnd()) {
break;
}
QXmlStreamReader reader2(geo);
while(!reader2.atEnd())
{
reader2.readNext();
if(reader2.isStartElement())
{
if(reader2.name() == "status")
{
reader2.readNext();
if(reader2.atEnd())
break;
if(reader2.isCharacters())
{
QString text = reader2.text().toString();
qDebug() << text;
status = text;
break;
}
}
}
}
if (reader2.isCharacters()) {
QString text = reader2.text().toString();
#ifdef DEBUG_URLFACTORY
qDebug() << text;
#endif
status = text;
break;
}
}
}
}
// cache geocoding
if (useCache && geo.startsWith("200")) {
@ -676,35 +637,31 @@ internals::PointLatLng UrlFactory::GetLatLngFromGeocoderUrl(const QString &url,
{
if (status == "OK") {
double lat = QString(latxml).toDouble();
double lng = QString(lonxml).toDouble();
if (status == "OK") {
double lat = QString(latxml).toDouble();
double lng = QString(lonxml).toDouble();
ret = internals::PointLatLng(lat, lng);
ret = internals::PointLatLng(lat, lng);
#ifdef DEBUG_URLFACTORY
qDebug() << "Status is: " << status;
qDebug() << "Lat=" << lat << " Lng=" << lng;
#endif // DEBUG_URLFACTORY
}
else if (status == "ZERO_RESULTS") {
qDebug() << "No results";
}
else if (status == "OVER_QUERY_LIMIT") {
qDebug() << "You are over quota on queries";
}
else if (status == "REQUEST_DENIED") {
qDebug() << "Request was denied";
}
else if (status == "INVALID_REQUEST") {
qDebug() << "Invalid request, missing address, lat long or location";
}
else if (status == "UNKNOWN_ERROR") {
qDebug() << "Some sort of server error.";
}
else
{
qDebug() << "UrlFactory loop error";
}
qDebug() << "Status is: " << status;
qDebug() << "Lat=" << lat << " Lng=" << lng;
#endif
}
#ifdef DEBUG_URLFACTORY
else if (status == "ZERO_RESULTS") {
qDebug() << "No results";
} else if (status == "OVER_QUERY_LIMIT") {
qDebug() << "You are over quota on queries";
} else if (status == "REQUEST_DENIED") {
qDebug() << "Request was denied";
} else if (status == "INVALID_REQUEST") {
qDebug() << "Invalid request, missing address, lat long or location";
} else if (status == "UNKNOWN_ERROR") {
qDebug() << "Some sort of server error.";
} else {
qDebug() << "UrlFactory loop error";
}
#endif
}
return ret;
}

View File

@ -111,18 +111,13 @@ void Core::run()
do {
QByteArray img;
// tile number inversion(BottomLeft -> TopLeft) for pergo maps
if (tl == MapType::PergoTurkeyMap) {
img = OPMaps::Instance()->GetImageFrom(tl, Point(task.Pos.X(), maxOfTiles.Height() - task.Pos.Y()), task.Zoom);
} else { // ok
#ifdef DEBUG_CORE
qDebug() << "start getting image" << " ID=" << debug;
qDebug() << "start getting image" << " ID=" << debug;
#endif // DEBUG_CORE
img = OPMaps::Instance()->GetImageFrom(tl, task.Pos, task.Zoom);
img = OPMaps::Instance()->GetImageFrom(tl, task.Pos, task.Zoom);
#ifdef DEBUG_CORE
qDebug() << "Core::run:gotimage size:" << img.count() << " ID=" << debug << " time=" << t.elapsed();
qDebug() << "Core::run:gotimage size:" << img.count() << " ID=" << debug << " time=" << t.elapsed();
#endif // DEBUG_CORE
}
if (img.length() != 0) {
Moverlays.lock();
@ -264,6 +259,11 @@ void Core::SetMapType(const MapType::Types &value)
case MapType::ArcGIS_Map:
case MapType::ArcGIS_Satellite:
case MapType::ArcGIS_ShadedRelief:
{
maxzoom = 10;
}
break;
case MapType::ArcGIS_Terrain:
{
if (Projection()->Type() != "PlateCarreeProjection") {
@ -273,36 +273,6 @@ void Core::SetMapType(const MapType::Types &value)
}
break;
case MapType::ArcGIS_MapsLT_Map_Hybrid:
case MapType::ArcGIS_MapsLT_Map_Labels:
case MapType::ArcGIS_MapsLT_Map:
case MapType::ArcGIS_MapsLT_OrtoFoto:
{
if (Projection()->Type() != "LKS94Projection") {
SetProjection(new LKS94Projection());
maxzoom = 11;
}
}
break;
case MapType::PergoTurkeyMap:
{
if (Projection()->Type() != "PlateCarreeProjectionPergo") {
SetProjection(new PlateCarreeProjectionPergo());
maxzoom = 17;
}
}
break;
case MapType::YandexMapRu:
{
if (Projection()->Type() != "MercatorProjectionYandex") {
SetProjection(new MercatorProjectionYandex());
maxzoom = 13;
}
}
break;
default:
{
if (Projection()->Type() != "MercatorProjection") {
@ -379,15 +349,13 @@ void Core::OnMapClose()
}
QString Core::SetCurrentPositionByKeywords(QString const & keys)
{
QString status = "ZERO_RESULTS";
QString status = "ZERO_RESULTS";
PointLatLng pos = OPMaps::Instance()->GetLatLngFromGeodecoder(keys, status);
if (!pos.IsEmpty() && (status == "OK")) {
SetCurrentPosition(pos);
}
else
{
qDebug() << "Status is not OK: " << status;
} else {
qDebug() << "Status is not OK: " << status;
}
return status;
}

View File

@ -44,9 +44,7 @@
#include "rectlatlng.h"
#include "../internals/projections/lks94projection.h"
#include "../internals/projections/mercatorprojection.h"
#include "../internals/projections/mercatorprojectionyandex.h"
#include "../internals/projections/platecarreeprojection.h"
#include "../internals/projections/platecarreeprojectionpergo.h"
#include "../core/geodecoderstatus.h"
#include "../core/opmaps.h"
#include "../core/diagnostics.h"

View File

@ -23,13 +23,9 @@ SOURCES += core.cpp \
mousewheelzoomtype.cpp
HEADERS += ./projections/lks94projection.h \
./projections/mercatorprojection.h \
./projections/mercatorprojectionyandex.h \
./projections/platecarreeprojection.h \
./projections/platecarreeprojectionpergo.h
./projections/platecarreeprojection.h
SOURCES += ./projections/lks94projection.cpp \
./projections/mercatorprojection.cpp \
./projections/mercatorprojectionyandex.cpp \
./projections/platecarreeprojection.cpp \
./projections/platecarreeprojectionpergo.cpp
./projections/platecarreeprojection.cpp
LIBS += -L../build \
-lcore

View File

@ -34,8 +34,8 @@ namespace mapcontrol {
MapGraphicItem::MapGraphicItem(internals::Core *core, Configuration *configuration) : core(core), config(configuration), MapRenderTransform(1),
maxZoom(17), minZoom(2), zoomReal(0), zoomDigi(0), isSelected(false), rotation(0)
{
dragons.load(QString::fromUtf8(":/markers/images/dragons1.jpg"));
showTileGridLines = false;
// dragons.load(QString::fromUtf8(":/markers/images/dragons1.jpg"));
showTileGridLines = true;
isMouseOverMarker = false;
maprect = QRectF(0, 0, 1022, 680);
core->SetCurrentRegion(internals::Rectangle(0, 0, maprect.width(), maprect.height()));
@ -296,7 +296,7 @@ void MapGraphicItem::wheelEvent(QGraphicsSceneWheelEvent *event)
}
void MapGraphicItem::DrawMap2D(QPainter *painter)
{
painter->drawImage(this->boundingRect(), dragons.toImage());
// painter->drawImage(this->boundingRect(), dragons.toImage());
if (!lastimage.isNull()) {
painter->drawImage(core->GetrenderOffset().X() - lastimagepoint.X(), core->GetrenderOffset().Y() - lastimagepoint.Y(), lastimage);
}

View File

@ -46,35 +46,34 @@ private slots:
private:
enum XplaneOutputData // ***WARNING***: Elements in this enum are in a precise order, do
{ // not change. Cf. http://www.nuclearprojects.com/xplane/info.shtml (outdated version 9 info)
// These fields have been updated for X-Plane version 10.x
/* 0 */ FramRate,
/* 1 */ Times,
/* 2 */ SimStats,
/* 3 */ Speed,
/* 4 */ Gload,
/* 5 */ AtmosphereWeather,
/* 6 */ AtmosphereAircraft,
/* 7 */ SystemPressures,
/* 8 */ Joystick1,
/* 9 */ Joystick2,
/* 10 */ ArtStab,
/* 11 */ FlightCon,
/* 12 */ WingSweep,
/* 13 */ Trim,
/* 14 */ Brakes,
/* 15 */ AngularMoments,
/* 16 */ AngularVelocities,
/* 17 */ PitchRollHeading,
/* 18 */ AoA,
/* 19 */ MagCompass,
/* 20 */ LatitudeLongitude,
/* 21 */ LocVelDistTraveled,
/* 22 */ AllPlanesLat,
/* 23 */ AllPlanesLon,
/* 24 */ AllPlanesAlt,
/* 25 */ ThrottleCommand
/* .. */
// These fields have been updated for X-Plane version 10.x
/* 0 */ FramRate,
/* 1 */ Times,
/* 2 */ SimStats,
/* 3 */ Speed,
/* 4 */ Gload,
/* 5 */ AtmosphereWeather,
/* 6 */ AtmosphereAircraft,
/* 7 */ SystemPressures,
/* 8 */ Joystick1,
/* 9 */ Joystick2,
/* 10 */ ArtStab,
/* 11 */ FlightCon,
/* 12 */ WingSweep,
/* 13 */ Trim,
/* 14 */ Brakes,
/* 15 */ AngularMoments,
/* 16 */ AngularVelocities,
/* 17 */ PitchRollHeading,
/* 18 */ AoA,
/* 19 */ MagCompass,
/* 20 */ LatitudeLongitude,
/* 21 */ LocVelDistTraveled,
/* 22 */ AllPlanesLat,
/* 23 */ AllPlanesLon,
/* 24 */ AllPlanesAlt,
/* 25 */ ThrottleCommand
/* .. */
};
void processUpdate(const QByteArray & data);

View File

@ -2318,9 +2318,9 @@ void OPMapGadgetWidget::SetUavPic(QString UAVPic)
void OPMapGadgetWidget::on_tbFind_clicked()
{
QPalette pal = m_widget->leFind->palette();
QPalette pal = m_widget->leFind->palette();
QString status = m_map->SetCurrentPositionByKeywords(m_widget->leFind->text());
QString status = m_map->SetCurrentPositionByKeywords(m_widget->leFind->text());
if (status == "OK") {
pal.setColor(m_widget->leFind->backgroundRole(), Qt::green);
@ -2351,7 +2351,6 @@ void OPMapGadgetWidget::on_tbFind_clicked()
m_widget->leFind->setPalette(pal);
qDebug() << "Some sort of code error!";
}
}
void OPMapGadgetWidget::onHomeDoubleClick(HomeItem *)