Revision 161
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/provider/DefaultRasterProvider.java | ||
---|---|---|
27 | 27 |
import java.io.File; |
28 | 28 |
import java.lang.reflect.Constructor; |
29 | 29 |
import java.lang.reflect.InvocationTargetException; |
30 |
import java.util.Date; |
|
30 | 31 |
import java.util.Iterator; |
31 | 32 |
|
32 | 33 |
import org.cresques.cts.IProjection; |
... | ... | |
58 | 59 |
import org.gvsig.fmap.dal.exception.ReadException; |
59 | 60 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
60 | 61 |
import org.gvsig.fmap.dal.raster.impl.DefaultCoverageStore; |
62 |
import org.gvsig.fmap.dal.raster.spi.AbstractCoverageStoreProvider; |
|
61 | 63 |
import org.gvsig.fmap.dal.resource.spi.ResourceProvider; |
62 | 64 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer; |
63 | 65 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters; |
... | ... | |
67 | 69 |
import org.gvsig.raster.impl.datastruct.serializer.ColorTableRmfSerializer; |
68 | 70 |
import org.gvsig.raster.impl.datastruct.serializer.NoDataRmfSerializer; |
69 | 71 |
import org.gvsig.raster.impl.store.AbstractRasterStoreParameters; |
70 |
import org.gvsig.raster.impl.store.GeoInfo; |
|
71 | 72 |
import org.gvsig.raster.impl.store.properties.DatasetColorInterpretation; |
72 | 73 |
import org.gvsig.raster.impl.store.properties.DatasetHistogram; |
73 | 74 |
import org.gvsig.raster.impl.store.properties.DatasetMetadata; |
... | ... | |
96 | 97 |
* |
97 | 98 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
98 | 99 |
*/ |
99 |
public abstract class DefaultRasterProvider extends GeoInfo {
|
|
100 |
public abstract class DefaultRasterProvider extends AbstractCoverageStoreProvider implements RasterProvider {
|
|
100 | 101 |
/** |
101 | 102 |
* Flags que representan a las bandas visualizables |
102 | 103 |
*/ |
103 |
public static final int RED_BAND = 0x01; |
|
104 |
public static final int GREEN_BAND = 0x02; |
|
105 |
public static final int BLUE_BAND = 0x04; |
|
106 |
public static final int ALPHA_BAND = 0x08; |
|
104 |
public static final int RED_BAND = 0x01;
|
|
105 |
public static final int GREEN_BAND = 0x02;
|
|
106 |
public static final int BLUE_BAND = 0x04;
|
|
107 |
public static final int ALPHA_BAND = 0x08;
|
|
107 | 108 |
|
108 |
protected int bandCount = 1; |
|
109 |
private int[] dataType = null; |
|
110 |
protected double noData = 0; |
|
111 |
protected String wktProjection = ""; |
|
109 |
protected int bandCount = 1;
|
|
110 |
private int[] dataType = null;
|
|
111 |
protected double noData = 0;
|
|
112 |
protected String wktProjection = "";
|
|
112 | 113 |
|
113 |
protected DatasetStatistics stats = new DatasetStatistics(this); |
|
114 |
protected DatasetHistogram histogram = null; |
|
115 |
protected AbstractRasterStoreParameters param = null; |
|
116 |
protected RmfBlocksManager rmfBlocksManager = null; |
|
117 |
protected ColorTable colorTable = null; |
|
118 |
protected DatasetColorInterpretation colorInterpretation = null; |
|
114 |
protected DatasetStatistics stats = new DatasetStatistics(this);
|
|
115 |
protected DatasetHistogram histogram = null;
|
|
116 |
protected AbstractRasterStoreParameters param = null;
|
|
117 |
protected RmfBlocksManager rmfBlocksManager = null;
|
|
118 |
protected ColorTable colorTable = null;
|
|
119 |
protected DatasetColorInterpretation colorInterpretation = null;
|
|
119 | 120 |
|
120 | 121 |
/** |
121 | 122 |
* Indica si el valor NoData esta activo |
122 | 123 |
*/ |
123 |
protected boolean noDataEnabled = false; |
|
124 |
protected FileUtils fileUtil = RasterLocator.getManager().getFileUtils(); |
|
125 |
protected RasterUtils rasterUtil = RasterLocator.getManager().getRasterUtils(); |
|
124 |
protected boolean noDataEnabled = false;
|
|
125 |
protected FileUtils fileUtil = RasterLocator.getManager().getFileUtils();
|
|
126 |
protected RasterUtils rasterUtil = RasterLocator.getManager().getRasterUtils();
|
|
126 | 127 |
|
128 |
protected IProjection proj = null; |
|
129 |
protected long fileSize = 0; |
|
130 |
protected long bytesReaded = 0; |
|
131 |
protected long lineCnt = 0; |
|
132 |
protected String name; |
|
133 |
/** |
|
134 |
* Transformaci?n creada a partir de la informaci?n de georreferencia de la |
|
135 |
* propia imagen. Esta informaci?n est? en la cabecera o en ficheros |
|
136 |
* worldfile. |
|
137 |
*/ |
|
138 |
protected AffineTransform ownTransformation = null; |
|
139 |
/** |
|
140 |
* Transformaci?n asignada de forma externa, bien desde el fichero rmf o |
|
141 |
* asignada directamente por el usuario. |
|
142 |
*/ |
|
143 |
protected AffineTransform externalTransformation = null; |
|
144 |
|
|
127 | 145 |
public DefaultRasterProvider(AbstractRasterStoreParameters params, |
128 | 146 |
DataStoreProviderServices storeServices, DynObject metadata) { |
129 | 147 |
super(params, storeServices, metadata); |
... | ... | |
132 | 150 |
if(f.exists()) |
133 | 151 |
setFileSize(f.length()); |
134 | 152 |
} |
153 |
|
|
154 |
if(params.getFileName() != null) |
|
155 |
name = translateFileName(params.getFileName()); |
|
156 |
|
|
157 |
ownTransformation = new AffineTransform(); |
|
158 |
externalTransformation = new AffineTransform(); |
|
135 | 159 |
} |
136 | 160 |
|
137 | 161 |
public DefaultRasterProvider(String params) { |
138 |
super(params);
|
|
162 |
super(); |
|
139 | 163 |
} |
140 | 164 |
|
141 | 165 |
public DefaultRasterProvider() { |
... | ... | |
277 | 301 |
* Carga un fichero raster. Puede usarse para calcular el extent e instanciar |
278 | 302 |
* un objeto de este tipo. |
279 | 303 |
*/ |
280 |
abstract public GeoInfo load();
|
|
304 |
abstract public RasterProvider load();
|
|
281 | 305 |
|
282 | 306 |
/** |
283 | 307 |
* Cierra el fichero y libera los recursos. |
... | ... | |
285 | 309 |
abstract public void close(); |
286 | 310 |
|
287 | 311 |
/** |
288 |
* Carga metadatos desde el fichero Rmf si estos existen |
|
289 |
* @param fName Nombre del fichero |
|
290 |
* @throws ParsingException |
|
291 |
*/ |
|
292 |
protected void loadFromRmf(RmfBlocksManager manager) throws ParsingException { |
|
293 |
if (!manager.checkRmf()) |
|
294 |
return; |
|
295 |
|
|
296 |
if (!new File(manager.getPath()).exists()) |
|
297 |
return; |
|
298 |
|
|
299 |
GeoInfoRmfSerializer geoInfoSerializer = new GeoInfoRmfSerializer(this); |
|
300 |
ColorTableRmfSerializer colorTableSerializer = new ColorTableRmfSerializer(); |
|
301 |
NoDataRmfSerializer noDataSerializer = new NoDataRmfSerializer(new DefaultNoData(noData, RasterLibrary.NODATATYPE_LAYER)); |
|
302 |
ColorInterpretationRmfSerializer colorInterpSerializer = new ColorInterpretationRmfSerializer(); |
|
303 |
ProjectionRmfSerializer projectionRmfSerializer = new ProjectionRmfSerializer(); |
|
304 |
|
|
305 |
manager.addClient(geoInfoSerializer); |
|
306 |
manager.addClient(colorTableSerializer); |
|
307 |
manager.addClient(noDataSerializer); |
|
308 |
manager.addClient(colorInterpSerializer); |
|
309 |
manager.addClient(projectionRmfSerializer); |
|
310 |
|
|
311 |
manager.read(null); |
|
312 |
|
|
313 |
manager.removeAllClients(); |
|
314 |
|
|
315 |
if (colorTableSerializer.getResult() != null) |
|
316 |
setColorTable((ColorTable) colorTableSerializer.getResult()); |
|
317 |
|
|
318 |
if (noDataSerializer.getResult() != null) { |
|
319 |
noData = ((DefaultNoData) noDataSerializer.getResult()).getValue(); |
|
320 |
noDataEnabled = (((DefaultNoData) noDataSerializer.getResult()).getType() != RasterLibrary.NODATATYPE_DISABLED); |
|
321 |
} |
|
322 |
|
|
323 |
if (colorInterpSerializer.getResult() != null) { |
|
324 |
DatasetColorInterpretation ci = (DatasetColorInterpretation) colorInterpSerializer.getResult(); |
|
325 |
setColorInterpretation(ci); |
|
326 |
if (ci.getBand(DatasetColorInterpretation.ALPHA_BAND) != -1) |
|
327 |
getTransparency().setTransparencyBand(ci.getBand(DatasetColorInterpretation.ALPHA_BAND)); |
|
328 |
} |
|
329 |
|
|
330 |
if (projectionRmfSerializer.getResult() != null) |
|
331 |
wktProjection = RasterLocator.getManager().getCRSUtils().convertIProjectionToWkt((IProjection) projectionRmfSerializer.getResult()); |
|
332 |
} |
|
333 |
|
|
334 |
/** |
|
335 | 312 |
* Obtiene el ancho de la imagen |
336 | 313 |
* @return Ancho de la imagen |
337 | 314 |
*/ |
... | ... | |
366 | 343 |
abstract public Object getData(int x, int y, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException; |
367 | 344 |
|
368 | 345 |
/** |
369 |
* Obtiene el n?nero de bandas del fichero |
|
370 |
* @return Entero que representa el n?mero de bandas |
|
371 |
*/ |
|
372 |
public int getBandCount() { |
|
373 |
return bandCount; |
|
374 |
} |
|
375 |
|
|
376 |
/** |
|
377 |
* @return Returns the dataType. |
|
378 |
*/ |
|
379 |
public int[] getDataType() { |
|
380 |
return dataType; |
|
381 |
} |
|
382 |
|
|
383 |
/** |
|
384 |
* @param dataType The dataType to set. |
|
385 |
*/ |
|
386 |
public void setDataType(int[] dataType) { |
|
387 |
this.dataType = dataType; |
|
388 |
} |
|
389 |
|
|
390 |
/* |
|
391 |
* (non-Javadoc) |
|
392 |
* @see org.gvsig.fmap.dal.coverage.dataset.RasterDataSet#getPixelSizeX() |
|
393 |
*/ |
|
394 |
public double getPixelSizeX() { |
|
395 |
return externalTransformation.getScaleX(); |
|
396 |
} |
|
397 |
|
|
398 |
/* |
|
399 |
* (non-Javadoc) |
|
400 |
* @see org.gvsig.fmap.dal.coverage.dataset.RasterDataSet#getPixelSizeY() |
|
401 |
*/ |
|
402 |
public double getPixelSizeY() { |
|
403 |
return externalTransformation.getScaleY(); |
|
404 |
} |
|
405 |
|
|
406 |
/** |
|
407 | 346 |
* Obtiene una ventana de datos de la imagen a partir de coordenadas reales. |
408 | 347 |
* No aplica supersampleo ni subsampleo sino que devuelve una matriz de igual tama?o a los |
409 | 348 |
* pixeles de disco. |
... | ... | |
480 | 419 |
abstract public Buffer getWindowRaster(int x, int y, int w, int h, int bufWidth, int bufHeight, BandList bandList, Buffer rasterBuf)throws ProcessInterruptedException, RasterDriverException; |
481 | 420 |
|
482 | 421 |
abstract public int getBlockSize(); |
422 |
|
|
423 |
/* |
|
424 |
* (non-Javadoc) |
|
425 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getOverviewHeight(int, int) |
|
426 |
*/ |
|
427 |
abstract public int getOverviewHeight(int band, int overview) throws BandAccessException, RasterDriverException; |
|
483 | 428 |
|
484 | 429 |
/** |
430 |
* Informa de si el dataset soporta overviews o no. |
|
431 |
* @return true si soporta overviews y false si no las soporta. |
|
432 |
*/ |
|
433 |
abstract public boolean overviewsSupport(); |
|
434 |
|
|
435 |
/** |
|
436 |
* Lee una l?nea completa del raster y devuelve un array del tipo correcto. Esta funci?n es util |
|
437 |
* para una lectura rapida de todo el fichero sin necesidad de asignar vista. |
|
438 |
* @param nLine N?mero de l?nea a leer |
|
439 |
* @param band Banda requerida |
|
440 |
* @return Object que es un array unidimendional del tipo de datos del raster |
|
441 |
* @throws InvalidSetViewException |
|
442 |
* @throws FileNotOpenException |
|
443 |
* @throws RasterDriverException |
|
444 |
*/ |
|
445 |
abstract public Object readCompleteLine(int line, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException; |
|
446 |
|
|
447 |
/** |
|
448 |
* Lee un bloque completo de datos del raster y devuelve un array tridimensional del tipo correcto. Esta funci?n es util |
|
449 |
* para una lectura rapida de todo el fichero sin necesidad de asignar vista. |
|
450 |
* @param pos Posici?n donde se empieza a leer |
|
451 |
* @param blockHeight Altura m?xima del bloque leido |
|
452 |
* @return Object que es un array tridimendional del tipo de datos del raster. (Bandas X Filas X Columnas) |
|
453 |
* @throws InvalidSetViewException |
|
454 |
* @throws FileNotOpenException |
|
455 |
* @throws RasterDriverException |
|
456 |
*/ |
|
457 |
abstract public Object readBlock(int pos, int blockHeight) |
|
458 |
throws InvalidSetViewException, FileNotOpenException, RasterDriverException, ProcessInterruptedException; |
|
459 |
|
|
460 |
/** |
|
461 |
* Carga metadatos desde el fichero Rmf si estos existen |
|
462 |
* @param fName Nombre del fichero |
|
463 |
* @throws ParsingException |
|
464 |
*/ |
|
465 |
protected void loadFromRmf(RmfBlocksManager manager) throws ParsingException { |
|
466 |
if (!manager.checkRmf()) |
|
467 |
return; |
|
468 |
|
|
469 |
if (!new File(manager.getPath()).exists()) |
|
470 |
return; |
|
471 |
|
|
472 |
GeoInfoRmfSerializer geoInfoSerializer = new GeoInfoRmfSerializer(this); |
|
473 |
ColorTableRmfSerializer colorTableSerializer = new ColorTableRmfSerializer(); |
|
474 |
NoDataRmfSerializer noDataSerializer = new NoDataRmfSerializer(new DefaultNoData(noData, RasterLibrary.NODATATYPE_LAYER)); |
|
475 |
ColorInterpretationRmfSerializer colorInterpSerializer = new ColorInterpretationRmfSerializer(); |
|
476 |
ProjectionRmfSerializer projectionRmfSerializer = new ProjectionRmfSerializer(); |
|
477 |
|
|
478 |
manager.addClient(geoInfoSerializer); |
|
479 |
manager.addClient(colorTableSerializer); |
|
480 |
manager.addClient(noDataSerializer); |
|
481 |
manager.addClient(colorInterpSerializer); |
|
482 |
manager.addClient(projectionRmfSerializer); |
|
483 |
|
|
484 |
manager.read(null); |
|
485 |
|
|
486 |
manager.removeAllClients(); |
|
487 |
|
|
488 |
if (colorTableSerializer.getResult() != null) |
|
489 |
setColorTable((ColorTable) colorTableSerializer.getResult()); |
|
490 |
|
|
491 |
if (noDataSerializer.getResult() != null) { |
|
492 |
noData = ((DefaultNoData) noDataSerializer.getResult()).getValue(); |
|
493 |
noDataEnabled = (((DefaultNoData) noDataSerializer.getResult()).getType() != RasterLibrary.NODATATYPE_DISABLED); |
|
494 |
} |
|
495 |
|
|
496 |
if (colorInterpSerializer.getResult() != null) { |
|
497 |
DatasetColorInterpretation ci = (DatasetColorInterpretation) colorInterpSerializer.getResult(); |
|
498 |
setColorInterpretation(ci); |
|
499 |
if (ci.getBand(DatasetColorInterpretation.ALPHA_BAND) != -1) |
|
500 |
getTransparency().setTransparencyBand(ci.getBand(DatasetColorInterpretation.ALPHA_BAND)); |
|
501 |
} |
|
502 |
|
|
503 |
if (projectionRmfSerializer.getResult() != null) |
|
504 |
wktProjection = RasterLocator.getManager().getCRSUtils().convertIProjectionToWkt((IProjection) projectionRmfSerializer.getResult()); |
|
505 |
} |
|
506 |
|
|
507 |
/** |
|
508 |
* Obtiene el n?nero de bandas del fichero |
|
509 |
* @return Entero que representa el n?mero de bandas |
|
510 |
*/ |
|
511 |
public int getBandCount() { |
|
512 |
return bandCount; |
|
513 |
} |
|
514 |
|
|
515 |
/** |
|
516 |
* @return Returns the dataType. |
|
517 |
*/ |
|
518 |
public int[] getDataType() { |
|
519 |
return dataType; |
|
520 |
} |
|
521 |
|
|
522 |
/** |
|
523 |
* @param dataType The dataType to set. |
|
524 |
*/ |
|
525 |
public void setDataType(int[] dataType) { |
|
526 |
this.dataType = dataType; |
|
527 |
} |
|
528 |
|
|
529 |
/* |
|
530 |
* (non-Javadoc) |
|
531 |
* @see org.gvsig.fmap.dal.coverage.dataset.RasterDataSet#getPixelSizeX() |
|
532 |
*/ |
|
533 |
public double getPixelSizeX() { |
|
534 |
return externalTransformation.getScaleX(); |
|
535 |
} |
|
536 |
|
|
537 |
/* |
|
538 |
* (non-Javadoc) |
|
539 |
* @see org.gvsig.fmap.dal.coverage.dataset.RasterDataSet#getPixelSizeY() |
|
540 |
*/ |
|
541 |
public double getPixelSizeY() { |
|
542 |
return externalTransformation.getScaleY(); |
|
543 |
} |
|
544 |
|
|
545 |
/** |
|
485 | 546 |
* Obtiene el valor NoData asociado al raster. Si hay un valor en el fichero |
486 | 547 |
* RMF se devuelve este, sino se buscar? en la cabecera del raster o metadatos de |
487 | 548 |
* este. Si finalmente no encuentra ninguno se devuelve el valor por defecto |
... | ... | |
589 | 650 |
} |
590 | 651 |
|
591 | 652 |
/** |
592 |
* Lee una l?nea completa del raster y devuelve un array del tipo correcto. Esta funci?n es util |
|
593 |
* para una lectura rapida de todo el fichero sin necesidad de asignar vista. |
|
594 |
* @param nLine N?mero de l?nea a leer |
|
595 |
* @param band Banda requerida |
|
596 |
* @return Object que es un array unidimendional del tipo de datos del raster |
|
597 |
* @throws InvalidSetViewException |
|
598 |
* @throws FileNotOpenException |
|
599 |
* @throws RasterDriverException |
|
600 |
*/ |
|
601 |
abstract public Object readCompleteLine(int line, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException; |
|
602 |
|
|
603 |
/** |
|
604 |
* Lee un bloque completo de datos del raster y devuelve un array tridimensional del tipo correcto. Esta funci?n es util |
|
605 |
* para una lectura rapida de todo el fichero sin necesidad de asignar vista. |
|
606 |
* @param pos Posici?n donde se empieza a leer |
|
607 |
* @param blockHeight Altura m?xima del bloque leido |
|
608 |
* @return Object que es un array tridimendional del tipo de datos del raster. (Bandas X Filas X Columnas) |
|
609 |
* @throws InvalidSetViewException |
|
610 |
* @throws FileNotOpenException |
|
611 |
* @throws RasterDriverException |
|
612 |
*/ |
|
613 |
abstract public Object readBlock(int pos, int blockHeight) |
|
614 |
throws InvalidSetViewException, FileNotOpenException, RasterDriverException, ProcessInterruptedException; |
|
615 |
|
|
616 |
/** |
|
617 | 653 |
* Convierte un punto desde coordenadas pixel a coordenadas del mundo. |
618 | 654 |
* @param pt Punto a transformar |
619 | 655 |
* @return punto transformado en coordenadas del mundo |
... | ... | |
679 | 715 |
*/ |
680 | 716 |
abstract public int getOverviewWidth(int band, int overview) throws BandAccessException, RasterDriverException; |
681 | 717 |
|
682 |
/* |
|
683 |
* (non-Javadoc) |
|
684 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getOverviewHeight(int, int) |
|
685 |
*/ |
|
686 |
abstract public int getOverviewHeight(int band, int overview) throws BandAccessException, RasterDriverException; |
|
687 |
|
|
688 | 718 |
/** |
689 |
* Informa de si el dataset soporta overviews o no. |
|
690 |
* @return true si soporta overviews y false si no las soporta. |
|
691 |
*/ |
|
692 |
abstract public boolean overviewsSupport(); |
|
693 |
|
|
694 |
/** |
|
695 | 719 |
* Obtiene el gestor de ficheros RMF |
696 | 720 |
* @return RmfBloksManager |
697 | 721 |
*/ |
... | ... | |
1015 | 1039 |
*/ |
1016 | 1040 |
public void open() throws OpenException { |
1017 | 1041 |
} |
1042 |
|
|
1043 |
/** |
|
1044 |
* Traduce el nombre del fichero por un alias asignado por el propio driver. |
|
1045 |
* Cuando es traducido por un alias el driver intentar? abrir el alias y no el |
|
1046 |
* fichero. Esto es util porque algunos formatos tienen la extensi?n en el |
|
1047 |
* fichero de cabecera pero lo que se abre realmente es el fichero de datos. |
|
1048 |
* @param fileName |
|
1049 |
* @return |
|
1050 |
*/ |
|
1051 |
public String translateFileName(String fileName) { |
|
1052 |
return fileName; |
|
1053 |
} |
|
1054 |
|
|
1055 |
public String getFName() { |
|
1056 |
return name; |
|
1057 |
} |
|
1058 |
|
|
1059 |
public void setFName(String n) { |
|
1060 |
name = n; |
|
1061 |
} |
|
1062 |
|
|
1063 |
public long getFileSize() { |
|
1064 |
return fileSize; |
|
1065 |
} |
|
1066 |
|
|
1067 |
public void setFileSize(long sz) { |
|
1068 |
fileSize = sz; |
|
1069 |
} |
|
1070 |
|
|
1071 |
/* |
|
1072 |
* (non-Javadoc) |
|
1073 |
* @see org.gvsig.raster.impl.provider.RasterProvider#getProjection() |
|
1074 |
*/ |
|
1075 |
public IProjection getProjection() { |
|
1076 |
return proj; |
|
1077 |
} |
|
1078 |
|
|
1079 |
public void setProjection(IProjection p) { |
|
1080 |
proj = p; |
|
1081 |
} |
|
1082 |
|
|
1083 |
protected long getTime() { |
|
1084 |
return (new Date()).getTime(); |
|
1085 |
} |
|
1086 |
|
|
1087 |
/* |
|
1088 |
* (non-Javadoc) |
|
1089 |
* @see org.gvsig.fmap.dal.coverage.dataset.RasterDataSet#setAffineTransform(java.awt.geom.AffineTransform) |
|
1090 |
*/ |
|
1091 |
public void setAffineTransform(AffineTransform t) { |
|
1092 |
externalTransformation = (AffineTransform) t.clone(); |
|
1093 |
} |
|
1094 |
|
|
1095 |
/* |
|
1096 |
* (non-Javadoc) |
|
1097 |
* @see org.gvsig.fmap.dal.coverage.dataset.RasterDataSet#getAffineTransform() |
|
1098 |
*/ |
|
1099 |
public AffineTransform getAffineTransform() { |
|
1100 |
return externalTransformation; |
|
1101 |
} |
|
1102 |
|
|
1103 |
/** |
|
1104 |
* Elimina la matriz de transformaci?n asociada al raster y que se tiene en |
|
1105 |
* cuenta para el setView. Este reseteo tendr? en cuenta que si el raster |
|
1106 |
* tiene asociado un rmf esta transformaci?n no ser? eliminada sino que se |
|
1107 |
* asignar? la correspondiente al rmf existente. |
|
1108 |
* @return devuelve true si tiene fichero rmf asociado y false si no lo tiene. |
|
1109 |
*/ |
|
1110 |
public void resetAffineTransform() { |
|
1111 |
externalTransformation.setToIdentity(); |
|
1112 |
} |
|
1113 |
|
|
1114 |
/* |
|
1115 |
* (non-Javadoc) |
|
1116 |
* @see org.gvsig.fmap.dal.coverage.dataset.RasterDataSet#getOwnAffineTransform() |
|
1117 |
*/ |
|
1118 |
public AffineTransform getOwnAffineTransform() { |
|
1119 |
return ownTransformation; |
|
1120 |
} |
|
1018 | 1121 |
} |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/store/GeoInfo.java | ||
---|---|---|
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.impl.store; |
|
23 |
|
|
24 |
import java.awt.geom.AffineTransform; |
|
25 |
import java.util.Date; |
|
26 |
|
|
27 |
import org.cresques.cts.IProjection; |
|
28 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
|
29 |
import org.gvsig.fmap.dal.raster.spi.AbstractCoverageStoreProvider; |
|
30 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
31 |
import org.gvsig.raster.impl.provider.RasterProvider; |
|
32 |
import org.gvsig.tools.dynobject.DynObject; |
|
33 |
/** |
|
34 |
* Parent of each provider. This contais geographical information |
|
35 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
36 |
*/ |
|
37 |
public abstract class GeoInfo extends AbstractCoverageStoreProvider implements RasterProvider { |
|
38 |
protected IProjection proj = null; |
|
39 |
protected long fileSize = 0; |
|
40 |
protected long bytesReaded = 0; |
|
41 |
protected long lineCnt = 0; |
|
42 |
protected String name; |
|
43 |
/** |
|
44 |
* Transformaci?n creada a partir de la informaci?n de georreferencia de la |
|
45 |
* propia imagen. Esta informaci?n est? en la cabecera o en ficheros |
|
46 |
* worldfile. |
|
47 |
*/ |
|
48 |
protected AffineTransform ownTransformation = null; |
|
49 |
/** |
|
50 |
* Transformaci?n asignada de forma externa, bien desde el fichero rmf o |
|
51 |
* asignada directamente por el usuario. |
|
52 |
*/ |
|
53 |
protected AffineTransform externalTransformation = null; |
|
54 |
|
|
55 |
/*public GeoInfo() {} |
|
56 |
|
|
57 |
public GeoInfo(Object param) { |
|
58 |
if (param instanceof String) |
|
59 |
name = translateFileName((String) param); |
|
60 |
else |
|
61 |
if (param instanceof IRegistrableRasterFormat) |
|
62 |
name = ((IRegistrableRasterFormat) param).getFormatID(); |
|
63 |
else |
|
64 |
name = String.valueOf(System.currentTimeMillis()); |
|
65 |
ownTransformation = new AffineTransform(); |
|
66 |
externalTransformation = new AffineTransform(); |
|
67 |
}*/ |
|
68 |
|
|
69 |
public GeoInfo(String params) { |
|
70 |
super(); |
|
71 |
} |
|
72 |
|
|
73 |
public GeoInfo(AbstractRasterStoreParameters params, |
|
74 |
DataStoreProviderServices storeServices, |
|
75 |
DynObject metadata) { |
|
76 |
super(params, storeServices, metadata); |
|
77 |
if(params.getFileName() != null) |
|
78 |
name = translateFileName(params.getFileName()); |
|
79 |
|
|
80 |
ownTransformation = new AffineTransform(); |
|
81 |
externalTransformation = new AffineTransform(); |
|
82 |
} |
|
83 |
|
|
84 |
/** |
|
85 |
* Traduce el nombre del fichero por un alias asignado por el propio driver. |
|
86 |
* Cuando es traducido por un alias el driver intentar? abrir el alias y no el |
|
87 |
* fichero. Esto es util porque algunos formatos tienen la extensi?n en el |
|
88 |
* fichero de cabecera pero lo que se abre realmente es el fichero de datos. |
|
89 |
* @param fileName |
|
90 |
* @return |
|
91 |
*/ |
|
92 |
public String translateFileName(String fileName) { |
|
93 |
return fileName; |
|
94 |
} |
|
95 |
|
|
96 |
public String getFName() { |
|
97 |
return name; |
|
98 |
} |
|
99 |
|
|
100 |
public void setFName(String n) { |
|
101 |
name = n; |
|
102 |
} |
|
103 |
|
|
104 |
public long getFileSize() { |
|
105 |
return fileSize; |
|
106 |
} |
|
107 |
|
|
108 |
public void setFileSize(long sz) { |
|
109 |
fileSize = sz; |
|
110 |
} |
|
111 |
|
|
112 |
/* |
|
113 |
* (non-Javadoc) |
|
114 |
* @see org.cresques.geo.Projected#getProjection() |
|
115 |
*/ |
|
116 |
public IProjection getProjection() { |
|
117 |
return proj; |
|
118 |
} |
|
119 |
|
|
120 |
public void setProjection(IProjection p) { |
|
121 |
proj = p; |
|
122 |
} |
|
123 |
|
|
124 |
/** |
|
125 |
* Extent completo del raster. |
|
126 |
* @return Extent |
|
127 |
*/ |
|
128 |
abstract public Extent getExtent(); |
|
129 |
|
|
130 |
/** |
|
131 |
* Este es el extent sobre el que se ajusta una petici?n para que esta no |
|
132 |
* exceda el extent m?ximo del raster. Para un raster sin rotar ser? igual al |
|
133 |
* extent pero para un raster rotado ser? igual al extent del raster como si |
|
134 |
* no tuviera rotaci?n. Esto ha de ser as? ya que la rotaci?n solo se hace |
|
135 |
* sobre la vista y las peticiones han de hacerse en coordenadas de la imagen |
|
136 |
* sin shearing aplicado. |
|
137 |
* @return Extent |
|
138 |
*/ |
|
139 |
abstract public Extent getExtentWithoutRot(); |
|
140 |
|
|
141 |
abstract public GeoInfo load(); |
|
142 |
|
|
143 |
abstract public void close(); |
|
144 |
|
|
145 |
/** |
|
146 |
* Filtra espacios en blanco. Deja solo uno por |
|
147 |
*/ |
|
148 |
public static String filterWS(String buf) { |
|
149 |
boolean lastCharWhite = false; |
|
150 |
String str = ""; |
|
151 |
buf = buf.trim(); |
|
152 |
|
|
153 |
for (int i = 0; i < buf.length(); i++) { |
|
154 |
char c = buf.charAt(i); |
|
155 |
|
|
156 |
if (Character.isWhitespace(c)) { |
|
157 |
if (lastCharWhite) { |
|
158 |
continue; |
|
159 |
} |
|
160 |
lastCharWhite = true; |
|
161 |
c = ' '; |
|
162 |
} else { |
|
163 |
lastCharWhite = false; |
|
164 |
} |
|
165 |
str += c; |
|
166 |
} |
|
167 |
|
|
168 |
return str; |
|
169 |
} |
|
170 |
|
|
171 |
protected long getTime() { |
|
172 |
return (new Date()).getTime(); |
|
173 |
} |
|
174 |
|
|
175 |
/* |
|
176 |
* (non-Javadoc) |
|
177 |
* @see org.gvsig.fmap.dal.coverage.dataset.RasterDataSet#getWktProjection() |
|
178 |
*/ |
|
179 |
public String getWktProjection() { |
|
180 |
return null; |
|
181 |
} |
|
182 |
|
|
183 |
/* |
|
184 |
* (non-Javadoc) |
|
185 |
* @see org.gvsig.fmap.dal.coverage.dataset.RasterDataSet#setAffineTransform(java.awt.geom.AffineTransform) |
|
186 |
*/ |
|
187 |
public void setAffineTransform(AffineTransform t) { |
|
188 |
externalTransformation = (AffineTransform) t.clone(); |
|
189 |
} |
|
190 |
|
|
191 |
/* |
|
192 |
* (non-Javadoc) |
|
193 |
* @see org.gvsig.fmap.dal.coverage.dataset.RasterDataSet#getAffineTransform() |
|
194 |
*/ |
|
195 |
public AffineTransform getAffineTransform() { |
|
196 |
return externalTransformation; |
|
197 |
} |
|
198 |
|
|
199 |
/** |
|
200 |
* Elimina la matriz de transformaci?n asociada al raster y que se tiene en |
|
201 |
* cuenta para el setView. Este reseteo tendr? en cuenta que si el raster |
|
202 |
* tiene asociado un rmf esta transformaci?n no ser? eliminada sino que se |
|
203 |
* asignar? la correspondiente al rmf existente. |
|
204 |
* @return devuelve true si tiene fichero rmf asociado y false si no lo tiene. |
|
205 |
*/ |
|
206 |
public void resetAffineTransform() { |
|
207 |
externalTransformation.setToIdentity(); |
|
208 |
} |
|
209 |
|
|
210 |
/* |
|
211 |
* (non-Javadoc) |
|
212 |
* @see org.gvsig.fmap.dal.coverage.dataset.RasterDataSet#getOwnAffineTransform() |
|
213 |
*/ |
|
214 |
public AffineTransform getOwnAffineTransform() { |
|
215 |
return ownTransformation; |
|
216 |
} |
|
217 |
} |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/store/DefaultMosaicRasterStore.java | ||
---|---|---|
80 | 80 |
private Statistics stats = null; |
81 | 81 |
private BandListImpl bandList = null; |
82 | 82 |
private boolean readOnly = false; |
83 |
|
|
84 | 83 |
/** |
85 | 84 |
* Flag que fuerza al buffer en memoria |
86 | 85 |
*/ |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.io/org.gvsig.raster.io.base/src/main/java/org/gvsig/fmap/dal/coverage/dataset/io/ErmapperDriver.java | ||
---|---|---|
51 | 51 |
import org.gvsig.raster.impl.process.RasterTask; |
52 | 52 |
import org.gvsig.raster.impl.process.RasterTaskQueue; |
53 | 53 |
import org.gvsig.raster.impl.provider.DefaultRasterProvider; |
54 |
import org.gvsig.raster.impl.provider.RasterProvider; |
|
54 | 55 |
import org.gvsig.raster.impl.store.AbstractRasterStoreParameters; |
55 |
import org.gvsig.raster.impl.store.GeoInfo; |
|
56 | 56 |
import org.gvsig.raster.impl.store.properties.DatasetColorInterpretation; |
57 | 57 |
import org.gvsig.raster.impl.store.properties.DatasetTransparency; |
58 | 58 |
import org.gvsig.tools.ToolsLocator; |
... | ... | |
184 | 184 |
* Carga un ECW. |
185 | 185 |
* @param fname |
186 | 186 |
*/ |
187 |
public GeoInfo load() {
|
|
187 |
public RasterProvider load() {
|
|
188 | 188 |
ownTransformation = new AffineTransform(file.cellIncrementX, 0, 0, file.cellIncrementY, file.originX, file.originY); |
189 | 189 |
externalTransformation = (AffineTransform) ownTransformation.clone(); |
190 | 190 |
return this; |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.io/org.gvsig.raster.io.base/src/main/java/org/gvsig/fmap/dal/coverage/dataset/io/MrSidDriver.java | ||
---|---|---|
50 | 50 |
import org.gvsig.raster.impl.process.RasterTask; |
51 | 51 |
import org.gvsig.raster.impl.process.RasterTaskQueue; |
52 | 52 |
import org.gvsig.raster.impl.provider.DefaultRasterProvider; |
53 |
import org.gvsig.raster.impl.provider.RasterProvider; |
|
53 | 54 |
import org.gvsig.raster.impl.store.AbstractRasterStoreParameters; |
54 |
import org.gvsig.raster.impl.store.GeoInfo; |
|
55 | 55 |
import org.gvsig.raster.impl.store.properties.DatasetColorInterpretation; |
56 | 56 |
import org.gvsig.raster.impl.store.properties.DatasetTransparency; |
57 | 57 |
import org.gvsig.tools.ToolsLocator; |
... | ... | |
155 | 155 |
/** |
156 | 156 |
* Obtenemos o calculamos el extent de la imagen. |
157 | 157 |
*/ |
158 |
public GeoInfo load() {
|
|
158 |
public RasterProvider load() {
|
|
159 | 159 |
ownTransformation = file.getOwnTransformation(); |
160 | 160 |
externalTransformation = (AffineTransform) ownTransformation.clone(); |
161 | 161 |
return this; |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.io/org.gvsig.raster.io.base/src/main/java/org/gvsig/fmap/dal/coverage/dataset/io/GdalDriver.java | ||
---|---|---|
51 | 51 |
import org.gvsig.metadata.MetadataLocator; |
52 | 52 |
import org.gvsig.raster.impl.datastruct.ExtentImpl; |
53 | 53 |
import org.gvsig.raster.impl.provider.DefaultRasterProvider; |
54 |
import org.gvsig.raster.impl.provider.RasterProvider; |
|
54 | 55 |
import org.gvsig.raster.impl.store.AbstractRasterStoreParameters; |
55 |
import org.gvsig.raster.impl.store.GeoInfo; |
|
56 | 56 |
import org.gvsig.raster.impl.store.properties.DatasetColorInterpretation; |
57 | 57 |
import org.gvsig.raster.impl.store.properties.DatasetMetadata; |
58 | 58 |
import org.gvsig.raster.impl.store.properties.DatasetTransparency; |
... | ... | |
256 | 256 |
/** |
257 | 257 |
* Obtenemos o calculamos el extent de la imagen. |
258 | 258 |
*/ |
259 |
public GeoInfo load() {
|
|
259 |
public RasterProvider load() {
|
|
260 | 260 |
return this; |
261 | 261 |
} |
262 | 262 |
|
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.io/org.gvsig.raster.io.base/src/main/java/org/gvsig/fmap/dal/coverage/dataset/io/MemoryRasterDriver.java | ||
---|---|---|
39 | 39 |
import org.gvsig.metadata.MetadataLocator; |
40 | 40 |
import org.gvsig.raster.impl.datastruct.ExtentImpl; |
41 | 41 |
import org.gvsig.raster.impl.provider.DefaultRasterProvider; |
42 |
import org.gvsig.raster.impl.store.GeoInfo;
|
|
42 |
import org.gvsig.raster.impl.provider.RasterProvider;
|
|
43 | 43 |
import org.gvsig.raster.impl.store.AbstractRasterStoreParameters; |
44 | 44 |
import org.gvsig.raster.impl.store.properties.DatasetTransparency; |
45 | 45 |
import org.gvsig.tools.ToolsLocator; |
... | ... | |
116 | 116 |
* (non-Javadoc) |
117 | 117 |
* @see org.gvsig.raster.dataset.GeoInfo#load() |
118 | 118 |
*/ |
119 |
public GeoInfo load() {
|
|
119 |
public RasterProvider load() {
|
|
120 | 120 |
return this; |
121 | 121 |
} |
122 | 122 |
|
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/DefaultFLyrRaster.java | ||
---|---|---|
152 | 152 |
private boolean firstLoad = false; |
153 | 153 |
private boolean removeRasterFlag = true; |
154 | 154 |
protected RasterDataStore dataStore = null; |
155 |
protected RasterStoreParameters params = null; |
|
156 | 155 |
protected Render render = null; |
157 | 156 |
private int posX = 0; |
158 | 157 |
private int posY = 0; |
... | ... | |
163 | 162 |
private int b = 0; |
164 | 163 |
private LayerChangeSupport layerChangeSupport = new LayerChangeSupport(); |
165 | 164 |
private FLyrState state = new FLyrState(); |
166 |
private ArrayList filterArguments = null; |
|
167 | 165 |
protected ILegend lastLegend = null; |
168 | 166 |
protected ColorTable loadedFromProject = null; |
169 | 167 |
private ArrayList<ROI> rois = null; |
... | ... | |
204 | 202 |
* @throws RasterNotLoadException |
205 | 203 |
* @throws LoadLayerException |
206 | 204 |
*/ |
205 |
@SuppressWarnings("deprecation") |
|
207 | 206 |
public static DefaultFLyrRaster createLayer(String layerName, File file) throws LoadLayerException { |
208 | 207 |
ProviderServices provServ = RasterLocator.getManager().getProviderServices(); |
209 | 208 |
RasterStoreParameters storeParameters = provServ.createParameters(file.getName()); |
... | ... | |
235 | 234 |
super.setName(name); |
236 | 235 |
|
237 | 236 |
//Si la capa tiene nombre acivamos el estado awake |
238 |
if(params != null && name != null)
|
|
237 |
if(name != null) |
|
239 | 238 |
try { |
240 | 239 |
if(isClosed()) |
241 | 240 |
enableAwake(); |
... | ... | |
283 | 282 |
|
284 | 283 |
String fName = null; |
285 | 284 |
int test = -1; |
285 |
RasterStoreParameters params = (RasterStoreParameters)getDataStore().getParameters(); |
|
286 | 286 |
if (params != null) { |
287 | 287 |
fName = params.getFileName(); |
288 | 288 |
test = fName.indexOf("ecwp:"); |
... | ... | |
532 | 532 |
|
533 | 533 |
strategy = new RasterDrawStrategy(getMapContext(), this); |
534 | 534 |
strategy.stackStrategy(); |
535 |
HashMap tStr = strategy.getStrategy(); |
|
535 |
HashMap<DefaultFLyrRaster, Boolean> tStr = strategy.getStrategy();
|
|
536 | 536 |
if (tStr != null && |
537 | 537 |
tStr.get(this) != null && |
538 | 538 |
((Boolean) (tStr.get(this))).booleanValue() == false) { |
... | ... | |
628 | 628 |
} |
629 | 629 |
} |
630 | 630 |
|
631 |
@SuppressWarnings("deprecation") |
|
631 | 632 |
private void draw(BufferedImage image, Graphics2D g, ViewPort vp, Cancellable cancel) throws RasterDriverException, InvalidSetViewException, InterruptedException { |
632 | 633 |
Envelope adjustedExtent = vp.getAdjustedExtent(); |
633 | 634 |
if (adjustedExtent == null) |
... | ... | |
747 | 748 |
|
748 | 749 |
String data = "<file:" + normalizeAsXMLTag(getName()) + ">\n"; |
749 | 750 |
|
750 |
ArrayList attr = getAttributes(); |
|
751 |
ArrayList<Object> attr = getAttributes();
|
|
751 | 752 |
data += " <raster\n"; |
752 | 753 |
data += " File=\"" + getFile() + "\"\n"; |
753 | 754 |
for (int i = 0; i < attr.size(); i++) { |
... | ... | |
1544 | 1545 |
* @return Fichero. |
1545 | 1546 |
*/ |
1546 | 1547 |
public File getFile() { |
1547 |
return params.getFile();
|
|
1548 |
return ((RasterStoreParameters)getDataStore().getParameters()).getFile();
|
|
1548 | 1549 |
} |
1549 | 1550 |
|
1550 | 1551 |
/** |
... | ... | |
1758 | 1759 |
* como que han sido modificadas para que se vuelvan a leer. |
1759 | 1760 |
*/ |
1760 | 1761 |
if(getMapContext() != null) { |
1761 |
ArrayList listLayers = new ArrayList();
|
|
1762 |
ArrayList<FLayer> listLayers = new ArrayList<FLayer>();
|
|
1762 | 1763 |
listLayers = RasterDrawStrategy.getLayerList(getMapContext().getLayers(), listLayers); |
1763 | 1764 |
for (int i = 0; i < listLayers.size(); i++) |
1764 | 1765 |
if(listLayers.get(i) instanceof DefaultFLyrRaster) |
... | ... | |
2003 | 2004 |
public boolean isStopped() {return state.isStopped();} |
2004 | 2005 |
|
2005 | 2006 |
|
2007 |
@SuppressWarnings("unchecked") |
|
2006 | 2008 |
public Set getMetadataChildren() { |
2007 |
// TODO Auto-generated method stub |
|
2008 | 2009 |
return null; |
2009 | 2010 |
} |
2010 | 2011 |
|
2011 | 2012 |
public Object getMetadataID() { |
2012 |
// TODO: create a more correct implementation with a real unique ID, |
|
2013 |
// maybe extracted from the raster driver. |
|
2014 | 2013 |
return getName(); |
2015 | 2014 |
} |
2016 | 2015 |
|
2017 | 2016 |
public String getMetadataName() { |
2018 |
// TODO Auto-generated method stub |
|
2019 | 2017 |
return null; |
2020 | 2018 |
} |
2021 | 2019 |
|
... | ... | |
2038 | 2036 |
} |
2039 | 2037 |
} else |
2040 | 2038 |
this.dataStore = (RasterDataStore) dataStore; |
2041 |
params = (RasterStoreParameters)dataStore.getParameters(); |
|
2042 | 2039 |
try { |
2043 | 2040 |
enableAwake(); |
2044 | 2041 |
} catch (NotAvailableStateException e) { |
... | ... | |
2072 | 2069 |
this.readingData = readingData; |
2073 | 2070 |
} |
2074 | 2071 |
|
2072 |
@SuppressWarnings("unchecked") |
|
2075 | 2073 |
public Iterator getInfo(Point p, double tolerance, Cancellable cancel) |
2076 | 2074 |
throws LoadLayerException, DataException { |
2077 |
// TODO Auto-generated method stub |
|
2078 | 2075 |
return null; |
2079 | 2076 |
} |
2080 | 2077 |
|
Also available in: Unified diff