Revision 80 org.gvsig.raster.osm/branches/org.gvsig.raster.osm_dataaccess_refactoring/org.gvsig.raster.osm.io/src/main/java/org/gvsig/raster/osm/downloader/TileDownloaderForOSM.java
TileDownloaderForOSM.java | ||
---|---|---|
28 | 28 |
import java.io.FileOutputStream; |
29 | 29 |
import java.net.HttpURLConnection; |
30 | 30 |
import java.net.MalformedURLException; |
31 |
import java.net.URI; |
|
32 |
import java.net.URISyntaxException; |
|
31 | 33 |
import java.net.URL; |
32 | 34 |
|
33 | 35 |
import org.gvsig.compat.net.ICancellable; |
... | ... | |
44 | 46 |
public class TileDownloaderForOSM extends BaseTileDownloader { |
45 | 47 |
private String server = null; |
46 | 48 |
private String suffix = null; |
49 |
private String slash = "/"; |
|
47 | 50 |
|
48 | 51 |
public TileDownloaderForOSM(RasterDataStore store, |
49 | 52 |
int tileSize) { |
... | ... | |
56 | 59 |
int level = tile.getLevel(); |
57 | 60 |
int y = tile.getRow(); |
58 | 61 |
int x = tile.getCol(); |
59 |
String url = server + |
|
60 |
(server.endsWith(File.separator) ? "" : File.separator) + |
|
61 |
level + File.separator + |
|
62 |
x + File.separator + |
|
63 |
y + "." + suffix; |
|
64 | 62 |
try { |
65 |
//System.out.println("====>>>>" + url); |
|
66 |
downloadFile(new URL(url), tile.getFile(), tile.getCancelled()); |
|
63 |
URI uri = new URI( |
|
64 |
server + |
|
65 |
(server.endsWith(slash) ? "" : slash) + |
|
66 |
level + slash + |
|
67 |
x + slash + |
|
68 |
y + "." + suffix); |
|
69 |
|
|
70 |
downloadFile(uri.toURL(), tile.getFile(), tile.getCancelled()); |
|
67 | 71 |
} catch (MalformedURLException e) { |
68 | 72 |
throw new TileGettingException(e); |
73 |
} catch (URISyntaxException e) { |
|
74 |
throw new TileGettingException(e); |
|
69 | 75 |
} |
70 | 76 |
readTileFromDisk(tile); |
71 | 77 |
return tile; |
Also available in: Unified diff