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/positioning/qgeoshape.cpp | |
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/positioning/qgeoshape.cpp')
-rw-r--r-- | src/positioning/qgeoshape.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/positioning/qgeoshape.cpp b/src/positioning/qgeoshape.cpp index 932f7618..c331ef81 100644 --- a/src/positioning/qgeoshape.cpp +++ b/src/positioning/qgeoshape.cpp @@ -185,6 +185,21 @@ bool QGeoShape::contains(const QGeoCoordinate &coordinate) const } /*! + Returns the coordinate located at the geometric center of the geo shape. + + \since 5.5 +*/ +QGeoCoordinate QGeoShape::center() const +{ + Q_D(const QGeoShape); + + if (d) + return d->center(); + else + return QGeoCoordinate(); +} + +/*! Extends the geo shape to also cover the coordinate \a coordinate */ void QGeoShape::extendShape(const QGeoCoordinate &coordinate) |