diff options
author | Erik Mattsson <erik.mattsson@appello.com> | 2013-09-27 15:44:01 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-10-07 09:43:44 +0200 |
commit | 7ec8919a055e35232b5127e312a525f61b0bc483 (patch) | |
tree | 80436fb4170376af1ffc9f31408db9f0a212358b /src/imports | |
parent | 7ca062e008db1543519f9258812b0d577d5da5ac (diff) | |
download | qtlocation-7ec8919a055e35232b5127e312a525f61b0bc483.tar.gz |
Added possibility to create a georectangle from a list of coordinates
It will create the smallest possible rectangle that contains all of the
coordinates. This is accessible from qml using the locationsingleton.
The plan is to include the ability to fit the view-port of the map
to a georectangle.
Change-Id: I616ac8ef169f697e53a3d9ebcf114f4f2cde8298
Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
Diffstat (limited to 'src/imports')
-rw-r--r-- | src/imports/positioning/locationsingleton.cpp | 18 | ||||
-rw-r--r-- | src/imports/positioning/locationsingleton.h | 2 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/imports/positioning/locationsingleton.cpp b/src/imports/positioning/locationsingleton.cpp index c44db946..0b1a5d6d 100644 --- a/src/imports/positioning/locationsingleton.cpp +++ b/src/imports/positioning/locationsingleton.cpp @@ -140,6 +140,24 @@ QGeoRectangle LocationSingleton::rectangle(const QGeoCoordinate &topLeft, } /*! + \qmlmethod georectangle QtLocation5::QtLocation::rectangle(list<coordinate> coordinates) const + + Constructs a georectangle from the list of coordinates, the returned list is the smallest possible + containing all the coordinates. + + \sa {georectangle} +*/ +QGeoRectangle LocationSingleton::rectangle(const QVariantList &coordinates) const +{ + QList<QGeoCoordinate> internalCoordinates; + for (int i = 0; i < coordinates.size(); i++) { + if (coordinates.at(i).canConvert<QGeoCoordinate>()) + internalCoordinates << coordinates.at(i).value<QGeoCoordinate>(); + } + return QGeoRectangle(internalCoordinates); +} + +/*! \qmlmethod geocircle QtPositioning::circle() const Constructs an invalid geocircle. diff --git a/src/imports/positioning/locationsingleton.h b/src/imports/positioning/locationsingleton.h index b5e6476e..6c8d4496 100644 --- a/src/imports/positioning/locationsingleton.h +++ b/src/imports/positioning/locationsingleton.h @@ -48,6 +48,7 @@ #include <QtPositioning/QGeoShape> #include <QtPositioning/QGeoRectangle> #include <QtPositioning/QGeoCircle> +#include <QVariant> class LocationSingleton : public QObject { @@ -67,6 +68,7 @@ public: double width, double height) const; Q_INVOKABLE QGeoRectangle rectangle(const QGeoCoordinate &topLeft, const QGeoCoordinate &bottomRight) const; + Q_INVOKABLE QGeoRectangle rectangle(const QVariantList &coordinates) const; Q_INVOKABLE QGeoCircle circle() const; Q_INVOKABLE QGeoCircle circle(const QGeoCoordinate ¢er, qreal radius = -1.0) const; |