37 enum CardinalDirection {
67 inline static bool isValidLat(
double lat) {
68 return lat >= -90.0 && lat <= 90.0;
70 inline static bool isValidLong(
double lng) {
71 return lng >= -180.0 && lng <= 180.0;
74 inline static double clipLat(
double lat,
double clipValue = 90.0) {
77 else if (lat < -clipValue)
82 inline static double wrapLong(
double lng) {
85 else if (lng < -180.0)
90 inline static CardinalDirection azimuthToCardinalDirection4(
double azimuth)
92 azimuth = fmod(azimuth, 360.0);
93 if (azimuth < 45.0 || azimuth > 315.0 )
95 else if (azimuth < 135.0)
97 else if (azimuth < 225.0)
103 inline static CardinalDirection azimuthToCardinalDirection8(
double azimuth)
105 azimuth = fmod(azimuth, 360.0);
106 if (azimuth < 22.5 || azimuth > 337.5 )
108 else if (azimuth < 67.5)
110 else if (azimuth < 112.5)
112 else if (azimuth < 157.5)
114 else if (azimuth < 202.5)
117 else if (azimuth < 247.5)
119 else if (azimuth < 292.5)
125 inline static CardinalDirection azimuthToCardinalDirection16(
double azimuth)
127 azimuth = fmod(azimuth, 360.0);
128 if (azimuth < 11.5 || azimuth > 348.75 )
130 else if (azimuth < 33.75)
132 else if (azimuth < 56.25)
134 else if (azimuth < 78.75)
136 else if (azimuth < 101.25)
138 else if (azimuth < 123.75)
140 else if (azimuth < 146.25)
142 else if (azimuth < 168.75)
144 else if (azimuth < 191.25)
147 else if (azimuth < 213.75)
149 else if (azimuth < 236.25)
151 else if (azimuth < 258.75)
153 else if (azimuth < 281.25)
155 else if (azimuth < 303.75)
157 else if (azimuth < 326.25)
164 inline static double wrapLongExt(
double lng) {
165 double remainder = fmod(lng + 180.0, 360.0);
166 return fmod(remainder + 360.0, 360.0) - 180.0;
170 inline static double mirrorAzimuthX(
double azimuth) {
172 return 180.0 - azimuth;
174 return 180.0 + (360.0 - azimuth);
178 inline static double mirrorAzimuthY(
double azimuth) {
181 return 360.0 - azimuth;
184 inline static double radians(
double degrees)
186 return qDegreesToRadians(degrees);
189 inline static double degrees(
double radians)
191 return qRadiansToDegrees(radians);
194 inline static double earthMeanRadius()
199 inline static double earthMeanCircumference()
201 return earthMeanRadius() * 2.0 *
M_PI;
204 inline static double mercatorMaxLatitude()
209 inline static QGeoCoordinate antipodalPoint(
const QGeoCoordinate &p)
211 return QGeoCoordinate(-p.latitude(), wrapLong(p.longitude() + 180.0));
215 inline static double mapLeftLongitude(
double centerLongitude)
217 return wrapLong(centerLongitude + leftOffset);
221 inline static double mapRightLongitude(
double centerLongitude)
223 return wrapLong(centerLongitude - leftOffset);
226 inline static void split_double(
double input,
float *hipart,
float *lopart)
228 *hipart = (
float) input;
229 double delta = input - ((
double) *hipart);
230 *lopart = (
float) delta;
233 static qreal metersPerPixel(qreal zoomLevel,
const QGeoCoordinate &coordinate)
235 const qreal metersPerTile = earthMeanCircumference() * std::cos(radians(coordinate.latitude())) / std::pow(2, zoomLevel);
236 return metersPerTile / 256.0;
240
241
242 static NmeaSentence getNmeaSentenceType(QByteArrayView bv);
245
246
247
248 static QGeoSatelliteInfo::SatelliteSystem getSatelliteSystem(QByteArrayView bv);
251
252
253
254 static QGeoSatelliteInfo::SatelliteSystem getSatelliteSystemBySatelliteId(
int satId);
257
258
259
260
261
262
263
264
265 static bool getPosInfoFromNmea(QByteArrayView bv,
266 QGeoPositionInfo *info,
double uere,
267 bool *hasFix =
nullptr);
270
271
272
273
274
275
276
277 static QNmeaSatelliteInfoSource::SatelliteInfoParseStatus
278 getSatInfoFromNmea(QByteArrayView bv, QList<QGeoSatelliteInfo> &infos, QGeoSatelliteInfo::SatelliteSystem &system);
281
282
283
284
285
286 static QGeoSatelliteInfo::SatelliteSystem getSatInUseFromNmea(QByteArrayView bv,
287 QList<
int> &pnrsInUse);
290
291
292 static bool hasValidNmeaChecksum(QByteArrayView bv);
295
296
297 static bool getNmeaTime(
const QByteArray &bytes, QTime *time);
300
301
302
303 static bool getNmeaLatLong(
const QByteArray &latString,
305 const QByteArray &lngString,