X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=src%2Ftim%2Fprune%2Fgui%2Fmap%2FMffMapSource.java;fp=src%2Ftim%2Fprune%2Fgui%2Fmap%2FMffMapSource.java;h=42806fc75e7e104c8fa2c3140fc9ad9d0deec459;hp=0000000000000000000000000000000000000000;hb=ce6f2161b8596f7018d6a76bff79bc9e571f35fd;hpb=2d8cb72e84d5cc1089ce77baf1e34ea3ea2f8465 diff --git a/src/tim/prune/gui/map/MffMapSource.java b/src/tim/prune/gui/map/MffMapSource.java new file mode 100644 index 0000000..42806fc --- /dev/null +++ b/src/tim/prune/gui/map/MffMapSource.java @@ -0,0 +1,89 @@ +package tim.prune.gui.map; + +import tim.prune.I18nManager; + +/** + * Class to provide a map source for maps-for-free sources + * These are double-layer sources with jpg and gif tiles + */ +public class MffMapSource extends MapSource +{ + /** Name for this source */ + private String _name = null; + /** Base urls */ + private String[] _baseUrls = null; + /** Site names */ + private String[] _siteNames = null; + /** Maximum zoom level */ + private int _maxZoom = 0; + + /** + * Constructor giving name, url and maximum zoom + * @param inName source name + * @param inUrl base url + * @param inMaxZoom maximum zoom level + */ + public MffMapSource(String inName, String inUrl1, String inExt1, + String inUrl2, String inExt2, int inMaxZoom) + { + _name = inName; + if (_name == null || _name.trim().equals("")) {_name = I18nManager.getText("mapsource.unknown");} + _baseUrls = new String[2]; + _baseUrls[0] = fixBaseUrl(inUrl1); + _baseUrls[1] = fixBaseUrl(inUrl2); + _siteNames = new String[2]; + _siteNames[0] = fixSiteName(_baseUrls[0]); + _siteNames[1] = fixSiteName(_baseUrls[1]); + _extensions = new String[2]; + _extensions[0] = inExt1; + _extensions[1] = inExt2; + _maxZoom = inMaxZoom; + } + + /** + * @return name + */ + public String getName() { + return _name; + } + + /** Number of layers is always 2 for mff sources */ + public int getNumLayers() { + return 2; + } + + /** Get base url for specified layer */ + public String getBaseUrl(int inLayerNum) { + return _baseUrls[inLayerNum]; + } + + /** site name without protocol or www. */ + public String getSiteName(int inLayerNum) { + return _siteNames[inLayerNum]; + } + + /** + * Make the URL to get the specified tile + */ + public String makeURL(int inLayerNum, int inZoom, int inX, int inY) + { + return _baseUrls[inLayerNum] + "z" + inZoom + "/row" + inY + "/" + inZoom + "_" + inX + "-" + inY + "." + getFileExtension(inLayerNum); + } + + /** + * @return maximum zoom level + */ + public final int getMaxZoomLevel() + { + return _maxZoom; + } + + /** + * @return semicolon-separated list of all fields + */ + public String getConfigString() + { + // TODO: Maybe a gui will be necessary for this one day + return "not required"; + } +}