X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosui%2FAltosSiteMap.java;h=7575c10e62d3b95cfa23ca2c7d938485573d79af;hp=8097060508989859c30ba1ee23efdfc76f549bb0;hb=0e67b6890dd3a06665239f8dfd2e69266d055e46;hpb=3fbefb3eea981d34a09496cf8abf0119de2e35bf diff --git a/altosui/AltosSiteMap.java b/altosui/AltosSiteMap.java index 80970605..7575c10e 100644 --- a/altosui/AltosSiteMap.java +++ b/altosui/AltosSiteMap.java @@ -164,8 +164,6 @@ public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay { } public static void prefetchMaps(double lat, double lng, int w, int h) { - AltosPreferences.init(null); - AltosSiteMap asm = new AltosSiteMap(true); asm.centre = asm.getBaseLocation(lat, lng); @@ -211,10 +209,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)); } @@ -228,18 +226,19 @@ public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay { int last_state = -1; public void show(final AltosState state, final int crc_errors) { // if insufficient gps data, nothing to update - if (state.gps == null) - return; - if (state.pad_lat == 0 && state.pad_lon == 0) + if (!state.gps.locked && state.gps.nsat < 4) return; - if (!state.gps.locked) { - if (state.gps.nsat < 4) - return; - } if (!initialised) { - initMaps(state.pad_lat, state.pad_lon); - initialised = true; + if (state.pad_lat != 0 || state.pad_lon != 0) { + initMaps(state.pad_lat, state.pad_lon); + initialised = true; + } else if (state.gps.lat != 0 || state.gps.lon != 0) { + initMaps(state.gps.lat, state.gps.lon); + initialised = true; + } else { + return; + } } final Point2D.Double pt = pt(state.gps.lat, state.gps.lon);