altosui: move maps to subdir, fix E/W mismatch
authorAnthony Towns <aj@erisian.com.au>
Mon, 13 Dec 2010 17:40:18 +0000 (03:40 +1000)
committerAnthony Towns <aj@erisian.com.au>
Mon, 13 Dec 2010 17:40:18 +0000 (03:40 +1000)
altosui/AltosPreferences.java
altosui/AltosSiteMap.java

index e2a3df3b7717bb5b92f9cf150706bdc49a7ecbb3..c6ae6cbd176d39cdae30b075f77fc2812f065df4 100644 (file)
@@ -52,6 +52,9 @@ class AltosPreferences {
        /* Log directory */
        static File logdir;
 
+       /* Map directory -- hangs of logdir */
+       static File mapdir;
+
        /* Channel (map serial to channel) */
        static Hashtable<Integer, Integer> channels;
 
@@ -79,6 +82,9 @@ class AltosPreferences {
                        if (!logdir.exists())
                                logdir.mkdirs();
                }
+               mapdir = new File(logdir, "maps");
+               if (!mapdir.exists())
+                       mapdir.mkdirs();
 
                channels = new Hashtable<Integer,Integer>();
 
@@ -106,6 +112,9 @@ class AltosPreferences {
 
        public static void set_logdir(File new_logdir) {
                logdir = new_logdir;
+               mapdir = new File(logdir, "maps");
+               if (!mapdir.exists())
+                       mapdir.mkdirs();
                synchronized (preferences) {
                        preferences.put(logdirPreference, logdir.getPath());
                        flush_preferences();
@@ -151,6 +160,10 @@ class AltosPreferences {
                return logdir;
        }
 
+       public static File mapdir() {
+               return mapdir;
+       }
+
        public static void set_channel(int serial, int new_channel) {
                channels.put(serial, new_channel);
                synchronized (preferences) {
index d4a4cbf43dbaa66b7c0c69ca6da2be09bef08e5c..d6bd6d1f43cfc0cbdf4030d8f604a7466ae713c5 100644 (file)
@@ -211,10 +211,10 @@ public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay {
 
        private File MapFile(double lat, double lng) {
                char chlat = lat < 0 ? 'S' : 'N';
-               char chlng = lng < 0 ? 'E' : 'W';
+               char chlng = lng < 0 ? 'W' : 'E';
                if (lat < 0) lat = -lat;
                if (lng < 0) lng = -lng;
-               return new File(AltosPreferences.logdir(),
+               return new File(AltosPreferences.mapdir(),
                                String.format("map-%c%.6f,%c%.6f-%d.png",
                                              chlat, lat, chlng, lng, zoom));
        }