MCPcopy Create free account
hub / github.com/aethersdr/AetherSDR / encodeUncompressedPosition

Function encodeUncompressedPosition

src/core/aprs/AprsPacket.cpp:569–598  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

567}
568
569QString encodeUncompressedPosition(double lat, double lon,
570 char symbolTable, char symbolCode,
571 const QString& comment,
572 bool messagingCapable)
573{
574 lat = qBound(-90.0, lat, 90.0);
575 lon = qBound(-180.0, lon, 180.0);
576 const char latHemi = lat < 0 ? 'S' : 'N';
577 const char lonHemi = lon < 0 ? 'W' : 'E';
578 lat = qAbs(lat);
579 lon = qAbs(lon);
580 int latDeg = int(lat);
581 int lonDeg = int(lon);
582 // Round minutes to the 2 decimals we print, then carry a 60.00 overflow
583 // into the degrees. Without this, e.g. 38.999999° formats latMin=59.99994
584 // as "60.00""3860.00N", which every APRS parser (including ours)
585 // rejects as min >= 60. A GPS-fed beacon hits this near minute boundaries.
586 double latMin = qRound((lat - latDeg) * 60.0 * 100.0) / 100.0;
587 double lonMin = qRound((lon - lonDeg) * 60.0 * 100.0) / 100.0;
588 if (latMin >= 60.0) { latMin -= 60.0; latDeg += 1; }
589 if (lonMin >= 60.0) { lonMin -= 60.0; lonDeg += 1; }
590 QString out;
591 out += QLatin1Char(messagingCapable ? '=' : '!');
592 out += QString::asprintf("%02d%05.2f%c", latDeg, latMin, latHemi);
593 out += QLatin1Char(symbolTable);
594 out += QString::asprintf("%03d%05.2f%c", lonDeg, lonMin, lonHemi);
595 out += QLatin1Char(symbolCode);
596 out += comment.trimmed();
597 return out;
598}
599
600QString encodeMessage(const QString& addressee, const QString& text,
601 const QString& msgNo)

Callers 2

sendNowMethod · 0.85
testEncodersFunction · 0.85

Calls

no outgoing calls

Tested by 1

testEncodersFunction · 0.68