From 01a00ccafd6a632386acf94c9ccd99b93a189c33 Mon Sep 17 00:00:00 2001 From: Kevin Finisterre Date: Wed, 13 May 2015 10:35:46 -0400 Subject: [PATCH] Continue debugging troublesome maps... remove the Dragons from the map!!! https://progress.openpilot.org/browse/OP-392 was more annoying than useful. Attempt to change HTTP request method to debug failed tile downloads. --- .../libs/opmapcontrol/src/core/debugheader.h | 16 +++---- .../src/libs/opmapcontrol/src/core/opmaps.cpp | 48 ++++++++++--------- .../libs/opmapcontrol/src/core/urlfactory.cpp | 11 +++-- .../src/mapwidget/mapgraphicitem.cpp | 6 +-- 4 files changed, 44 insertions(+), 37 deletions(-) diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/debugheader.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/debugheader.h index d4590fb59..893ba7350 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/debugheader.h +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/debugheader.h @@ -1,13 +1,13 @@ #ifndef DEBUGHEADER_H #define DEBUGHEADER_H -// #define DEBUG_MEMORY_CACHE -// #define DEBUG_CACHE -// #define DEBUG_GMAPS -// #define DEBUG_PUREIMAGECACHE -// #define DEBUG_TILECACHEQUEUE + #define DEBUG_MEMORY_CACHE + #define DEBUG_CACHE + #define DEBUG_GMAPS + #define DEBUG_PUREIMAGECACHE + #define DEBUG_TILECACHEQUEUE // #define DEBUG_URLFACTORY -// #define DEBUG_MEMORY_CACHE -// #define DEBUG_GetGeocoderFromCache - + #define DEBUG_MEMORY_CACHE + #define DEBUG_GetGeocoderFromCache + #define DEBUG_TIMINGS #endif // DEBUGHEADER_H diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/opmaps.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/opmaps.cpp index a39cf8b01..648615ff9 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/opmaps.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/opmaps.cpp @@ -100,15 +100,9 @@ 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())); network.setProxy(Proxy); #ifdef DEBUG_GMAPS qDebug() << "Try Tile from the Internet"; @@ -145,6 +139,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: @@ -184,26 +186,28 @@ QByteArray OPMaps::GetImageFrom(const MapType::Types &type, const Point &pos, co 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; - } - tT.stop(); - if ((reply->error() != QNetworkReply::NoError)) { - errorvars.lock(); - ++diag.networkerrors; - errorvars.unlock(); - reply->deleteLater(); - return ret; - } + QTime time; + while ((!(reply->isFinished()) || (time.elapsed() > (6 * Timeout)))) { + QCoreApplication::processEvents(QEventLoop::AllEvents); + } + + qDebug() << "Finished?" << reply->error() << " abort?" << (time.elapsed() > Timeout * 6); + + if ((reply->error() != QNetworkReply::NoError) | (time.elapsed() > Timeout * 6)) { + return ret; + } + else + { + qDebug() << "QNetworkReply Errors!"; + } ret = reply->readAll(); + qDebug() << "ret " << ret; reply->deleteLater(); // TODO can't this be global?? + if (ret.isEmpty()) { #ifdef DEBUG_GMAPS qDebug() << "Invalid Tile"; diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp index a0ebd84d6..569a79e24 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/core/urlfactory.cpp @@ -320,6 +320,7 @@ 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= + 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); 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; @@ -331,9 +332,10 @@ QString UrlFactory::MakeImageUrl(const MapType::Types &type, const Point &pos, c 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 + // https://mts1.google.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); + qDebug() << QString("https://%1%2.google.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); + return QString("https://%1%2.google.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; // *.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 @@ -468,14 +470,15 @@ QString UrlFactory::MakeImageUrl(const MapType::Types &type, const Point &pos, c 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? + qDebug() << 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); 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); + qDebug() << QString("http://sigpac.magrama.es/SDG/raster/MTN2000@3785/%2.%3.%4.img").arg(zoom).arg(pos.X()).arg((2 << (zoom - 1)) - pos.Y() - 1); + return QString("http://sigpac.magrama.es/SDG/raster/MTN2000@3785/%2.%3.%4.img").arg(zoom).arg(pos.X()).arg((2 << (zoom - 1)) - pos.Y() - 1); } break; diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.cpp b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.cpp index cc338fc75..78781d580 100644 --- a/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.cpp +++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.cpp @@ -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); }