summaryrefslogtreecommitdiff
path: root/altoslib/AltosState.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-04-11 23:56:47 -0700
committerKeith Packard <keithp@keithp.com>2013-04-11 23:58:56 -0700
commitf02bb1df132443fc27b69f23f382ea87e610f533 (patch)
tree885c5009e93740294734e74cefc17a8e1f25d392 /altoslib/AltosState.java
parent9a8cc23de5776ea3fa2bdc96cbe63422eb555d63 (diff)
altoslib: Add range and elevation to AltosGreatCircle
Move the computations from AltosState here so they can be re-used elsewhere. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib/AltosState.java')
-rw-r--r--altoslib/AltosState.java22
1 files changed, 10 insertions, 12 deletions
diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java
index f1bcb1c1..a3b9a8c0 100644
--- a/altoslib/AltosState.java
+++ b/altoslib/AltosState.java
@@ -248,23 +248,21 @@ public class AltosState {
if (height != AltosRecord.MISSING && height > max_height)
max_height = height;
+ elevation = 0;
+ range = -1;
+ gps_height = 0;
if (data.gps != null) {
if (gps == null || !gps.locked || data.gps.locked)
gps = data.gps;
if (ngps > 0 && gps.locked) {
- from_pad = new AltosGreatCircle(pad_lat, pad_lon, gps.lat, gps.lon);
- }
- }
- elevation = 0;
- range = -1;
- if (ngps > 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);
+ double h = height;
+
+ if (h == AltosRecord.MISSING) h = 0;
+ from_pad = new AltosGreatCircle(pad_lat, pad_lon, 0, gps.lat, gps.lon, h);
+ elevation = from_pad.elevation;
+ range = from_pad.range;
+ gps_height = gps.alt - pad_alt;
}
- } else {
- gps_height = 0;
}
}