gvsig-raster / org.gvsig.raster.wmts / trunk / org.gvsig.raster.wmts / org.gvsig.raster.wmts.io / src / main / java / org / gvsig / raster / wmts / io / downloader / TileDownloaderForWMTS.java @ 393
History | View | Annotate | Download (2.69 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.raster.wmts.io.downloader; |
23 |
|
24 |
import java.io.File; |
25 |
|
26 |
import org.gvsig.raster.wmts.io.WMTSConnector; |
27 |
import org.gvsig.raster.wmts.io.WMTSProvider; |
28 |
import org.gvsig.raster.cache.tile.Tile; |
29 |
import org.gvsig.raster.cache.tile.exception.TileGettingException; |
30 |
import org.gvsig.remoteclient.exceptions.ServerErrorException; |
31 |
import org.gvsig.remoteclient.wmts.WMTSStatus; |
32 |
import org.gvsig.remoteclient.wmts.exception.WMTSException; |
33 |
import org.gvsig.fmap.dal.coverage.dataset.io.tile.downloader.BaseTileDownloader; |
34 |
|
35 |
/**
|
36 |
* Tile getter
|
37 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
38 |
*/
|
39 |
public class TileDownloaderForWMTS extends BaseTileDownloader { |
40 |
private WMTSConnector connector = null; |
41 |
|
42 |
public TileDownloaderForWMTS(WMTSProvider prov,
|
43 |
int tilePxWidth,
|
44 |
int tilePxHeight,
|
45 |
WMTSConnector connector) { |
46 |
super(prov, tilePxWidth, tilePxHeight);
|
47 |
this.connector = connector;
|
48 |
} |
49 |
|
50 |
/*
|
51 |
* (non-Javadoc)
|
52 |
* @see org.gvsig.raster.cache.tile.provider.Downloader#getTile(org.gvsig.raster.cache.tile.Tile)
|
53 |
*/
|
54 |
public synchronized Tile downloadTile(Tile tile) throws TileGettingException { |
55 |
try {
|
56 |
WMTSStatus status = (WMTSStatus)tile.getDownloaderParams("WMTSStatus");
|
57 |
status.setTileRow(tile.getRow()); |
58 |
status.setTileCol(tile.getCol()); |
59 |
File f = connector.getTile(status, null, tile.getFile()); |
60 |
tile.setFile(f); |
61 |
//Si borramos el rmf no se puede leer la etiqueta Alpha. En caso de que se modifique jgdal para
|
62 |
//poder guardar esta etiqueta deberiamos borrar el rmf para ahorrar ficheros
|
63 |
//File rmf = new File(tile.getFile().getAbsolutePath() + ".rmf");
|
64 |
//if(rmf.exists())
|
65 |
//rmf.delete();
|
66 |
} catch (WMTSException e) {
|
67 |
throw new TileGettingException(e); |
68 |
} catch (ServerErrorException e) {
|
69 |
throw new TileGettingException(e); |
70 |
} |
71 |
readTileFromDisk(tile); |
72 |
return tile;
|
73 |
} |
74 |
|
75 |
} |