summaryrefslogtreecommitdiff
path: root/src/plugins/geoservices
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2017-12-20 17:48:00 +0100
committerPaolo Angelelli <paolo.angelelli@qt.io>2018-01-09 10:37:50 +0000
commitcc988feee350e3ff35d11c7c484fed08981ef67c (patch)
treed4f05112f90c240e22ef0f54a93472ed9ba6408a /src/plugins/geoservices
parent4b7889ff9e3784f9201b7d878606a9f84521815a (diff)
downloadqtlocation-cc988feee350e3ff35d11c7c484fed08981ef67c.tar.gz
Use QGeoShapes properly throughout the module
Adds proper support to other valid shapes and use ::boundingGeoRectangle where appropriate. Change-Id: Ibba4cb18f5cca08df62d15b76fa0e1f249dc6fbb Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/plugins/geoservices')
-rw-r--r--src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp4
-rw-r--r--src/plugins/geoservices/nokia/qgeocodingmanagerengine_nokia.cpp26
-rw-r--r--src/plugins/geoservices/osm/qgeocodingmanagerengineosm.cpp4
-rw-r--r--src/plugins/geoservices/osm/qplacemanagerengineosm.cpp20
4 files changed, 18 insertions, 36 deletions
diff --git a/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp b/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
index fcdc5962..976c51cf 100644
--- a/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+++ b/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
@@ -118,8 +118,8 @@ QGeoCodeReply *GeoCodingManagerEngineEsri::geocode(const QString &address, int l
query.addQueryItem(QStringLiteral("f"), QStringLiteral("json"));
query.addQueryItem(QStringLiteral("outFields"), "*");
- if (bounds.type() == QGeoShape::RectangleType)
- query.addQueryItem(QStringLiteral("searchExtent"), boundingBoxToLtrb(bounds));
+ if (bounds.type() != QGeoShape::UnknownType)
+ query.addQueryItem(QStringLiteral("searchExtent"), boundingBoxToLtrb(bounds.boundingGeoRectangle()));
if (limit != -1)
query.addQueryItem(QStringLiteral("maxLocations"), QString::number(limit));
diff --git a/src/plugins/geoservices/nokia/qgeocodingmanagerengine_nokia.cpp b/src/plugins/geoservices/nokia/qgeocodingmanagerengine_nokia.cpp
index b3c74a63..68b2429e 100644
--- a/src/plugins/geoservices/nokia/qgeocodingmanagerengine_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeocodingmanagerengine_nokia.cpp
@@ -111,18 +111,8 @@ QGeoCodeReply *QGeoCodingManagerEngineNokia::geocode(const QGeoAddress &address,
requestString += languageToMarc(locale().language());
bool manualBoundsRequired = false;
- if (bounds.type() == QGeoShape::RectangleType) {
- QGeoRectangle rect(bounds);
- if (rect.isValid()) {
- requestString += "&bbox=";
- requestString += trimDouble(rect.topLeft().latitude());
- requestString += ",";
- requestString += trimDouble(rect.topLeft().longitude());
- requestString += ";";
- requestString += trimDouble(rect.bottomRight().latitude());
- requestString += ",";
- requestString += trimDouble(rect.bottomRight().longitude());
- }
+ if (bounds.type() == QGeoShape::UnknownType) {
+ manualBoundsRequired = true;
} else if (bounds.type() == QGeoShape::CircleType) {
QGeoCircle circ(bounds);
if (circ.isValid()) {
@@ -134,7 +124,17 @@ QGeoCodeReply *QGeoCodingManagerEngineNokia::geocode(const QGeoAddress &address,
requestString += trimDouble(circ.radius());
}
} else {
- manualBoundsRequired = true;
+ QGeoRectangle rect = bounds.boundingGeoRectangle();
+ if (rect.isValid()) {
+ requestString += "&bbox=";
+ requestString += trimDouble(rect.topLeft().latitude());
+ requestString += ",";
+ requestString += trimDouble(rect.topLeft().longitude());
+ requestString += ";";
+ requestString += trimDouble(rect.bottomRight().latitude());
+ requestString += ",";
+ requestString += trimDouble(rect.bottomRight().longitude());
+ }
}
if (address.country().isEmpty()) {
diff --git a/src/plugins/geoservices/osm/qgeocodingmanagerengineosm.cpp b/src/plugins/geoservices/osm/qgeocodingmanagerengineosm.cpp
index 693a80a1..6065870a 100644
--- a/src/plugins/geoservices/osm/qgeocodingmanagerengineosm.cpp
+++ b/src/plugins/geoservices/osm/qgeocodingmanagerengineosm.cpp
@@ -111,8 +111,8 @@ QGeoCodeReply *QGeoCodingManagerEngineOsm::geocode(const QString &address, int l
query.addQueryItem(QStringLiteral("format"), QStringLiteral("json"));
query.addQueryItem(QStringLiteral("accept-language"), locale().name().left(2));
//query.addQueryItem(QStringLiteral("countrycodes"), QStringLiteral("au,jp"));
- if (bounds.type() == QGeoShape::RectangleType) {
- query.addQueryItem(QStringLiteral("viewbox"), boundingBoxToLtrb(bounds));
+ if (bounds.type() != QGeoShape::UnknownType) {
+ query.addQueryItem(QStringLiteral("viewbox"), boundingBoxToLtrb(bounds.boundingGeoRectangle()));
query.addQueryItem(QStringLiteral("bounded"), QStringLiteral("1"));
}
query.addQueryItem(QStringLiteral("polygon_geojson"), QStringLiteral("1"));
diff --git a/src/plugins/geoservices/osm/qplacemanagerengineosm.cpp b/src/plugins/geoservices/osm/qplacemanagerengineosm.cpp
index dcf02b13..16632b67 100644
--- a/src/plugins/geoservices/osm/qplacemanagerengineosm.cpp
+++ b/src/plugins/geoservices/osm/qplacemanagerengineosm.cpp
@@ -134,25 +134,7 @@ QPlaceSearchReply *QPlaceManagerEngineOsm::search(const QPlaceSearchRequest &req
//queryItems.addQueryItem(QStringLiteral("accept-language"), QStringLiteral("en"));
- QGeoRectangle boundingBox;
- QGeoShape searchArea = request.searchArea();
- switch (searchArea.type()) {
- case QGeoShape::CircleType: {
- QGeoCircle c(searchArea);
- qreal radius = c.radius();
- if (radius < 0)
- radius = 50000;
-
- boundingBox = QGeoRectangle(c.center().atDistanceAndAzimuth(radius, -45),
- c.center().atDistanceAndAzimuth(radius, 135));
- break;
- }
- case QGeoShape::RectangleType:
- boundingBox = searchArea;
- break;
- default:
- ;
- }
+ QGeoRectangle boundingBox = request.searchArea().boundingGeoRectangle();
if (!boundingBox.isEmpty()) {
queryItems.addQueryItem(QStringLiteral("bounded"), QStringLiteral("1"));