diff options
| author | Keith Packard <keithp@keithp.com> | 2010-08-27 10:58:55 -0700 |
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2010-08-27 10:58:55 -0700 |
| commit | 63bd34cd1b5a411489e8c3ab377f0fe0eec11f67 (patch) | |
| tree | 8daae29a81a791c57fdd526a4820768757ff4f06 /ao-tools/altosui/AltosState.java | |
| parent | 2923cf5057f9cef110dd547d8677ea5b60e00796 (diff) | |
altosui: add elevation and range information
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'ao-tools/altosui/AltosState.java')
| -rw-r--r-- | ao-tools/altosui/AltosState.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/ao-tools/altosui/AltosState.java b/ao-tools/altosui/AltosState.java index c13dfe68..3ef00f35 100644 --- a/ao-tools/altosui/AltosState.java +++ b/ao-tools/altosui/AltosState.java @@ -64,6 +64,8 @@ public class AltosState { boolean gps_ready; AltosGreatCircle from_pad; + double elevation; /* from pad */ + double range; /* total distance */ double gps_height; @@ -124,7 +126,7 @@ public class AltosState { } if (state == Altos.ao_flight_pad) { - if (data.gps != null && data.gps.locked && data.gps.nsat >= 4) { + if (data.gps != null && data.gps.locked) { npad++; if (npad > 1) { /* filter pad position */ @@ -161,11 +163,18 @@ public class AltosState { if (data.gps != null) { if (gps == null || !gps.locked || data.gps.locked) gps = data.gps; - if (npad > 0 && gps.locked) + if (npad > 0 && gps.locked) { from_pad = new AltosGreatCircle(pad_lat, pad_lon, gps.lat, gps.lon); + } } + elevation = 0; + range = -1; if (npad > 0) { gps_height = gps.alt - pad_alt; + if (from_pad != null) { + elevation = Math.atan2(height, from_pad.distance) * 180 / Math.PI; + range = Math.sqrt(height * height + from_pad.distance * from_pad.distance); + } } else { gps_height = 0; } |
