1 package tim.prune.gui.map;
3 import tim.prune.I18nManager;
6 * Class to provide a map source for maps-for-free sources
7 * These are double-layer sources with jpg and gif tiles
9 public class MffMapSource extends MapSource
11 /** Name for this source */
12 private String _name = null;
14 private String[] _baseUrls = null;
16 private String[] _siteNames = null;
17 /** File extensions */
18 private String[] _extensions = null;
19 /** Maximum zoom level */
20 private int _maxZoom = 0;
23 * Constructor giving name, url and maximum zoom
24 * @param inName source name
25 * @param inUrl base url
26 * @param inMaxZoom maximum zoom level
28 public MffMapSource(String inName, String inUrl1, String inExt1,
29 String inUrl2, String inExt2, int inMaxZoom)
32 if (_name == null || _name.trim().equals("")) {_name = I18nManager.getText("mapsource.unknown");}
33 _baseUrls = new String[2];
34 _baseUrls[0] = fixBaseUrl(inUrl1);
35 _baseUrls[1] = fixBaseUrl(inUrl2);
36 _siteNames = new String[2];
37 _siteNames[0] = fixSiteName(_baseUrls[0]);
38 _siteNames[1] = fixSiteName(_baseUrls[1]);
39 _extensions = new String[2];
40 _extensions[0] = inExt1;
41 _extensions[1] = inExt2;
48 public String getName() {
52 /** Number of layers is always 2 for mff sources */
53 public int getNumLayers() {
57 /** Get base url for specified layer */
58 public String getBaseUrl(int inLayerNum) {
59 return _baseUrls[inLayerNum];
62 /** site name without protocol or www. */
63 public String getSiteName(int inLayerNum) {
64 return _siteNames[inLayerNum];
68 * Make the URL to get the specified tile
70 public String makeURL(int inLayerNum, int inZoom, int inX, int inY)
72 return _baseUrls[inLayerNum] + "z" + inZoom + "/row" + inY + "/" + inZoom + "_" + inX + "-" + inY + getFileExtension(inLayerNum);
75 /** Get right file extension for this layer */
76 public final String getFileExtension(int inLayerNum) {
77 return _extensions[inLayerNum];
81 * @return maximum zoom level
83 public final int getMaxZoomLevel()
89 * @return semicolon-separated list of all fields
91 public String getConfigString()
93 // TODO: Maybe a gui will be necessary for this one day
94 return "not required";