jwo.landserf.structure
Class SpatialObject

java.lang.Object
  extended by jwo.landserf.structure.SpatialObject
All Implemented Interfaces:
Serializable, SpatialModel
Direct Known Subclasses:
DummySpatialObject, GISVector, RasterMap, VectorMap

public abstract class SpatialObject
extends Object
implements SpatialModel, Serializable

Class for defining spatial objects. All such spatial objects have some geographical footprint and can compare themselves with other geographical footprints. The also have a colour table associated with them for display.

Version:
2.3, 13th May, 2006.
Author:
Jo Wood
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface jwo.landserf.structure.SpatialModel
ADJACENT, AREA, CONTOUR, ENCLOSES, INTERSECTION, LINE, MATCHES, MSN, NO_VALUE, OUT_OF_BOUNDS, OVERLAPS, POINT, RASTER_2D, RASTER_3D, SEPARATE, TIN, UNDEFINED, UNION, UNKNOWN, UNKNOWN_MODEL, VECTOR_2D, VECTOR_3D, VOLUME, WITHIN
 
Constructor Summary
SpatialObject()
          Creates a spatial object with a default spatial footprint.
SpatialObject(Footprint footprint)
          Creates an spatial object with the given spatial footprint.
SpatialObject(Footprint footprint, Header header)
          Creates an spatial object with the given spatial footprint and header.
SpatialObject(SpatialObject oldSpatialObject)
          Creates a spatial object based on the attributes of the given one.
 
Method Summary
 int compare(SpatialModel other)
          Makes a spatial comparison between this object and another.
abstract  float getAttribute(Footprint location)
          Should report the attribute of the model at the given location.
 AttributeTable getAttributeTable()
          Returns optional attribute table associated with this object or null if one has not been created.
 Footprint getBounds()
          Returns the 2d bounding rectangle of the object.
 ColourTable getColourTable()
          Returns colour table associated with this object.
static String getComparisonText(int comparison)
          Reports a textual representation of the given comparison type.
 Header getHeader()
          Reports the header information associated with this object.
abstract  void getImage(int[] img, int imgWidth)
          Should convert the spatial object into colour image for display.
 Footprint getIntersectionMER(Footprint otherFp)
          Calculates the the intersection of the given footprint with this MER.
abstract  float getMaxAttribute()
          Should report the maximum attribute value of the object.
abstract  float getMinAttribute()
          Should report the minimum attribute value of the object.
 Projection getProjection()
          Reports the projection information used by this spatial object.
 int getType()
          Reports the type of spatial object.
 String getTypeName()
          Name describing the this spatial object type.
static String getTypeName(int vectType)
          Name describing the given spatial object type.
 Footprint getUnionMER(Footprint otherFp)
          Calculates the MER of the union of the given footprint with this MER.
 void move(float xOffset, float yOffset)
          Moves the spatial object relatively by the given x,y coordinates.
 void setAttributeTable(AttributeTable aTable)
          Sets the attribute table associated with this object.
 void setBounds(Footprint footprint)
          Sets the bounding rectangle of this object.
 void setColourTable(ColourTable cTable)
          Sets the colour table associated with this object.
 void setHeader(Header newHeader)
          Sets a new the header to be associated with this object.
 void setProjection(Projection projection)
          Sets the projection information to be used by this spatial object.
abstract  SpatialModel subset(Footprint bounds)
          Should creates a new spatial model that is clipped to the given bounds.
 String toString()
          Reports the details of this spatial object.
abstract  void updateBounds()
          Should force the object to find its new spatial and attribute bounds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SpatialObject

public SpatialObject()
Creates a spatial object with a default spatial footprint.


SpatialObject

public SpatialObject(Footprint footprint)
Creates an spatial object with the given spatial footprint.

Parameters:
footprint - Spatial footprint of this object.

SpatialObject

public SpatialObject(Footprint footprint,
                     Header header)
Creates an spatial object with the given spatial footprint and header.

Parameters:
footprint - Spatial footprint of this object.
header - Header associated with this spatial object.

SpatialObject

public SpatialObject(SpatialObject oldSpatialObject)
Creates a spatial object based on the attributes of the given one.

Parameters:
oldSpatialObject - Spatial object map to copy.
Method Detail

compare

public int compare(SpatialModel other)
Makes a spatial comparison between this object and another. Assumes that both objects are rectangular.

Specified by:
compare in interface SpatialModel
Parameters:
other - Spatial model with which to make a comparison.
Returns:
One of five topological relations (WITHIN, MATCHES, OVERLAPS, ENCLOSES, or SEPARATE).

getUnionMER

public Footprint getUnionMER(Footprint otherFp)
Calculates the MER of the union of the given footprint with this MER.

Parameters:
otherFp - Footprint of object to union with this MER.
Returns:
Footprint of the minimum enclosing rectangle.

getIntersectionMER

public Footprint getIntersectionMER(Footprint otherFp)
Calculates the the intersection of the given footprint with this MER.

Parameters:
otherFp - Footprint of object to intersect with this MER.
Returns:
Footprint of the intersecting rectangle.

move

public void move(float xOffset,
                 float yOffset)
Moves the spatial object relatively by the given x,y coordinates.

Parameters:
xOffset - Offset in the x direction.
yOffset - Offset in the y direction.

toString

public String toString()
Reports the details of this spatial object.

Overrides:
toString in class Object
Returns:
Summary of this spatial object.

subset

public abstract SpatialModel subset(Footprint bounds)
Should creates a new spatial model that is clipped to the given bounds. Result can be null if the bounds are separate from the model.

Specified by:
subset in interface SpatialModel
Parameters:
bounds - Bounds defining the clipping region.
Returns:
Subset spatial object.

updateBounds

public abstract void updateBounds()
Should force the object to find its new spatial and attribute bounds.


getType

public int getType()
Reports the type of spatial object. Types can be redefined in subclasses, so calls to this method must be aware of the type of class that is being queried in order to interpret the meaning of the type index.

Specified by:
getType in interface SpatialModel
Returns:
Type index of spatial object (e.g. SpatialModel.LINE, SpatialModel.AREA etc.).

getTypeName

public String getTypeName()
Name describing the this spatial object type. This method is often overridden in order for more specific types of spatial object to be defined.

Returns:
Text describing this spatial object type.

getTypeName

public static String getTypeName(int vectType)
Name describing the given spatial object type. This method is often overridden in order for more specific types of spatial object to be defined.

Parameters:
vectType - Type of spatial object. Should be one of SpatialModel.VOLUME / AREA / LINE / POINT.
Returns:
Text describing the spatial object type.

getProjection

public Projection getProjection()
Reports the projection information used by this spatial object.

Returns:
Projection information or possibly null if not defined.

setProjection

public void setProjection(Projection projection)
Sets the projection information to be used by this spatial object.

Parameters:
projection - New projection information to be used.

getAttribute

public abstract float getAttribute(Footprint location)
Should report the attribute of the model at the given location.

Specified by:
getAttribute in interface SpatialModel
Parameters:
location - Location to query.
Returns:
Attribute at given location or NO_VALUE if none defined.

getMinAttribute

public abstract float getMinAttribute()
Should report the minimum attribute value of the object.

Returns:
Minimum attribute value.

getMaxAttribute

public abstract float getMaxAttribute()
Should report the maximum attribute value of the object.

Returns:
Maximum attribute value.

getImage

public abstract void getImage(int[] img,
                              int imgWidth)
Should convert the spatial object into colour image for display. Colours should be based on colour table associated with the object.

Specified by:
getImage in interface SpatialModel
Parameters:
img - Image array to store colours.
imgWidth - Image width.

getHeader

public Header getHeader()
Reports the header information associated with this object.

Specified by:
getHeader in interface SpatialModel
Returns:
Header information (title, copyright etc).

setHeader

public void setHeader(Header newHeader)
Sets a new the header to be associated with this object.

Parameters:
newHeader - New header information (title, copyright etc).

setBounds

public void setBounds(Footprint footprint)
Sets the bounding rectangle of this object.

Specified by:
setBounds in interface SpatialModel
Parameters:
footprint - Spatial footprint to assign to this object.

getBounds

public Footprint getBounds()
Returns the 2d bounding rectangle of the object.

Specified by:
getBounds in interface SpatialModel
Returns:
Minimum enclosing rectangle of object.

getColourTable

public ColourTable getColourTable()
Returns colour table associated with this object.

Returns:
Object's colour table.

setColourTable

public void setColourTable(ColourTable cTable)
Sets the colour table associated with this object.

Parameters:
cTable - New colour table to associate with this object

getAttributeTable

public AttributeTable getAttributeTable()
Returns optional attribute table associated with this object or null if one has not been created. Attribute tables are only needed if each item that makes up a spatial object has more than one value, or if that value is non-numeric.

Returns:
Object's attribute table or null if it does not exist.

setAttributeTable

public void setAttributeTable(AttributeTable aTable)
Sets the attribute table associated with this object. Attribute tables are only needed if each item that makes up a spatial object has more than one value, or if that value is non-numeric.

Parameters:
aTable - New attribute table to associate with this object

getComparisonText

public static String getComparisonText(int comparison)
Reports a textual representation of the given comparison type.

Parameters:
comparison - Type of comparison to query.
Returns:
Text representation of the given comparison.


Copyright Jo Wood, 1996-2009, last modified, 17th April, 2009