mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-10 23:22:05 +00:00
Fix wrong-side-of-globe when precision set to 32
This commit is contained in:
parent
d434117ffd
commit
0dcd3584e4
@ -118,13 +118,16 @@ meshtastic_MeshPacket *PositionModule::allocReply()
|
||||
|
||||
// lat/lon are unconditionally included - IF AVAILABLE!
|
||||
LOG_DEBUG("Sending location with precision %i\n", precision);
|
||||
p.latitude_i = localPosition.latitude_i & (INT32_MAX << (32 - precision));
|
||||
p.longitude_i = localPosition.longitude_i & (INT32_MAX << (32 - precision));
|
||||
if (precision < 32 && precision > 0) {
|
||||
p.latitude_i = localPosition.latitude_i & (INT32_MAX << (32 - precision));
|
||||
p.longitude_i = localPosition.longitude_i & (INT32_MAX << (32 - precision));
|
||||
|
||||
// We want the imprecise position to be the middle of the possible location, not
|
||||
if (precision < 31 && precision > 1) {
|
||||
// We want the imprecise position to be the middle of the possible location, not
|
||||
p.latitude_i += (1 << (31 - precision));
|
||||
p.longitude_i += (1 << (31 - precision));
|
||||
} else {
|
||||
p.latitude_i = localPosition.latitude_i;
|
||||
p.longitude_i = localPosition.longitude_i;
|
||||
}
|
||||
p.precision_bits = precision;
|
||||
p.time = localPosition.time;
|
||||
|
Loading…
Reference in New Issue
Block a user