Fixed the mixing of aircraft coordinates in the details view, by

checking if the ICAO address of the frame and the current item
in the details view match. Slight refactor by placing the decimal
to string conversion function into the string_format module.
This commit is contained in:
teixeluis
2021-06-23 23:52:15 +01:00
parent 97349b06ef
commit b09439afb1
7 changed files with 45 additions and 42 deletions
+17
View File
@@ -112,6 +112,23 @@ std::string to_string_dec_int(
return q;
}
std::string to_string_decimal(float decimal, int8_t precision) {
double integer_part;
double fractional_part;
std::string result;
fractional_part = modf(decimal, &integer_part) * pow(10, precision);
if (fractional_part < 0) {
fractional_part = -fractional_part;
}
result = to_string_dec_int(integer_part) + "." + to_string_dec_uint(fractional_part, precision);
return result;
}
std::string to_string_short_freq(const uint64_t f) {
auto final_str = to_string_dec_int(f / 1000000,4) + "." + to_string_dec_int((f / 100) % 10000, 4, '0');
return final_str;