org.cresques.io
Class GeoRasterFile

java.lang.Object
  extended byorg.cresques.io.GeoFile
      extended byorg.cresques.io.GeoRasterFile
All Implemented Interfaces:
Extent.Has, Projected
Direct Known Subclasses:
EcwFile, GdalFile, MapServerInputStream, MrSidFile, TifGeoRefFile

public abstract class GeoRasterFile
extends GeoFile

Manejador de ficheros raster georeferenciados. Esta clase abstracta es el ancestro de todas las clases que proporcionan soporte para ficheros raster georeferenciados.
Actua tambien como una 'Fabrica', ocultando al cliente la manera en que se ha implementado ese manejo. Una clase nueva que soportara un nuevo tipo de raster tendría que registrar su extensión o extensiones usando el método @see registerExtension.

Author:
"Luis W. Sevilla" *

Field Summary
protected  int bandCount
           
protected  int bBandNr
           
static int BLUE_BAND
           
protected  boolean doTransparency
           
protected  int gBandNr
           
static int GREEN_BAND
           
protected  int rBandNr
           
static int RED_BAND
           
protected  PixelFilter tFilter
           
protected  java.awt.Component updatable
           
 
Fields inherited from class org.cresques.io.GeoFile
bytesReaded, extent, lineCnt
 
Constructor Summary
GeoRasterFile(IProjection proj, java.lang.String name)
           
 
Method Summary
abstract  void close()
           
static double[] cornersToWorldFile(java.awt.geom.Point2D[] esq, java.awt.Dimension size)
          Calcula los parámetros de un worl file a partir de las esquinas del raster. 1.
static boolean fileIsSupported(java.lang.String fName)
          Tipo de fichero soportado.
 int getAlpha()
           
 int getBand(int flag)
          Devuelve el colorBand activo en la banda especificada.
 int getBandCount()
           
abstract  int getBlockSize()
           
static PxContour getContour(java.lang.String fName, java.lang.String name, IProjection proj)
           
abstract  java.lang.Object getData(int x, int y, int band)
          Obtiene el valor del raster en la coordenada que se le pasa.
 int getDataType()
           
abstract  int getHeight()
           
 IObjList getObjects()
           
 boolean getTransparency()
           
abstract  Extent getView()
           
abstract  int getWidth()
           
abstract  byte[] getWindow(int ulX, int ulY, int sizeX, int sizeY, int band)
           
abstract  GeoFile load()
           
static GeoRasterFile openFile(IProjection proj, java.lang.String fName)
          Factoria para abrir distintos tipos de raster.
static java.lang.String printWF(java.lang.String fName, java.awt.geom.Point2D[] esq, java.awt.Dimension sz)
           
static void registerExtension(java.lang.String ext, java.lang.Class clase)
          Registra una clase que soporta una extensión raster.
abstract  void reProject(ICoordTrans rp)
           
static void saveWF(java.lang.String fName, java.lang.String data)
           
 void setAlpha(int alpha)
           
 void setBand(int flag, int bandNr)
          Asocia un colorBand al rojo, verde o azul.
 void setDataType(int dataType)
           
 void setTransparency(boolean t)
           
 void setTransparency(int t)
           
 void setUpdatable(java.awt.Component c)
           
abstract  void setView(Extent e)
           
abstract  java.awt.Image updateImage(int width, int height, ICoordTrans rp)
           
abstract  java.awt.Image updateImage(int width, int height, ICoordTrans rp, java.awt.Image img, int origBand, int destBand)
          Actualiza la/s banda/s especificadas en la imagen.
 
Methods inherited from class org.cresques.io.GeoFile
filterWS, getExtent, getFileSize, getName, getProjection, getTime, setFileSize, setName, setProjection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RED_BAND

public static final int RED_BAND
See Also:
Constant Field Values

GREEN_BAND

public static final int GREEN_BAND
See Also:
Constant Field Values

BLUE_BAND

public static final int BLUE_BAND
See Also:
Constant Field Values

updatable

protected java.awt.Component updatable

doTransparency

protected boolean doTransparency

tFilter

protected PixelFilter tFilter

rBandNr

protected int rBandNr

gBandNr

protected int gBandNr

bBandNr

protected int bBandNr

bandCount

protected int bandCount
Constructor Detail

GeoRasterFile

public GeoRasterFile(IProjection proj,
                     java.lang.String name)
Method Detail

openFile

public static GeoRasterFile openFile(IProjection proj,
                                     java.lang.String fName)
Factoria para abrir distintos tipos de raster.

Parameters:
proj - Proyección en la que está el raster.
fName - Nombre del fichero.
Returns:
GeoRasterFile, o null si hay problemas.

registerExtension

public static void registerExtension(java.lang.String ext,
                                     java.lang.Class clase)
Registra una clase que soporta una extensión raster.

Parameters:
ext - extensión soportada.
clase - clase que la soporta.

fileIsSupported

public static boolean fileIsSupported(java.lang.String fName)
Tipo de fichero soportado. Devuelve true si el tipo de fichero (extension) está soportado, si no devuelve false.

Parameters:
fName - Fichero raster
Returns:
true si está soportado, si no false.

load

public abstract GeoFile load()
Specified by:
load in class GeoFile

close

public abstract void close()
Specified by:
close in class GeoFile

getContour

public static PxContour getContour(java.lang.String fName,
                                   java.lang.String name,
                                   IProjection proj)

getWidth

public abstract int getWidth()

getHeight

public abstract int getHeight()

reProject

public abstract void reProject(ICoordTrans rp)
Specified by:
reProject in interface Projected
Specified by:
reProject in class GeoFile

setView

public abstract void setView(Extent e)

getView

public abstract Extent getView()

setTransparency

public void setTransparency(boolean t)

setTransparency

public void setTransparency(int t)

getTransparency

public boolean getTransparency()

setAlpha

public void setAlpha(int alpha)

getAlpha

public int getAlpha()

setUpdatable

public void setUpdatable(java.awt.Component c)

updateImage

public abstract java.awt.Image updateImage(int width,
                                           int height,
                                           ICoordTrans rp)

getData

public abstract java.lang.Object getData(int x,
                                         int y,
                                         int band)
Obtiene el valor del raster en la coordenada que se le pasa. El valor será Double, Int, Byte, etc. dependiendo del tipo de raster.

Parameters:
x - coordenada X
y - coordenada Y
Returns:

updateImage

public abstract java.awt.Image updateImage(int width,
                                           int height,
                                           ICoordTrans rp,
                                           java.awt.Image img,
                                           int origBand,
                                           int destBand)
Actualiza la/s banda/s especificadas en la imagen.

Parameters:
width - ancho
height - alto
rp - reproyección
img - imagen
Returns:
img

getBandCount

public int getBandCount()

setBand

public void setBand(int flag,
                    int bandNr)
Asocia un colorBand al rojo, verde o azul.

Parameters:
flag - cual (o cuales) de las bandas.

getBand

public int getBand(int flag)
Devuelve el colorBand activo en la banda especificada.

Parameters:
flag - banda.

getDataType

public int getDataType()
Returns:
Returns the dataType.

setDataType

public void setDataType(int dataType)
Parameters:
dataType - The dataType to set.

getObjects

public IObjList getObjects()
Specified by:
getObjects in class GeoFile

cornersToWorldFile

public static double[] cornersToWorldFile(java.awt.geom.Point2D[] esq,
                                          java.awt.Dimension size)
Calcula los parámetros de un worl file a partir de las esquinas del raster. 1. X pixel size A 2. X rotation term D 3. Y rotation term B 4. Y pixel size E 5. X coordinate of upper left corner C 6. Y coordinate of upper left corner F where the real-world coordinates x',y' can be calculated from the image coordinates x,y with the equations x' = Ax + By + C and y' = Dx + Ey + F. The signs of the first 4 parameters depend on the orientation of the image. In the usual case where north is more or less at the top of the image, the X pixel size will be positive and the Y pixel size will be negative. For a south-up image, these signs would be reversed. You can calculate the World file parameters yourself based on the corner coordinates. The X and Y pixel sizes can be determined simply by dividing the distance between two adjacent corners by the number of columns or rows in the image. The rotation terms are calculated with these equations: # B = (A * number_of_columns + C - lower_right_x') / number_of_rows * -1 # D = (E * number_of_rows + F - lower_right_y') / number_of_columns * -1

Returns:

printWF

public static java.lang.String printWF(java.lang.String fName,
                                       java.awt.geom.Point2D[] esq,
                                       java.awt.Dimension sz)

saveWF

public static void saveWF(java.lang.String fName,
                          java.lang.String data)
                   throws java.io.IOException
Throws:
java.io.IOException

getWindow

public abstract byte[] getWindow(int ulX,
                                 int ulY,
                                 int sizeX,
                                 int sizeY,
                                 int band)

getBlockSize

public abstract int getBlockSize()