X-Git-Url: https://git.gag.com/?a=blobdiff_plain;ds=sidebyside;f=altoslib%2FAltosMapTile.java;h=19332de191385254591155f755f0c85fabebdaea;hb=0a50669b1fde3e3c1cbc08c4836613b58ead219b;hp=fdc8ff65995ab0752843e88ad3f58b62afd52049;hpb=e0081f7ba6fc9f1e4484d3e291fd30065ad5b620;p=fw%2Faltos diff --git a/altoslib/AltosMapTile.java b/altoslib/AltosMapTile.java index fdc8ff65..19332de1 100644 --- a/altoslib/AltosMapTile.java +++ b/altoslib/AltosMapTile.java @@ -20,7 +20,7 @@ package org.altusmetrum.altoslib_10; import java.io.*; import java.util.*; -public abstract class AltosMapTile implements AltosFontListener, AltosMapStoreListener { +public class AltosMapTile implements AltosFontListener, AltosMapStoreListener { LinkedList listeners = new LinkedList(); public AltosLatLon upper_left, center; public int px_size; @@ -38,45 +38,6 @@ public abstract class AltosMapTile implements AltosFontListener, AltosMapStoreLi static public final int bad_request = 4;/* downloading failed */ static public final int forbidden = 5; /* downloading failed */ - private File map_file() { - double lat = center.lat; - double lon = center.lon; - char chlat = lat < 0 ? 'S' : 'N'; - char chlon = lon < 0 ? 'W' : 'E'; - - if (lat < 0) lat = -lat; - if (lon < 0) lon = -lon; - String maptype_string = String.format("%s-", AltosMap.maptype_names[maptype]); - String format_string; - if (maptype == AltosMap.maptype_hybrid || maptype == AltosMap.maptype_satellite || maptype == AltosMap.maptype_terrain) - format_string = "jpg"; - else - format_string = "png"; - return new File(AltosPreferences.mapdir(), - String.format("map-%c%.6f,%c%.6f-%s%d%s.%s", - chlat, lat, chlon, lon, maptype_string, zoom, scale == 1 ? "" : String.format("-%d", scale), format_string)); - } - - private String map_url() { - String format_string; - int z = zoom; - - if (maptype == AltosMap.maptype_hybrid || maptype == AltosMap.maptype_satellite || maptype == AltosMap.maptype_terrain) - format_string = "jpg"; - else - format_string = "png32"; - - for (int s = 1; s < scale; s <<= 1) - z--; - - if (AltosVersion.has_google_maps_api_key()) - return String.format("http://maps.google.com/maps/api/staticmap?center=%.6f,%.6f&zoom=%d&size=%dx%d&scale=%d&sensor=false&maptype=%s&format=%s&key=%s", - center.lat, center.lon, z, px_size/scale, px_size/scale, scale, AltosMap.maptype_names[maptype], format_string, AltosVersion.google_maps_api_key); - else - return String.format("http://maps.google.com/maps/api/staticmap?center=%.6f,%.6f&zoom=%d&size=%dx%d&scale=%d&sensor=false&maptype=%s&format=%s", - center.lat, center.lon, z, px_size/scale, px_size/scale, AltosMap.maptype_names[maptype], format_string); - } - public void font_size_changed(int font_size) { } @@ -87,7 +48,6 @@ public abstract class AltosMapTile implements AltosFontListener, AltosMapStoreLi } public void notify_store(AltosMapStore store, int status) { -// System.out.printf("AltosMapTile.notify_store %d\n", status); notify_listeners(status); } @@ -99,7 +59,8 @@ public abstract class AltosMapTile implements AltosFontListener, AltosMapStoreLi notify_listeners(status); } - public abstract void paint(AltosMapTransform t); + public void paint(AltosMapTransform t) { + } public AltosImage get_image() { if (cache == null) @@ -132,7 +93,7 @@ public abstract class AltosMapTile implements AltosFontListener, AltosMapStoreLi this.px_size = px_size; this.scale = scale; - store = AltosMapStore.get(map_url(), map_file()); + store = AltosMapStore.get(center, zoom, maptype, px_size, scale); store.add_listener(this); }