root / trunk / extensions / extWCS / src / com / iver / cit / gvsig / fmap / layers / FLyrWCS.java @ 17875
History | View | Annotate | Download (35.4 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package com.iver.cit.gvsig.fmap.layers; |
42 |
|
43 |
import java.awt.Dimension; |
44 |
import java.awt.Graphics2D; |
45 |
import java.awt.Point; |
46 |
import java.awt.Rectangle; |
47 |
import java.awt.geom.AffineTransform; |
48 |
import java.awt.geom.NoninvertibleTransformException; |
49 |
import java.awt.geom.Point2D; |
50 |
import java.awt.geom.Rectangle2D; |
51 |
import java.awt.image.BufferedImage; |
52 |
import java.awt.image.DataBuffer; |
53 |
import java.io.File; |
54 |
import java.io.IOException; |
55 |
import java.lang.reflect.Constructor; |
56 |
import java.lang.reflect.InvocationTargetException; |
57 |
import java.net.MalformedURLException; |
58 |
import java.net.URL; |
59 |
import java.util.ArrayList; |
60 |
import java.util.Hashtable; |
61 |
import java.util.Iterator; |
62 |
import java.util.Map; |
63 |
|
64 |
import javax.print.attribute.PrintRequestAttributeSet; |
65 |
|
66 |
import org.exolab.castor.xml.ValidationException; |
67 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
68 |
import org.gvsig.fmap.raster.layers.IRasterLayerActions; |
69 |
import org.gvsig.fmap.raster.layers.IStatusRaster; |
70 |
import org.gvsig.fmap.raster.layers.StatusLayerRaster; |
71 |
import org.gvsig.raster.dataset.CompositeDataset; |
72 |
import org.gvsig.raster.dataset.IBuffer; |
73 |
import org.gvsig.raster.dataset.MosaicNotValidException; |
74 |
import org.gvsig.raster.dataset.MultiRasterDataset; |
75 |
import org.gvsig.raster.dataset.NotSupportedExtensionException; |
76 |
import org.gvsig.raster.dataset.io.RasterDriverException; |
77 |
import org.gvsig.raster.datastruct.ColorTable; |
78 |
import org.gvsig.raster.datastruct.Extent; |
79 |
import org.gvsig.raster.datastruct.ViewPortData; |
80 |
import org.gvsig.raster.grid.GridTransparency; |
81 |
import org.gvsig.raster.grid.filter.FilterTypeException; |
82 |
import org.gvsig.raster.grid.filter.RasterFilterList; |
83 |
import org.gvsig.raster.grid.filter.RasterFilterListManager; |
84 |
import org.gvsig.raster.grid.filter.enhancement.LinearEnhancementFilter; |
85 |
import org.gvsig.raster.grid.filter.statistics.TailTrimFilter; |
86 |
import org.gvsig.remoteClient.wcs.WCSStatus; |
87 |
import org.gvsig.remoteClient.wms.ICancellable; |
88 |
|
89 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
90 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
91 |
import com.iver.cit.gvsig.exceptions.layers.ConnectionErrorLayerException; |
92 |
import com.iver.cit.gvsig.exceptions.layers.LoadLayerException; |
93 |
import com.iver.cit.gvsig.exceptions.layers.UnsupportedVersionLayerException; |
94 |
import com.iver.cit.gvsig.fmap.ViewPort; |
95 |
import com.iver.cit.gvsig.fmap.crs.CRSFactory; |
96 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
97 |
import com.iver.cit.gvsig.fmap.drivers.wcs.FMapWCSDriver; |
98 |
import com.iver.cit.gvsig.fmap.drivers.wcs.FMapWCSDriverFactory; |
99 |
import com.iver.cit.gvsig.fmap.drivers.wcs.WCSDriverException; |
100 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.XMLItem; |
101 |
import com.iver.utiles.StringUtilities; |
102 |
import com.iver.utiles.XMLEntity; |
103 |
import com.iver.utiles.swing.threads.Cancellable; |
104 |
|
105 |
|
106 |
/**
|
107 |
* Class for the WCS layer.
|
108 |
*
|
109 |
* Capa para el WCS.
|
110 |
*
|
111 |
* Las capas WCS son tileadas para descargarlas del servidor. Esto quiere decir que
|
112 |
* est?n formadas por multiples ficheros raster. Por esto la fuente de datos raster (IRasterDatasource)
|
113 |
* de la capa FLyrWCS es un objeto de tipo CompositeDataset. Este objeto est? compuesto por un array
|
114 |
* bidimensional de MultiRasterDataset. Cada uno de los MultiRasterDataset corresponde con un tile
|
115 |
* salvado en disco. Estos MultiRasterDataset se crean cada vez que se repinta ya que en WCS a cada
|
116 |
* zoom varian los ficheros fuente. La secuencia de creaci?n de un CompositeDataset ser?a la siguiente:
|
117 |
* <UL>
|
118 |
* <LI>Se hace una petici?n de dibujado por parte del usuario llamando al m?todo draw de FLyrWCS</LI>
|
119 |
* <LI>Se tilea la petici?n</LI>
|
120 |
* <LI>Cada tile se dibuja abriendo una FLyrRaster para ese tile</LI>
|
121 |
* <LI>Si es el primer dibujado se guarda una referencia en la capa WMS a las propiedades de renderizado, orden de bandas,
|
122 |
* transparencia, filtros aplicados, ...</LI>
|
123 |
* <LI>Si no es el primer dibujado se asignan las propiedades de renderizado cuya referencia se guarda en la capa WMS</LI>
|
124 |
* <LI>Se guarda el MultiRasterDataset de cada tile</LI>
|
125 |
* <LI>Al acabar todos los tiles creamos un CompositeDataset con los MultiRasterDataset de todos los tiles</LI>
|
126 |
* <LI>Asignamos a la capa la referencia de las propiedades de renderizado que tenemos almacenadas. De esta forma si hay
|
127 |
* alguna modificaci?n desde el cuadro de propiedades ser? efectiva sobre los tiles que se dibujan.</LI>
|
128 |
* </UL>
|
129 |
*
|
130 |
* @author jaume - jaume.dominguez@iver.es
|
131 |
*/
|
132 |
public class FLyrWCS extends FLyrRasterSE { |
133 |
private FMapWCSDriver wcs = null; |
134 |
|
135 |
private URL host; |
136 |
private String coverageName; |
137 |
private Rectangle2D fullExtent; |
138 |
private String format; |
139 |
private String srs; |
140 |
private String time; |
141 |
private String parameter; |
142 |
private Point2D maxRes; |
143 |
private Hashtable onlineResources = new Hashtable(); |
144 |
|
145 |
private WCSStatus wcsStatus = new WCSStatus(); |
146 |
|
147 |
private int posX = 0, posY = 0; |
148 |
private double posXWC = 0, posYWC = 0; |
149 |
private int r = 0, g = 0, b = 0; |
150 |
private boolean firstLoad = false; |
151 |
private VisualStatus visualStatus = new VisualStatus(); |
152 |
|
153 |
private boolean mustTileDraw = false; |
154 |
private int maxTileDrawWidth = 1023; |
155 |
private int maxTileDrawHeight = 1023; |
156 |
//private int maxTilePrintWidth = 250;
|
157 |
//private int maxTilePrintHeight = 250;
|
158 |
/**
|
159 |
* Lista de filtros aplicada en la renderizaci?n
|
160 |
*/
|
161 |
private RasterFilterList filterList = null; |
162 |
private GridTransparency transparency = null; |
163 |
private int[] renderBands = null; |
164 |
private FLyrRasterSE layerRaster = null; |
165 |
private ArrayList filterArguments = null; |
166 |
|
167 |
private class MyCancellable implements ICancellable |
168 |
{ |
169 |
|
170 |
private Cancellable original;
|
171 |
public MyCancellable(Cancellable cancelOriginal)
|
172 |
{ |
173 |
this.original = cancelOriginal;
|
174 |
} |
175 |
public boolean isCanceled() { |
176 |
return original.isCanceled();
|
177 |
} |
178 |
public Object getID() { |
179 |
return this; |
180 |
} |
181 |
|
182 |
} |
183 |
|
184 |
public FLyrWCS(){
|
185 |
super();
|
186 |
} |
187 |
|
188 |
public FLyrWCS(Map args) throws DriverIOException{ |
189 |
FMapWCSDriver drv = null;
|
190 |
String host = (String)args.get("HOST"); |
191 |
String sCoverage = (String) args.get((String) "COVERAGE"); |
192 |
|
193 |
try {
|
194 |
this.setHost(new URL(host)); |
195 |
} catch (MalformedURLException e) { |
196 |
//e.printStackTrace();
|
197 |
throw new DriverIOException("Malformed host URL, '" + host + "' (" + e.toString() + ")."); |
198 |
} |
199 |
try {
|
200 |
drv = this.getDriver();
|
201 |
} catch (Exception e) { |
202 |
// e.printStackTrace();
|
203 |
throw new DriverIOException("Can't get driver to host '" + host + "' (" + e.toString() + ")."); |
204 |
} |
205 |
|
206 |
try{
|
207 |
if (!drv.connect(false, null)){ |
208 |
throw new DriverIOException("Can't connect to host '" + host + "'."); |
209 |
} |
210 |
}catch(Exception e){ |
211 |
throw new DriverIOException("Can't connect to host '" + host + "'."); |
212 |
} |
213 |
|
214 |
WCSLayer wcsNode = drv.getLayer(sCoverage); |
215 |
|
216 |
if (wcsNode == null){ |
217 |
throw new DriverIOException("The server '" + host + "' doesn't has the coverage '" + sCoverage + "'."); |
218 |
} |
219 |
|
220 |
try{
|
221 |
this.setFullExtent(drv.getFullExtent(sCoverage,
|
222 |
(String) args.get((String) "CRS"))); |
223 |
this.setFormat((String) args.get((String) "FORMAT")); |
224 |
this.setParameter("BANDS=" + (String) args.get((String) "BANDS")); |
225 |
this.setSRS((String) args.get((String) "CRS")); |
226 |
this.setName(sCoverage);
|
227 |
this.setCoverageName(sCoverage);
|
228 |
}catch (Exception e){ |
229 |
throw new DriverIOException("The server '" + host + "' is not able to load the coverage '" + sCoverage + "'."); |
230 |
} |
231 |
|
232 |
} |
233 |
|
234 |
/**
|
235 |
* Clase que contiene los datos de visualizaci?n de WCS. Tiene datos que representan al
|
236 |
* raster en la vista. Este raster puede estar compuesto por tiles por lo que valores
|
237 |
* como el ancho total o el m?nimo o m?ximo deben ser calculados a partir de todos los
|
238 |
* tiles visualizados.
|
239 |
* @author Nacho Brodin (brodin_ign@gva.es)
|
240 |
*/
|
241 |
private class VisualStatus { |
242 |
/**
|
243 |
* Ancho y alto de la imagen o del conjunto de tiles si los tiene. Coincide con
|
244 |
* el ancho y alto del viewPort
|
245 |
*/
|
246 |
private int width = 0, height = 0; |
247 |
private double minX = 0D, minY = 0D, maxX = 0D, maxY = 0D; |
248 |
private int bandCount = 0; |
249 |
private int dataType = DataBuffer.TYPE_UNDEFINED; |
250 |
|
251 |
/**
|
252 |
* Ancho y alto total del raster que ser? la suma de todos los tiles.
|
253 |
*/
|
254 |
private int rasterWidth = 0, rasterHeight = 0; |
255 |
private double rasterMinX = Double.MAX_VALUE, rasterMinY = Double.MAX_VALUE; |
256 |
private double rasterMaxX = 0, rasterMaxY = 0; |
257 |
/**
|
258 |
* Lista de nombre de fichero que componen toda la visualizaci?n.
|
259 |
*/
|
260 |
private String[] fileNames = null; |
261 |
} |
262 |
|
263 |
/**
|
264 |
* @deprecated
|
265 |
* @see com.iver.cit.gvsig.fmap.layers.layerOperations.InfoByPoint#getInfo
|
266 |
*/
|
267 |
public String queryByPoint(Point p) { |
268 |
String data = "<file:"+getName().replaceAll("[^a-zA-Z0-9]","")+">\n"; |
269 |
ArrayList attr = this.getAttributes(); |
270 |
data += " <raster\n";
|
271 |
data += " File=\""+getName()+"\"\n"; |
272 |
for (int i=0; i<attr.size(); i++) { |
273 |
Object [] a = (Object []) attr.get(i); |
274 |
|
275 |
data += " "+a[0].toString()+"="; |
276 |
if (a[1].toString() instanceof String) |
277 |
data += "\""+a[1].toString()+"\"\n"; |
278 |
else
|
279 |
data += a[1].toString()+"\n"; |
280 |
} |
281 |
data += " Point=\""+posX+" , "+posY+"\"\n"; |
282 |
data += " Point_WC=\""+posXWC+" , "+posYWC+"\"\n"; |
283 |
data += " RGB=\""+r+", "+g+", "+b+"\"\n"; |
284 |
data += " />\n";
|
285 |
|
286 |
data += "</file:"+getName().replaceAll("[^a-zA-Z0-9]","")+">\n"; |
287 |
System.out.println(data);
|
288 |
return data;
|
289 |
} |
290 |
|
291 |
/**
|
292 |
* @see com.iver.cit.gvsig.fmap.layers.layerOperations.InfoByPoint#getInfo
|
293 |
*/
|
294 |
public XMLItem[] getInfo(Point point, double tolerance, Cancellable cancel ) throws ReadDriverException { |
295 |
return super.getInfo(point, tolerance, cancel); |
296 |
} |
297 |
|
298 |
/*
|
299 |
* (non-Javadoc)
|
300 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#getFullExtent()
|
301 |
*/
|
302 |
public Rectangle2D getFullExtent() { |
303 |
return fullExtent;
|
304 |
} |
305 |
|
306 |
/*
|
307 |
* (non-Javadoc)
|
308 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#draw(java.awt.image.BufferedImage, java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, com.iver.cit.gvsig.fmap.operations.Cancellable, double)
|
309 |
*/
|
310 |
public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale) throws ReadDriverException { |
311 |
enableStopped(); |
312 |
// callLegendChanged(null);
|
313 |
|
314 |
if (isWithinScale(scale)) {
|
315 |
Point2D p = viewPort.getOffset();
|
316 |
// p will be (0, 0) when drawing a view or other when painting onto
|
317 |
// the Layout.
|
318 |
visualStatus.width = viewPort.getImageWidth(); |
319 |
visualStatus.height = viewPort.getImageHeight(); |
320 |
visualStatus.minX = viewPort.getAdjustedExtent().getMinX(); |
321 |
visualStatus.minY = viewPort.getAdjustedExtent().getMinY(); |
322 |
visualStatus.maxX = viewPort.getAdjustedExtent().getMaxX(); |
323 |
visualStatus.maxY = viewPort.getAdjustedExtent().getMaxY(); |
324 |
visualStatus.rasterWidth = 0;
|
325 |
visualStatus.rasterHeight = 0;
|
326 |
visualStatus.rasterMinX = Double.MAX_VALUE;
|
327 |
visualStatus.rasterMinY = Double.MAX_VALUE;
|
328 |
visualStatus.rasterMaxX = 0;
|
329 |
visualStatus.rasterMaxY = 0;
|
330 |
visualStatus.fileNames = new String[1]; |
331 |
|
332 |
try {
|
333 |
if (true) { |
334 |
if (viewPort.getImageWidth() <= maxTileDrawWidth && viewPort.getImageHeight() <= maxTileDrawHeight) {
|
335 |
drawTile(g, viewPort, cancel, 0, scale);
|
336 |
if (layerRaster == null) |
337 |
return;
|
338 |
dataset = layerRaster.getDataSource(); |
339 |
getRender().setLastRenderBuffer(layerRaster.getRender().getLastRenderBuffer()); |
340 |
initializeRasterLayer(null, new IBuffer[][] { { layerRaster.getRender().getLastRenderBuffer() } }); |
341 |
} else {
|
342 |
Rectangle r = new Rectangle((int) p.getX(), (int) p.getY(), viewPort.getImageWidth(), viewPort.getImageHeight()); |
343 |
Tiling tiles = new Tiling(maxTileDrawWidth, maxTileDrawHeight, r);
|
344 |
tiles.setAffineTransform((AffineTransform) viewPort.getAffineTransform().clone());
|
345 |
MultiRasterDataset[][] datasets = new MultiRasterDataset[tiles.getNumRows()][tiles.getNumCols()]; |
346 |
IBuffer[][] buf = new IBuffer[tiles.getNumRows()][tiles.getNumCols()]; |
347 |
visualStatus.fileNames = new String[tiles.getNumTiles()]; |
348 |
for (int tileNr = 0; tileNr < tiles.getNumTiles(); tileNr++) { |
349 |
// drawing part
|
350 |
try {
|
351 |
ViewPort vp = tiles.getTileViewPort(viewPort, tileNr); |
352 |
boolean painted = drawTile(g, vp, cancel, tileNr, scale);
|
353 |
if (layerRaster != null && painted) { |
354 |
datasets[(int) (tileNr / tiles.getNumCols())][tileNr % tiles.getNumCols()] = (MultiRasterDataset) layerRaster.getDataSource().newDataset();
|
355 |
buf[(int) (tileNr / tiles.getNumCols())][tileNr % tiles.getNumCols()] = layerRaster.getRender().getLastRenderBuffer();
|
356 |
} |
357 |
} catch (NoninvertibleTransformException e) { |
358 |
e.printStackTrace(); |
359 |
} |
360 |
} |
361 |
try {
|
362 |
if (datasets != null && datasets[0][0] != null) { |
363 |
dataset = new CompositeDataset(datasets);
|
364 |
initializeRasterLayer(datasets, buf); |
365 |
} |
366 |
} catch (MosaicNotValidException e) {
|
367 |
throw new ReadDriverException("No hay continuidad en el mosaico.", e); |
368 |
} catch (LoadLayerException e) {
|
369 |
throw new ReadDriverException("Error inicializando la capa.", e); |
370 |
} |
371 |
} |
372 |
} else {
|
373 |
drawTile(g, viewPort, cancel, 0, scale);
|
374 |
if (layerRaster == null) |
375 |
return;
|
376 |
dataset = layerRaster.getDataSource(); |
377 |
getRender().setLastRenderBuffer(layerRaster.getRender().getLastRenderBuffer()); |
378 |
initializeRasterLayer(null, new IBuffer[][] { { layerRaster.getRender().getLastRenderBuffer() } }); |
379 |
} |
380 |
} catch (ConnectionErrorLayerException e) {
|
381 |
e.printStackTrace(); |
382 |
} catch (UnsupportedVersionLayerException e) {
|
383 |
e.printStackTrace(); |
384 |
} catch (LoadLayerException e) {
|
385 |
e.printStackTrace(); |
386 |
} |
387 |
} |
388 |
disableStopped(); |
389 |
// callLegendChanged(null);
|
390 |
Runtime r = Runtime.getRuntime(); |
391 |
long mem = r.totalMemory() - r.freeMemory();
|
392 |
System.err.println("Memoria total: " + (mem / 1024) +"KB"); |
393 |
} |
394 |
|
395 |
/**
|
396 |
* Acciones que se realizan despu?s de asignar la fuente de datos a
|
397 |
* la capa raster.
|
398 |
*
|
399 |
* @throws LoadLayerException
|
400 |
*/
|
401 |
private void initializeRasterLayer(MultiRasterDataset[][] datasets, IBuffer[][] buf) throws LoadLayerException { |
402 |
if(this.filterList != null) |
403 |
getRender().setFilterList(filterList); |
404 |
|
405 |
/*
|
406 |
if(this.transparency != null)
|
407 |
getRender().setLastTransparency(transparency);
|
408 |
*/
|
409 |
if(this.renderBands != null) |
410 |
getRender().setRenderBands(renderBands); |
411 |
if(datasets != null) { |
412 |
String[][] names = new String[datasets.length][datasets[0].length]; |
413 |
for (int i = 0; i < datasets.length; i++) { |
414 |
for (int j = 0; j < datasets[i].length; j++) { |
415 |
if(datasets[i][j] != null) |
416 |
names[i][j] = datasets[i][j].getDataset(0)[0].getFName(); |
417 |
} |
418 |
} |
419 |
super.setLoadParams(names);
|
420 |
} |
421 |
super.init();
|
422 |
if(buf != null) { |
423 |
int drawablesBandCount = layerRaster.getDataSource().getBands().getDrawableBandsCount();
|
424 |
IBuffer buff = null;
|
425 |
if(dataset instanceof CompositeDataset) |
426 |
buff = ((CompositeDataset)dataset).generateBuffer(buf, drawablesBandCount); |
427 |
else
|
428 |
buff = buf[0][0]; |
429 |
getRender().setLastRenderBuffer(buff); |
430 |
} |
431 |
|
432 |
if (transparency == null) |
433 |
transparency = new GridTransparency(getDataSource().getTransparencyFilesStatus());
|
434 |
|
435 |
getRender().setLastTransparency(transparency); |
436 |
} |
437 |
|
438 |
/**
|
439 |
* This is the method used to draw a tile in a WCS mosaic layer.
|
440 |
* @param tile Tile number to draw
|
441 |
* @throws ReadDriverException
|
442 |
* @return true when a tile has been painted
|
443 |
*/
|
444 |
private boolean drawTile(Graphics2D g, ViewPort vp, Cancellable cancel, int tile, double scale) throws LoadLayerException, ReadDriverException { |
445 |
|
446 |
// Compute the query geometry
|
447 |
// 1. Check if it is within borders
|
448 |
Rectangle2D extent = getFullExtent();
|
449 |
if ((vp.getAdjustedExtent().getMinX() > extent.getMaxX()) ||
|
450 |
(vp.getAdjustedExtent().getMinY() > extent.getMaxY()) || |
451 |
(vp.getAdjustedExtent().getMaxX() < extent.getMinX()) || |
452 |
(vp.getAdjustedExtent().getMaxY() < extent.getMinY())) |
453 |
return false; |
454 |
|
455 |
// 2. Compute extent to be requested.
|
456 |
Rectangle2D bBox = new Rectangle2D.Double(); |
457 |
Rectangle2D.intersect(vp.getAdjustedExtent(), extent, bBox);
|
458 |
|
459 |
// 3. Compute size in pixels
|
460 |
double scalex = vp.getAffineTransform().getScaleX();
|
461 |
double scaley = vp.getAffineTransform().getScaleY();
|
462 |
int wImg = (int) Math.ceil(Math.abs(bBox.getWidth() * scalex) + 1); |
463 |
int hImg = (int) Math.ceil(Math.abs(bBox.getHeight() * scaley) + 1); |
464 |
Dimension sz = new Dimension(wImg, hImg); |
465 |
|
466 |
if ((wImg <= 0) || (hImg <= 0)) |
467 |
return false; |
468 |
|
469 |
try {
|
470 |
sz = new Dimension(wImg, hImg); |
471 |
|
472 |
wcsStatus.setCoveraName( coverageName ); |
473 |
wcsStatus.setExtent( bBox ); |
474 |
wcsStatus.setFormat( format ); |
475 |
wcsStatus.setHeight( hImg ); |
476 |
wcsStatus.setWidth( wImg ); |
477 |
wcsStatus.setSrs(srs); |
478 |
wcsStatus.setParameters( parameter ); |
479 |
wcsStatus.setTime( time ); |
480 |
wcsStatus.setOnlineResource((String) onlineResources.get("GetCoverage")); |
481 |
|
482 |
File f = getDriver().getCoverage(wcsStatus, new MyCancellable(cancel)); |
483 |
if (f == null) |
484 |
return false; |
485 |
String nameWordFile = f.getPath() + getExtensionWorldFile();
|
486 |
com.iver.andami.Utilities.createTemp(nameWordFile, this.getDataWorldFile(bBox, sz));
|
487 |
|
488 |
IStatusRaster status = super.getStatus();
|
489 |
if(status!=null && firstLoad){ |
490 |
try {
|
491 |
status.applyStatus(this);
|
492 |
} catch (NotSupportedExtensionException e) {
|
493 |
throw new ReadDriverException("", e); |
494 |
} catch (RasterDriverException e) {
|
495 |
throw new ReadDriverException("", e); |
496 |
} catch (FilterTypeException e) {
|
497 |
throw new ReadDriverException("", e); |
498 |
} |
499 |
firstLoad = false;
|
500 |
} |
501 |
ViewPortData vpData = new ViewPortData(
|
502 |
vp.getProjection(), new Extent(bBox), sz );
|
503 |
vpData.setMat(vp.getAffineTransform()); |
504 |
|
505 |
String filePath = f.getAbsolutePath();
|
506 |
visualStatus.fileNames[tile] = filePath; |
507 |
|
508 |
try {
|
509 |
rasterProcess(filePath, g, vp, scale, cancel); |
510 |
} catch (FilterTypeException e) {
|
511 |
} |
512 |
|
513 |
// this.getRender().draw(g, vpData);
|
514 |
// rasterProcess(g, vpData, f);
|
515 |
|
516 |
// } catch (ValidationException e) {
|
517 |
// UnknownResponseFormatExceptionType type =
|
518 |
// new UnknownResponseFormatExceptionType();
|
519 |
// type.setLayerName(getName());
|
520 |
// try {
|
521 |
// type.setDriverName(getDriver().getName());
|
522 |
// } catch (Exception e1) {
|
523 |
// e1.printStackTrace();
|
524 |
// }
|
525 |
// type.setFormat(format);
|
526 |
// type.setHost(host);
|
527 |
// type.setProtocol("WCS");
|
528 |
// ReadDriverException exception = new ReadDriverException("unknown_response_format",type);
|
529 |
// throw exception;
|
530 |
// azabala throw new DriverException(PluginServices.getText(this, "unknown_response_format"), e);
|
531 |
// }
|
532 |
// catch (UnsupportedVersionLayerException e) {
|
533 |
// UnsuportedProtocolVersionExceptionType type =
|
534 |
// new UnsuportedProtocolVersionExceptionType();
|
535 |
// type.setLayerName(getName());
|
536 |
// try {
|
537 |
// type.setDriverName(getDriver().getName());
|
538 |
// } catch (Exception ex){
|
539 |
// }
|
540 |
// type.setUrl(host);
|
541 |
// throw new ReadDriverException(PluginServices.getText(this, "version_conflict"), e, type);
|
542 |
|
543 |
// azabala throw new DriverException(PluginServices.getText(this, "version_conflict"), e);
|
544 |
} catch (IOException e) { |
545 |
// ConnectionErrorExceptionType type = new ConnectionErrorExceptionType();
|
546 |
// type.setLayerName(getName());
|
547 |
// try {
|
548 |
// type.setDriverName(getDriver().getName());
|
549 |
// } catch (Exception e1) {
|
550 |
// }
|
551 |
// type.setHost(host);
|
552 |
throw new ConnectionErrorLayerException(getName(),e); |
553 |
} |
554 |
// catch (WCSLayerException e) {
|
555 |
////azabala: la capturamos y la convertimos en DriverException
|
556 |
// WCSDriverExceptionType type = new WCSDriverExceptionType();
|
557 |
// type.setLayerName(getName());
|
558 |
// try {
|
559 |
// type.setDriverName(getDriver().getName());
|
560 |
// } catch (Exception e1) {
|
561 |
// }
|
562 |
// type.setWcsStatus(wcsStatus);
|
563 |
// this.setVisible(false);
|
564 |
// throw new WDriverException("Error WCS", e, type);
|
565 |
//
|
566 |
//// JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), e.getMessage());
|
567 |
//
|
568 |
// }//
|
569 |
catch (WCSDriverException e) {
|
570 |
throw new LoadLayerException(getName(),e); |
571 |
} catch (IllegalStateException e) { |
572 |
throw new LoadLayerException(getName(),e); |
573 |
} |
574 |
return true; |
575 |
} |
576 |
|
577 |
/**
|
578 |
* Devuelve el FMapWMSDriver.
|
579 |
*
|
580 |
* @return FMapWMSDriver
|
581 |
*
|
582 |
* @throws IllegalStateException
|
583 |
* @throws ValidationException
|
584 |
* @throws UnsupportedVersionLayerException
|
585 |
* @throws IOException
|
586 |
*/
|
587 |
private FMapWCSDriver getDriver() throws IllegalStateException, IOException { |
588 |
if (wcs == null) { |
589 |
wcs = FMapWCSDriverFactory.getFMapDriverForURL(host); |
590 |
} |
591 |
return wcs;
|
592 |
} |
593 |
|
594 |
/**
|
595 |
* Calcula el contenido del fichero de georreferenciaci?n de una imagen.
|
596 |
* @param bBox Tama?o y posici?n de la imagen (en coordenadas de usuario)
|
597 |
* @param sz Tama?o de la imagen en pixeles.
|
598 |
* @return el 'WorldFile', como String.
|
599 |
* @throws IOException
|
600 |
*/
|
601 |
public String getDataWorldFile(Rectangle2D bBox, Dimension sz) throws IOException { |
602 |
StringBuffer data = new StringBuffer(); |
603 |
data.append((bBox.getMaxX() - bBox.getMinX())/(sz.getWidth() - 1)+"\n"); |
604 |
data.append("0.0\n");
|
605 |
data.append("0.0\n");
|
606 |
data.append("-"+(bBox.getMaxY() - bBox.getMinY())/(sz.getHeight() - 1)+"\n"); |
607 |
data.append(""+bBox.getMinX()+"\n"); |
608 |
data.append(""+bBox.getMaxY()+"\n"); |
609 |
return data.toString();
|
610 |
} |
611 |
|
612 |
/**
|
613 |
* Carga y dibuja el raster usando la librer?a
|
614 |
* @param filePath Ruta al fichero en disco
|
615 |
* @param g Graphics2D
|
616 |
* @param vp ViewPort
|
617 |
* @param scale Escala para el draw
|
618 |
* @param cancel Cancelaci?n para el draw
|
619 |
* @throws ReadDriverException
|
620 |
* @throws LoadLayerException
|
621 |
*/
|
622 |
private void rasterProcess(String filePath, Graphics2D g, ViewPort vp, double scale, Cancellable cancel) throws ReadDriverException, LoadLayerException, FilterTypeException { |
623 |
//Cerramos el dataset asociado a la capa si est? abierto.
|
624 |
if(layerRaster != null) { |
625 |
layerRaster.setRemoveRasterFlag(true);
|
626 |
layerRaster.getDataSource().close(); |
627 |
} |
628 |
|
629 |
//Cargamos el dataset con el raster de disco.
|
630 |
layerRaster = FLyrRasterSE.createLayer("", filePath, vp.getProjection());
|
631 |
layerRaster.getRender().setBufferFactory(layerRaster.getBufferFactory()); |
632 |
|
633 |
if(visualStatus.dataType == IBuffer.TYPE_UNDEFINED && layerRaster.getDataType() != null) |
634 |
visualStatus.dataType = layerRaster.getDataType()[0];
|
635 |
if(visualStatus.bandCount == 0 && layerRaster.getBandCount() != 0) |
636 |
visualStatus.bandCount = layerRaster.getBandCount(); |
637 |
|
638 |
if (getLegend() == null) |
639 |
lastLegend = layerRaster.getLegend(); |
640 |
|
641 |
//En caso de cargar un proyecto con XMLEntity se crean los filtros
|
642 |
if(filterArguments != null) { |
643 |
RasterFilterList fl = new RasterFilterList();
|
644 |
fl.addEnvParam("IStatistics", layerRaster.getDataSource().getStatistics());
|
645 |
fl.addEnvParam("MultiRasterDataset", layerRaster.getDataSource());
|
646 |
fl.setInitDataType(layerRaster.getDataType()[0]);
|
647 |
RasterFilterListManager filterListManager = new RasterFilterListManager(fl);
|
648 |
filterListManager.createFilterListFromStrings(filterArguments); |
649 |
if (fl.move(TailTrimFilter.class, 0)) |
650 |
fl.move(LinearEnhancementFilter.class, 1);
|
651 |
else
|
652 |
fl.move(LinearEnhancementFilter.class, 0);
|
653 |
fl.controlTypes(); |
654 |
filterArguments = null;
|
655 |
filterList = fl; |
656 |
} |
657 |
|
658 |
//Como el raster se carga a cada zoom el render se crea nuevamente y la lista de
|
659 |
//filtros siempre estar? vacia a cada visualizaci?n. Para evitarlo tenemos que
|
660 |
//guardar la lista de filtro aplicada en la visualizaci?n anterior.
|
661 |
if (filterList != null) |
662 |
layerRaster.getRender().setFilterList(filterList); |
663 |
if (transparency == null) |
664 |
transparency = layerRaster.getRender().getLastTransparency(); |
665 |
if (transparency != null) |
666 |
layerRaster.getRender().setLastTransparency(transparency); |
667 |
if (renderBands != null) |
668 |
layerRaster.getRender().setRenderBands(renderBands); |
669 |
|
670 |
//Dibujamos
|
671 |
layerRaster.draw(null, g, vp, cancel, scale);
|
672 |
|
673 |
//La primera vez asignamos la lista de filtros asociada al renderizador. Guardamos una referencia
|
674 |
//en esta clase para que a cada zoom no se pierda.
|
675 |
if (filterList == null) |
676 |
filterList = layerRaster.getRender().getFilterList(); |
677 |
if (renderBands == null) |
678 |
renderBands = layerRaster.getRender().getRenderBands(); |
679 |
} |
680 |
|
681 |
/*
|
682 |
* (non-Javadoc)
|
683 |
* @see com.iver.cit.gvsig.fmap.layers.FLyrDefault#cloneLayer()
|
684 |
*/
|
685 |
public FLayer cloneLayer() throws Exception { |
686 |
Object par = null; |
687 |
if (dataset instanceof CompositeDataset) |
688 |
par = ((CompositeDataset) dataset).getFileNames(); |
689 |
else
|
690 |
if (layerRaster != null) |
691 |
par = layerRaster.getLoadParams(); |
692 |
|
693 |
FLyrRasterSE newLayer = FLyrRasterSE.createLayer(this.getName(), par, this.getProjection()); |
694 |
|
695 |
ArrayList filters = getRender().getFilterList().getStatusCloned();
|
696 |
newLayer.getRender().getFilterList().setStatus(filters); |
697 |
|
698 |
return newLayer;
|
699 |
} |
700 |
|
701 |
/*
|
702 |
* (non-Javadoc)
|
703 |
* @see org.gvsig.fmap.raster.IRasterRendering#getRenderFilterList()
|
704 |
*/
|
705 |
public RasterFilterList getRenderFilterList(){
|
706 |
return (filterList != null) ? filterList : getRender().getFilterList(); |
707 |
} |
708 |
|
709 |
/*
|
710 |
* (non-Javadoc)
|
711 |
* @see org.gvsig.raster.hierarchy.IRasterRendering#setRenderFilterList(org.gvsig.raster.grid.filter.RasterFilterList)
|
712 |
*/
|
713 |
public void setRenderFilterList(RasterFilterList filterList) { |
714 |
this.filterList = filterList;
|
715 |
super.getRender().setFilterList(filterList);
|
716 |
} |
717 |
|
718 |
/*
|
719 |
* (non-Javadoc)
|
720 |
* @see org.gvsig.fmap.raster.IRasterRendering#getRenderTransparency()
|
721 |
*/
|
722 |
public GridTransparency getRenderTransparency() {
|
723 |
return getRender().getLastTransparency();
|
724 |
// return (transparency != null) ? transparency : getRender().getLastTransparency();
|
725 |
} |
726 |
|
727 |
/*
|
728 |
* (non-Javadoc)
|
729 |
* @see org.gvsig.raster.hierarchy.IRasterRendering#getRenderBands()
|
730 |
*/
|
731 |
public int[] getRenderBands() { |
732 |
return (renderBands != null) ? renderBands : getRender().getRenderBands(); |
733 |
} |
734 |
|
735 |
/*
|
736 |
* (non-Javadoc)
|
737 |
* @see org.gvsig.raster.hierarchy.IRasterRendering#setRenderBands(int[])
|
738 |
*/
|
739 |
public void setRenderBands(int[] renderBands) { |
740 |
this.renderBands = renderBands;
|
741 |
getRender().setRenderBands(renderBands); |
742 |
} |
743 |
|
744 |
/*
|
745 |
* (non-Javadoc)
|
746 |
* @see org.gvsig.fmap.raster.layers.FLyrRasterSE#print(java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, com.iver.utiles.swing.threads.Cancellable, double, javax.print.attribute.PrintRequestAttributeSet)
|
747 |
*/
|
748 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale, PrintRequestAttributeSet properties) throws ReadDriverException { |
749 |
if (isVisible() && isWithinScale(scale)){
|
750 |
draw(null, g, viewPort, cancel, scale);
|
751 |
} |
752 |
} |
753 |
|
754 |
/**
|
755 |
* Returns the XMLEntity containing the necessary info for reproduce
|
756 |
* the layer.
|
757 |
*
|
758 |
* Devuelve el XMLEntity con la informaci?n necesaria para reproducir
|
759 |
* la capa.
|
760 |
*
|
761 |
* @return XMLEntity.
|
762 |
* @throws XMLException
|
763 |
*/
|
764 |
public XMLEntity getXMLEntity() throws XMLException { |
765 |
XMLEntity xml = super.getXMLEntity();
|
766 |
|
767 |
xml.putProperty("wcs.host", getHost());
|
768 |
xml.putProperty("wcs.fullExtent", StringUtilities.rect2String( fullExtent ));
|
769 |
xml.putProperty("wcs.layerQuery", coverageName );
|
770 |
xml.putProperty("wcs.format", format );
|
771 |
xml.putProperty("wcs.srs", srs );
|
772 |
xml.putProperty("wcs.time", time );
|
773 |
xml.putProperty("wcs.parameter", parameter );
|
774 |
xml.putProperty("wcs.coverageName", coverageName );
|
775 |
xml.putProperty("wcs.maxResX", maxRes.getX());
|
776 |
xml.putProperty("wcs.maxResY", maxRes.getY());
|
777 |
|
778 |
Iterator it = onlineResources.keySet().iterator();
|
779 |
String strOnlines = ""; |
780 |
while (it.hasNext()) {
|
781 |
String key = (String) it.next(); |
782 |
String value = (String) onlineResources.get(key); |
783 |
strOnlines += key+"~##SEP2##~"+value;
|
784 |
if (it.hasNext())
|
785 |
strOnlines += "~##SEP1##~";
|
786 |
} |
787 |
xml.putProperty("onlineResources", strOnlines);
|
788 |
|
789 |
IStatusRaster status = super.getStatus();
|
790 |
if (status!=null) |
791 |
status.getXMLEntity(xml, true, this); |
792 |
else{
|
793 |
status = new StatusLayerRaster();
|
794 |
status.getXMLEntity(xml, true, this); |
795 |
} |
796 |
return xml;
|
797 |
} |
798 |
|
799 |
/**
|
800 |
* Reproduces the layer from an XMLEntity.
|
801 |
*
|
802 |
* A partir del XMLEntity reproduce la capa.
|
803 |
*
|
804 |
* @param xml XMLEntity
|
805 |
*
|
806 |
* @throws XMLException
|
807 |
* @throws DriverException
|
808 |
* @throws DriverIOException
|
809 |
*/
|
810 |
public void setXMLEntity(XMLEntity xml) throws XMLException { |
811 |
super.setXMLEntity(xml);
|
812 |
|
813 |
// host
|
814 |
try {
|
815 |
host = new URL(xml.getStringProperty("wcs.host")); |
816 |
} catch (MalformedURLException e) { |
817 |
throw new XMLException(e); |
818 |
} |
819 |
|
820 |
// full extent
|
821 |
fullExtent = StringUtilities.string2Rect(xml.getStringProperty("wcs.fullExtent"));
|
822 |
|
823 |
// coverageQuery
|
824 |
coverageName = xml.getStringProperty("wcs.layerQuery");
|
825 |
|
826 |
// format
|
827 |
format = xml.getStringProperty("wcs.format");
|
828 |
|
829 |
// srs
|
830 |
srs = xml.getStringProperty("wcs.srs");
|
831 |
|
832 |
// time
|
833 |
time = xml.getStringProperty("wcs.time");
|
834 |
|
835 |
// parameter
|
836 |
parameter = xml.getStringProperty("wcs.parameter");
|
837 |
|
838 |
// coverage name
|
839 |
coverageName = xml.getStringProperty("wcs.coverageName");
|
840 |
|
841 |
// max resolution
|
842 |
if (xml.contains("wcs.maxRes")) |
843 |
maxRes = new Point2D.Double(xml.getDoubleProperty("wcs.maxRes"), xml.getDoubleProperty("wcs.maxRes")); |
844 |
else if (xml.contains("wcs.maxResX") && xml.contains("wcs.maxResY")) |
845 |
maxRes = new Point2D.Double(xml.getDoubleProperty("wcs.maxResX"), xml.getDoubleProperty("wcs.maxResY")); |
846 |
|
847 |
// OnlineResources
|
848 |
if (xml.contains("onlineResources")) { |
849 |
String[] operations = xml.getStringProperty("onlineResources").split("~##SEP1##~"); |
850 |
for (int i = 0; i < operations.length; i++) { |
851 |
String[] resources = operations[i].split("~##SEP2##~"); |
852 |
if (resources.length==2 && resources[1]!="") |
853 |
onlineResources.put(resources[0], resources[1]); |
854 |
} |
855 |
} |
856 |
String claseStr = null; |
857 |
if (xml.contains("raster.class")) { |
858 |
claseStr = xml.getStringProperty("raster.class");
|
859 |
} |
860 |
|
861 |
IStatusRaster status = super.getStatus();
|
862 |
if (status!=null) |
863 |
status.setXMLEntity(xml, this);
|
864 |
else {
|
865 |
//Cuando cargamos un proyecto
|
866 |
|
867 |
if(claseStr!=null && !claseStr.equals("")){ |
868 |
try{
|
869 |
Class clase = LayerFactory.getLayerClassForLayerClassName(claseStr);
|
870 |
Constructor constr = clase.getConstructor(null); |
871 |
status = (IStatusRaster)constr.newInstance(null);
|
872 |
if(status != null) { |
873 |
((StatusLayerRaster)status).setNameClass(claseStr); |
874 |
status.setXMLEntity(xml, this);
|
875 |
filterArguments = status.getFilterArguments(); |
876 |
// transparency = status.getTransparency();
|
877 |
renderBands = status.getRenderBands(); |
878 |
ColorTable ct = status.getColorTable(); |
879 |
if(ct != null) |
880 |
setLastLegend(ct); |
881 |
} |
882 |
} catch(ClassNotFoundException exc) { |
883 |
exc.printStackTrace(); |
884 |
} catch(InstantiationException exc) { |
885 |
exc.printStackTrace(); |
886 |
} catch(IllegalAccessException exc) { |
887 |
exc.printStackTrace(); |
888 |
} catch(NoSuchMethodException exc) { |
889 |
exc.printStackTrace(); |
890 |
} catch(InvocationTargetException exc) { |
891 |
exc.printStackTrace(); |
892 |
} catch (FilterTypeException exc) {
|
893 |
exc.printStackTrace(); |
894 |
} |
895 |
} |
896 |
} |
897 |
firstLoad = true;
|
898 |
} |
899 |
|
900 |
public void setCoverageName(String coverageName) { |
901 |
this.coverageName = coverageName;
|
902 |
} |
903 |
|
904 |
public void setParameter(String parametersString) { |
905 |
this.parameter = parametersString;
|
906 |
} |
907 |
|
908 |
public void setTime(String time) { |
909 |
this.time = time;
|
910 |
} |
911 |
|
912 |
public void setSRS(String srs) { |
913 |
this.srs = srs;
|
914 |
setProjection(CRSFactory.getCRS(srs)); |
915 |
} |
916 |
|
917 |
public void setFormat(String format) { |
918 |
this.format = format;
|
919 |
} |
920 |
|
921 |
|
922 |
/**
|
923 |
* Inserta el URL.
|
924 |
*
|
925 |
* @param host String.
|
926 |
* @throws MalformedURLException
|
927 |
*/
|
928 |
public void setHost(String host) { |
929 |
try {
|
930 |
setHost(new URL(host)); |
931 |
} catch (MalformedURLException e) { |
932 |
|
933 |
} |
934 |
} |
935 |
|
936 |
/**
|
937 |
* Inserta el URL.
|
938 |
*
|
939 |
* @param host URL.
|
940 |
*/
|
941 |
public void setHost(URL host) { |
942 |
this.host = host;
|
943 |
} |
944 |
|
945 |
/**
|
946 |
* Sets the layer's full extent.
|
947 |
*
|
948 |
* Establece la extensi?n m?xima de la capa.
|
949 |
*
|
950 |
* @param rect
|
951 |
*/
|
952 |
public void setFullExtent(Rectangle2D rect) { |
953 |
this.fullExtent = rect;
|
954 |
} |
955 |
|
956 |
/**
|
957 |
* Devuelve el URL.
|
958 |
*
|
959 |
* @return URL.
|
960 |
*/
|
961 |
public URL getHost() { |
962 |
return host;
|
963 |
} |
964 |
|
965 |
/**
|
966 |
* Remote source layers have a bunch of properties that are required for get them from
|
967 |
* the servers. This method supplies a hash table containing any needed field. This hash
|
968 |
* table may be used to let the client to connect to a server and restore a previously saved
|
969 |
* layer. So, the layer itself may not be saved to the disk since the actual saved
|
970 |
* info is just its properties.
|
971 |
*
|
972 |
* @return Returns a hash table containing all the required information for
|
973 |
* set up a wms layer
|
974 |
*/
|
975 |
public Hashtable getProperties(){ |
976 |
Hashtable info = new Hashtable(); |
977 |
info.put( "name", coverageName);
|
978 |
info.put( "host", getHost());
|
979 |
info.put( "crs", srs);
|
980 |
info.put( "format", format);
|
981 |
String str = time;
|
982 |
if (str==null) |
983 |
str = "";
|
984 |
info.put( "time", str);
|
985 |
str = parameter; |
986 |
if (str==null) |
987 |
str = "";
|
988 |
info.put("parameter", str);
|
989 |
|
990 |
return info;
|
991 |
} |
992 |
|
993 |
/**
|
994 |
* Obtiene la extensi?n del fichero de georreferenciaci?n
|
995 |
* @return String con la extensi?n del fichero de georreferenciaci?n dependiendo
|
996 |
* del valor del formato obtenido del servidor. Por defecto asignaremos un .wld
|
997 |
*/
|
998 |
private String getExtensionWorldFile(){ |
999 |
String extWorldFile = ".wld"; |
1000 |
if (format.equals("image/tif") || format.equals("image/tiff")) |
1001 |
extWorldFile = ".tfw";
|
1002 |
if (format.equals("image/jpeg")) |
1003 |
extWorldFile = ".jpgw";
|
1004 |
return extWorldFile;
|
1005 |
} |
1006 |
|
1007 |
public void setMaxResolution(Point2D maxResolution) { |
1008 |
this.maxRes = maxResolution;
|
1009 |
} |
1010 |
|
1011 |
/**
|
1012 |
* <p>
|
1013 |
* Gets the max resolution allowed by the coverage. Requesting a higher resolution
|
1014 |
* than this value does not cause any error, but the info responsed is just an
|
1015 |
* interpolation. <br>
|
1016 |
* </p>
|
1017 |
*
|
1018 |
* <p>
|
1019 |
* In exchange for obtaining a greater file and without additional information,
|
1020 |
* we can easily fit it into the View. <br>
|
1021 |
* </p>
|
1022 |
*
|
1023 |
* <p>
|
1024 |
* Obtiene la resoluci?n m?xima soportada por la cobertura. La petici?n
|
1025 |
* de una resoluci?n superior a la soportada no provoca ning?n error, aunque
|
1026 |
* la informaci?n obtenida s?lo es una mera interpolaci?n de informaci?n. <br>
|
1027 |
* </p>
|
1028 |
*
|
1029 |
* <p>
|
1030 |
* A cambio de obtener un archivo mayor y sin informaci?n adicional, podemos
|
1031 |
* f?cilmente acoplarlo a la vista. <br>
|
1032 |
* </p>
|
1033 |
*
|
1034 |
* @return double
|
1035 |
*/
|
1036 |
public Point2D getMaxResolution() { |
1037 |
if (maxRes==null) |
1038 |
maxRes = wcs.getMaxResolution(coverageName); |
1039 |
return maxRes;
|
1040 |
} |
1041 |
|
1042 |
|
1043 |
public void setDriver(FMapWCSDriver driver) { |
1044 |
this.wcs = driver;
|
1045 |
} |
1046 |
|
1047 |
/*
|
1048 |
* (non-Javadoc)
|
1049 |
* @see com.iver.cit.gvsig.fmap.layers.RasterOperations#getTileSize()
|
1050 |
*/
|
1051 |
public int[] getTileSize() { |
1052 |
int[] size = {maxTileDrawWidth, maxTileDrawHeight}; |
1053 |
return size;
|
1054 |
} |
1055 |
|
1056 |
/*
|
1057 |
* (non-Javadoc)
|
1058 |
* @see com.iver.cit.gvsig.fmap.layers.RasterOperations#isTiled()
|
1059 |
*/
|
1060 |
public boolean isTiled() { |
1061 |
return mustTileDraw;
|
1062 |
} |
1063 |
|
1064 |
/*
|
1065 |
* (non-Javadoc)
|
1066 |
* @see org.gvsig.fmap.raster.layers.FLyrRasterSE#isActionEnabled(int)
|
1067 |
*/
|
1068 |
public boolean isActionEnabled(int action) { |
1069 |
switch (action) {
|
1070 |
case IRasterLayerActions.ZOOM_PIXEL_RESOLUTION:
|
1071 |
case IRasterLayerActions.FLYRASTER_BAR_TOOLS:
|
1072 |
case IRasterLayerActions.BANDS_FILE_LIST:
|
1073 |
case IRasterLayerActions.GEOLOCATION:
|
1074 |
case IRasterLayerActions.PANSHARPENING:
|
1075 |
return false; |
1076 |
case IRasterLayerActions.BANDS_RGB:
|
1077 |
return true; |
1078 |
} |
1079 |
|
1080 |
return super.isActionEnabled(action); |
1081 |
} |
1082 |
|
1083 |
} |