001// License: GPL. For details, see Readme.txt file. 002package org.openstreetmap.gui.jmapviewer.tilesources; 003 004import java.util.Map; 005import java.util.Set; 006 007/** 008 * Data class that keeps basic information about a tile source. 009 * 010 * @since 31122 011 */ 012public class TileSourceInfo { 013 /** id for this imagery entry, optional at the moment */ 014 protected String id; 015 016 /** URL of the imagery service */ 017 protected String url; 018 019 /** name of the imagery layer */ 020 protected String name; 021 022 /** headers meaning, that there is no tile at this zoom level */ 023 protected Map<String, Set<String>> noTileHeaders; 024 025 /** checksum of empty tiles */ 026 protected Map<String, Set<String>> noTileChecksums; 027 028 /** minimum zoom level supported by the tile source */ 029 protected int minZoom; 030 031 /** maximum zoom level supported by the tile source */ 032 protected int maxZoom; 033 034 /** cookies that needs to be sent to tile source */ 035 protected String cookies = ""; 036 037 /** tile size of the displayed tiles */ 038 private int tileSize = -1; 039 040 /** mapping <header key, metadata key> */ 041 protected Map<String, String> metadataHeaders; 042 043 /** 044 * Create a TileSourceInfo class 045 * 046 * @param name name 047 * @param baseUrl base URL 048 * @param id unique id 049 */ 050 public TileSourceInfo(String name, String baseUrl, String id) { 051 this.name = name; 052 this.url = baseUrl; 053 this.id = id; 054 } 055 056 /** 057 * Create a TileSourceInfo class 058 * 059 * @param name name 060 */ 061 public TileSourceInfo(String name) { 062 this(name, null, null); 063 } 064 065 /** 066 * Creates empty TileSourceInfo class 067 */ 068 public TileSourceInfo() { 069 this(null, null, null); 070 } 071 072 /** 073 * Request name of the tile source 074 * @return name of the tile source 075 */ 076 public final String getName() { 077 return name; 078 } 079 080 /** 081 * Request URL of the tile source 082 * @return url of the tile source 083 */ 084 public final String getUrl() { 085 return url; 086 } 087 088 /** 089 * Request ID of the tile source. Id can be null. This gets the configured id as is. 090 * Due to a user error, this may not be unique. 091 * @return id of the tile source 092 */ 093 public final String getId() { 094 return id; 095 } 096 097 /** 098 * Request header information for empty tiles for servers delivering such tile types 099 * @return map of headers, that when set, means that this is "no tile at this zoom level" situation 100 * @since 32022 101 */ 102 public Map<String, Set<String>> getNoTileHeaders() { 103 return noTileHeaders; 104 } 105 106 /** 107 * Checkusm for empty tiles for servers delivering such tile types 108 * @return map of checksums, that when detected, means that this is "no tile at this zoom level" situation 109 * @since 32022 110 */ 111 public Map<String, Set<String>> getNoTileChecksums() { 112 return noTileChecksums; 113 } 114 115 /** 116 * Request supported minimum zoom level 117 * @return minimum zoom level supported by tile source 118 */ 119 public int getMinZoom() { 120 return minZoom; 121 } 122 123 /** 124 * Request supported maximum zoom level 125 * @return maximum zoom level supported by tile source 126 */ 127 public int getMaxZoom() { 128 return maxZoom; 129 } 130 131 /** 132 * Request cookies to be sent together with request 133 * @return cookies to be sent along with request to tile source 134 */ 135 public String getCookies() { 136 return cookies; 137 } 138 139 /** 140 * Request tile size of this tile source 141 * @return tile size provided by this tile source, or -1 when default value should be used 142 */ 143 public int getTileSize() { 144 return tileSize; 145 } 146 147 /** 148 * Request metadata headers 149 * @return mapping <HTTP header name, Metadata key name> for copying HTTP headers to Tile metadata 150 * @since 31125 151 */ 152 public Map<String, String> getMetadataHeaders() { 153 return metadataHeaders; 154 } 155 156 /** 157 * Sets the tile size provided by this tile source 158 * @param tileSize tile size in pixels 159 */ 160 public final void setTileSize(int tileSize) { 161 if (tileSize == 0 || tileSize < -1) { 162 throw new AssertionError("Invalid tile size: " + tileSize); 163 } 164 this.tileSize = tileSize; 165 } 166 167 /** 168 * Sets the tile URL. 169 * @param url tile URL 170 */ 171 public final void setUrl(String url) { 172 this.url = url; 173 } 174 175 /** 176 * Sets the tile name. 177 * @param name tile name 178 */ 179 public final void setName(String name) { 180 this.name = name; 181 } 182 183 /** 184 * Sets the tile id. 185 * @param id tile id 186 */ 187 public final void setId(String id) { 188 this.id = id; 189 } 190}