diff options
author | Paolo Angelelli <paolo.angelelli@qt.io> | 2016-08-05 22:21:12 +0200 |
---|---|---|
committer | Paolo Angelelli <paolo.angelelli@qt.io> | 2016-12-01 13:45:41 +0000 |
commit | e568470c6409febdb5187e3f53af32164c63169f (patch) | |
tree | 6e93b51f86750740a276464b92253e0ad3a9a0bf /src/positioning/qgeoshape.cpp | |
parent | 6ac41c0f58f34606afaa289243d762afd5f879d4 (diff) | |
download | qtlocation-e568470c6409febdb5187e3f53af32164c63169f.tar.gz |
Add support for QGeoPath
This patch adds an addition qgeoshapes, QGeoPath.
This represents a geographical path where each consecutive geopoints
are connected along the shortest line of constant bearing
(rhumb line).
The path has a width, in meters, that is used in the contains()
method to decide whether a coordinate is or not on the path, based
on shortest distance to the rhumb line segments.
Change-Id: Ia02780e3c8ac6c6d63a6083f53ea0677f8a21a1d
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/positioning/qgeoshape.cpp')
-rw-r--r-- | src/positioning/qgeoshape.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/positioning/qgeoshape.cpp b/src/positioning/qgeoshape.cpp index dd358fb5..c1f7bd9d 100644 --- a/src/positioning/qgeoshape.cpp +++ b/src/positioning/qgeoshape.cpp @@ -41,6 +41,8 @@ #include "qgeoshape_p.h" #include "qgeorectangle.h" #include "qgeocircle.h" +#include "qgeopath.h" + #ifndef QT_NO_DEBUG_STREAM #include <QtCore/QDebug> @@ -329,6 +331,9 @@ QDebug operator<<(QDebug dbg, const QGeoShape &shape) case QGeoShape::RectangleType: dbg << "Rectangle"; break; + case QGeoShape::PathType: + dbg << "Path"; + break; case QGeoShape::CircleType: dbg << "Circle"; } @@ -356,6 +361,13 @@ QDataStream &operator<<(QDataStream &stream, const QGeoShape &shape) stream << c.center() << c.radius(); break; } + case QGeoShape::PathType: { + QGeoPath p = shape; + stream << p.path().size(); + for (const auto &c: p.path()) + stream << c; + break; + } } return stream; @@ -384,6 +396,18 @@ QDataStream &operator>>(QDataStream &stream, QGeoShape &shape) shape = QGeoCircle(c, r); break; } + case QGeoShape::PathType: { + QList<QGeoCoordinate> l; + QGeoCoordinate c; + int sz; + stream >> sz; + for (int i = 0; i < sz; i++) { + stream >> c; + l.append(c); + } + shape = QGeoPath(l); + break; + } } return stream; |