Fixes to the log and screen rendering of the geo coordinates.

This commit is contained in:
teixeluis 2021-06-23 19:54:34 +01:00
parent 2ceb49e4f2
commit 97349b06ef
2 changed files with 37 additions and 6 deletions

View File

@ -20,6 +20,7 @@
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#include "ui_adsb_rx.hpp" #include "ui_adsb_rx.hpp"
#include "ui_alphanum.hpp" #include "ui_alphanum.hpp"
@ -233,14 +234,38 @@ void ADSBRxView::on_frame(const ADSBFrameMessage * message) {
entry.set_frame_pos(frame, raw_data[6] & 4); entry.set_frame_pos(frame, raw_data[6] & 4);
if (entry.pos.valid) { if (entry.pos.valid) {
std::string latitude_str(8, '\0');
std::string longitude_str(8, '\0');
int written = std::snprintf(&latitude_str[0], latitude_str.size(), "%.2f", entry.pos.latitude);
latitude_str.resize(written);
written = std::snprintf(&longitude_str[0], longitude_str.size(), "%.2f", entry.pos.longitude);
longitude_str.resize(written);
str_info = "Alt:" + to_string_dec_int(entry.pos.altitude) + str_info = "Alt:" + to_string_dec_int(entry.pos.altitude) +
" Lat:" + to_string_dec_int(entry.pos.latitude) + " Lat:" + latitude_str +
"." + to_string_dec_int((int)abs(entry.pos.latitude * 1000) % 100, 2, '0') + " Lon:" + longitude_str;
" Lon:" + to_string_dec_int(entry.pos.longitude) +
"." + to_string_dec_int((int)abs(entry.pos.longitude * 1000) % 100, 2, '0'); // printing the coordinates in the log file with more
// resolution, as we are not constrained by screen
// real estate there:
latitude_str.resize(13, '\0');
longitude_str.resize(13, '\0');
written = std::snprintf(&latitude_str[0], latitude_str.size(), "%.7f", entry.pos.latitude);
latitude_str.resize(written);
written = std::snprintf(&longitude_str[0], longitude_str.size(), "%.7f", entry.pos.longitude);
longitude_str.resize(written);
std::string log_info = "Alt:" + to_string_dec_int(entry.pos.altitude) +
" Lat:" + latitude_str +
" Lon:" + longitude_str;
entry.set_info_string(str_info); entry.set_info_string(str_info);
logentry+=str_info+ " "; logentry+=log_info + " ";
if (send_updates) if (send_updates)
details_view->update(entry); details_view->update(entry);

View File

@ -158,6 +158,12 @@ int cpr_NL_approx(float lat) {
} }
int cpr_NL(float lat) { int cpr_NL(float lat) {
// TODO prove that the approximate function is good
// enough for the precision we need. Uncomment if
// that is true:
//return cpr_NL_approx(lat);
return cpr_NL_precise(lat); return cpr_NL_precise(lat);
} }