From cd8880cc04b22610e835e6cc02cc16ac22ec9fae Mon Sep 17 00:00:00 2001 From: Paolo Angelelli Date: Fri, 5 Aug 2016 22:21:12 +0200 Subject: Add support for boundingGeoRectangle to QGeoShape this patch introduces QGeoShape::boundingGeoRectangle, which returns a QGeoRectangle containing the latitudinal/longitudinal bounds of a geoshape. The bounding geo rectangle is projection independent, as it returns a georectangle containing the min/max latitudes/longitudes of the shape. Change-Id: Ie3a83ec41f87ea3753899d2278e664fe2469f778 Reviewed-by: Alex Blasche --- src/positioning/qlocationutils_p.h | 49 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'src/positioning/qlocationutils_p.h') diff --git a/src/positioning/qlocationutils_p.h b/src/positioning/qlocationutils_p.h index 00c4d3e3..32addb63 100644 --- a/src/positioning/qlocationutils_p.h +++ b/src/positioning/qlocationutils_p.h @@ -53,6 +53,14 @@ #include #include +#ifndef M_1_180 +#define M_1_180 0.0055555555555555555555555555555555555555556 +#endif + +#ifndef M_1_PI +#define M_1_PI 0.31830988618379067154 +#endif + QT_BEGIN_NAMESPACE class QTime; class QByteArray; @@ -176,6 +184,47 @@ public: return CardinalNNW; } + // For values exceeding +- 720.0 + inline static double wrapLongExt(double lng) { + double remainder = fmod(lng + 180.0, 360.0); + return fmod(remainder + 360.0, 360.0) - 180.0; + } + + // Mirrors the azimuth against the X axis. Azimuth assumed to be in [0,360[ + inline static double mirrorAzimuthX(double azimuth) { + if (azimuth <= 90.0) + return 180.0 - azimuth; + else + return 180.0 + (360.0 - azimuth); + } + + // Mirrors the azimuth against the Y axis. Azimuth assumed to be in [0,360[ + inline static double mirrorAzimuthY(double azimuth) { + if (azimuth == 0.0) + return 0.0; + return 360.0 - azimuth; + } + + inline static double radians(double degrees) + { + return degrees * M_PI * M_1_180; + } + + inline static double degrees(double radians) + { + return radians * 180.0 * M_1_PI; + } + + inline static double earthMeanRadius() + { + return 6371007.2; + } + + inline static double mercatorMaxLatitude() + { + return 85.05113; + } + /* Creates a QGeoPositionInfo from a GGA, GLL, RMC, VTG or ZDA sentence. -- cgit v1.2.1