1 | // License: GPL. For details, see Readme.txt file.
|
---|
2 | package org.openstreetmap.gui.jmapviewer.tilesources;
|
---|
3 |
|
---|
4 | import java.util.Map;
|
---|
5 | import java.util.Set;
|
---|
6 |
|
---|
7 | /**
|
---|
8 | * Data class that keeps basic information about a tile source.
|
---|
9 | *
|
---|
10 | * @since 31122
|
---|
11 | */
|
---|
12 | public class TileSourceInfo {
|
---|
13 | /** id for this imagery entry, optional at the moment */
|
---|
14 | protected String id;
|
---|
15 |
|
---|
16 | /** URL of the imagery service */
|
---|
17 | protected String url;
|
---|
18 |
|
---|
19 | /** name of the imagery layer */
|
---|
20 | protected String name;
|
---|
21 |
|
---|
22 | /** headers meaning, that there is no tile at this zoom level */
|
---|
23 | protected Map<String, Set<String>> noTileHeaders;
|
---|
24 |
|
---|
25 | /** checksum of empty tiles */
|
---|
26 | protected Map<String, Set<String>> noTileChecksums;
|
---|
27 |
|
---|
28 | /** minimum zoom level supported by the tile source */
|
---|
29 | protected int minZoom;
|
---|
30 |
|
---|
31 | /** maximum zoom level supported by the tile source */
|
---|
32 | protected int maxZoom;
|
---|
33 |
|
---|
34 | /** cookies that needs to be sent to tile source */
|
---|
35 | protected String cookies = "";
|
---|
36 |
|
---|
37 | /** tile size of the displayed tiles */
|
---|
38 | private int tileSize = -1;
|
---|
39 |
|
---|
40 | /** mapping <header key, metadata key> */
|
---|
41 | protected Map<String, String> metadataHeaders;
|
---|
42 |
|
---|
43 | /** supports "/dirty" mode (tile re-rendering) */
|
---|
44 | protected boolean dirtyMode;
|
---|
45 |
|
---|
46 | /**
|
---|
47 | * Create a TileSourceInfo class
|
---|
48 | *
|
---|
49 | * @param name name
|
---|
50 | * @param baseUrl base URL
|
---|
51 | * @param id unique id
|
---|
52 | */
|
---|
53 | public TileSourceInfo(String name, String baseUrl, String id) {
|
---|
54 | this.name = name;
|
---|
55 | this.url = baseUrl;
|
---|
56 | this.id = id;
|
---|
57 | }
|
---|
58 |
|
---|
59 | /**
|
---|
60 | * Create a TileSourceInfo class
|
---|
61 | *
|
---|
62 | * @param name name
|
---|
63 | */
|
---|
64 | public TileSourceInfo(String name) {
|
---|
65 | this(name, null, null);
|
---|
66 | }
|
---|
67 |
|
---|
68 | /**
|
---|
69 | * Creates empty TileSourceInfo class
|
---|
70 | */
|
---|
71 | public TileSourceInfo() {
|
---|
72 | this(null, null, null);
|
---|
73 | }
|
---|
74 |
|
---|
75 | /**
|
---|
76 | * Request name of the tile source
|
---|
77 | * @return name of the tile source
|
---|
78 | */
|
---|
79 | public final String getName() {
|
---|
80 | return name;
|
---|
81 | }
|
---|
82 |
|
---|
83 | /**
|
---|
84 | * Request URL of the tile source
|
---|
85 | * @return url of the tile source
|
---|
86 | */
|
---|
87 | public final String getUrl() {
|
---|
88 | return url;
|
---|
89 | }
|
---|
90 |
|
---|
91 | /**
|
---|
92 | * Request ID of the tile source. Id can be null. This gets the configured id as is.
|
---|
93 | * Due to a user error, this may not be unique.
|
---|
94 | * @return id of the tile source
|
---|
95 | */
|
---|
96 | public final String getId() {
|
---|
97 | return id;
|
---|
98 | }
|
---|
99 |
|
---|
100 | /**
|
---|
101 | * Request header information for empty tiles for servers delivering such tile types
|
---|
102 | * @return map of headers, that when set, means that this is "no tile at this zoom level" situation
|
---|
103 | * @since 32022
|
---|
104 | */
|
---|
105 | public Map<String, Set<String>> getNoTileHeaders() {
|
---|
106 | return noTileHeaders;
|
---|
107 | }
|
---|
108 |
|
---|
109 | /**
|
---|
110 | * Checkusm for empty tiles for servers delivering such tile types
|
---|
111 | * @return map of checksums, that when detected, means that this is "no tile at this zoom level" situation
|
---|
112 | * @since 32022
|
---|
113 | */
|
---|
114 | public Map<String, Set<String>> getNoTileChecksums() {
|
---|
115 | return noTileChecksums;
|
---|
116 | }
|
---|
117 |
|
---|
118 | /**
|
---|
119 | * Request supported minimum zoom level
|
---|
120 | * @return minimum zoom level supported by tile source
|
---|
121 | */
|
---|
122 | public int getMinZoom() {
|
---|
123 | return minZoom;
|
---|
124 | }
|
---|
125 |
|
---|
126 | /**
|
---|
127 | * Request supported maximum zoom level
|
---|
128 | * @return maximum zoom level supported by tile source
|
---|
129 | */
|
---|
130 | public int getMaxZoom() {
|
---|
131 | return maxZoom;
|
---|
132 | }
|
---|
133 |
|
---|
134 | /**
|
---|
135 | * Request cookies to be sent together with request
|
---|
136 | * @return cookies to be sent along with request to tile source
|
---|
137 | */
|
---|
138 | public String getCookies() {
|
---|
139 | return cookies;
|
---|
140 | }
|
---|
141 |
|
---|
142 | /**
|
---|
143 | * Request tile size of this tile source
|
---|
144 | * @return tile size provided by this tile source, or -1 when default value should be used
|
---|
145 | */
|
---|
146 | public int getTileSize() {
|
---|
147 | return tileSize;
|
---|
148 | }
|
---|
149 |
|
---|
150 | /**
|
---|
151 | * Request metadata headers
|
---|
152 | * @return mapping <HTTP header name, Metadata key name> for copying HTTP headers to Tile metadata
|
---|
153 | * @since 31125
|
---|
154 | */
|
---|
155 | public Map<String, String> getMetadataHeaders() {
|
---|
156 | return metadataHeaders;
|
---|
157 | }
|
---|
158 |
|
---|
159 | /**
|
---|
160 | * Sets the tile size provided by this tile source
|
---|
161 | * @param tileSize tile size in pixels
|
---|
162 | */
|
---|
163 | public final void setTileSize(int tileSize) {
|
---|
164 | if (tileSize == 0 || tileSize < -1) {
|
---|
165 | throw new AssertionError("Invalid tile size: " + tileSize);
|
---|
166 | }
|
---|
167 | this.tileSize = tileSize;
|
---|
168 | }
|
---|
169 |
|
---|
170 | /**
|
---|
171 | * Sets the tile URL.
|
---|
172 | * @param url tile URL
|
---|
173 | */
|
---|
174 | public final void setUrl(String url) {
|
---|
175 | this.url = url;
|
---|
176 | }
|
---|
177 |
|
---|
178 | /**
|
---|
179 | * Sets the tile name.
|
---|
180 | * @param name tile name
|
---|
181 | */
|
---|
182 | public final void setName(String name) {
|
---|
183 | this.name = name;
|
---|
184 | }
|
---|
185 |
|
---|
186 | /**
|
---|
187 | * Sets the tile id.
|
---|
188 | * @param id tile id
|
---|
189 | */
|
---|
190 | public final void setId(String id) {
|
---|
191 | this.id = id;
|
---|
192 | }
|
---|
193 |
|
---|
194 | /**
|
---|
195 | * Determines if this imagery supports "/dirty" mode (tile re-rendering).
|
---|
196 | * @return <code>true</code> if it supports "/dirty" mode (tile re-rendering)
|
---|
197 | */
|
---|
198 | public final boolean isDirtyMode() {
|
---|
199 | return dirtyMode;
|
---|
200 | }
|
---|
201 |
|
---|
202 | /**
|
---|
203 | * Sets whether this imagery supports "/dirty" mode (tile re-rendering).
|
---|
204 | * @param dirtyMode <code>true</code> if it supports "/dirty" mode (tile re-rendering)
|
---|
205 | */
|
---|
206 | public final void setDirtyMode(boolean dirtyMode) {
|
---|
207 | this.dirtyMode = dirtyMode;
|
---|
208 | }
|
---|
209 | }
|
---|