001package org.openstreetmap.gui.jmapviewer.tilesources; 002 003/** 004 * OSM Tile source. 005 */ 006public class OsmTileSource { 007 008 /** 009 * The default "Mapnik" OSM tile source URL 010 */ 011 public static final String MAP_MAPNIK = "http://tile.openstreetmap.org"; 012 013 /** 014 * The default "Mapnik" OSM tile source. 015 */ 016 public static class Mapnik extends AbstractOsmTileSource { 017 018 /** 019 * Constructs a new {@code "Mapnik"} tile source. 020 */ 021 public Mapnik() { 022 super("Mapnik", MAP_MAPNIK); 023 } 024 025 public TileUpdate getTileUpdate() { 026 return TileUpdate.IfNoneMatch; 027 } 028 } 029 030 /** 031 * The "Cycle Map" OSM tile source. 032 */ 033 public static class CycleMap extends AbstractOsmTileSource { 034 035 private static final String PATTERN = "http://%s.tile.opencyclemap.org/cycle"; 036 037 private static final String[] SERVER = { "a", "b", "c" }; 038 039 private int SERVER_NUM = 0; 040 041 /** 042 * Constructs a new {@code CycleMap} tile source. 043 */ 044 public CycleMap() { 045 super("OSM Cycle Map", PATTERN); 046 } 047 048 @Override 049 public String getBaseUrl() { 050 String url = String.format(this.baseUrl, new Object[] { SERVER[SERVER_NUM] }); 051 SERVER_NUM = (SERVER_NUM + 1) % SERVER.length; 052 return url; 053 } 054 055 @Override 056 public int getMaxZoom() { 057 return 18; 058 } 059 060 public TileUpdate getTileUpdate() { 061 return TileUpdate.LastModified; 062 } 063 } 064}