From 390a8cccb51a4d9ad4399ad77114ff9a6632b51c Mon Sep 17 00:00:00 2001 From: Kevin Finisterre Date: Sun, 10 May 2015 16:36:01 -0400 Subject: [PATCH] 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 *)