diff options
author | Paolo Angelelli <paolo.angelelli@qt.io> | 2017-07-11 15:55:27 +0200 |
---|---|---|
committer | Paolo Angelelli <paolo.angelelli@qt.io> | 2017-08-04 11:19:14 +0000 |
commit | 92d8e4dc93400250b47f8dbe96ec7e2f748d8d4b (patch) | |
tree | 0545f115d23f74be1979ec483a63f19bbc9b1d55 /src/positioning/qgeoshape.cpp | |
parent | 4511bc9b9bc85a0021ce59feab1a28c711dec691 (diff) | |
download | qtlocation-92d8e4dc93400250b47f8dbe96ec7e2f748d8d4b.tar.gz |
Add QGeoPolygon to QtPositioning
This patch introduces a new QGeoShape, QGeoPolygon, together
with helper functions in the location singleton (QtPositioning.*)
to create and convert geopolygons from QML.
[ChangeLog][QtPositioning][QGeoPolygon] Added QGeoPolygon shape.
Change-Id: I111c576d7428f2a953f0459d16c25eea7ab2bd7c
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/positioning/qgeoshape.cpp')
-rw-r--r-- | src/positioning/qgeoshape.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/positioning/qgeoshape.cpp b/src/positioning/qgeoshape.cpp index ad7b0c58..7acbc9fa 100644 --- a/src/positioning/qgeoshape.cpp +++ b/src/positioning/qgeoshape.cpp @@ -42,6 +42,7 @@ #include "qgeorectangle.h" #include "qgeocircle.h" #include "qgeopath.h" +#include "qgeopolygon.h" #ifndef QT_NO_DEBUG_STREAM @@ -345,6 +346,9 @@ QDebug operator<<(QDebug dbg, const QGeoShape &shape) case QGeoShape::PathType: dbg << "Path"; break; + case QGeoShape::PolygonType: + dbg << "Polygon"; + break; case QGeoShape::CircleType: dbg << "Circle"; } @@ -379,6 +383,13 @@ QDataStream &operator<<(QDataStream &stream, const QGeoShape &shape) stream << c; break; } + case QGeoShape::PolygonType: { + QGeoPolygon p = shape; + stream << p.path().size(); + for (const auto &c: p.path()) + stream << c; + break; + } } return stream; @@ -419,6 +430,18 @@ QDataStream &operator>>(QDataStream &stream, QGeoShape &shape) shape = QGeoPath(l); break; } + case QGeoShape::PolygonType: { + QList<QGeoCoordinate> l; + QGeoCoordinate c; + int sz; + stream >> sz; + for (int i = 0; i < sz; i++) { + stream >> c; + l.append(c); + } + shape = QGeoPolygon(l); + break; + } } return stream; |