jwo.landserf.structure
Class VectorMap

java.lang.Object
  extended byjwo.landserf.structure.SpatialObject
      extended byjwo.landserf.structure.VectorMap
All Implemented Interfaces:
Cloneable, Serializable, SpatialModel

public class VectorMap
extends SpatialObject
implements Cloneable

A collection of GIS vectors that model object boundaries.

Version:
2.2, 5th February, 2005.
Author:
Jo Wood
See Also:
Serialized Form

Field Summary
static int QUALITY
          Indicates a rendering style to maximise quality.
static int SPEED
          Indicates a rendering style to maximise speed.
protected  DelaunayTriang triangulation
          Triangulation topology.
 
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_MODEL, VECTOR_2D, VECTOR_3D, VOLUME, WITHIN
 
Constructor Summary
VectorMap()
          Creates an empty vector map with default characteristics.
VectorMap(Footprint fp, Header header)
          Creates an empty vector map with a given footprint and header.
VectorMap(GISVector gisVector, Header header)
          Creates a vector map from the given GIS vector.
VectorMap(SpatialObject spObj)
          Creates a vector map based on the dimensions and header of the spatial object
 
Method Summary
 void add(GISVector gisVector)
          Adds the given GIS vector object to the map and updates the vector bounds.
 void add(GISVector gisVector, boolean updateBounds)
          Adds the given GIS vector object to the map with option boundary update.
 void add(VectorMap newVectorMap)
          Adds the given vector map to this one and updates the bounds.
 Object clone()
          Clones this vector map.
 void draw(AffineTransform trans, AffineTransform iTrans, float lineWidth, float pointWidth, Color borderColour, float transparency, int renderStyle, Graphics g)
          Draws the vector map using the given graphics context.
 void drawLabels(AffineTransform trans, AffineTransform iTrans, Color backgroundColour, Color foregroundColour, float fontSize, Graphics g)
          Draws the attributes associated with point vectors.
 float getAttribute(Footprint fp)
          Reports the attribute at the given point location.
 Object getAttribute(Footprint fp, AttributeTable attributeTable)
          Reports the attribute at the given point location.
 GISVector getGISVector(Footprint fp)
          Reports the GISVector at the given point location.
 Vector getGISVectors()
          Returns a collection of GIS vectors stored in this map.
 void getImage(int[] pixels, int imgWidth)
          Converts the vector map into a centred colour image for display.
 float getMaxAttribute()
          Reports the maximum attribute value of the object.
 float getMinAttribute()
          Reports the minimum attribute value of the object.
 int getNumObjects()
          Returns the number of GIS vector objects associated with the vector map.
 DelaunayTriang getTriangulation()
          Returns the triangulation topology associated with vector map.
 int getType()
          Reports the type of spatial model.
 boolean hasZCoords()
          Processes all GIS vectors to see if they all have z coordinates.
 boolean readFile(String fileName)
          Reads the contents of the given native format file into this vector map.
 boolean remove(GISVector gisVector)
          Removes the given GIS vector object from the map.
 void setDefaultColours()
          Sets up a default colour scheme based on the range of values in this vector map.
 void setImageContainer(Container imageContainer)
          Sets the image container that can hold a rasterised version of this vector map.
 void setTriangulation(DelaunayTriang tri)
          Sets the triangulation topology associated with vector map.
 void setType(int type)
          Sets the type of vector model (e.g.
 SpatialModel subset(Footprint clipRect)
          Creates a subset of this vector map based on the given rectangle.
 void tinToVector()
          Creates a vector map from current triangulation topology.
 String toString()
          Reports the details of this vector map.
 void updateBounds()
          Updates the minimum enclosing rectangle as that enclosing all GIS Vectors within this map.
 void vectorToTin()
          Creates and stores TIN topology from this vector map.
 boolean writeFile(String fileName, int fileType, GISFrame gisFrame)
          Writes the contents of the vector map to one or more files.
 boolean writeFile(String fileName, int fileType, GISFrame gisFrame, LSThread lsThread)
          Writes the contents of the vector map to one or more files.
 
Methods inherited from class jwo.landserf.structure.SpatialObject
compare, getAttributeTable, getBounds, getColourTable, getComparisonText, getHeader, getIntersectionMER, getProjection, getUnionMER, move, setAttributeTable, setBounds, setColourTable, setHeader, setProjection
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

triangulation

protected transient DelaunayTriang triangulation
Triangulation topology.


SPEED

public static final int SPEED
Indicates a rendering style to maximise speed.

See Also:
Constant Field Values

QUALITY

public static final int QUALITY
Indicates a rendering style to maximise quality.

See Also:
Constant Field Values
Constructor Detail

VectorMap

public VectorMap()
Creates an empty vector map with default characteristics.


VectorMap

public VectorMap(Footprint fp,
                 Header header)
Creates an empty vector map with a given footprint and header.

Parameters:
fp - Footprint defining map's bounds.
header - Header associated with the vector map.

VectorMap

public VectorMap(GISVector gisVector,
                 Header header)
Creates a vector map from the given GIS vector. Note that this method does not clone the geometry, just the metadata. If you need a fully cloned copy of this vector map object, use clone().

Parameters:
gisVector - GIS vector object from which to create map.
header - Header associated with the vector map.

VectorMap

public VectorMap(SpatialObject spObj)
Creates a vector map based on the dimensions and header of the spatial object

Parameters:
spObj - Spatial object from which to extract bounds and header.
Method Detail

clone

public Object clone()
Clones this vector map. The cloned map is entirely independent of this one, but is initially identical.

Returns:
A 'deep' clone of this vector map.

add

public void add(GISVector gisVector)
Adds the given GIS vector object to the map and updates the vector bounds.

Parameters:
gisVector - GIS vector object to add.

add

public void add(GISVector gisVector,
                boolean updateBounds)
Adds the given GIS vector object to the map with option boundary update.

Parameters:
gisVector - GIS vector object to add.
updateBounds - Will update the map's bounds if true.

add

public void add(VectorMap newVectorMap)
Adds the given vector map to this one and updates the bounds.

Parameters:
newVectorMap - Vector map to add.

remove

public boolean remove(GISVector gisVector)
Removes the given GIS vector object from the map. If the map does not contain the object, it is unchanged.

Parameters:
gisVector - GIS Vector object to remove.
Returns:
True if vector object removed.

getGISVectors

public Vector getGISVectors()
Returns a collection of GIS vectors stored in this map.

Returns:
Collection of GIS vectors.

tinToVector

public void tinToVector()
Creates a vector map from current triangulation topology. Note that to maintain precision, the triangulation, while in geographical units, has a zero origin. Therefore this conversion offsets the triangulation by the origin of the vector boundary.


vectorToTin

public void vectorToTin()
Creates and stores TIN topology from this vector map. Can only be applied to VectorMaps that are of type TIN. Note that to maintain precision, the triangulation, while in geographical units, has a zero origin. Therefore this transformation will translate the vector coordinates by -xOrigin,-yOrigin.


toString

public String toString()
Reports the details of this vector map.

Overrides:
toString in class SpatialObject
Returns:
Summary of this vector map.

writeFile

public boolean writeFile(String fileName,
                         int fileType,
                         GISFrame gisFrame)
Writes the contents of the vector map to one or more files.

Parameters:
fileName - Name of main file to save.
fileType - Type of file format to save.
gisFrame - GUI in which to report results.
Returns:
True if written sucessfully.
See Also:
FileHandler

writeFile

public boolean writeFile(String fileName,
                         int fileType,
                         GISFrame gisFrame,
                         LSThread lsThread)
Writes the contents of the vector map to one or more files. This version allows the writing process to be interrupted if a valid LSThread is passed to it.

Parameters:
fileName - Name to save file under.
fileType - Type of file format to save.
gisFrame - GUI in which to report results.
lsThread - Thread that called this method (allowing it to be interrupted). Can be null, in which case, method cannot be interrupted.
Returns:
True if written sucessfully.
See Also:
FileHandler

readFile

public boolean readFile(String fileName)
Reads the contents of the given native format file into this vector map.

Parameters:
fileName - Name to file to read.
Returns:
True if read sucessfully.

draw

public void draw(AffineTransform trans,
                 AffineTransform iTrans,
                 float lineWidth,
                 float pointWidth,
                 Color borderColour,
                 float transparency,
                 int renderStyle,
                 Graphics g)
Draws the vector map using the given graphics context.

Parameters:
trans - georeference to pixel transformation.
iTrans - pixel to georeference transformation.
lineWidth - Line width of vector representation (in pixels, can be fractions of a pixel).
pointWidth - Size of point features in pixels.
borderColour - Colour of polygon borders or null if no border.
transparency - Polygon interior transparency.
renderStyle - Either optimise for QUALITY or SPEED.
g - Graphics context in which to draw.

drawLabels

public void drawLabels(AffineTransform trans,
                       AffineTransform iTrans,
                       Color backgroundColour,
                       Color foregroundColour,
                       float fontSize,
                       Graphics g)
Draws the attributes associated with point vectors. Can be used for labelling.

Parameters:
trans - georeference to pixel transformation.
iTrans - pixel to georeference transformation.
backgroundColour - Colour of label background.
foregroundColour - Colour of label foregroundground.
fontSize - Size of label text in font point units.
g - Graphics context in which to draw.

getMinAttribute

public float getMinAttribute()
Reports the minimum attribute value of the object.

Specified by:
getMinAttribute in class SpatialObject
Returns:
Minimum attribute value.

getMaxAttribute

public float getMaxAttribute()
Reports the maximum attribute value of the object.

Specified by:
getMaxAttribute in class SpatialObject
Returns:
Maximum attribute value.

setImageContainer

public void setImageContainer(Container imageContainer)
Sets the image container that can hold a rasterised version of this vector map.

Parameters:
imageContainer - Container in which to draw rasterised image.

getNumObjects

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

Returns:
Number of vector objects in map.

getTriangulation

public DelaunayTriang getTriangulation()
Returns the triangulation topology associated with vector map. Note that to maintain precision, the triangulation, while in geographical units, has a zero origin.

Returns:
Triangulation topology.

setTriangulation

public void setTriangulation(DelaunayTriang tri)
Sets the triangulation topology associated with vector map. Note that to maintain precision, the triangulation should be in geographical units and have a zero origin.

Parameters:
tri - Triangulation topology.

setType

public void setType(int type)
Sets the type of vector model (e.g. VECTOR_2D, TIN, CONTOUR, MSN).

Parameters:
type - Type of vector model.

updateBounds

public void updateBounds()
Updates the minimum enclosing rectangle as that enclosing all GIS Vectors within this map.

Specified by:
updateBounds in class SpatialObject

hasZCoords

public boolean hasZCoords()
Processes all GIS vectors to see if they all have z coordinates.

Returns:
true only if all GIS vectors contain z values.

subset

public SpatialModel subset(Footprint clipRect)
Creates a subset of this vector map based on the given rectangle. The footprint provided must be a rectangle, or no clipping will take place. Note that if the map contains any objects that intersect with boundary and contain z values, these will be reset during clipping. Objects entirely within the clipping region will be unaffected.

Specified by:
subset in interface SpatialModel
Specified by:
subset in class SpatialObject
Parameters:
clipRect - Clipping rectangle.
Returns:
Vector map with clipped bounds.

getType

public int getType()
Reports the type of spatial model.

Specified by:
getType in interface SpatialModel
Overrides:
getType in class SpatialObject
Returns:
Type of spatial model (VECTOR_2D, VECTOR_3D, CONTOUR, TIN etc).

getAttribute

public float getAttribute(Footprint fp)
Reports the attribute at the given point location.

Specified by:
getAttribute in interface SpatialModel
Specified by:
getAttribute in class SpatialObject
Parameters:
fp - Location to query. The larger of the width/height is used to define the snapping distance for the query.
Returns:
Attribute associated with the GIS vector if given location intersects with object, otherwise OUT_OF_BOUNDS.

getGISVector

public GISVector getGISVector(Footprint fp)
Reports the GISVector at the given point location. If there isn't one within the snapping distance of the point location, a null value is returned.

Parameters:
fp - Location to query. The larger of the width/height is used to define the snapping distance for the query.
Returns:
GISVector if given location intersects with object, otherwise null.

getAttribute

public Object getAttribute(Footprint fp,
                           AttributeTable attributeTable)
Reports the attribute at the given point location. This method can return an attribute of any type as determined by the given lookup table.

Parameters:
fp - Location to query.
attributeTable - Attribute table to look up.
Returns:
Attribute associated with the GIS vector if given location intersects with object, otherwise OUT_OF_BOUNDS.

getImage

public void getImage(int[] pixels,
                     int imgWidth)
Converts the vector map into a centred colour image for display. Colours are based on colour table associated with the object.

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

setDefaultColours

public void setDefaultColours()
Sets up a default colour scheme based on the range of values in this vector map.



Copyright Jo Wood, 1996-2005, last modified, 11th March, 2005