Revision 15076
import/ext3D/trunk/ext3D/src/com/iver/ai2/gvsig3d/cacheservices/FLayerCacheService.java | ||
---|---|---|
13 | 13 |
import java.util.Vector; |
14 | 14 |
|
15 | 15 |
import org.cresques.cts.IProjection; |
16 |
// import org.cresques.io.data.Grid; RASTER_GRID |
|
17 |
// import org.cresques.io.data.RasterBuf; RASTER_GRID |
|
16 | 18 |
import org.cresques.px.Extent; |
17 | 19 |
import org.gvsig.cacheservice.CacheService; |
18 | 20 |
import org.gvsig.cacheservice.CacheServiceException; |
... | ... | |
28 | 30 |
import com.iver.cit.gvsig.fmap.drivers.wms.FMapWMSDriver; |
29 | 31 |
import com.iver.cit.gvsig.fmap.drivers.wms.FMapWMSDriverFactory; |
30 | 32 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
31 |
import com.iver.cit.gvsig.fmap.layers.FLyrDefault;
|
|
33 |
import com.iver.cit.gvsig.fmap.layers.FLyrRaster;
|
|
32 | 34 |
import com.iver.cit.gvsig.fmap.layers.FLyrWMS; |
33 | 35 |
import com.iver.utiles.FileUtils; |
34 | 36 |
import com.iver.utiles.swing.threads.Cancellable; |
... | ... | |
136 | 138 |
} |
137 | 139 |
return image; |
138 | 140 |
} |
139 |
else { // TEST |
|
140 |
try { |
|
141 |
FLyrWMS wmsLayer = (FLyrWMS)_layer; |
|
142 |
if (_wmsDriver == null) { |
|
143 |
|
|
144 |
URL host = wmsLayer.getHost(); |
|
145 |
_wmsDriver = FMapWMSDriverFactory.getFMapDriverForURL(host); |
|
141 |
else { // Elevation data |
|
142 |
/* RASTER_GRID |
|
143 |
if (_layer instanceof FLyrRaster) { |
|
144 |
FLyrRaster rasterLayer = (FLyrRaster)_layer; |
|
145 |
|
|
146 |
Grid grid = rasterLayer.getSource().getGrid(); |
|
147 |
// TODO |
|
148 |
// GeoRaster grf = GeoRasterFile.openFile(proyecc, ruta_al_fichero); //Abre el |
|
149 |
// dataset del fichero. |
|
150 |
// Grid grid = new Grid(grf); //Crea el grid. Si quieres a?adir m?s ficheros |
|
151 |
// con el mismo extent tiene un m?todo addfile |
|
152 |
|
|
153 |
grid.clearDrawableBand(); |
|
154 |
int bands[] = {0}; |
|
155 |
grid.addDrawableBands(bands); |
|
156 |
|
|
157 |
grid.setAreaOfInterest(tileExtent.getMinX(), tileExtent.getMinY(), |
|
158 |
tileExtent.getWidth(), tileExtent.getHeight()); |
|
159 |
//grid.setAreaOfInterest(0, 0, 32, 32); //Asigna el ?rea a recuperar |
|
160 |
RasterBuf raster = grid.getRasterBuf(); |
|
161 |
try { |
|
162 |
raster.save(fName, new Extent(tileExtent)); |
|
163 |
} catch (Exception e) { |
|
164 |
return null; |
|
146 | 165 |
} |
147 |
if (_wmsStatus == null) { |
|
148 |
_wmsStatus = new WMSStatus(); |
|
149 |
_wmsStatus.setFormat(wmsLayer.getFormat()); |
|
150 |
_wmsStatus.setHeight(32); |
|
151 |
_wmsStatus.setWidth(32); |
|
152 |
_wmsStatus.setLayerNames(Utilities.createVector(wmsLayer.getLayerQuery(),",")); |
|
153 |
_wmsStatus.setSrs(wmsLayer.getSRS()); |
|
154 |
|
|
155 |
HashMap props = wmsLayer.getProperties(); |
|
156 |
Vector styles; |
|
157 |
Vector dimensions; |
|
158 |
styles = (Vector)(props.get("styles")); |
|
159 |
dimensions = (Vector)(props.get("dimensions")); |
|
160 |
_wmsStatus.setStyles(styles); |
|
161 |
_wmsStatus.setDimensions(dimensions); |
|
162 |
_wmsStatus.setTransparency(false); |
|
163 |
String getMapStr = wmsLayer.getOnlineResource("GetMap"); |
|
164 |
_wmsStatus.setOnlineResource(getMapStr); |
|
166 |
} |
|
167 |
else*/ |
|
168 |
if (_layer instanceof FLyrWMS) { |
|
169 |
try { // for WMS layers |
|
170 |
FLyrWMS wmsLayer = (FLyrWMS)_layer; |
|
171 |
if (_wmsDriver == null) { |
|
172 |
|
|
173 |
URL host = wmsLayer.getHost(); |
|
174 |
_wmsDriver = FMapWMSDriverFactory.getFMapDriverForURL(host); |
|
175 |
} |
|
176 |
if (_wmsStatus == null) { |
|
177 |
_wmsStatus = new WMSStatus(); |
|
178 |
_wmsStatus.setFormat(wmsLayer.getFormat()); |
|
179 |
_wmsStatus.setHeight(32); |
|
180 |
_wmsStatus.setWidth(32); |
|
181 |
_wmsStatus.setLayerNames(Utilities.createVector(wmsLayer.getLayerQuery(),",")); |
|
182 |
_wmsStatus.setSrs(wmsLayer.getSRS()); |
|
183 |
|
|
184 |
HashMap props = wmsLayer.getProperties(); |
|
185 |
Vector styles; |
|
186 |
Vector dimensions; |
|
187 |
styles = (Vector)(props.get("styles")); |
|
188 |
dimensions = (Vector)(props.get("dimensions")); |
|
189 |
_wmsStatus.setStyles(styles); |
|
190 |
_wmsStatus.setDimensions(dimensions); |
|
191 |
_wmsStatus.setTransparency(false); |
|
192 |
String getMapStr = wmsLayer.getOnlineResource("GetMap"); |
|
193 |
_wmsStatus.setOnlineResource(getMapStr); |
|
194 |
} |
|
195 |
_wmsStatus.setExtent(tileExtent); |
|
196 |
|
|
197 |
File f = _wmsDriver.getMap(_wmsStatus, new MyCancel()); |
|
198 |
if (f == null) |
|
199 |
return null; |
|
200 |
FileUtils.copy(f, new File(fName)); |
|
201 |
|
|
202 |
String fileName = f.getPath(); |
|
203 |
System.out.println(fileName); |
|
204 |
|
|
205 |
} catch (Exception e) { |
|
206 |
return null; |
|
165 | 207 |
} |
166 |
_wmsStatus.setExtent(tileExtent); |
|
167 |
|
|
168 |
File f = _wmsDriver.getMap(_wmsStatus, new MyCancel()); |
|
169 |
if (f == null) |
|
170 |
return null; |
|
171 |
FileUtils.copy(f, new File(fName)); |
|
172 |
|
|
173 |
String fileName = f.getPath(); |
|
174 |
System.out.println(fileName); |
|
175 |
|
|
176 |
} catch (Exception e) { |
|
177 |
return null; |
|
178 | 208 |
} |
179 | 209 |
return null; // no image |
180 | 210 |
} |
Also available in: Unified diff