diff options
author | Keith Packard <keithp@keithp.com> | 2019-09-02 15:20:14 -0500 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2019-09-02 15:45:30 -0500 |
commit | 2524730217e6972f3d0f04a9954350ba1964a83a (patch) | |
tree | 959e388b0ea4908cb9cd21b60c662f2cedcb9bfb /altoslib | |
parent | b13893245e8c66b48e23bb2005ef6ce46e69744f (diff) |
altosui: Add speed and gps height to map display data
And generalize the API so that any other GPS data could be added in
the future.
This feature was proposed by Mike Beattie
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib')
-rw-r--r-- | altoslib/AltosGPS.java | 4 | ||||
-rw-r--r-- | altoslib/AltosMap.java | 7 | ||||
-rw-r--r-- | altoslib/AltosMapPath.java | 10 | ||||
-rw-r--r-- | altoslib/AltosMapPathPoint.java | 12 | ||||
-rw-r--r-- | altoslib/AltosMapTransform.java | 14 |
5 files changed, 30 insertions, 17 deletions
diff --git a/altoslib/AltosGPS.java b/altoslib/AltosGPS.java index 8037eb93..57ac4061 100644 --- a/altoslib/AltosGPS.java +++ b/altoslib/AltosGPS.java @@ -92,6 +92,10 @@ public class AltosGPS implements Cloneable { return odt.toEpochSecond(); } + public AltosLatLon lat_lon() { + return new AltosLatLon(lat, lon); + } + public AltosGPS(AltosTelemetryMap map) throws ParseException { String state = map.get_string(AltosTelemetryLegacy.AO_TELEM_GPS_STATE, AltosTelemetryLegacy.AO_TELEM_GPS_STATE_ERROR); diff --git a/altoslib/AltosMap.java b/altoslib/AltosMap.java index b9c4bfc1..69142c37 100644 --- a/altoslib/AltosMap.java +++ b/altoslib/AltosMap.java @@ -222,8 +222,7 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { return false; } - public void show(AltosGPS gps, double time, int state) { - + public void show(AltosGPS gps, double time, int state, double gps_height) { /* * If insufficient gps data, nothing to update */ @@ -250,7 +249,7 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { } if (path != null) { - AltosMapRectangle damage = path.add(gps.lat, gps.lon, time, state); + AltosMapRectangle damage = path.add(gps, time, state, gps_height); if (damage != null) repaint(damage, AltosMapPath.stroke_width); @@ -262,7 +261,7 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { } public void show(AltosState state, AltosListenerState listener_state) { - show(state.gps, state.time, state.state()); + show(state.gps, state.time, state.state(), state.gps_height()); } public void centre(AltosLatLon lat_lon) { diff --git a/altoslib/AltosMapPath.java b/altoslib/AltosMapPath.java index 54ff51fc..bbb6c994 100644 --- a/altoslib/AltosMapPath.java +++ b/altoslib/AltosMapPath.java @@ -32,13 +32,13 @@ public abstract class AltosMapPath { public abstract void paint(AltosMapTransform t); - public AltosMapRectangle add(double lat, double lon, double time, int state) { - AltosMapPathPoint point = new AltosMapPathPoint(new AltosLatLon (lat, lon), time, state); + public AltosMapRectangle add(AltosGPS gps, double time, int state, double gps_height) { + AltosMapPathPoint point = new AltosMapPathPoint(gps, time, state, gps_height); AltosMapRectangle rect = null; if (!point.equals(last_point)) { if (last_point != null) - rect = new AltosMapRectangle(last_point.lat_lon, point.lat_lon); + rect = new AltosMapRectangle(last_point.gps.lat_lon(), point.gps.lat_lon()); points.add (point); last_point = point; } @@ -48,8 +48,8 @@ public abstract class AltosMapPath { private double dist(AltosLatLon lat_lon, AltosMapPathPoint point) { return (new AltosGreatCircle(lat_lon.lat, lat_lon.lon, - point.lat_lon.lat, - point.lat_lon.lon)).distance; + point.gps.lat, + point.gps.lon)).distance; } public AltosMapPathPoint nearest(AltosLatLon lat_lon) { diff --git a/altoslib/AltosMapPathPoint.java b/altoslib/AltosMapPathPoint.java index c23d8567..88a8bfcf 100644 --- a/altoslib/AltosMapPathPoint.java +++ b/altoslib/AltosMapPathPoint.java @@ -24,12 +24,13 @@ import java.util.*; import java.util.concurrent.*; public class AltosMapPathPoint { - public AltosLatLon lat_lon; + public AltosGPS gps; public double time; public int state; + public double gps_height; public int hashCode() { - return lat_lon.hashCode() ^ state; + return Double.valueOf(gps.lat).hashCode() ^ Double.valueOf(gps.lon).hashCode() ^ state; } public boolean equals(Object o) { @@ -41,13 +42,14 @@ public class AltosMapPathPoint { AltosMapPathPoint other = (AltosMapPathPoint) o; - return lat_lon.equals(other.lat_lon) && state == other.state; + return gps.lat == other.gps.lat && gps.lon == other.gps.lon && state == other.state; } - public AltosMapPathPoint(AltosLatLon lat_lon, double time, int state) { - this.lat_lon = lat_lon; + public AltosMapPathPoint(AltosGPS gps, double time, int state, double gps_height) { + this.gps = gps; this.time = time; this.state = state; + this.gps_height = gps_height; } } diff --git a/altoslib/AltosMapTransform.java b/altoslib/AltosMapTransform.java index 6bc6c6f8..9eac2654 100644 --- a/altoslib/AltosMapTransform.java +++ b/altoslib/AltosMapTransform.java @@ -67,13 +67,13 @@ public class AltosMapTransform { return lat_lon(screen_point(screen)); } - public AltosPointDouble point(AltosLatLon lat_lon) { + public AltosPointDouble point(double lat, double lon) { double x, y; double e; - x = lat_lon.lon * scale_x; + x = lon * scale_x; - e = Math.sin(Math.toRadians(lat_lon.lat)); + e = Math.sin(Math.toRadians(lat)); e = Math.max(e,-(1-1.0E-15)); e = Math.min(e, 1-1.0E-15 ); @@ -82,6 +82,10 @@ public class AltosMapTransform { return new AltosPointDouble(x, y); } + public AltosPointDouble point(AltosLatLon lat_lon) { + return point(lat_lon.lat, lat_lon.lon); + } + public AltosPointDouble screen(AltosPointDouble point) { return new AltosPointDouble(point.x - offset_x, point.y - offset_y); } @@ -102,6 +106,10 @@ public class AltosMapTransform { return screen(point(lat_lon)); } + public AltosPointDouble screen(double lat, double lon) { + return screen(point(lat, lon)); + } + private boolean has_location; public boolean has_location() { |