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 / WMTSTileServer.java @ 871
History | View | Annotate | Download (3.26 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 org.gvsig.raster.cache.tile.provider.CacheStruct; |
25 |
import org.gvsig.raster.cache.tile.provider.Downloader; |
26 |
import org.gvsig.raster.cache.tile.provider.TileServer; |
27 |
import org.gvsig.raster.wmts.io.WMTSProvider; |
28 |
import org.gvsig.remoteclient.wmts.exception.WMTSException; |
29 |
import org.gvsig.remoteclient.wmts.struct.WMTSTileMatrix; |
30 |
import org.gvsig.remoteclient.wmts.struct.WMTSTileMatrixSetLink; |
31 |
|
32 |
/**
|
33 |
* Data server for the tile cache in a WMTSProvider
|
34 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
35 |
*/
|
36 |
public class WMTSTileServer implements TileServer { |
37 |
private CacheStruct struct = null; |
38 |
private Downloader downloader = null; |
39 |
private WMTSProvider provider = null; |
40 |
private String suffix = ".tif"; |
41 |
private WMTSTileMatrixSetLink tileMatrixSetLink = null; |
42 |
|
43 |
public WMTSTileServer(WMTSProvider prov,
|
44 |
WMTSTileMatrixSetLink tileMatrixSetLink) { |
45 |
this.provider = prov;
|
46 |
this.tileMatrixSetLink = tileMatrixSetLink;
|
47 |
} |
48 |
|
49 |
/*
|
50 |
* (non-Javadoc)
|
51 |
* @see org.gvsig.raster.cache.tile.provider.TileServer#getDownloader()
|
52 |
*/
|
53 |
public Downloader getDownloader() {
|
54 |
if(downloader == null) { |
55 |
int tileWidth = ((WMTSTileMatrix)tileMatrixSetLink.getTileMatrixSet().getTileMatrix().get(0)).getTileWidth(); |
56 |
int tileHeight = ((WMTSTileMatrix)tileMatrixSetLink.getTileMatrixSet().getTileMatrix().get(0)).getTileHeight(); |
57 |
try {
|
58 |
downloader = new TileDownloaderForWMTS(provider, tileWidth, tileHeight, provider.getConnector());
|
59 |
} catch (WMTSException e) {
|
60 |
return null; |
61 |
} |
62 |
} |
63 |
return downloader;
|
64 |
} |
65 |
|
66 |
public CacheStruct getStruct() {
|
67 |
if(struct == null) { |
68 |
struct = new WMTSCacheStruct(provider, tileMatrixSetLink);
|
69 |
} |
70 |
return struct;
|
71 |
} |
72 |
|
73 |
/*
|
74 |
* (non-Javadoc)
|
75 |
* @see org.gvsig.raster.cache.tile.provider.TileServer#setStruct(org.gvsig.raster.cache.tile.provider.CacheStruct)
|
76 |
*/
|
77 |
public void setStruct(CacheStruct struct) { |
78 |
//La structura de cache es proporcionada por el servidor
|
79 |
} |
80 |
|
81 |
/*
|
82 |
* (non-Javadoc)
|
83 |
* @see org.gvsig.raster.cache.tile.provider.TileServer#getFileSuffix()
|
84 |
*/
|
85 |
public String getFileSuffix() { |
86 |
return suffix;
|
87 |
} |
88 |
|
89 |
/*
|
90 |
* (non-Javadoc)
|
91 |
* @see org.gvsig.raster.cache.tile.provider.TileServer#setFileExtension(java.lang.String)
|
92 |
*/
|
93 |
public void setFileSuffix(String extension) { |
94 |
this.suffix = extension;
|
95 |
} |
96 |
} |