com.oziexplorer
Class BNGGridRef
java.lang.Object
com.oziexplorer.Position
com.oziexplorer.GridRef
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.
Field Summary |
static String |
DATUM
Datum used by BNG grid references. |
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. |
DATUM
public static final String DATUM
- Datum used by BNG grid references.
- See Also:
- Constant Field Values
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.
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.