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 next

This commit is contained in:
abeck70 2015-05-19 18:20:06 +10:00
commit 869bfaaee5
16 changed files with 284 additions and 372 deletions

View File

@ -52,7 +52,8 @@ typedef enum {
NOTIFY_SEQUENCE_ALM_CONFIG = 17, NOTIFY_SEQUENCE_ALM_CONFIG = 17,
NOTIFY_SEQUENCE_ALM_RECEIVER = 18, NOTIFY_SEQUENCE_ALM_RECEIVER = 18,
NOTIFY_SEQUENCE_DISARMED = 19, NOTIFY_SEQUENCE_DISARMED = 19,
NOTIFY_SEQUENCE_NULL = 255, // skips any signalling for this condition NOTIFY_SEQUENCE_ALM_ATTITUDE = 20,
NOTIFY_SEQUENCE_NULL = 255, // skips any signalling for this condition
} NotifySequences; } NotifySequences;
// This structure determine sequences attached to an alarm // This structure determine sequences attached to an alarm
@ -60,6 +61,7 @@ typedef struct {
uint32_t timeBetweenNotifications; // time in milliseconds to wait between each notification iteration uint32_t timeBetweenNotifications; // time in milliseconds to wait between each notification iteration
uint8_t alarmIndex; // Index of the alarm, use one of the SYSTEMALARMS_ALARM_XXXXX defines uint8_t alarmIndex; // Index of the alarm, use one of the SYSTEMALARMS_ALARM_XXXXX defines
uint8_t warnNotification; // index of the sequence to be used when alarm is in warning status(pick one from NotifySequences enum) uint8_t warnNotification; // index of the sequence to be used when alarm is in warning status(pick one from NotifySequences enum)
uint8_t criticalNotification; // index of the sequence to be used when alarm is in critical status(pick one from NotifySequences enum)
uint8_t errorNotification; // index of the sequence to be used when alarm is in error status(pick one from NotifySequences enum) uint8_t errorNotification; // index of the sequence to be used when alarm is in error status(pick one from NotifySequences enum)
} AlarmDefinition_t; } AlarmDefinition_t;
@ -112,7 +114,7 @@ const LedSequence_t notifications[] = {
}, }, }, },
[NOTIFY_SEQUENCE_ARMED_FM_STABILIZED6] = { .repeats = -1, .steps = { [NOTIFY_SEQUENCE_ARMED_FM_STABILIZED6] = { .repeats = -1, .steps = {
{ .time_off = 100, .time_on = 100, .color = COLOR_PURPLE, .repeats = 1, }, { .time_off = 100, .time_on = 100, .color = COLOR_PURPLE, .repeats = 1, },
{ .time_off = 100, .time_on = 100, .color = COLOR_PURPLE, .repeats = 1, }, { .time_off = 100, .time_on = 100, .color = COLOR_BLUE, .repeats = 1, },
{ .time_off = 500, .time_on = 100, .color = COLOR_BLUE, .repeats = 1, }, { .time_off = 500, .time_on = 100, .color = COLOR_BLUE, .repeats = 1, },
}, }, }, },
[NOTIFY_SEQUENCE_ARMED_FM_GPS] = { .repeats = -1, .steps = { [NOTIFY_SEQUENCE_ARMED_FM_GPS] = { .repeats = -1, .steps = {
@ -156,6 +158,10 @@ const LedSequence_t notifications[] = {
{ .time_off = 50, .time_on = 50, .color = COLOR_ORANGE, .repeats = 9, }, { .time_off = 50, .time_on = 50, .color = COLOR_ORANGE, .repeats = 9, },
{ .time_off = 500, .time_on = 50, .color = COLOR_ORANGE, .repeats = 1, }, { .time_off = 500, .time_on = 50, .color = COLOR_ORANGE, .repeats = 1, },
}, }, }, },
[NOTIFY_SEQUENCE_ALM_ATTITUDE] = { .repeats = 10, .steps = {
{ .time_off = 0, .time_on = 50, .color = COLOR_RED, .repeats = 1, },
{ .time_off = 0, .time_on = 50, .color = COLOR_BLUE, .repeats = 1, },
}, },
}; };
// List of background sequences attached to each flight mode // List of background sequences attached to each flight mode
@ -185,32 +191,44 @@ const AlarmDefinition_t alarmsMap[] = {
.timeBetweenNotifications = 10000, .timeBetweenNotifications = 10000,
.alarmIndex = SYSTEMALARMS_ALARM_GPS, .alarmIndex = SYSTEMALARMS_ALARM_GPS,
.warnNotification = NOTIFY_SEQUENCE_ALM_WARN_GPS, .warnNotification = NOTIFY_SEQUENCE_ALM_WARN_GPS,
.criticalNotification = NOTIFY_SEQUENCE_ALM_ERROR_GPS,
.errorNotification = NOTIFY_SEQUENCE_ALM_ERROR_GPS, .errorNotification = NOTIFY_SEQUENCE_ALM_ERROR_GPS,
}, },
{ {
.timeBetweenNotifications = 15000, .timeBetweenNotifications = 5000,
.alarmIndex = SYSTEMALARMS_ALARM_MAGNETOMETER, .alarmIndex = SYSTEMALARMS_ALARM_MAGNETOMETER,
.warnNotification = NOTIFY_SEQUENCE_NULL, .warnNotification = NOTIFY_SEQUENCE_NULL,
.criticalNotification = NOTIFY_SEQUENCE_ALM_MAG,
.errorNotification = NOTIFY_SEQUENCE_ALM_MAG, .errorNotification = NOTIFY_SEQUENCE_ALM_MAG,
}, },
{ {
.timeBetweenNotifications = 15000, .timeBetweenNotifications = 15000,
.alarmIndex = SYSTEMALARMS_ALARM_BATTERY, .alarmIndex = SYSTEMALARMS_ALARM_BATTERY,
.warnNotification = NOTIFY_SEQUENCE_ALM_WARN_BATTERY, .warnNotification = NOTIFY_SEQUENCE_ALM_WARN_BATTERY,
.criticalNotification = NOTIFY_SEQUENCE_ALM_ERROR_BATTERY,
.errorNotification = NOTIFY_SEQUENCE_ALM_ERROR_BATTERY, .errorNotification = NOTIFY_SEQUENCE_ALM_ERROR_BATTERY,
}, },
{ {
.timeBetweenNotifications = 5000, .timeBetweenNotifications = 5000,
.alarmIndex = SYSTEMALARMS_ALARM_SYSTEMCONFIGURATION, .alarmIndex = SYSTEMALARMS_ALARM_SYSTEMCONFIGURATION,
.warnNotification = NOTIFY_SEQUENCE_NULL, .warnNotification = NOTIFY_SEQUENCE_NULL,
.criticalNotification = NOTIFY_SEQUENCE_ALM_CONFIG,
.errorNotification = NOTIFY_SEQUENCE_ALM_CONFIG, .errorNotification = NOTIFY_SEQUENCE_ALM_CONFIG,
}, },
{ {
.timeBetweenNotifications = 5000, .timeBetweenNotifications = 2000,
.alarmIndex = SYSTEMALARMS_ALARM_RECEIVER, .alarmIndex = SYSTEMALARMS_ALARM_RECEIVER,
.warnNotification = NOTIFY_SEQUENCE_ALM_RECEIVER, .warnNotification = NOTIFY_SEQUENCE_ALM_RECEIVER,
.criticalNotification = NOTIFY_SEQUENCE_ALM_RECEIVER,
.errorNotification = NOTIFY_SEQUENCE_ALM_RECEIVER, .errorNotification = NOTIFY_SEQUENCE_ALM_RECEIVER,
}, },
{
.timeBetweenNotifications = 1000,
.alarmIndex = SYSTEMALARMS_ALARM_ATTITUDE,
.warnNotification = NOTIFY_SEQUENCE_ALM_ATTITUDE,
.criticalNotification = NOTIFY_SEQUENCE_NULL,
.errorNotification = NOTIFY_SEQUENCE_ALM_ATTITUDE,
},
}; };
const uint8_t alarmsMapSize = NELEMENTS(alarmsMap); const uint8_t alarmsMapSize = NELEMENTS(alarmsMap);

View File

@ -49,7 +49,7 @@ typedef struct {
static void updatedCb(UAVObjEvent *ev); static void updatedCb(UAVObjEvent *ev);
static void onTimerCb(UAVObjEvent *ev); static void onTimerCb(UAVObjEvent *ev);
static void checkAlarm(uint8_t alarm, uint8_t *last_alarm, uint32_t *last_alm_time, static void checkAlarm(uint8_t alarm, uint8_t *last_alarm, uint32_t *last_alm_time,
uint8_t warn_sequence, uint8_t error_sequence, uint8_t warn_sequence, uint8_t critical_sequence, uint8_t error_sequence,
uint32_t timeBetweenNotifications); uint32_t timeBetweenNotifications);
static AlarmStatus_t *alarmStatus; static AlarmStatus_t *alarmStatus;
int32_t NotifyInitialize(void) int32_t NotifyInitialize(void)
@ -111,17 +111,19 @@ void onTimerCb(__attribute__((unused)) UAVObjEvent *ev)
&alarmStatus[i].lastAlarm, &alarmStatus[i].lastAlarm,
&alarmStatus[i].lastAlarmTime, &alarmStatus[i].lastAlarmTime,
alarmsMap[i].warnNotification, alarmsMap[i].warnNotification,
alarmsMap[i].criticalNotification,
alarmsMap[i].errorNotification, alarmsMap[i].errorNotification,
alarmsMap[i].timeBetweenNotifications); alarmsMap[i].timeBetweenNotifications);
} }
} }
void checkAlarm(uint8_t alarm, uint8_t *last_alarm, uint32_t *last_alm_time, uint8_t warn_sequence, uint8_t error_sequence, uint32_t timeBetweenNotifications) void checkAlarm(uint8_t alarm, uint8_t *last_alarm, uint32_t *last_alm_time, uint8_t warn_sequence, uint8_t critical_sequence, uint8_t error_sequence, uint32_t timeBetweenNotifications)
{ {
if (alarm > SYSTEMALARMS_ALARM_OK) { if (alarm > SYSTEMALARMS_ALARM_OK) {
uint32_t current_time = PIOS_DELAY_GetuS(); uint32_t current_time = PIOS_DELAY_GetuS();
if (*last_alarm < alarm || *last_alm_time + timeBetweenNotifications * 1000 < current_time) { if (*last_alarm < alarm || *last_alm_time + timeBetweenNotifications * 1000 > current_time) {
uint8_t sequence = (alarm == SYSTEMALARMS_ALARM_WARNING) ? warn_sequence : error_sequence; uint8_t sequence = (alarm == SYSTEMALARMS_ALARM_WARNING) ? warn_sequence :
((alarm == SYSTEMALARMS_ALARM_CRITICAL) ? critical_sequence : error_sequence);
if (sequence != NOTIFY_SEQUENCE_NULL) { if (sequence != NOTIFY_SEQUENCE_NULL) {
PIOS_NOTIFICATION_Default_Ext_Led_Play( PIOS_NOTIFICATION_Default_Ext_Led_Play(
&notifications[sequence], &notifications[sequence],

View File

@ -795,9 +795,9 @@ static void applyDeadband(float *value, float deadband)
if (fabsf(*value) < deadband) { if (fabsf(*value) < deadband) {
*value = 0.0f; *value = 0.0f;
} else if (*value > 0.0f) { } else if (*value > 0.0f) {
*value -= deadband; *value = (*value - deadband) / (1.0f - deadband);
} else { } else {
*value += deadband; *value = (*value + deadband) / (1.0f - deadband);
} }
} }

View File

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

View File

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

View File

@ -52,35 +52,15 @@ public:
OpenStreetMapSurfer = 34, OpenStreetMapSurfer = 34,
OpenStreetMapSurferTerrain = 35, OpenStreetMapSurferTerrain = 35,
BingMap = 444, BingMap = 444,
BingSatellite = 555, BingSatellite = 555,
BingHybrid = 666, BingHybrid = 666,
ArcGIS_Map = 777, ArcGIS_Map = 777,
ArcGIS_Satellite = 788, ArcGIS_Satellite = 788,
ArcGIS_ShadedRelief = 799, ArcGIS_ShadedRelief = 799,
ArcGIS_Terrain = 811, 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, SigPacSpainMap = 3001,
GoogleMapKorea = 4001, GoogleMapKorea = 4001,
@ -88,7 +68,7 @@ public:
GoogleLabelsKorea = 4003, GoogleLabelsKorea = 4003,
GoogleHybridKorea = 4005, GoogleHybridKorea = 4005,
YandexMapRu = 5000 Statkart_Topo2 = 5500
}; };
static QString StrByType(Types const & value) static QString StrByType(Types const & value)
{ {

View File

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

View File

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

View File

@ -63,10 +63,6 @@ public:
// BingMaps // BingMaps
QString VersionBingMaps; QString VersionBingMaps;
// YandexMap
QString VersionYandexMap;
/// <summary> /// <summary>
/// Bing Maps Customer Identification, more info here /// Bing Maps Customer Identification, more info here
/// http://msdn.microsoft.com/en-us/library/bb924353.aspx /// 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 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; return (pos.X() + 2 * pos.Y()) % max;
} }
void UrlFactory::setIsCorrectGoogleVersions(bool value) void UrlFactory::setIsCorrectGoogleVersions(bool value)
@ -98,12 +102,12 @@ void UrlFactory::TryCorrectGoogleVersions()
if (CorrectGoogleVersions && !IsCorrectGoogleVersions()) { if (CorrectGoogleVersions && !IsCorrectGoogleVersions()) {
QNetworkReply *reply; QNetworkReply *reply;
QNetworkRequest qheader; QNetworkRequest qheader;
// This SSL Hack is half assed... technically bad *security* joojoo. // This SSL Hack is half assed... technically bad *security* joojoo.
// Required due to a QT5 bug on linux and Mac // Required due to a QT5 bug on linux and Mac
// //
QSslConfiguration conf = qheader.sslConfiguration(); QSslConfiguration conf = qheader.sslConfiguration();
conf.setPeerVerifyMode(QSslSocket::VerifyNone); conf.setPeerVerifyMode(QSslSocket::VerifyNone);
qheader.setSslConfiguration(conf); qheader.setSslConfiguration(conf);
QNetworkAccessManager network; QNetworkAccessManager network;
QEventLoop q; QEventLoop q;
QTimer tT; QTimer tT;
@ -116,9 +120,9 @@ void UrlFactory::TryCorrectGoogleVersions()
qDebug() << "Correct GoogleVersion"; qDebug() << "Correct GoogleVersion";
#endif // DEBUG_URLFACTORY #endif // DEBUG_URLFACTORY
// setIsCorrectGoogleVersions(true); // setIsCorrectGoogleVersions(true);
// QString url = "https://www.google.com/maps/@0,-0,7z?dg=dbrw&newdg=1"; // 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 // 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 // https://productforums.google.com/forum/#!category-topic/maps/navigation/k6EFrp7J7Jk
QString url = "https://www.google.com/lochp"; QString url = "https://www.google.com/lochp";
qheader.setUrl(QUrl(url)); qheader.setUrl(QUrl(url));
@ -139,7 +143,7 @@ void UrlFactory::TryCorrectGoogleVersions()
QString html = QString(reply->readAll()); QString html = QString(reply->readAll());
#ifdef DEBUG_URLFACTORY #ifdef DEBUG_URLFACTORY
qDebug() << html; qDebug() << html;
#endif // DEBUG_URLFACTORY #endif // DEBUG_URLFACTORY
QRegExp reg("\"*https://mts0.google.com/vt/lyrs=m@(\\d*)", Qt::CaseInsensitive); QRegExp reg("\"*https://mts0.google.com/vt/lyrs=m@(\\d*)", Qt::CaseInsensitive);
@ -171,7 +175,9 @@ void UrlFactory::TryCorrectGoogleVersions()
VersionGoogleSatelliteKorea = VersionGoogleSatellite; VersionGoogleSatelliteKorea = VersionGoogleSatellite;
VersionGoogleSatelliteChina = "s@" + VersionGoogleSatellite; VersionGoogleSatelliteChina = "s@" + VersionGoogleSatellite;
#ifdef DEBUG_URLFACTORY
qDebug() << "TryCorrectGoogleVersions, VersionGoogleSatellite: " << VersionGoogleSatellite; qDebug() << "TryCorrectGoogleVersions, VersionGoogleSatellite: " << VersionGoogleSatellite;
#endif // DEBUG_URLFACTORY
} }
reg = QRegExp("\"*https://mts0.google.com/vt/lyrs=t@(\\d*),r@(\\d*)", Qt::CaseInsensitive); 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=... QString sec2 = ""; // after &zoom=...
GetSecGoogleWords(pos, sec1, sec2); GetSecGoogleWords(pos, sec1, sec2);
TryCorrectGoogleVersions(); 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); 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); 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; break;
@ -276,7 +284,9 @@ QString UrlFactory::MakeImageUrl(const MapType::Types &type, const Point &pos, c
TryCorrectGoogleVersions(); TryCorrectGoogleVersions();
// http://mt0.google.cn/vt/v=w2t.110&hl=zh-CN&gl=cn&x=12&y=6&z=4&s=Ga // 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); 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); 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; break;
@ -290,7 +300,7 @@ QString UrlFactory::MakeImageUrl(const MapType::Types &type, const Point &pos, c
TryCorrectGoogleVersions(); TryCorrectGoogleVersions();
// http://mt0.google.cn/vt/v=w2p.110&hl=zh-CN&gl=cn&x=12&y=6&z=4&s=Ga // 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; break;
case MapType::GoogleMapKorea: 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/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= // 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); #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);
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); #endif
return ret; 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; break;
case MapType::GoogleSatelliteKorea: case MapType::GoogleSatelliteKorea:
@ -320,20 +330,25 @@ QString UrlFactory::MakeImageUrl(const MapType::Types &type, const Point &pos, c
TryCorrectGoogleVersions(); TryCorrectGoogleVersions();
// http://khm1.google.co.kr/kh/v=54&x=109&y=49&z=7&s= // 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); 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; break;
case MapType::GoogleLabelsKorea: case MapType::GoogleLabelsKorea:
{ {
QString server = "mts"; QString server = "mts";
QString request = "mt"; QString request = "vt";
QString sec1 = ""; // after &x=... QString sec1 = ""; // after &x=...
QString sec2 = ""; // after &zoom=... QString sec2 = ""; // after &zoom=...
GetSecGoogleWords(pos, sec1, sec2); GetSecGoogleWords(pos, sec1, sec2);
TryCorrectGoogleVersions(); 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; 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 // *.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: case MapType::OpenStreetOsm:
{ {
char letter = "abc"[GetServerNum(pos, 3)]; 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()); 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()); return QString("http://%1.tile.openstreetmap.org/%2/%3/%4.png").arg(letter).arg(zoom).arg(pos.X()).arg(pos.Y());
} }
break; break;
case MapType::OpenStreetMapSurfer: 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); // Searched Google for tms_r.ashx and found korona.geog.uni-heidelberg.de has a service on port 8001
return QString("http://tiles1.mapsurfer.net/tms_r.ashx?x=%1&y=%2&z=%3").arg(pos.X()).arg(pos.Y()).arg(zoom); // 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; break;
case MapType::OpenStreetMapSurferTerrain: 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); #ifdef DEBUG_URLFACTORY
return QString("http://tiles2.mapsurfer.net/tms_t.ashx?x=%1&y=%2&z=%3").arg(pos.X()).arg(pos.Y()).arg(zoom); 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; break;
case MapType::BingMap: 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 // 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()); 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()); 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; 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()); 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; 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: case MapType::SigPacSpainMap:
{ {
// http://sigpac.magrama.es/fega/h5visor/ is new server location // 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); #ifdef DEBUG_URLFACTORY
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); 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; break;
case MapType::Statkart_Topo2:
case MapType::YandexMapRu:
{ {
/* #ifdef DEBUG_URLFACTORY
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 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());
map: 'https:\/\/vec0%d.maps.yandex.net\/tiles?l=map&%c&%l', #endif
sat: 'https:\/\/sat0%d.maps.yandex.net\/tiles?l=sat&%c&%l', 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());
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);
} }
break; break;
default: default:
break; break;
@ -515,12 +478,16 @@ void UrlFactory::GetSecGoogleWords(const Point &pos, QString &sec1, QString &sec
QString UrlFactory::MakeGeocoderUrl(QString keywords) QString UrlFactory::MakeGeocoderUrl(QString keywords)
{ {
QString key = keywords.replace(' ', '+'); 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); 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) 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())); 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) internals::PointLatLng UrlFactory::GetLatLngFromGeodecoder(const QString &keywords, QString &status)
@ -530,7 +497,7 @@ internals::PointLatLng UrlFactory::GetLatLngFromGeodecoder(const QString &keywor
QString latxml; QString latxml;
QString lonxml; QString lonxml;
//QString status; // QString status;
internals::PointLatLng UrlFactory::GetLatLngFromGeocoderUrl(const QString &url, const bool &useCache, 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(); geo = reply->readAll();
#ifdef DEBUG_URLFACTORY #ifdef DEBUG_URLFACTORY
qDebug() << "GetLatLngFromGeocoderUrl:Reply ok"; 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 #endif // DEBUG_URLFACTORY
// This is SOOOO horribly hackish, code duplication needs to go. Needed a quick fix. // This is SOOOO horribly hackish, code duplication needs to go. Needed a quick fix.
QXmlStreamReader reader(geo); QXmlStreamReader reader(geo);
while(!reader.atEnd()) while (!reader.atEnd()) {
{ reader.readNext();
reader.readNext();
if(reader.isStartElement()) if (reader.isStartElement()) {
{ if (reader.name() == "lat") {
if(reader.name() == "lat") reader.readNext();
{ if (reader.atEnd()) {
reader.readNext(); break;
if(reader.atEnd()) }
break;
if(reader.isCharacters()) if (reader.isCharacters()) {
{ QString text = reader.text().toString();
QString text = reader.text().toString(); #ifdef DEBUG_URLFACTORY
qDebug() << text; qDebug() << text;
latxml = text; #endif
break; latxml = text;
} break;
} }
} }
}
}
} while (!reader.atEnd()) {
reader.readNext();
while(!reader.atEnd()) if (reader.isStartElement()) {
{ if (reader.name() == "lng") {
reader.readNext(); reader.readNext();
if (reader.atEnd()) {
break;
}
if(reader.isStartElement()) if (reader.isCharacters()) {
{ QString text = reader.text().toString();
if(reader.name() == "lng") #ifdef DEBUG_URLFACTORY
{ qDebug() << text;
reader.readNext(); #endif
if(reader.atEnd()) lonxml = text;
break; break;
}
}
}
}
if(reader.isCharacters()) QXmlStreamReader reader2(geo);
{ while (!reader2.atEnd()) {
QString text = reader.text().toString(); reader2.readNext();
qDebug() << text;
lonxml = text;
break;
}
}
}
} if (reader2.isStartElement()) {
if (reader2.name() == "status") {
reader2.readNext();
if (reader2.atEnd()) {
break;
}
QXmlStreamReader reader2(geo); if (reader2.isCharacters()) {
while(!reader2.atEnd()) QString text = reader2.text().toString();
{ #ifdef DEBUG_URLFACTORY
reader2.readNext(); qDebug() << text;
#endif
if(reader2.isStartElement()) status = text;
{ break;
if(reader2.name() == "status") }
{ }
reader2.readNext(); }
if(reader2.atEnd()) }
break;
if(reader2.isCharacters())
{
QString text = reader2.text().toString();
qDebug() << text;
status = text;
break;
}
}
}
}
// cache geocoding // cache geocoding
if (useCache && geo.startsWith("200")) { if (useCache && geo.startsWith("200")) {
@ -676,35 +637,31 @@ internals::PointLatLng UrlFactory::GetLatLngFromGeocoderUrl(const QString &url,
{ {
if (status == "OK") { if (status == "OK") {
double lat = QString(latxml).toDouble(); double lat = QString(latxml).toDouble();
double lng = QString(lonxml).toDouble(); double lng = QString(lonxml).toDouble();
ret = internals::PointLatLng(lat, lng); ret = internals::PointLatLng(lat, lng);
#ifdef DEBUG_URLFACTORY #ifdef DEBUG_URLFACTORY
qDebug() << "Status is: " << status; qDebug() << "Status is: " << status;
qDebug() << "Lat=" << lat << " Lng=" << lng; qDebug() << "Lat=" << lat << " Lng=" << lng;
#endif // DEBUG_URLFACTORY #endif
} }
else if (status == "ZERO_RESULTS") { #ifdef DEBUG_URLFACTORY
qDebug() << "No results"; else if (status == "ZERO_RESULTS") {
} qDebug() << "No results";
else if (status == "OVER_QUERY_LIMIT") { } else if (status == "OVER_QUERY_LIMIT") {
qDebug() << "You are over quota on queries"; qDebug() << "You are over quota on queries";
} } else if (status == "REQUEST_DENIED") {
else if (status == "REQUEST_DENIED") { qDebug() << "Request was denied";
qDebug() << "Request was denied"; } else if (status == "INVALID_REQUEST") {
} qDebug() << "Invalid request, missing address, lat long or location";
else if (status == "INVALID_REQUEST") { } else if (status == "UNKNOWN_ERROR") {
qDebug() << "Invalid request, missing address, lat long or location"; qDebug() << "Some sort of server error.";
} } else {
else if (status == "UNKNOWN_ERROR") { qDebug() << "UrlFactory loop error";
qDebug() << "Some sort of server error."; }
} #endif
else
{
qDebug() << "UrlFactory loop error";
}
} }
return ret; return ret;
} }

View File

@ -111,18 +111,13 @@ void Core::run()
do { do {
QByteArray img; 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 #ifdef DEBUG_CORE
qDebug() << "start getting image" << " ID=" << debug; qDebug() << "start getting image" << " ID=" << debug;
#endif // DEBUG_CORE #endif // DEBUG_CORE
img = OPMaps::Instance()->GetImageFrom(tl, task.Pos, task.Zoom); img = OPMaps::Instance()->GetImageFrom(tl, task.Pos, task.Zoom);
#ifdef DEBUG_CORE #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 #endif // DEBUG_CORE
}
if (img.length() != 0) { if (img.length() != 0) {
Moverlays.lock(); Moverlays.lock();
@ -264,6 +259,11 @@ void Core::SetMapType(const MapType::Types &value)
case MapType::ArcGIS_Map: case MapType::ArcGIS_Map:
case MapType::ArcGIS_Satellite: case MapType::ArcGIS_Satellite:
case MapType::ArcGIS_ShadedRelief: case MapType::ArcGIS_ShadedRelief:
{
maxzoom = 10;
}
break;
case MapType::ArcGIS_Terrain: case MapType::ArcGIS_Terrain:
{ {
if (Projection()->Type() != "PlateCarreeProjection") { if (Projection()->Type() != "PlateCarreeProjection") {
@ -273,36 +273,6 @@ void Core::SetMapType(const MapType::Types &value)
} }
break; 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: default:
{ {
if (Projection()->Type() != "MercatorProjection") { if (Projection()->Type() != "MercatorProjection") {
@ -379,15 +349,13 @@ void Core::OnMapClose()
} }
QString Core::SetCurrentPositionByKeywords(QString const & keys) QString Core::SetCurrentPositionByKeywords(QString const & keys)
{ {
QString status = "ZERO_RESULTS"; QString status = "ZERO_RESULTS";
PointLatLng pos = OPMaps::Instance()->GetLatLngFromGeodecoder(keys, status); PointLatLng pos = OPMaps::Instance()->GetLatLngFromGeodecoder(keys, status);
if (!pos.IsEmpty() && (status == "OK")) { if (!pos.IsEmpty() && (status == "OK")) {
SetCurrentPosition(pos); SetCurrentPosition(pos);
} } else {
else qDebug() << "Status is not OK: " << status;
{
qDebug() << "Status is not OK: " << status;
} }
return status; return status;
} }

View File

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

View File

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

View File

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

View File

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

View File

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