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