uchicago.src.sim.space
Class RasterSpace

java.lang.Object
  extended by uchicago.src.sim.space.RasterSpace
All Implemented Interfaces:
java.io.Serializable, Discrete2DSpace

public class RasterSpace
extends java.lang.Object
implements java.io.Serializable, Discrete2DSpace

A class that represents a raster image as a space. This is designed to be used in conjunction with a GIS system such as ESRI ArcGis or GRASS. The raster image is treated as a continuous system of coordinates with cells that hold values underlying. Much of the code for reading the ESRI ASCII Raster format is based on code by Ian Turton Centre for Computational Geography University of Leeds, LS2 9Jt, 1998.
i.turton@geog.leeds.ac.uk, as included in GeoTools, an open source gis visualization framework.

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface uchicago.src.sim.space.Discrete2DSpace
MOORE, VON_NEUMANN
 
Constructor Summary
RasterSpace(double left, double bottom, double right, double top, double cellSize, int w, int h)
          Constructs an empty RasterSpace.
RasterSpace(double top, double left, double cellSize, int w, int h)
          Constructs an empty RasterSpace.
RasterSpace(java.io.InputStream stream)
          Creates a RasterSpace from an ESRI ASCII Raster file connected to the specified input stream.
RasterSpace(java.lang.String name)
          Creates a RasterSpace from an ESRI ASCII Raster file.
 
Method Summary
 int getCellCol(double x)
           
 int getCellRow(double y)
           
 double getCellSize()
           
 BaseMatrix getMatrix()
          Gets the matrix collection class that contains all the values
 java.lang.Object getObjectAt(double x, double y)
          Return the object at a coordinate point.
 java.lang.Object getObjectAt(int x, int y)
          Return the object at an integer point.
 double getOriginX()
           
 double getOriginY()
           
 java.awt.Dimension getSize()
          Gets the dimension of the space
 int getSizeX()
          Gets the size of the x dimension
 int getSizeY()
          Gets the size of the y dimension
 double getTermX()
           
 double getTermY()
           
 double getValueAt(double x, double y)
          Get the value at a coordinate point.
 double getValueAt(int x, int y)
          Get the value at an integer point.
 boolean onSurface(double x, double y)
          Determines if a set of coordinates is on the raster.
 void putObjectAt(double x, double y, java.lang.Object object)
          Put an object at a coordinate point.
 void putObjectAt(int x, int y, java.lang.Object object)
          Put an object at an integer point.
 void putValueAt(double x, double y, double value)
          Put a value at a coordinate point.
 void putValueAt(int x, int y, double value)
          Put a value at an integer point.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RasterSpace

public RasterSpace(double top,
                   double left,
                   double cellSize,
                   int w,
                   int h)
Constructs an empty RasterSpace.

Parameters:
top - The uppermost y coordinate
left - The leftmost x coordinate
cellSize - The size of a raster cell
h - The height of the space
w - The width of the space

RasterSpace

public RasterSpace(double left,
                   double bottom,
                   double right,
                   double top,
                   double cellSize,
                   int w,
                   int h)
Constructs an empty RasterSpace.

Parameters:
left - The westernmost x coordinate
bottom - The southernmost y coordinate
right - The easternmost x coordinate
top - The northernmost y coordinate
cellSize - The size of the raster cell

RasterSpace

public RasterSpace(java.lang.String name)
            throws java.io.IOException
Creates a RasterSpace from an ESRI ASCII Raster file.

Parameters:
name - The name of the ESRI ASCII raster file.
Throws:
java.io.IOException - if there is a problem reading the file

RasterSpace

public RasterSpace(java.io.InputStream stream)
            throws java.io.IOException
Creates a RasterSpace from an ESRI ASCII Raster file connected to the specified input stream.

Parameters:
stream - The input stream for the raster file of the ESRI ASCII raster file.
Throws:
java.io.IOException - if there is a problem reading from the stream
Method Detail

onSurface

public final boolean onSurface(double x,
                               double y)
Determines if a set of coordinates is on the raster.


getCellRow

public final int getCellRow(double y)

getCellCol

public final int getCellCol(double x)

getMatrix

public BaseMatrix getMatrix()
Description copied from interface: Discrete2DSpace
Gets the matrix collection class that contains all the values

Specified by:
getMatrix in interface Discrete2DSpace

getOriginX

public double getOriginX()

getOriginY

public double getOriginY()

getTermX

public double getTermX()

getTermY

public double getTermY()

getObjectAt

public java.lang.Object getObjectAt(int x,
                                    int y)
Return the object at an integer point.

Specified by:
getObjectAt in interface Discrete2DSpace
Parameters:
x - The column
y - The Row
Returns:
the Object at x,y

getObjectAt

public java.lang.Object getObjectAt(double x,
                                    double y)
Return the object at a coordinate point.

Parameters:
x - The x coordinate
y - The y cooredinate

getSize

public java.awt.Dimension getSize()
Description copied from interface: Discrete2DSpace
Gets the dimension of the space

Specified by:
getSize in interface Discrete2DSpace

getSizeX

public int getSizeX()
Description copied from interface: Discrete2DSpace
Gets the size of the x dimension

Specified by:
getSizeX in interface Discrete2DSpace

getSizeY

public int getSizeY()
Description copied from interface: Discrete2DSpace
Gets the size of the y dimension

Specified by:
getSizeY in interface Discrete2DSpace

getValueAt

public double getValueAt(int x,
                         int y)
Get the value at an integer point.

Specified by:
getValueAt in interface Discrete2DSpace
Parameters:
x - The column
y - The row
Returns:
the value at x, y

getValueAt

public double getValueAt(double x,
                         double y)
Get the value at a coordinate point.

Parameters:
x - The x coordinate
y - The y coordinate

putObjectAt

public void putObjectAt(int x,
                        int y,
                        java.lang.Object object)
Put an object at an integer point.

Specified by:
putObjectAt in interface Discrete2DSpace
Parameters:
x - The column
y - The row
object - the object to put

putObjectAt

public void putObjectAt(double x,
                        double y,
                        java.lang.Object object)
Put an object at a coordinate point.

Parameters:
x - The x coordinate
y - The y coordinate

putValueAt

public void putValueAt(int x,
                       int y,
                       double value)
Put a value at an integer point.

Specified by:
putValueAt in interface Discrete2DSpace
Parameters:
x - The column
y - The row
value - the value to put at x,y

putValueAt

public void putValueAt(double x,
                       double y,
                       double value)
Put a value at a coordinate point.

Parameters:
x - The x coordinate
y - The y coordinate

getCellSize

public double getCellSize()