38 enum CardinalDirection {
68 inline static bool isValidLat(
double lat) {
69 return lat >= -90.0 && lat <= 90.0;
71 inline static bool isValidLong(
double lng) {
72 return lng >= -180.0 && lng <= 180.0;
75 inline static double clipLat(
double lat,
double clipValue = 90.0) {
78 else if (lat < -clipValue)
83 inline static double wrapLong(
double lng) {
86 else if (lng < -180.0)
91 inline static CardinalDirection azimuthToCardinalDirection4(
double azimuth)
93 azimuth = fmod(azimuth, 360.0);
94 if (azimuth < 45.0 || azimuth > 315.0 )
96 else if (azimuth < 135.0)
98 else if (azimuth < 225.0)
104 inline static CardinalDirection azimuthToCardinalDirection8(
double azimuth)
106 azimuth = fmod(azimuth, 360.0);
107 if (azimuth < 22.5 || azimuth > 337.5 )
109 else if (azimuth < 67.5)
111 else if (azimuth < 112.5)
113 else if (azimuth < 157.5)
115 else if (azimuth < 202.5)
118 else if (azimuth < 247.5)
120 else if (azimuth < 292.5)
126 inline static CardinalDirection azimuthToCardinalDirection16(
double azimuth)
128 azimuth = fmod(azimuth, 360.0);
129 if (azimuth < 11.5 || azimuth > 348.75 )
131 else if (azimuth < 33.75)
133 else if (azimuth < 56.25)
135 else if (azimuth < 78.75)
137 else if (azimuth < 101.25)
139 else if (azimuth < 123.75)
141 else if (azimuth < 146.25)
143 else if (azimuth < 168.75)
145 else if (azimuth < 191.25)
148 else if (azimuth < 213.75)
150 else if (azimuth < 236.25)
152 else if (azimuth < 258.75)
154 else if (azimuth < 281.25)
156 else if (azimuth < 303.75)
158 else if (azimuth < 326.25)
165 inline static double wrapLongExt(
double lng) {
166 double remainder = fmod(lng + 180.0, 360.0);
167 return fmod(remainder + 360.0, 360.0) - 180.0;
171 inline static double mirrorAzimuthX(
double azimuth) {
173 return 180.0 - azimuth;
175 return 180.0 + (360.0 - azimuth);
179 inline static double mirrorAzimuthY(
double azimuth) {
182 return 360.0 - azimuth;
185 inline static double radians(
double degrees)
187 return qDegreesToRadians(degrees);
190 inline static double degrees(
double radians)
192 return qRadiansToDegrees(radians);
195 inline static double earthMeanRadius()
200 inline static double earthMeanCircumference()
202 return earthMeanRadius() * 2.0 *
M_PI;
205 inline static double mercatorMaxLatitude()
210 inline static QGeoCoordinate antipodalPoint(
const QGeoCoordinate &p)
212 return QGeoCoordinate(-p.latitude(), wrapLong(p.longitude() + 180.0));
216 inline static double mapLeftLongitude(
double centerLongitude)
218 return wrapLong(centerLongitude + leftOffset);
222 inline static double mapRightLongitude(
double centerLongitude)
224 return wrapLong(centerLongitude - leftOffset);
227 inline static void split_double(
double input,
float *hipart,
float *lopart)
229 *hipart = (
float) input;
230 double delta = input - ((
double) *hipart);
231 *lopart = (
float) delta;
234 static qreal metersPerPixel(qreal zoomLevel,
const QGeoCoordinate &coordinate)
236 const qreal metersPerTile = earthMeanCircumference() * std::cos(radians(coordinate.latitude())) / std::pow(2, zoomLevel);
237 return metersPerTile / 256.0;
241
242
243 static NmeaSentence getNmeaSentenceType(QByteArrayView bv);
246
247
248
249 static QGeoSatelliteInfo::SatelliteSystem getSatelliteSystem(QByteArrayView bv);
252
253
254
255 static QGeoSatelliteInfo::SatelliteSystem getSatelliteSystemBySatelliteId(
int satId);
258
259
260
261
262
263
264
265
266 static bool getPosInfoFromNmea(QByteArrayView bv,
267 QGeoPositionInfo *info,
double uere,
268 bool *hasFix =
nullptr);
271
272
273
274
275
276
277
278 static QNmeaSatelliteInfoSource::SatelliteInfoParseStatus
279 getSatInfoFromNmea(QByteArrayView bv, QList<QGeoSatelliteInfo> &infos, QGeoSatelliteInfo::SatelliteSystem &system);
282
283
284
285
286
287 static QGeoSatelliteInfo::SatelliteSystem getSatInUseFromNmea(QByteArrayView bv,
288 QList<
int> &pnrsInUse);
291
292
293 static bool hasValidNmeaChecksum(QByteArrayView bv);
296
297
298 static bool getNmeaTime(
const QByteArray &bytes, QTime *time);
301
302
303
304 static bool getNmeaLatLong(
const QByteArray &latString,
306 const QByteArray &lngString,