altoslib: Use Locale.ROOT for KML export
authorKeith Packard <keithp@keithp.com>
Mon, 18 May 2015 17:52:24 +0000 (10:52 -0700)
committerKeith Packard <keithp@keithp.com>
Mon, 18 May 2015 17:52:24 +0000 (10:52 -0700)
This avoids locale-specific number formatting, which breaks
googleearth when importing the resulting file.

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosKML.java

index aa80fc21dd8465ee5ac17769c5179343ef440cdf..1a0fcf3d6be8096c21a23ea6cd0d3c0d98c1c86d 100644 (file)
 package org.altusmetrum.altoslib_6;
 
 import java.io.*;
 package org.altusmetrum.altoslib_6;
 
 import java.io.*;
+import java.util.*;
+
+class KMLWriter extends PrintWriter {
+       public PrintWriter printf(String format, Object ... arguments) {
+               return printf(Locale.ROOT, format, arguments);
+       }
+
+       public KMLWriter(File name) throws FileNotFoundException {
+               super(name);
+       }
+}
 
 public class AltosKML implements AltosWriter {
 
        File                    name;
 
 public class AltosKML implements AltosWriter {
 
        File                    name;
-       PrintStream             out;
+       PrintWriter             out;
        int                     flight_state = -1;
        AltosState              prev = null;
        double                  gps_start_altitude;
        int                     flight_state = -1;
        AltosState              prev = null;
        double                  gps_start_altitude;
@@ -137,6 +148,10 @@ public class AltosKML implements AltosWriter {
                        end();
                        prev = null;
                }
                        end();
                        prev = null;
                }
+               if (out != null) {
+                       out.close();
+                       out = null;
+               }
        }
 
        public void write(AltosState state) {
        }
 
        public void write(AltosState state) {
@@ -177,7 +192,7 @@ public class AltosKML implements AltosWriter {
 
        public AltosKML(File in_name) throws FileNotFoundException {
                name = in_name;
 
        public AltosKML(File in_name) throws FileNotFoundException {
                name = in_name;
-               out = new PrintStream(name);
+               out = new KMLWriter(name);
        }
 
        public AltosKML(String in_string) throws FileNotFoundException {
        }
 
        public AltosKML(String in_string) throws FileNotFoundException {