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);
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
*/
}
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);
}
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) {
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;
}
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) {
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) {
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;
}
}
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 );
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);
}
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() {
void fill_map(AltosFlightSeries flight_series) {
boolean any_gps = false;
AltosGPSTimeValue gtv_last = null;
+ double gps_pad_altitude = flight_series.cal_data().gps_pad_altitude;;
if (flight_series.gps_series != null) {
for (AltosGPSTimeValue gtv : flight_series.gps_series) {
gps.nsat >= 4) {
if (map == null)
map = new AltosUIMap();
- map.show(gps, gtv. time, (int) flight_series.value_before(AltosFlightSeries.state_name, gtv.time));
+ double gps_height = gps.alt - gps_pad_altitude;
+ int state = (int) flight_series.value_before(AltosFlightSeries.state_name, gtv.time);
+ map.show(gps, gtv.time, state, gps_height);
this.gps = gps;
gtv_last = gtv;
has_gps = true;
}
if (gtv_last != null) {
int state = (int) flight_series.value_after(AltosFlightSeries.state_name, gtv_last.time);
+ double gps_height = gps.alt - gps_pad_altitude;
if (state == AltosLib.ao_flight_landed)
- map.show(gtv_last.gps, gtv_last.time, state);
+ map.show(gtv_last.gps, gtv_last.time, state,gps_height);
}
}
}
String pos(double p, String pos, String neg) {
+ if (p == AltosLib.MISSING)
+ return "";
String h = pos;
if (p < 0) {
h = neg;
return String.format("%s %4d° %9.6f'", h, deg, min);
}
+ String height(double h, String label) {
+ if (h == AltosLib.MISSING)
+ return "";
+ return String.format(" %s%s",
+ AltosConvert.height.show(6, h),
+ label);
+ }
+
+ String speed(double s, String label) {
+ if (s == AltosLib.MISSING)
+ return "";
+ return String.format(" %s%s",
+ AltosConvert.speed.show(6, s),
+ label);
+ }
+
public void mouseMoved(MouseEvent e) {
AltosMapPathPoint point = map.nearest(e.getPoint().x, e.getPoint().y);
if (nearest_mark == null)
- nearest_mark = map.add_mark(point.lat_lon.lat,
- point.lat_lon.lon,
+ nearest_mark = map.add_mark(point.gps.lat,
+ point.gps.lon,
point.state);
else {
- nearest_mark.lat_lon.lat = point.lat_lon.lat;
- nearest_mark.lat_lon.lon = point.lat_lon.lon;
+ nearest_mark.lat_lon.lat = point.gps.lat;
+ nearest_mark.lat_lon.lon = point.gps.lon;
nearest_mark.state = point.state;
}
if (point != null) {
- nearest_label.setText(String.format("Time: %9.2f Position: %s %s",
+ nearest_label.setText(String.format("%9.2f sec %s%s%s%s",
point.time,
- pos(point.lat_lon.lat,
+ pos(point.gps.lat,
"N", "S"),
- pos(point.lat_lon.lon,
- "E", "W")));
+ pos(point.gps.lon,
+ "E", "W"),
+ height(point.gps_height, ""),
+ speed(point.gps.ground_speed, "(h)"),
+ speed(point.gps.climb_rate, "(v)")));
} else {
nearest_label.setText("");
}
g.setStroke(new BasicStroke(stroke_width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
for (AltosMapPathPoint point : points) {
- Point2D.Double cur = point2d(t.screen(point.lat_lon));
+ Point2D.Double cur = point2d(t.screen(point.gps.lat, point.gps.lon));
if (prev != null) {
Line2D.Double line = new Line2D.Double (prev, cur);
Rectangle bounds = line.getBounds();
map.show(state, listener_state);
}
- public void show(AltosGPS gps, double time, int state) {
- map.show(gps, time, state);
+ public void show(AltosGPS gps, double time, int state, double gps_height) {
+ map.show(gps, time, state, gps_height);
}
public String getName() {