From: Keith Packard Date: Thu, 17 Jul 2014 00:13:25 +0000 (-0700) Subject: altoslib: Handle TeleGPS files for KML export X-Git-Tag: 1.4.9.3~23^2 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=165b7dcf6fba90b15ff32b891cba4b9111c1965b altoslib: Handle TeleGPS files for KML export TeleGPS files had state values that couldn't be converted to colors, which resulted in a truncated file that wasn't much use for anything. Signed-off-by: Keith Packard --- diff --git a/altoslib/AltosKML.java b/altoslib/AltosKML.java index e31ddfba..e701fda3 100644 --- a/altoslib/AltosKML.java +++ b/altoslib/AltosKML.java @@ -28,18 +28,25 @@ public class AltosKML implements AltosWriter { double gps_start_altitude; static final String[] kml_state_colors = { - "FF000000", - "FF000000", - "FF000000", - "FF0000FF", - "FF4080FF", - "FF00FFFF", - "FFFF0000", - "FF00FF00", - "FF000000", - "FFFFFFFF" + "FF000000", // startup + "FF000000", // idle + "FF000000", // pad + "FF0000FF", // boost + "FF4080FF", // fast + "FF00FFFF", // coast + "FFFF0000", // drogue + "FF00FF00", // main + "FF000000", // landed + "FFFFFFFF", // invalid + "FFFF0000", // stateless }; + static String state_color(int state) { + if (state < 0 || kml_state_colors.length <= state) + return kml_state_colors[AltosLib.ao_flight_invalid]; + return kml_state_colors[state]; + } + static final String kml_header_start = "\n" + "\n" + @@ -95,7 +102,8 @@ public class AltosKML implements AltosWriter { void state_start(AltosState state) { String state_name = AltosLib.state_name(state.state); - out.printf(kml_style_start, state_name, kml_state_colors[state.state]); + String state_color = state_color(state.state); + out.printf(kml_style_start, state_name, state_color); out.printf("\tState: %s\n", state_name); out.printf("%s", kml_style_end); out.printf(kml_placemark_start, state_name, state_name);