diff options
author | Aaron McCarthy <mccarthy.aaron@gmail.com> | 2014-07-28 09:57:04 +1000 |
---|---|---|
committer | Aaron McCarthy <mccarthy.aaron@gmail.com> | 2014-12-04 05:31:54 +0100 |
commit | b8681cdb51cc5d7040ecbe08b014bace2444c6f1 (patch) | |
tree | ebfe6a4e4cbbf178b1df2339abf91f7b4c84a2cf /src/plugins/geoservices | |
parent | fddb7c51231e1649081de3a1d5f2ad191e9cd7dc (diff) | |
download | qtlocation-b8681cdb51cc5d7040ecbe08b014bace2444c6f1.tar.gz |
Add center() function to QGeoShape.
It is frequently useful to calculate the geometric center of a shape.
Both QGeoCircle and QGeoRectangle already define center() functions,
however, the application developer must cast each QGeoShape into either
a QGeoCirlce or QGeoRectangle before calling. Providing
QGeoShape::center() allows application code to be simplified.
Existing QGeoCircle::center() and QGeoRectangle::center() functions are
kept for compatibility.
Change-Id: I92b727ab5e713f70174588a27040446c992ae14e
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/plugins/geoservices')
-rw-r--r-- | src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp index d200712e..5da9c3be 100644 --- a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp +++ b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp @@ -329,27 +329,15 @@ QPlaceContentReply *QPlaceManagerEngineNokiaV2::getPlaceContent(const QPlaceCont static bool addAtForBoundingArea(const QGeoShape &area, QUrlQuery *queryItems) { - QGeoCoordinate center; - switch (area.type()) { - case QGeoShape::RectangleType: - center = QGeoRectangle(area).center(); - break; - case QGeoShape::CircleType: - center = QGeoCircle(area).center(); - break; - case QGeoShape::UnknownType: - break; - } - - if (!center.isValid()) { + QGeoCoordinate center = area.center(); + if (!center.isValid()) return false; - } else { - queryItems->addQueryItem(QStringLiteral("at"), - QString::number(center.latitude()) + - QLatin1Char(',') + - QString::number(center.longitude())); - return true; - } + + queryItems->addQueryItem(QStringLiteral("at"), + QString::number(center.latitude()) + + QLatin1Char(',') + + QString::number(center.longitude())); + return true; } QPlaceSearchReply *QPlaceManagerEngineNokiaV2::search(const QPlaceSearchRequest &query) |