uk.me.jstott.jcoord
Class OSRef

java.lang.Object
  extended by uk.me.jstott.jcoord.OSRef

public class OSRef
extends java.lang.Object

Class to represent an Ordnance Survey grid reference (c) 2006 Jonathan Stott Created on 11-02-2006

Since:
1.0
Version:
1.0
Author:
Jonathan Stott

Constructor Summary
OSRef(double easting, double northing)
          Create a new Ordnance Survey grid reference.
OSRef(java.lang.String ref)
          Take a string formatted as a six-figure OS grid reference (e.g.
 
Method Summary
 double getEasting()
          Get the easting.
 double getNorthing()
          Get the northing.
 LatLng toLatLng()
          Convert this OSGB grid reference to a latitude/longitude pair using the OSGB36 datum.
 java.lang.String toSixFigureString()
          Return a String representation of this OSGB grid reference using the six-figure notation in the form XY123456
 java.lang.String toString()
          Return a String representation of this OSGB grid reference showing the easting and northing.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OSRef

public OSRef(double easting,
             double northing)
Create a new Ordnance Survey grid reference.

Parameters:
easting - the easting in metres
northing - the northing in metres
Since:
1.0

OSRef

public OSRef(java.lang.String ref)
      throws java.lang.IllegalArgumentException
Take a string formatted as a six-figure OS grid reference (e.g. "TG514131") and create a new OSRef object that represents that grid reference. The first character must be H, N, S, O or T. The second character can be any uppercase character from A through Z excluding I.

Parameters:
ref - a String representing a six-figure Ordnance Survey grid reference in the form XY123456
Throws:
java.lang.IllegalArgumentException - if ref is not of the form XY123456
Since:
1.0
Method Detail

toString

public java.lang.String toString()
Return a String representation of this OSGB grid reference showing the easting and northing.

Overrides:
toString in class java.lang.Object
Returns:
a String represenation of this OSGB grid reference
Since:
1.0

toSixFigureString

public java.lang.String toSixFigureString()
Return a String representation of this OSGB grid reference using the six-figure notation in the form XY123456

Returns:
a String representing this OSGB grid reference in six-figure notation
Since:
1.0

toLatLng

public LatLng toLatLng()
Convert this OSGB grid reference to a latitude/longitude pair using the OSGB36 datum. Note that, the LatLng object may need to be converted to the WGS84 datum depending on the application.

Returns:
a LatLng object representing this OSGB grid reference using the OSGB36 datum
Since:
1.0

getEasting

public double getEasting()
Get the easting.

Returns:
the easting in metres
Since:
1.0

getNorthing

public double getNorthing()
Get the northing.

Returns:
the northing in metres
Since:
1.0