hydroScalingAPI.io
Class MetaRaster

java.lang.Object
  extended by hydroScalingAPI.io.MetaRaster

public class MetaRaster
extends java.lang.Object

This class reads a *.metaDEM or *.metaVHC and creates an object that descibes an associated binary files.

Author:
Ricardo Mantilla

Constructor Summary
MetaRaster()
          Creates an empty MetaRaster instance
MetaRaster(java.io.File file)
          Creates a MetaRaster instance using the information on a file.
MetaRaster(MetaRaster mr)
          Creates new MetaRaster using another metaRaster as a template
 
Method Summary
 java.util.Hashtable cloneProperties()
          clones the Hashtable that contains the MetaRaster properties
 float[][] getArray()
          Returns a float[][] array with the infomation contained in the binary file
 java.util.Hashtable getCategoriesTable()
          Returns the Hashtable of categories for this variable
 java.lang.String getCategory(java.lang.String catToFind)
          Returns the lable associated to a category type
 visad.FlatField getField()
          Returns visad.FlatField appropriate for a visad.Display
 java.lang.String getFormat()
          Returns the value associated to the [Format] tag
 java.io.File getLocationBinaryFile()
          Returns a java.io.File object pointing to the location of the binary file described by this MetaRaster
 java.io.File getLocationMeta()
          Returns a java.io.File object pointing to the location of the meta file
 double getMaxLat()
          Calculates and returns the maximum latitude
 double getMaxLon()
          Calculates and returns the maximum longitude
 double getMinLat()
          Returns the value associated to the [Southernmost Latitude] tag.
 double getMinLon()
          Returns the value associated to the [Westernmost Longitude] tag.
 java.lang.String getMissing()
          Returns the value associated to the [Missing] tag
 java.lang.String getName()
          Returns the value associated to the [Name] tag
 int getNumCols()
          Returns the value associated to the [# Columns] tag
 int getNumRows()
          Returns the value associated to the [# Rows] tag
 java.lang.String getProperty(java.lang.String prop)
          Returs the value of a property of the MetaRaster.
 double getResLat()
          Returns the value associated to the [Latitudinal Resolution (ArcSec)] tag
 double getResLon()
          Returns the value associated to the [Longitudinal Resolution (ArcSec)] tag
 int getTemporalScale()
          Returns the value associated to the [Temporal Resolution] tag in milliseconds or -1 if "fix"
 java.lang.String getUnits()
          Returns the value associated to the [Units] tag
static void main(java.lang.String[] args)
          Tests for the class
 void restoreOriginalFormat()
          Restores the value of the [Format] tag to its original value if it has been modified using the setFormat(String format) method
 void setFormat(java.lang.String newFormat)
          Sets the value for the [Format] tag
 void setInformation(java.lang.String newInformation)
          Sets the value of the [Information] tag
 void setLocationBinaryFile(java.io.File file)
          Sets the path of the binary file assicitated with the information of the MetaRaster.
 void setLocationMeta(java.io.File file)
          Sets the path where the metaFile resides.
 void setMinLat(java.lang.String newMinLat)
          Sets the value for the [Southernmost Latitude] tag
 void setMinLon(java.lang.String newMinLon)
          Sets the value for the [Westernmost Longitude] tag
 void setMissing(java.lang.String newMissinng)
          Sets the value for the [Missing] tag
 void setName(java.lang.String newName)
          Sets the value for the [Name] tag
 void setNumCols(int newNumCols)
          Sets the value for the [# Columns] tag
 void setNumRows(int newNumRows)
          Sets the value for the [# Rows] tag
 void setResLat(double newResLat)
          Sets the value for the [Latitudinal Resolution (ArcSec)] tag
 void setResLon(double newResLon)
          Sets the value for the [Longitudinal Resolution (ArcSec)] tag
 void setTemporalScale(java.lang.String tempScale)
          Sets the value for the [Temporal Resolution] tag
 void setUnits(java.lang.String newUnits)
          Sets the value of the [Units] tag
 java.lang.String toString()
          Creates a String that describes the information in the meta file
 void writeMetaRaster(java.io.File newMetaLocation)
          Writes the information in the MetaRaster to the specified path
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MetaRaster

public MetaRaster(MetaRaster mr)
Creates new MetaRaster using another metaRaster as a template

Parameters:
mr - The MetaRaster to be used as template

MetaRaster

public MetaRaster()
Creates an empty MetaRaster instance


MetaRaster

public MetaRaster(java.io.File file)
           throws java.io.IOException
Creates a MetaRaster instance using the information on a file. The file must contain tags and information for each tag. File formats are descibed in the Developer's Manual.

Parameters:
file - The file that contains the information that describes associated binary files
Throws:
java.io.IOException - Captures errors while reading the meta file
Method Detail

toString

public java.lang.String toString()
Creates a String that describes the information in the meta file

Overrides:
toString in class java.lang.Object
Returns:
A string describing the information

setLocationMeta

public void setLocationMeta(java.io.File file)
Sets the path where the metaFile resides. This method is useful when an empty MetaRaster is created and it is necesary to sprcify the path where the meta file will be writen

Parameters:
file - The file where the meta file resides

setLocationBinaryFile

public void setLocationBinaryFile(java.io.File file)
Sets the path of the binary file assicitated with the information of the MetaRaster.

Parameters:
file - The path to the binary file

setName

public void setName(java.lang.String newName)
Sets the value for the [Name] tag

Parameters:
newName - The new name to assign to the information

setMinLat

public void setMinLat(java.lang.String newMinLat)
Sets the value for the [Southernmost Latitude] tag

Parameters:
newMinLat - A properly formated string DD:MM:SS.SS [N/S]. See DegreesToDMS for a static methods format geographic position descriptors.

setMinLon

public void setMinLon(java.lang.String newMinLon)
Sets the value for the [Westernmost Longitude] tag

Parameters:
newMinLon - A properly formated string DD:MM:SS.SS [N/S]. See DegreesToDMS for a static methods format geographic position descriptors.

setResLat

public void setResLat(double newResLat)
Sets the value for the [Latitudinal Resolution (ArcSec)] tag

Parameters:
newResLat - A double precision number indicating the Latitudinal resolution (vertical pixel size) in ArcSeconds

setResLon

public void setResLon(double newResLon)
Sets the value for the [Longitudinal Resolution (ArcSec)] tag

Parameters:
newResLon - A double precision number indicating the Longitudinal resolution (vertical pixel size) in ArcSeconds

setNumCols

public void setNumCols(int newNumCols)
Sets the value for the [# Columns] tag

Parameters:
newNumCols - A integer indicating the number of Columns in the raster binary file

setNumRows

public void setNumRows(int newNumRows)
Sets the value for the [# Rows] tag

Parameters:
newNumRows - A integer indicating the number of Rows in the raster binary file

setFormat

public void setFormat(java.lang.String newFormat)
Sets the value for the [Format] tag

Parameters:
newFormat - A String indicating the format of the raster binary file. Available formats are: Byte, Integer, Float and Double.

setMissing

public void setMissing(java.lang.String newMissinng)
Sets the value for the [Missing] tag

Parameters:
newMissinng - A number indicating missing information in the binary file

restoreOriginalFormat

public void restoreOriginalFormat()
Restores the value of the [Format] tag to its original value if it has been modified using the setFormat(String format) method


setTemporalScale

public void setTemporalScale(java.lang.String tempScale)
Sets the value for the [Temporal Resolution] tag

Parameters:
tempScale - A string describing the temporal resolution. It can be Fix for spatial variables with no temporal variability (e.g. a digital elevation model) or a number followed by a time descriptor (e.g. 1-minute, 20-hours, 1-year, etc)

setUnits

public void setUnits(java.lang.String newUnits)
Sets the value of the [Units] tag

Parameters:
newUnits - A string describing the units of the information

setInformation

public void setInformation(java.lang.String newInformation)
Sets the value of the [Information] tag

Parameters:
newInformation - A string describing the information

getLocationMeta

public java.io.File getLocationMeta()
Returns a java.io.File object pointing to the location of the meta file

Returns:
A java.io.File

getLocationBinaryFile

public java.io.File getLocationBinaryFile()
Returns a java.io.File object pointing to the location of the binary file described by this MetaRaster

Returns:
a java.io.File

getProperty

public java.lang.String getProperty(java.lang.String prop)
Returs the value of a property of the MetaRaster. Available properites are:

[Name]

[Southernmost Latitude]

[Westernmost Longitude]

[Longitudinal Resolution (ArcSec)]

[Latitudinal Resolution (ArcSec)]

[# Columns][# Rows]

[Format]

[Missing]

[Temporal Resolution]

[Units]

[Information]

Parameters:
prop - The tag of the desired property
Returns:
The value of the property

getMissing

public java.lang.String getMissing()
Returns the value associated to the [Missing] tag

Returns:
A String that can be parsed into the same format of the data

getFormat

public java.lang.String getFormat()
Returns the value associated to the [Format] tag

Returns:
A string with the format of the variable

getUnits

public java.lang.String getUnits()
Returns the value associated to the [Units] tag

Returns:
A string with the units of the variable

getCategory

public java.lang.String getCategory(java.lang.String catToFind)
Returns the lable associated to a category type

Parameters:
catToFind - The category to find
Returns:
A string desciging the category type

getCategoriesTable

public java.util.Hashtable getCategoriesTable()
Returns the Hashtable of categories for this variable

Returns:
A Hashtable with cagegories

getNumRows

public int getNumRows()
Returns the value associated to the [# Rows] tag

Returns:
An integer number with the number of Rows

getNumCols

public int getNumCols()
Returns the value associated to the [# Columns] tag

Returns:
An integer number with the number of Columns

getMinLat

public double getMinLat()
Returns the value associated to the [Southernmost Latitude] tag. This method uses the DMSToDegrees static method

Returns:
A double with the suthermost latitude in degrees

getMinLon

public double getMinLon()
Returns the value associated to the [Westernmost Longitude] tag. This method uses the DMSToDegrees static method

Returns:
A double with the Westernmost Longitude in degrees

getResLat

public double getResLat()
Returns the value associated to the [Latitudinal Resolution (ArcSec)] tag

Returns:
A double with the latitudinal resolution

getResLon

public double getResLon()
Returns the value associated to the [Longitudinal Resolution (ArcSec)] tag

Returns:
A double with the longitudinal resolution

getMaxLat

public double getMaxLat()
Calculates and returns the maximum latitude

Returns:
A double with the northermost latitude in degrees

getMaxLon

public double getMaxLon()
Calculates and returns the maximum longitude

Returns:
A double with the easternrnmost longitude in degrees

getName

public java.lang.String getName()
Returns the value associated to the [Name] tag

Returns:
A string with map name

getTemporalScale

public int getTemporalScale()
Returns the value associated to the [Temporal Resolution] tag in milliseconds or -1 if "fix"

Returns:
A double indicating the time resolution in milliseconds

getArray

public float[][] getArray()
                   throws java.io.IOException
Returns a float[][] array with the infomation contained in the binary file

Returns:
A float[numRows][numCols]
Throws:
java.io.IOException - Captures errors while reading the binary file

getField

public visad.FlatField getField()
                         throws visad.VisADException,
                                java.io.IOException
Returns visad.FlatField appropriate for a visad.Display

Returns:
A visad.FlatField
Throws:
visad.VisADException - Captures errors while creating the visad Data object
java.io.IOException - Captures errors while reading the information

writeMetaRaster

public void writeMetaRaster(java.io.File newMetaLocation)
                     throws java.io.IOException
Writes the information in the MetaRaster to the specified path

Parameters:
newMetaLocation - The path where the metafile must be writen
Throws:
java.io.IOException - Captures errors while writing the information

cloneProperties

public java.util.Hashtable cloneProperties()
clones the Hashtable that contains the MetaRaster properties

Returns:
A Hashtable

main

public static void main(java.lang.String[] args)
Tests for the class

Parameters:
args - Command line arguments


CUENCAS was initially developed by Ricardo Mantilla at the University of Colorado under the supervision of Dr. Vijay K. Gupta. We wish to recognize the support from the National Science Fundation.