com.oziexplorer
Class BNGGridRef

java.lang.Object
  extended by com.oziexplorer.Position
      extended by com.oziexplorer.GridRef
          extended by com.oziexplorer.BNGGridRef

public class BNGGridRef
extends GridRef

This class extends GridRef and provides British National Grid references.

Copyright 2011 Alan Burlison, . All rights reserved. Use is subject to license terms, see LICENSE.txt.
SourceForge.net


Field Summary
static String DATUM
          Datum used by BNG grid references.
 
Fields inherited from class com.oziexplorer.GridRef
defaultGrid, easting, grid, northing, zone
 
Fields inherited from class com.oziexplorer.Position
comparisonAccuracy, datum
 
Constructor Summary
BNGGridRef(Position pos)
          Create a new BNG reference from the specified position.
BNGGridRef(String ref)
          Create a new instance of BNGGridRef given a string grid reference.
BNGGridRef(String square, double easting, double northing)
          Creates a new instance of BNGGridRef given a grid square and 5-figure (easting, northing) values in metres.
 
Method Summary
 BNGGridRef addVector(SpatialVector vector)
          Return a new Position which is offset from the current position by the given vector, specified as a SpatialVector.
 String toString()
          Convert the grid reference to a string of the form "SK 12345 67890".
 String toString(int digits)
          Convert the grid reference to a string of the form "SK 123 456".
 
Methods inherited from class com.oziexplorer.GridRef
equals, getDefaultGrid, getEasting, getGrid, getNorthing, getZone, hashCode, setDefaultGrid, vectorBetween
 
Methods inherited from class com.oziexplorer.Position
getComparisonAccuracy, getDatum, setComparisonAccuracy
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DATUM

public static final String DATUM
Datum used by BNG grid references.

See Also:
Constant Field Values
Constructor Detail

BNGGridRef

public BNGGridRef(String square,
                  double easting,
                  double northing)
Creates a new instance of BNGGridRef given a grid square and 5-figure (easting, northing) values in metres.

Parameters:
square - name of the BNG grid square, e.g. "SK".
easting - easting in metres.
northing - northing in metres.

BNGGridRef

public BNGGridRef(String ref)
           throws OziException
Create a new instance of BNGGridRef given a string grid reference.

Parameters:
ref - string grid reference, e.g. "SK 123 456". Can contain any even number of digits from 0 to 10. Spaces between the parts of the reference are optional.
Throws:
OziException - if OziAPI reports an error.

BNGGridRef

public BNGGridRef(Position pos)
           throws OziException
Create a new BNG reference from the specified position.

Parameters:
pos - Position for the grid reference.
Throws:
OziException - if OziAPI reports an error.
Method Detail

addVector

public BNGGridRef addVector(SpatialVector vector)
                     throws OziException
Return a new Position which is offset from the current position by the given vector, specified as a SpatialVector.

Overrides:
addVector in class GridRef
Parameters:
vector - the SpatialVector to offset by.
Returns:
the new Position.
Throws:
OziException - if OziAPI returns an error.

toString

public String toString(int digits)
Convert the grid reference to a string of the form "SK 123 456". If the reference does not lie withing a BNG zone it is returned as "eeeeeeee nnnnnnnn".

Parameters:
digits - number of digits in the numeric part of the reference, e.g. 6 would result in "SK 123 456" being returned.
Returns:
string representation of the grid reference.

toString

public String toString()
Convert the grid reference to a string of the form "SK 12345 67890". If the reference does not lie within a BNG zone it is returned as "eeeeeeee nnnnnnnn".

Overrides:
toString in class GridRef
Returns:
string representation of the grid reference.