diff options
| author | Keith Packard <keithp@keithp.com> | 2014-07-16 17:13:25 -0700 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2014-07-16 17:13:25 -0700 | 
| commit | 165b7dcf6fba90b15ff32b891cba4b9111c1965b (patch) | |
| tree | 4a0bfe83888c4a46846a84b283b3125664c5298c /altoslib/AltosKML.java | |
| parent | ec7ceb607f5ba7e1ed5cfd32b7a452a5f364b095 (diff) | |
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 <keithp@keithp.com>
Diffstat (limited to 'altoslib/AltosKML.java')
| -rw-r--r-- | altoslib/AltosKML.java | 30 | 
1 files changed, 19 insertions, 11 deletions
| 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 =  		"<?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); | 
