}
}
- public static void prefetchMaps(double lat, double lng, int w, int h) {
+ public static void prefetchMaps(double lat, double lng) {
+ int w = AltosSiteMapPreload.width;
+ int h = AltosSiteMapPreload.height;
AltosSiteMap asm = new AltosSiteMap(true);
asm.centre = asm.getBaseLocation(lat, lng);
import java.net.URLConnection;
public class AltosSiteMapCache extends JLabel {
+ static final long google_maps_ratelimit_ms = 1200;
+ // Google limits static map queries to 50 per minute per IP, so
+ // each query should take at least 1.2 seconds.
+
public static boolean fetchMap(File file, String url) {
URL u;
+ long startTime = System.nanoTime();
try {
u = new URL(url);
}
return false;
}
+
+ long duration_ms = (System.nanoTime() - startTime) / 1000000;
+ if (duration_ms < google_maps_ratelimit_ms) {
+ try {
+ Thread.sleep(google_maps_ratelimit_ms - duration_ms);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ }
+ }
+
return true;
}
AltosMapPos lat;
AltosMapPos lon;
- final static int radius = 4;
+ final static int radius = 5;
final static int width = (radius * 2 + 1);
final static int height = (radius * 2 + 1);
pane.setLayout(new GridBagLayout());
- map = new AltosSiteMap(4);
+ map = new AltosSiteMap(radius);
c.fill = GridBagConstraints.BOTH;
c.anchor = GridBagConstraints.CENTER;
setLocationRelativeTo(owner);
setVisible(true);
}
-}
\ No newline at end of file
+}
} else {
double lat = Double.parseDouble(args[i+1]);
double lon = Double.parseDouble(args[i+2]);
- AltosSiteMap.prefetchMaps(lat, lon, 5, 5);
+ AltosSiteMap.prefetchMaps(lat, lon);
i += 2;
}
} else if (args[i].equals("--replay"))