altoslib: Handle TeleGPS files for KML export
authorKeith Packard <keithp@keithp.com>
Thu, 17 Jul 2014 00:13:25 +0000 (17:13 -0700)
committerKeith Packard <keithp@keithp.com>
Thu, 17 Jul 2014 00:13:25 +0000 (17:13 -0700)
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 <keithp@keithp.com>
altoslib/AltosKML.java

index e31ddfba19a3c4fa6eed978e2f2930a482b226ae..e701fda3ade3f3791b71f0271ec1d221f8688e8c 100644 (file)
@@ -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 =
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                "<kml xmlns=\"http://www.opengis.net/kml/2.2\">\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);