hydroScalingAPI.io
Class MetaPolygon

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

public class MetaPolygon
extends java.lang.Object

This class interacts with *.poly files. It reads their contents and produce appropriate outputs for graphic and other purposes.

Author:
Ricardo Mantilla

Constructor Summary
MetaPolygon()
          Creates a new instance of MetaPolygon with an empty set of properties
MetaPolygon(java.io.File file)
          Creates a new instance of MetaPolygon with a set of properties determined by a file
MetaPolygon(java.lang.String file)
          Creates a new instance of MetaPolygon with a set of properties determined by a file
 
Method Summary
 double getAverage(visad.FlatField localField)
          Calculates the average value of a spatially variable field inside the polygon
 java.io.File getLocationMeta()
          Returns the File with information used to create the MetaPolygon
 float[][] getLonLatPolygon()
          Returns a float array with the longitudes and latitudes of the points that describe the polygon
 java.lang.String getName()
          Returns the Name associated with the polygon
 visad.Gridded2DSet getPolygon()
          Creates and returns a visad.Gridded2DSet ready to be added into a visad.Display
 java.lang.String getProperty(java.lang.String prop)
          Returns the value of the property.
static void main(java.lang.String[] args)
          Tests for the class
 void setCoordinates(float[][] newXYCoords)
          Sets the coordinates of the polygon to using a float array
 void setInformation(java.lang.String newInformation)
          Sets the [information] property to the specified value
 void setName(java.lang.String newName)
          Sets the [name] property to the specified value
 java.lang.String toString()
          Returns a string describing this MetaPolygon
 void writeKmlPolygon(java.io.File newKmlLocation)
          Writes an *.kml file in the specified path
 void writePolygon(java.io.File newMetaLocation)
          Writes an *.poly file in the specified path
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MetaPolygon

public MetaPolygon()
Creates a new instance of MetaPolygon with an empty set of properties


MetaPolygon

public MetaPolygon(java.lang.String file)
            throws java.io.IOException
Creates a new instance of MetaPolygon with a set of properties determined by a file

Parameters:
file - A String with the path to the file that contains the properties of the Polygon
Throws:
java.io.IOException - Errors while reading the *.poly file

MetaPolygon

public MetaPolygon(java.io.File file)
            throws java.io.IOException
Creates a new instance of MetaPolygon with a set of properties determined by a file

Parameters:
file - The file that contains the properties of the Polygon
Throws:
java.io.IOException - Errors while reading the *.poly file
Method Detail

getProperty

public java.lang.String getProperty(java.lang.String prop)
Returns the value of the property. Available properties are [name] and [information].

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

getPolygon

public visad.Gridded2DSet getPolygon()
                              throws visad.VisADException
Creates and returns a visad.Gridded2DSet ready to be added into a visad.Display

Returns:
The Gridded2DSet
Throws:
visad.VisADException - Captures errors while creating the Gidded2DSet

getLonLatPolygon

public float[][] getLonLatPolygon()
Returns a float array with the longitudes and latitudes of the points that describe the polygon

Returns:
A float[2][Number of Points]

getName

public java.lang.String getName()
Returns the Name associated with the polygon

Returns:
The Name of the polygon

getLocationMeta

public java.io.File getLocationMeta()
Returns the File with information used to create the MetaPolygon

Returns:
A File descriptor of the origin data

toString

public java.lang.String toString()
Returns a string describing this MetaPolygon

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

setName

public void setName(java.lang.String newName)
Sets the [name] property to the specified value

Parameters:
newName - The value to assign to the [name] field

setCoordinates

public void setCoordinates(float[][] newXYCoords)
Sets the coordinates of the polygon to using a float array

Parameters:
newXYCoords - The array with coordinates

setInformation

public void setInformation(java.lang.String newInformation)
Sets the [information] property to the specified value

Parameters:
newInformation - The value to assign to the [information] field

getAverage

public double getAverage(visad.FlatField localField)
Calculates the average value of a spatially variable field inside the polygon

Parameters:
localField - The visad.FlatField to be integrated

writePolygon

public void writePolygon(java.io.File newMetaLocation)
                  throws java.io.IOException
Writes an *.poly file in the specified path

Parameters:
newMetaLocation - The File descriptor where the information will be written.
Throws:
java.io.IOException - Captures errors while writing the file

writeKmlPolygon

public void writeKmlPolygon(java.io.File newKmlLocation)
                     throws java.io.IOException
Writes an *.kml file in the specified path

Parameters:
newKmlLocation - The File descriptor where the information will be written.
Throws:
java.io.IOException - Captures errors while writing the file

main

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

Parameters:
args - the 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.