001 package org.openstreetmap.gui.jmapviewer.interfaces;
002
003 import java.awt.Image;
004 import java.io.IOException;
005
006 import org.openstreetmap.gui.jmapviewer.Coordinate;
007 import org.openstreetmap.gui.jmapviewer.JMapViewer;
008
009 //License: GPL. Copyright 2008 by Jan Peter Stotz
010
011 /**
012 *
013 * @author Jan Peter Stotz
014 */
015 public interface TileSource extends Attributed {
016
017 /**
018 * Specifies the different mechanisms for detecting updated tiles
019 * respectively only download newer tiles than those stored locally.
020 *
021 * <ul>
022 * <li>{@link #IfNoneMatch} Server provides ETag header entry for all tiles
023 * and <b>supports</b> conditional download via <code>If-None-Match</code>
024 * header entry.</li>
025 * <li>{@link #ETag} Server provides ETag header entry for all tiles but
026 * <b>does not support</b> conditional download via
027 * <code>If-None-Match</code> header entry.</li>
028 * <li>{@link #IfModifiedSince} Server provides Last-Modified header entry
029 * for all tiles and <b>supports</b> conditional download via
030 * <code>If-Modified-Since</code> header entry.</li>
031 * <li>{@link #LastModified} Server provides Last-Modified header entry for
032 * all tiles but <b>does not support</b> conditional download via
033 * <code>If-Modified-Since</code> header entry.</li>
034 * <li>{@link #None} The server does not support any of the listed
035 * mechanisms.</li>
036 * </ul>
037 *
038 */
039 public enum TileUpdate {
040 IfNoneMatch, ETag, IfModifiedSince, LastModified, None
041 }
042
043 /**
044 * Specifies the maximum zoom value. The number of zoom levels is [0..
045 * {@link #getMaxZoom()}].
046 *
047 * @return maximum zoom value that has to be smaller or equal to
048 * {@link JMapViewer#MAX_ZOOM}
049 */
050 int getMaxZoom();
051
052 /**
053 * Specifies the minimum zoom value. This value is usually 0.
054 * Only for maps that cover a certain region up to a limited zoom level
055 * this method should return a value different than 0.
056 *
057 * @return minimum zoom value - usually 0
058 */
059 int getMinZoom();
060
061 /**
062 * @return The supported tile update mechanism
063 * @see TileUpdate
064 */
065 TileUpdate getTileUpdate();
066
067 /**
068 * A tile layer name has to be unique and has to consist only of characters
069 * valid for filenames.
070 *
071 * @return Name of the tile layer
072 */
073 String getName();
074
075 /**
076 * Constructs the tile url.
077 *
078 * @param zoom
079 * @param tilex
080 * @param tiley
081 * @return fully qualified url for downloading the specified tile image
082 */
083 String getTileUrl(int zoom, int tilex, int tiley) throws IOException;
084
085 /**
086 * Specifies the tile image type. For tiles rendered by Mapnik or
087 * Osmarenderer this is usually <code>"png"</code>.
088 *
089 * @return file extension of the tile image type
090 */
091 String getTileType();
092
093 /**
094 * Specifies how large each tile is.
095 * @return The size of a single tile in pixels.
096 */
097 int getTileSize();
098
099 double latToTileY(double lat, int zoom);
100
101 double lonToTileX(double lon, int zoom);
102
103 double tileYToLat(int y, int zoom);
104
105 double tileXToLon(int x, int zoom);
106 }