jwo.landserf.structure
Class VectorObject

java.lang.Object
  |
  +--jwo.landserf.structure.VectorObject
All Implemented Interfaces:
Serializable

public class VectorObject
extends Object
implements Serializable

Class for storing single vector objects (points, lines or areas). Stores (x,y) pairs and object type (POINT, LINE, AREA, FLOW and TIN) and the object's single attribute.

Version:
1.8.0, 23rd August, 2000.
Author:
Jo Wood
See Also:
Serialized Form

Field Summary
static int AREA
          Area vector type.
static int FLOW
          Flow vector type.
static int LINE
          Line vector type.
static int POINT
          Point vector type.
static int TIN
          Triangulated Irregular Network vector type.
 
Constructor Summary
VectorObject()
          Constructs a minimal vector object.
VectorObject(float[] x, float[] y, int n, int type, float attrib)
          Constructs a vector object based on coordinate arrays.
VectorObject(VectorObject oldVectorObject)
          Constructs a copy of an existing vector object.
 
Method Summary
 float getAttribute()
          Reports the attribute of the vector object.
 Vector getIntersections(VectorObject otherObject)
          Reports whether this object intersects with the given object.
 Vector getIntersections(VectorObject otherObject, boolean interior)
          Reports the intersections beteen this and the given object.
 JWRectangle getMER()
          Reports the minimum enclosing rectangle of a vector object.
 int getNumCoords()
          Returns the number of coordinate in the vector object.
 int getType()
          Reports the type of vector object (POINT, LINE etc.).
 float getVersion()
          Reports the version of the object.
 float[] getX()
          Returns the array of X coordinates making up the vector object.
 float[] getY()
          Returns the array of Y coordinates making up the vector object.
 float[] getZ()
          Returns the array of Z coordinates making up the vector object.
 void initZ()
          Initialise the 'z' coordinates of the vector.
 boolean replaceFirstCoord(float xCoord, float yCoord)
          Replaces the first coordinate pair with the given pair of coordinates.
 boolean replaceLastCoord(float xCoord, float yCoord)
          Replaces the last coordinate pair with the given pair of coordinates.
 void reverse()
          Reveses the order of coordinates making up the object.
 void setAttribute(float attribute)
          Sets the attribute associated with the vector object.
 void setNumCoords(int numCoords)
          Sets the number of coordinate in the vector object to a given value.
 void setType(int type)
          Sets the type of vector object (POINT, LINE etc.).
 void setVersion(float version)
          Sets the version number of the object.
 void setX(float[] x)
          Stores an array of X coordinates making up the vector object.
 void setY(float[] y)
          Stores an array of Y coordinates making up the vector object.
 void setZ(float[] z)
          Stores an array of Z coordinates making up the vector object.
 Vector split(VectorObject otherObject)
          Splits this object into two new ones around the given object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POINT

public static final int POINT
Point vector type.

See Also:
Constant Field Values

LINE

public static final int LINE
Line vector type.

See Also:
Constant Field Values

AREA

public static final int AREA
Area vector type.

See Also:
Constant Field Values

FLOW

public static final int FLOW
Flow vector type.

See Also:
Constant Field Values

TIN

public static final int TIN
Triangulated Irregular Network vector type.

See Also:
Constant Field Values
Constructor Detail

VectorObject

public VectorObject()
Constructs a minimal vector object.


VectorObject

public VectorObject(VectorObject oldVectorObject)
Constructs a copy of an existing vector object.

Parameters:
oldVectorObject - Vector object to copy.

VectorObject

public VectorObject(float[] x,
                    float[] y,
                    int n,
                    int type,
                    float attrib)
Constructs a vector object based on coordinate arrays.

Parameters:
x - x coordinate array.
y - y coordinate array.
n - Number of coordinates in object.
type - Type of vector object (POINT, LINE, etc.)
attrib - Attribute associated with vector object.
Method Detail

initZ

public void initZ()
Initialise the 'z' coordinates of the vector. A z value can be stored with each vertex allowing the vector to be defined in 3 dimensions, or with a continuously varying attribute (FLOW). To save memory, z values are not initialised by default.


getX

public float[] getX()
Returns the array of X coordinates making up the vector object.

Returns:
X coordinate array.

setX

public void setX(float[] x)
Stores an array of X coordinates making up the vector object.

Parameters:
x - X coordinate array.

getY

public float[] getY()
Returns the array of Y coordinates making up the vector object.

Returns:
Y coordinate array.

setY

public void setY(float[] y)
Stores an array of Y coordinates making up the vector object.

Parameters:
y - Y coordinate array.

getZ

public float[] getZ()
Returns the array of Z coordinates making up the vector object. This will be null of z coordinates have not been initialised with initZ().

Returns:
Z coordinate array.

setZ

public void setZ(float[] z)
Stores an array of Z coordinates making up the vector object.

Parameters:
z - Z coordinate array.

getNumCoords

public int getNumCoords()
Returns the number of coordinate in the vector object.

Returns:
Number of coordinates in vector object.

setNumCoords

public void setNumCoords(int numCoords)
Sets the number of coordinate in the vector object to a given value.

Parameters:
numCoords - Number of coordinates in vector object.

getType

public int getType()
Reports the type of vector object (POINT, LINE etc.).

Returns:
Vector object type (POINT, LINE etc.).

setType

public void setType(int type)
Sets the type of vector object (POINT, LINE etc.).

Parameters:
type - Vector object type.

getAttribute

public float getAttribute()
Reports the attribute of the vector object.

Returns:
Vector object attribute.

setAttribute

public void setAttribute(float attribute)
Sets the attribute associated with the vector object.

Parameters:
attribute - Vector object attribute.

getMER

public JWRectangle getMER()
Reports the minimum enclosing rectangle of a vector object. Returns a rectangle with 0 width and height for a point object.

Returns:
MER of vector object.

split

public Vector split(VectorObject otherObject)
Splits this object into two new ones around the given object. Note, this currently only works if this object is a line, and the given object is a point.

Parameters:
otherObject - Vector object (point) about which to split.
Returns:
The split objects (should be two if point lies on the line).

reverse

public void reverse()
Reveses the order of coordinates making up the object. This can be used by processes that need to store vector objects with a given direction.


replaceFirstCoord

public boolean replaceFirstCoord(float xCoord,
                                 float yCoord)
Replaces the first coordinate pair with the given pair of coordinates. If object is a point, nothing is changed and false is returned.

Parameters:
xCoord - xCoordinate to replace existing one.
yCoord - yCoordinate to replace existing one.
Returns:
True if coordinates successfully replaced.

replaceLastCoord

public boolean replaceLastCoord(float xCoord,
                                float yCoord)
Replaces the last coordinate pair with the given pair of coordinates. If object is a point, nothing is changed and false is returned.

Parameters:
xCoord - xCoordinate to replace existing one.
yCoord - yCoordinate to replace existing one.
Returns:
True if coordinates successfully replaced.

getIntersections

public Vector getIntersections(VectorObject otherObject)
Reports whether this object intersects with the given object. This is a 2d operation that ignores the z values of both objects.

Parameters:
otherObject - Vector object with which to make comparison.
Returns:
A list of vector objects representing intersection, or null if no intersection.

getIntersections

public Vector getIntersections(VectorObject otherObject,
                               boolean interior)
Reports the intersections beteen this and the given object. This is a 2d operation that ignores the z values of both objects.

Parameters:
otherObject - Vector object with which to make comparison.
interior - Ignores endpoints of lines if true.
Returns:
A list of vector objects representing intersection, or null if no intersection.

getVersion

public float getVersion()
Reports the version of the object. This can be used for reading serialized VectorObjects that may be changed in the future.

Returns:
Version number of the vector object.

setVersion

public void setVersion(float version)
Sets the version number of the object.

Parameters:
version - Version number of the vector object.