From 38f0a609daf221d87cdb03a587a3dc5412a534db Mon Sep 17 00:00:00 2001 From: Kevin Finisterre Date: Sun, 10 May 2015 15:59:08 -0400 Subject: [PATCH 1/4] Fix Google Map tiles, https://maps.google.com/maps?output=classic is now depreciated. Legacy view temporarily available via https://www.google.com/lochp Need to update to Google Maps v3 soon. New URL will be https://www.google.com/maps/@0,-0,7z?dg=dbrw&newdg=1 (tile retrieval is completely different) Fix location search. Updated to v3 Google GeoCoder. CSV is no longer an option for output. Updated to XML parsed output. (needs a more robust parser!) New Geocode search urls are as follows: https://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address=california https://maps.googleapis.com/maps/api/geocode/xml?latlng=0.000000,-0.000000 Need to fix response after SetCurrentPositionByKeywords() all responses shade the box Green currently. --- .../src/libs/opmapcontrol/opmapcontrol.pro | 2 + .../src/libs/opmapcontrol/src/core/core.pro | 2 + .../libs/opmapcontrol/src/core/urlfactory.cpp | 152 +++++++++++++++--- .../libs/opmapcontrol/src/core/urlfactory.h | 4 +- .../libs/opmapcontrol/src/internals/core.cpp | 12 +- 5 files changed, 148 insertions(+), 24 deletions(-) diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/opmapcontrol.pro b/ground/openpilotgcs/src/libs/opmapcontrol/opmapcontrol.pro index dee478c28..1f27742bd 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/opmapcontrol.pro +++ b/ground/openpilotgcs/src/libs/opmapcontrol/opmapcontrol.pro @@ -2,3 +2,5 @@ TEMPLATE = subdirs SUBDIRS = src \ + +QT += xml diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/core.pro b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/core.pro index d606082a1..912d292fe 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/core.pro +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/core.pro @@ -38,3 +38,5 @@ HEADERS += opmaps.h \ kibertilecache.h \ debugheader.h \ diagnostics.h + +QT += xml diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp index e033d58dc..4df06c916 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp @@ -26,7 +26,8 @@ */ #include "urlfactory.h" #include - +#include +#include namespace core { const double UrlFactory::EarthRadiusKm = 6378.137; // WGS-84 @@ -97,6 +98,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); QNetworkAccessManager network; QEventLoop q; QTimer tT; @@ -109,7 +116,10 @@ void UrlFactory::TryCorrectGoogleVersions() qDebug() << "Correct GoogleVersion"; #endif // DEBUG_URLFACTORY // setIsCorrectGoogleVersions(true); - QString url = "https://maps.google.com/maps?output=classic"; + // 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)); qheader.setRawHeader("User-Agent", UserAgent); @@ -126,7 +136,12 @@ void UrlFactory::TryCorrectGoogleVersions() #endif // DEBUG_URLFACTORY return; } + QString html = QString(reply->readAll()); +#ifdef DEBUG_URLFACTORY + qDebug() << html; +#endif // DEBUG_URLFACTORY + QRegExp reg("\"*https://mts0.google.com/vt/lyrs=m@(\\d*)", Qt::CaseInsensitive); if (reg.indexIn(html) != -1) { QStringList gc = reg.capturedTexts(); @@ -148,6 +163,7 @@ void UrlFactory::TryCorrectGoogleVersions() qDebug() << "TryCorrectGoogleVersions, VersionGoogleLabels: " << VersionGoogleLabels; #endif // DEBUG_URLFACTORY } + reg = QRegExp("\"*https://khms0.google.com/kh/v=(\\d*)", Qt::CaseInsensitive); if (reg.indexIn(html) != -1) { QStringList gc = reg.capturedTexts(); @@ -157,6 +173,7 @@ void UrlFactory::TryCorrectGoogleVersions() qDebug() << "TryCorrectGoogleVersions, VersionGoogleSatellite: " << VersionGoogleSatellite; } + reg = QRegExp("\"*https://mts0.google.com/vt/lyrs=t@(\\d*),r@(\\d*)", Qt::CaseInsensitive); if (reg.indexIn(html) != -1) { QStringList gc = reg.capturedTexts(); @@ -492,23 +509,29 @@ void UrlFactory::GetSecGoogleWords(const Point &pos, QString &sec1, QString &sec 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); + // 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) { - 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); + // 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, GeoCoderStatusCode::Types &status) +internals::PointLatLng UrlFactory::GetLatLngFromGeodecoder(const QString &keywords, QString &status) { return GetLatLngFromGeocoderUrl(MakeGeocoderUrl(keywords), UseGeocoderCache, status); } -internals::PointLatLng UrlFactory::GetLatLngFromGeocoderUrl(const QString &url, const bool &useCache, GeoCoderStatusCode::Types &status) + +QString latxml; +QString lonxml; +//QString status; + +internals::PointLatLng UrlFactory::GetLatLngFromGeocoderUrl(const QString &url, const bool &useCache, QString &status) { #ifdef DEBUG_URLFACTORY qDebug() << "Entered GetLatLngFromGeocoderUrl:"; #endif // DEBUG_URLFACTORY - status = GeoCoderStatusCode::Unknow; + status = "ZERO_RESULTS"; internals::PointLatLng ret(0, 0); QString urlEnd = url.mid(url.indexOf("geo?q=") + 6); urlEnd.replace(QRegExp( @@ -529,6 +552,10 @@ internals::PointLatLng UrlFactory::GetLatLngFromGeocoderUrl(const QString &url, #endif // DEBUG_URLFACTORY QNetworkReply *reply; QNetworkRequest qheader; + // Lame hack *SSL security == none, bypass QT bug + QSslConfiguration conf = qheader.sslConfiguration(); + conf.setPeerVerifyMode(QSslSocket::VerifyNone); + qheader.setSslConfiguration(conf); QNetworkAccessManager network; network.setProxy(Proxy); qheader.setUrl(QUrl(url)); @@ -557,6 +584,82 @@ internals::PointLatLng UrlFactory::GetLatLngFromGeocoderUrl(const QString &url, #endif // DEBUG_URLFACTORY geo = reply->readAll(); + qDebug() << geo; // This is the response from the geocode request (no longer in CSV) + + // 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.isCharacters()) + { + QString text = reader.text().toString(); + qDebug() << text; + latxml = text; + break; + } + } + } + + } + + while(!reader.atEnd()) + { + reader.readNext(); + + if(reader.isStartElement()) + { + if(reader.name() == "lng") + { + reader.readNext(); + if(reader.atEnd()) + 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; + + if(reader2.isCharacters()) + { + QString text = reader2.text().toString(); + qDebug() << text; + status = text; + break; + } + } + } + + } // cache geocoding if (useCache && geo.startsWith("200")) { @@ -567,23 +670,36 @@ internals::PointLatLng UrlFactory::GetLatLngFromGeocoderUrl(const QString &url, } - // parse values - // true : 200,4,56.1451640,22.0681787 - // false: 602,0,0,0 { - QStringList values = geo.split(','); - if (values.count() == 4) { - status = (GeoCoderStatusCode::Types)QString(values[0]).toInt(); - if (status == GeoCoderStatusCode::G_GEO_SUCCESS) { - double lat = QString(values[2]).toDouble(); - double lng = QString(values[3]).toDouble(); + if (status == "OK") { + double lat = QString(latxml).toDouble(); + double lng = QString(lonxml).toDouble(); 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"; + } } return ret; } diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.h index ace8b52d3..76de69f0b 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.h @@ -56,7 +56,7 @@ public: UrlFactory(); ~UrlFactory(); QString MakeImageUrl(const MapType::Types &type, const core::Point &pos, const int &zoom, const QString &language); - internals::PointLatLng GetLatLngFromGeodecoder(const QString &keywords, GeoCoderStatusCode::Types &status); + internals::PointLatLng GetLatLngFromGeodecoder(const QString &keywords, QString &status); Placemark GetPlacemarkFromGeocoder(internals::PointLatLng location); int Timeout; private: @@ -79,7 +79,7 @@ protected: void setIsCorrectGoogleVersions(bool value); QString MakeGeocoderUrl(QString keywords); QString MakeReverseGeocoderUrl(internals::PointLatLng &pt, const QString &language); - internals::PointLatLng GetLatLngFromGeocoderUrl(const QString &url, const bool &useCache, GeoCoderStatusCode::Types &status); + internals::PointLatLng GetLatLngFromGeocoderUrl(const QString &url, const bool &useCache, QString &status); Placemark GetPlacemarkFromReverseGeocoderUrl(const QString &url, const bool &useCache); }; } diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/core.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/core.cpp index b56d84e75..bdeb54ed1 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/core.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/core.cpp @@ -379,14 +379,18 @@ void Core::OnMapClose() } GeoCoderStatusCode::Types Core::SetCurrentPositionByKeywords(QString const & keys) { - GeoCoderStatusCode::Types status = GeoCoderStatusCode::Unknow; + QString status = "ZERO_RESULTS"; PointLatLng pos = OPMaps::Instance()->GetLatLngFromGeodecoder(keys, status); - if (!pos.IsEmpty() && (status == GeoCoderStatusCode::G_GEO_SUCCESS)) { + if (!pos.IsEmpty() && (status == "OK")) { SetCurrentPosition(pos); } - - return status; + else + { + qDebug() << "Status is not OK: " << status; + } + //return status; + return GeoCoderStatusCode::G_GEO_SUCCESS; } RectLatLng Core::CurrentViewArea() { From 390a8cccb51a4d9ad4399ad77114ff9a6632b51c Mon Sep 17 00:00:00 2001 From: Kevin Finisterre Date: Sun, 10 May 2015 16:36:01 -0400 Subject: [PATCH 2/4] Add search coloring back to the location search. Google Maps should be functional again. Some locations on the extents of map do not render 'North Pole, South Pole, Antarctica, etc.' currently a *non issue* --- .../libs/opmapcontrol/src/core/urlfactory.cpp | 5 ++-- .../libs/opmapcontrol/src/internals/core.cpp | 5 ++-- .../libs/opmapcontrol/src/internals/core.h | 2 +- .../src/mapwidget/mapgraphicitem.h | 2 +- .../opmapcontrol/src/mapwidget/opmapwidget.h | 2 +- .../src/plugins/opmap/opmapgadgetwidget.cpp | 28 +++++++++++++++++-- 6 files changed, 32 insertions(+), 12 deletions(-) diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp index 4df06c916..d802acb99 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp @@ -579,12 +579,11 @@ internals::PointLatLng UrlFactory::GetLatLngFromGeocoderUrl(const QString &url, return internals::PointLatLng(0, 0); } { + geo = reply->readAll(); #ifdef DEBUG_URLFACTORY qDebug() << "GetLatLngFromGeocoderUrl:Reply ok"; -#endif // DEBUG_URLFACTORY - geo = reply->readAll(); - 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); diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/core.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/core.cpp index bdeb54ed1..f85b17958 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/core.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/core.cpp @@ -377,7 +377,7 @@ void Core::OnMapClose() CancelAsyncTasks(); } -GeoCoderStatusCode::Types Core::SetCurrentPositionByKeywords(QString const & keys) +QString Core::SetCurrentPositionByKeywords(QString const & keys) { QString status = "ZERO_RESULTS"; PointLatLng pos = OPMaps::Instance()->GetLatLngFromGeodecoder(keys, status); @@ -389,8 +389,7 @@ GeoCoderStatusCode::Types Core::SetCurrentPositionByKeywords(QString const & key { qDebug() << "Status is not OK: " << status; } - //return status; - return GeoCoderStatusCode::G_GEO_SUCCESS; + return status; } RectLatLng Core::CurrentViewArea() { diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/core.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/core.h index 9998f0408..7bcae973b 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/core.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/core.h @@ -266,7 +266,7 @@ public: void OnMapClose(); // TODO had as slot - GeoCoderStatusCode::Types SetCurrentPositionByKeywords(QString const & keys); + QString SetCurrentPositionByKeywords(QString const & keys); RectLatLng CurrentViewArea(); diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.h index e1b2c5d88..463800fb1 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.h @@ -229,7 +229,7 @@ private: { core->ReloadMap(); } - GeoCoderStatusCode::Types SetCurrentPositionByKeywords(QString const & keys) + QString SetCurrentPositionByKeywords(QString const & keys) { return core->SetCurrentPositionByKeywords(keys); } diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/opmapwidget.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/opmapwidget.h index 005509908..895baf452 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/opmapwidget.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/opmapwidget.h @@ -350,7 +350,7 @@ public: map->ReloadMap(); map->resize(); } - GeoCoderStatusCode::Types SetCurrentPositionByKeywords(QString const & keys) + QString SetCurrentPositionByKeywords(QString const & keys) { return map->SetCurrentPositionByKeywords(keys); } diff --git a/ground/openpilotgcs/src/plugins/opmap/opmapgadgetwidget.cpp b/ground/openpilotgcs/src/plugins/opmap/opmapgadgetwidget.cpp index 3a122afb9..98d0a267a 100644 --- a/ground/openpilotgcs/src/plugins/opmap/opmapgadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/opmap/opmapgadgetwidget.cpp @@ -2320,16 +2320,38 @@ void OPMapGadgetWidget::on_tbFind_clicked() { QPalette pal = m_widget->leFind->palette(); - int result = m_map->SetCurrentPositionByKeywords(m_widget->leFind->text()); + QString status = m_map->SetCurrentPositionByKeywords(m_widget->leFind->text()); - if (result == core::GeoCoderStatusCode::G_GEO_SUCCESS) { + if (status == "OK") { pal.setColor(m_widget->leFind->backgroundRole(), Qt::green); m_widget->leFind->setPalette(pal); m_map->SetZoom(12); - } else { + } else if (status == "ZERO_RESULTS") { pal.setColor(m_widget->leFind->backgroundRole(), Qt::red); m_widget->leFind->setPalette(pal); + qDebug() << "No results"; + } else if (status == "OVER_QUERY_LIMIT") { + pal.setColor(m_widget->leFind->backgroundRole(), Qt::yellow); + m_widget->leFind->setPalette(pal); + qDebug() << "You are over quota on queries"; + } else if (status == "REQUEST_DENIED") { + pal.setColor(m_widget->leFind->backgroundRole(), Qt::darkRed); + m_widget->leFind->setPalette(pal); + qDebug() << "Request was denied"; + } else if (status == "INVALID_REQUEST") { + pal.setColor(m_widget->leFind->backgroundRole(), Qt::darkYellow); + m_widget->leFind->setPalette(pal); + qDebug() << "Invalid request, missing address, lat long or location"; + } else if (status == "UNKNOWN_ERROR") { + pal.setColor(m_widget->leFind->backgroundRole(), Qt::darkYellow); + m_widget->leFind->setPalette(pal); + qDebug() << "Some sort of server error."; + } else { + pal.setColor(m_widget->leFind->backgroundRole(), Qt::gray); + m_widget->leFind->setPalette(pal); + qDebug() << "Some sort of code error!"; } + } void OPMapGadgetWidget::onHomeDoubleClick(HomeItem *) From 9fe4fb7216d7f1d095d0a55532549f1a89cf67d9 Mon Sep 17 00:00:00 2001 From: Kevin Finisterre Date: Sun, 10 May 2015 22:31:48 -0400 Subject: [PATCH 3/4] Remove depreciated Yahoo maps (now uses "Here" - https://developer.here.com/rest-apis which requires an API key we don't have) No desire to implement new Here interface. Fix Yandex.ru interface to reference Yandex.net --- .../opmapcontrol/src/core/alllayersoftype.cpp | 7 ----- .../src/libs/opmapcontrol/src/core/maptype.h | 5 ---- .../src/libs/opmapcontrol/src/core/opmaps.cpp | 9 ------ .../opmapcontrol/src/core/providerstrings.cpp | 5 ---- .../opmapcontrol/src/core/providerstrings.h | 5 ---- .../libs/opmapcontrol/src/core/urlfactory.cpp | 30 ++++++++----------- 6 files changed, 12 insertions(+), 49 deletions(-) diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/alllayersoftype.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/alllayersoftype.cpp index ca615f94b..ad3033bd0 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/alllayersoftype.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/alllayersoftype.cpp @@ -55,13 +55,6 @@ QVector AllLayersOfType::GetAllLayersOfType(const MapType::Types } break; - case MapType::YahooHybrid: - { - types.append(MapType::YahooSatellite); - types.append(MapType::YahooLabels); - } - break; - case MapType::ArcGIS_MapsLT_Map_Hybrid: { types.append(MapType::ArcGIS_MapsLT_OrtoFoto); diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/maptype.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/maptype.h index d31844f6b..8e5569764 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/maptype.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/maptype.h @@ -52,11 +52,6 @@ public: OpenStreetMapSurfer = 34, OpenStreetMapSurferTerrain = 35, - YahooMap = 64, - YahooSatellite = 128, - YahooLabels = 256, - YahooHybrid = 333, - BingMap = 444, BingSatellite = 555, BingHybrid = 666, diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/opmaps.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/opmaps.cpp index fd249f66d..a39cf8b01 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/opmaps.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/opmaps.cpp @@ -153,15 +153,6 @@ QByteArray OPMaps::GetImageFrom(const MapType::Types &type, const Point &pos, co } break; - case MapType::YahooHybrid: - case MapType::YahooLabels: - case MapType::YahooMap: - case MapType::YahooSatellite: - { - qheader.setRawHeader("Referrer", "http://maps.yahoo.com/"); - } - break; - case MapType::ArcGIS_MapsLT_Map_Labels: case MapType::ArcGIS_MapsLT_Map: case MapType::ArcGIS_MapsLT_OrtoFoto: diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/providerstrings.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/providerstrings.cpp index 50d16bbc9..5e1f1f0c8 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/providerstrings.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/providerstrings.cpp @@ -61,11 +61,6 @@ ProviderStrings::ProviderStrings() /// GoogleMapsAPIKey = "ABQIAAAAWaQgWiEBF3lW97ifKnAczhRAzBk5Igf8Z5n2W3hNnMT0j2TikxTLtVIGU7hCLLHMAuAMt-BO5UrEWA"; - // Yahoo version strings - VersionYahooMap = "4.3"; - VersionYahooSatellite = "1.9"; - VersionYahooLabels = "4.3"; - // BingMaps VersionBingMaps = "563"; diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/providerstrings.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/providerstrings.h index 1d349e7c2..b0d2389d9 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/providerstrings.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/providerstrings.h @@ -60,11 +60,6 @@ public: /// - // Yahoo version strings - QString VersionYahooMap; - QString VersionYahooSatellite; - QString VersionYahooLabels; - // BingMaps QString VersionBingMaps; diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp index d802acb99..da92f3d6f 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp @@ -335,21 +335,7 @@ QString UrlFactory::MakeImageUrl(const MapType::Types &type, const Point &pos, c 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); } break; - case MapType::YahooMap: - { - return QString("http://maps%1.yimg.com/hx/tl?v=%2&.intl=%3&x=%4&y=%5&z=%6&r=1").arg(((GetServerNum(pos, 2)) + 1)).arg(VersionYahooMap).arg(language).arg(pos.X()).arg((((1 << zoom) >> 1) - 1 - pos.Y())).arg((zoom + 1)); - } - - case MapType::YahooSatellite: - { - return QString("http://maps%1.yimg.com/ae/ximg?v=%2&t=a&s=256&.intl=%3&x=%4&y=%5&z=%6&r=1").arg("3").arg(VersionYahooSatellite).arg(language).arg(pos.X()).arg(((1 << zoom) >> 1) - 1 - pos.Y()).arg(zoom + 1); - } - break; - case MapType::YahooLabels: - { - return QString("http://maps%1.yimg.com/hx/tl?v=%2&t=h&.intl=%3&x=%4&y=%5&z=%6&r=1").arg("1").arg(VersionYahooLabels).arg(language).arg(pos.X()).arg(((1 << zoom) >> 1) - 1 - pos.Y()).arg(zoom + 1); - } - 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 case MapType::OpenStreetMap: { char letter = "abc"[GetServerNum(pos, 3)]; @@ -483,11 +469,19 @@ QString UrlFactory::MakeImageUrl(const MapType::Types &type, const Point &pos, c case MapType::YandexMapRu: { + /* + 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); - // http://vec01.maps.yandex.ru/tiles?l=map&v=2.10.2&x=1494&y=650&z=11 - - return QString("http://%1").arg(server) + QString("0%2.maps.yandex.ru/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; default: From 0377c3f333b956b21337f5ffd61c3157a104b356 Mon Sep 17 00:00:00 2001 From: Kevin Finisterre Date: Tue, 12 May 2015 17:35:16 -0400 Subject: [PATCH 4/4] Work through debugging faulty map rendering. Fix OpenStreetOSM option. --- .../libs/opmapcontrol/src/core/urlfactory.cpp | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp index da92f3d6f..a0ebd84d6 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp @@ -225,7 +225,7 @@ QString UrlFactory::MakeImageUrl(const MapType::Types &type, const Point &pos, c QString sec2 = ""; // after &zoom=... GetSecGoogleWords(pos, sec1, sec2); TryCorrectGoogleVersions(); - + 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); 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,6 +276,7 @@ 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 + 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); 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; @@ -342,16 +343,19 @@ QString UrlFactory::MakeImageUrl(const MapType::Types &type, const Point &pos, c return QString("http://%1.tile.openstreetmap.org/%2/%3/%4.png").arg(letter).arg(zoom).arg(pos.X()).arg(pos.Y()); } break; + // Need to update tile format to fit http://wiki.openstreetmap.org/wiki/Tile_servers case MapType::OpenStreetOsm: { char letter = "abc"[GetServerNum(pos, 3)]; - return QString("http://%1.tah.openstreetmap.org/Tiles/tile/%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()); + 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 + 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); } break; @@ -359,6 +363,7 @@ QString UrlFactory::MakeImageUrl(const MapType::Types &type, const Point &pos, c { // http://tiles2.mapsurfer.net/tms_t.ashx?x=9346&y=5209&z=14 + 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); } break; @@ -398,7 +403,8 @@ 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 - return QString("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_ShadedRelief_World_2D/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()); + 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; case MapType::ArcGIS_Terrain: @@ -417,6 +423,7 @@ QString UrlFactory::MakeImageUrl(const MapType::Types &type, const Point &pos, c // 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; @@ -429,6 +436,7 @@ QString UrlFactory::MakeImageUrl(const MapType::Types &type, const Point &pos, c // 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; @@ -438,6 +446,7 @@ QString UrlFactory::MakeImageUrl(const MapType::Types &type, const Point &pos, c // 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; @@ -458,12 +467,15 @@ QString UrlFactory::MakeImageUrl(const MapType::Types &type, const Point &pos, c 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: { - return 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); + // 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); } break;