1 package tim.prune.gui.map;
4 * Class to act as a source for Cloudmade maps with a given style
6 public class CloudmadeMapSource extends OsmMapSource
8 /** Selected style number */
9 private String _style = null;
10 /** Server prefix including API-key unique to GpsPrune application */
11 private static final String SERVER_PREFIX = "tile.cloudmade.com/03d86b66f51f4a3b8c236ac06f2a2e57/";
15 * @param inName name to use for map source
16 * @param inStyle style, given as integer
17 * @param inMaxZoom maximum zoom level, 18 by default
19 public CloudmadeMapSource(String inName, String inStyle, int inMaxZoom)
21 // Note: Could check style for valid integer value here
22 super(inName, SERVER_PREFIX + inStyle + "/256/", null, inMaxZoom);
27 * @return semicolon-separated list of all fields
29 public String getConfigString()
31 return "c:" + getName() + ";" + _style + ";" + getMaxZoomLevel();
35 * Construct a new map source from its config string
36 * @param inConfigString string from Config, separated by semicolons
37 * @return new map source, or null if not parseable
39 public static CloudmadeMapSource fromConfig(String inConfigString)
41 CloudmadeMapSource source = null;
42 if (inConfigString.startsWith("c:"))
44 String[] items = inConfigString.substring(2).split(";");
46 if (items.length == 3) {
47 source = new CloudmadeMapSource(items[0], items[1], Integer.parseInt(items[2]));
49 } catch (NumberFormatException nfe) {}