jwo.landserf.structure
Class VectorMap

java.lang.Object
  |
  +--jwo.landserf.structure.VectorMap

public class VectorMap
extends Object

Class for holding a vector map layer and supplementary information. Includes a header with georeferenced boundaries. This is the basic vector layer class that includes file input/output methods, but no analysis or visualisation. It includes topological connections for Delaunay triangulation.

Version:
1.8.0, 7th May, 2000.
Author:
Jo Wood

Field Summary
static float OUT_OF_BOUNDS
          Indiciates coordinate outside map's boundaries.
protected  DelaunayTriang triangulation
          Triangulation topology.
protected  ColourTable vectColours
          Colour table associated with vector map.
protected  VectHeader vectHead
          Vector header (outer boundaries etc.)
protected  Vector vectObjects
          1D array of vector objects (points, lines etc.
 
Constructor Summary
VectorMap()
          Creates a minimal empty vector map.
VectorMap(double north, double south, double east, double west)
          Creates an empty vector map with given dimensions.
VectorMap(float[] x, float[] y, float[] z, int type)
          Creates a vector map based on the given arrays of coordinates.
VectorMap(float[] x, float[] y, int type)
          Creates a vector map based on the given arrays of coordinates.
VectorMap(RastSurf rast)
          Creates vector map based around the dimensions of a raster.
VectorMap(VectorMap oldVectMap)
          Creates a copy of an existing vector map.
 
Method Summary
 void addPoint(float x, float y)
          Adds a vector point object to the current list.
 void addPoint(float x, float y, float z)
          Adds a vector point object with attribute to the current list.
 void addVectorObject(VectorObject vectObject)
          Adds a vector object to the current list.
 void createTinVector()
          Creates a vector map from current triangulation topology.
 void createTinVector(DelaunayTriang triangulation)
          Creates a vector map from the given Triangulation topology.
 float getAttribute(double x, double y)
          Returns the attribute value at given georeferenced coordinates.
 ColourTable getColourTable()
          Returns colour table associated with vector map.
 double getEast()
          Returns the eastern edge of the vector map.
 VectHeader getHeader()
          Returns header information associated with vector map.
 float getMax()
          Returns the maximum attribute value associated with the vector map.
 float getMin()
          Returns the minimum attribute value associated with the vector map.
 double getNorth()
          Returns the northern edge of the vector map.
 String getNotes()
          Returns the supplementary notes associated with the vector map.
 int getNumObjects()
          Returns the number of vector objects associated with the vector map.
 double getSouth()
          Returns the southern edge of the vector map.
 String getTitle()
          Returns the title of the vector map.
 DelaunayTriang getTriangulation()
          Returns the triangulation topology associated with vector map.
 VectorMap getVectorMap()
          Returns this VectorMap object (used for subclasses that need to identify their superclass).
 VectorObject getVectorObjectAt(int i)
          Gets a vector object at a given position in the list.
 Vector getVectorObjects()
          Returns the vector objects associated with the vector map.
 float getVersion()
          Reports the version of the vector map.
 double getWest()
          Returns the western edge of the vector map.
 boolean readFile(String fileName, int fileType)
          Reads one or more files and places the contents into the current vector map object.
 boolean readFile(String fileName, String attribName, int fileType)
          Reads one or more files and places the contents into the current vector map object.
 void removeVectorObject(VectorObject vectObj)
          Removes the given vector object from the map.
 void removeVectorObjectAt(int i)
          Removes vector object at the given position in the list.
 void removeVectorObjects()
          Removes all vector objects stored in map.
 void setColourTable(ColourTable ct)
          Sets the colour table assocaited with vector map.
 void setEast(double e)
          Sets the vector map eastern boundary.
 void setHeader(VectHeader newHeader)
          Sets the header information associated with vector map.
 void setNorth(double n)
          Sets the vector map northern boundary.
 void setNotes(String notes)
          Create notes to be associated with the vector map.
 void setSouth(double s)
          Sets the vector map southern boundary.
 void setTitle(String title)
          Sets the title of the vector map.
 void setTriangulation(DelaunayTriang triangulation)
          Sets the triangulation topology associated with vector map.
 void setVectorObjects(Vector newObjects)
          Sets the vector objects associated with the vector map.
 void setVersion(float version)
          Sets the version number of the vector map.
 void setWest(double w)
          Sets the vector map western boundary.
 void updateBounds()
          Updates the vector map with the minimum enclosing rectangle of the vector objects stored in this vector map.
 boolean writeFile(String fileName, int fileType)
          Writes the contents of the vector and supplementary information to a single file.
 boolean writeFile(String fileName, String attribName, int fileType)
          Writes the contents of the vector and supplementary information to one or more files.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

vectHead

protected VectHeader vectHead
Vector header (outer boundaries etc.)


vectObjects

protected Vector vectObjects
1D array of vector objects (points, lines etc.


vectColours

protected ColourTable vectColours
Colour table associated with vector map.


triangulation

protected DelaunayTriang triangulation
Triangulation topology.


OUT_OF_BOUNDS

public static final float OUT_OF_BOUNDS
Indiciates coordinate outside map's boundaries.

See Also:
Constant Field Values
Constructor Detail

VectorMap

public VectorMap()
Creates a minimal empty vector map.


VectorMap

public VectorMap(RastSurf rast)
Creates vector map based around the dimensions of a raster.

Parameters:
rast - Raster used to set vector map dimensions.

VectorMap

public VectorMap(double north,
                 double south,
                 double east,
                 double west)
Creates an empty vector map with given dimensions.

Parameters:
north - Northern boundary of vector map.
south - Southern boundary of vector map.
east - Eastern boundary of vector map.
west - Western boundary of vector map.

VectorMap

public VectorMap(float[] x,
                 float[] y,
                 int type)
Creates a vector map based on the given arrays of coordinates.

Parameters:
x - Array holding x coordinates.
y - Array holding y coordinates.
type - Type of vector feature (VectorObject.POINT, VectorObject.LINE).

VectorMap

public VectorMap(float[] x,
                 float[] y,
                 float[] z,
                 int type)
Creates a vector map based on the given arrays of coordinates.

Parameters:
x - Array holding x coordinates.
y - Array holding y coordinates.
z - Array holding z coordinates.
type - Type of vector feature (VectorObject.POINT, VectorObject.LINE).

VectorMap

public VectorMap(VectorMap oldVectMap)
Creates a copy of an existing vector map.

Parameters:
oldVectMap - Original vector map to copy.
Method Detail

updateBounds

public void updateBounds()
Updates the vector map with the minimum enclosing rectangle of the vector objects stored in this vector map.


removeVectorObjects

public void removeVectorObjects()
Removes all vector objects stored in map. This method can be called when resources need to be freed.


createTinVector

public void createTinVector(DelaunayTriang triangulation)
Creates a vector map from the given Triangulation topology.

Parameters:
triangulation - Triangulation topology.

createTinVector

public void createTinVector()
Creates a vector map from current triangulation topology.


writeFile

public boolean writeFile(String fileName,
                         int fileType)
Writes the contents of the vector and supplementary information to a single file.

Parameters:
fileName - Name to save file under.
fileType - Type of file format to save.
Returns:
Boolean value depending on success.

writeFile

public boolean writeFile(String fileName,
                         String attribName,
                         int fileType)
Writes the contents of the vector and supplementary information to one or more files.

Parameters:
fileName - Name to save file under.
attribName - Name of file containing attributes.
fileType - Type of file format to save.
Returns:
Boolean value depending on success.

readFile

public boolean readFile(String fileName,
                        int fileType)
Reads one or more files and places the contents into the current vector map object.

Parameters:
fileName - Name of file containing geometry to read.
fileType - Type of file format to read.
Returns:
Boolean value depending on success.

readFile

public boolean readFile(String fileName,
                        String attribName,
                        int fileType)
Reads one or more files and places the contents into the current vector map object.

Parameters:
fileName - Name of file containing geometry to read.
attribName - Name of file containing attributes to read.
fileType - Type of file format to read.
Returns:
Boolean value depending on success.

addVectorObject

public void addVectorObject(VectorObject vectObject)
Adds a vector object to the current list.


removeVectorObjectAt

public void removeVectorObjectAt(int i)
Removes vector object at the given position in the list.

Parameters:
i - Position in list to remove.

removeVectorObject

public void removeVectorObject(VectorObject vectObj)
Removes the given vector object from the map.

Parameters:
vectObj - Vector object to remove.

addPoint

public void addPoint(float x,
                     float y)
Adds a vector point object to the current list. Gives a default attribute of 0 to the point.

Parameters:
x - x coordinate of the point to add.
y - y coordinate of the point to add.

addPoint

public void addPoint(float x,
                     float y,
                     float z)
Adds a vector point object with attribute to the current list.

Parameters:
x - x coordinate of the point to add.
y - y coordinate of the point to add.
z - z attribute of the point to add.

getVectorMap

public VectorMap getVectorMap()
Returns this VectorMap object (used for subclasses that need to identify their superclass).

Returns:
Vector map object.

getHeader

public VectHeader getHeader()
Returns header information associated with vector map. This is only needed for classes that use the serialized header. To manipulate parts of the header, call the methods inside VectorMap (this class) instead.

Returns:
Vector map header information.

getVectorObjects

public Vector getVectorObjects()
Returns the vector objects associated with the vector map.

Returns:
A java vector (1D array) of vector objects.

getNumObjects

public int getNumObjects()
Returns the number of vector objects associated with the vector map.

Returns:
Number of vector objectsin map.

getVectorObjectAt

public VectorObject getVectorObjectAt(int i)
Gets a vector object at a given position in the list.

Parameters:
i - The position in the list to extract vector object.
Returns:
Vector object at position i in the list.

getTitle

public String getTitle()
Returns the title of the vector map.

Returns:
Vector map title.

getNotes

public String getNotes()
Returns the supplementary notes associated with the vector map.

Returns:
Vector map notes.

getNorth

public double getNorth()
Returns the northern edge of the vector map.

Returns:
Northern boundary.

getSouth

public double getSouth()
Returns the southern edge of the vector map.

Returns:
Southern boundary.

getEast

public double getEast()
Returns the eastern edge of the vector map.

Returns:
Eastern boundary.

getWest

public double getWest()
Returns the western edge of the vector map.

Returns:
Western boundary.

getMax

public float getMax()
Returns the maximum attribute value associated with the vector map.

Returns:
Maximum attribute value

getMin

public float getMin()
Returns the minimum attribute value associated with the vector map.

Returns:
Minimum attribute value

getAttribute

public float getAttribute(double x,
                          double y)
Returns the attribute value at given georeferenced coordinates. Looks to see if point is inside a polygon, if not, it finds the nearest point or line. NOTE: This only compares points at present, retuning OUT_OF_BOUNDS if no point value matches coorinates.

Parameters:
x - X coordinate of the location to interrogate.
y - Y coordinate of the location to interrogate.
Returns:
Attribute value, or OUT_OF_BOUNDS if coordinates are out of bounds.

getTriangulation

public DelaunayTriang getTriangulation()
Returns the triangulation topology associated with vector map.

Returns:
Triangulation topology.

getColourTable

public ColourTable getColourTable()
Returns colour table associated with vector map.

Returns:
Vector map colour table.

getVersion

public float getVersion()
Reports the version of the vector map. This can be used for reading serialized VectorObjects that may be changed in the future. Returns 0 if map has no vector objects.

Returns:
Version number of the vector map.

setHeader

public void setHeader(VectHeader newHeader)
Sets the header information associated with vector map. This is only needed for classes that use the serialized header. To manipulate parts of the header, call the methods inside VectorMap (this class) instead.

Parameters:
newHeader - New vector map header information.

setVectorObjects

public void setVectorObjects(Vector newObjects)
Sets the vector objects associated with the vector map.

Parameters:
newObjects - A java vector (1D array) of vector objects.

setTitle

public void setTitle(String title)
Sets the title of the vector map.

Parameters:
title - New vector map title.

setNotes

public void setNotes(String notes)
Create notes to be associated with the vector map.

Parameters:
notes - New vector map notes.

setNorth

public void setNorth(double n)
Sets the vector map northern boundary.

Parameters:
n - Northern boundary

setSouth

public void setSouth(double s)
Sets the vector map southern boundary.

Parameters:
s - Southern boundary

setEast

public void setEast(double e)
Sets the vector map eastern boundary.

Parameters:
e - Eastern boundary

setWest

public void setWest(double w)
Sets the vector map western boundary.

Parameters:
w - Western boundary

setTriangulation

public void setTriangulation(DelaunayTriang triangulation)
Sets the triangulation topology associated with vector map.

Parameters:
triangulation - Triangulation topology to associate with vector.

setColourTable

public void setColourTable(ColourTable ct)
Sets the colour table assocaited with vector map.

Parameters:
ct - New colour table to associate with vector

setVersion

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

Parameters:
version - Version number of the vector map.