gvsig-raster / org.gvsig.raster.wms / trunk / org.gvsig.raster.wms / org.gvsig.raster.wms.io / src / main / java / org / gvsig / raster / wms / io / downloader / TileDownloaderForWMS.java @ 990
History | View | Annotate | Download (3.36 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.wms.io.downloader; |
23 |
|
24 |
import java.awt.geom.Rectangle2D; |
25 |
|
26 |
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException; |
27 |
import org.gvsig.raster.cache.tile.Tile; |
28 |
import org.gvsig.raster.cache.tile.exception.TileGettingException; |
29 |
import org.gvsig.raster.impl.provider.tile.BaseTileDownloader; |
30 |
import org.gvsig.raster.wms.io.WMSConnector; |
31 |
import org.gvsig.raster.wms.io.WMSDataParameters; |
32 |
import org.gvsig.raster.wms.io.WMSProvider; |
33 |
import org.gvsig.remoteclient.utils.Utilities; |
34 |
import org.gvsig.remoteclient.wms.WMSStatus; |
35 |
|
36 |
/**
|
37 |
* Tile getter
|
38 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
39 |
*/
|
40 |
public class TileDownloaderForWMS extends BaseTileDownloader { |
41 |
private WMSConnector connector = null; |
42 |
|
43 |
public TileDownloaderForWMS(WMSProvider prov,
|
44 |
int tilePxWidth,
|
45 |
int tilePxHeight,
|
46 |
WMSConnector connector) { |
47 |
super(prov, tilePxWidth, tilePxHeight);
|
48 |
this.connector = connector;
|
49 |
} |
50 |
|
51 |
/*
|
52 |
* (non-Javadoc)
|
53 |
* @see org.gvsig.raster.cache.tile.provider.Downloader#getTile(org.gvsig.raster.cache.tile.Tile)
|
54 |
*/
|
55 |
public synchronized Tile downloadTile(Tile tile) throws TileGettingException { |
56 |
try {
|
57 |
Rectangle2D r = new Rectangle2D.Double(tile.getExtent().getMinX(), |
58 |
tile.getExtent().getMinY() - tile.getExtent().getHeight(), |
59 |
tile.getExtent().getWidth(), |
60 |
tile.getExtent().getHeight()); |
61 |
WMSDataParameters p = ((WMSProvider)prov).getParameters(); |
62 |
WMSStatus wmsStatus = new WMSStatus();
|
63 |
wmsStatus.setLayerNames(Utilities.createVector(p.getLayerQuery(), ",")); |
64 |
wmsStatus.setSrs(p.getSRSCode()); |
65 |
wmsStatus.setFormat(p.getFormat()); |
66 |
wmsStatus.setStyles(p.getStyles()); |
67 |
wmsStatus.setDimensions(p.getDimensions()); |
68 |
wmsStatus.setTransparency(p.isWmsTransparent()); |
69 |
wmsStatus.setOnlineResource((String) p.getOnlineResource().get("GetMap")); |
70 |
/*if(p.isSizeFixed()) {
|
71 |
wmsStatus.setExtent(getExtent().toRectangle2D());
|
72 |
} else*/
|
73 |
wmsStatus.setExtent(r); |
74 |
wmsStatus.setHeight(tile.getHeightPx()); |
75 |
wmsStatus.setWidth(tile.getWidthPx()); |
76 |
|
77 |
connector.getMap(wmsStatus, tile.getCancelled(), tile.getFile()); |
78 |
//Si borramos el rmf no se puede leer la etiqueta Alpha. En caso de que se modifique jgdal para
|
79 |
//poder guardar esta etiqueta deberiamos borrar el rmf para ahorrar ficheros
|
80 |
//File rmf = new File(tile.getFile().getAbsolutePath() + ".rmf");
|
81 |
//if(rmf.exists())
|
82 |
//rmf.delete();
|
83 |
} catch (RemoteServiceException e) {
|
84 |
throw new TileGettingException(e); |
85 |
} |
86 |
readTileFromDisk(tile); |
87 |
return tile;
|
88 |
} |
89 |
|
90 |
} |