Class TLcdBNGUtil

java.lang.Object
com.luciad.view.map.TLcdBNGUtil

public class TLcdBNGUtil extends Object
Utility class to format and parse coordinates in the British National Grid (BNG) notation.

BNG notation is commonly used in Great Britain and has two letters that indicate a square cell followed by two numbers that refine the position, for example "HU 396 753".

This class supports converting between lon-lat points (WGS84) and BNG notation, and converting between grid points in the BNG reference system and BNG notation.

In this class the terminology is as follows: "Points in the BNG reference system" are XY points given by numerical coordinates in the BNG reference system (The EPSG:27700 reference system, using the OSGB36 datum). This is also referred to as "BNG XY" here. "BNG Notation" or "BNG formatted string" is a notation for these same points, using two letters followed by numbers, a BNG formatted string.

This class is not thread safe.

Since:
9.1
  • Constructor Details

    • TLcdBNGUtil

      public TLcdBNGUtil()
      Constructs a new TLcdBngUtil object
  • Method Details

    • lonLat2Bng

      public String lonLat2Bng(ILcdPoint aLonLatPoint, int aNumberOfDigits, boolean aIncludeSpaces) throws TLcdOutOfBoundsException
      Converts a lon-lat point (WGS84) into BNG notation. For example lon-lat point (WGS84) to "HU 396 753".
      Parameters:
      aLonLatPoint - point to be converted. The point has to be specified within WGS84!
      aNumberOfDigits - defines the number of digits per coordinate in the formatted string.
      aIncludeSpaces - defines whether or not a space will be placed after the letters and between the two numbers in the formatted string.
      Returns:
      a string representing the coordinates in BNG notation.
      Throws:
      TLcdOutOfBoundsException - if the coordinate is outside the valid area of the British grid reference system.
    • bng2LonLat

      public void bng2LonLat(String aBng, ILcd2DEditablePoint a2DPointSFCT) throws ParseException
      Finds the geodetic coordinates of the south-west corner of a square cell expressed in the British national grid notation. For example "HU 396 753" to lon-lat point (WGS84).
      Parameters:
      aBng - the string in BNG notation. The string must contain two letters followed by two numbers which must both have the same amount of digits.
      a2DPointSFCT - a point that will be set to the coordinates of the south-west corner of the BNG cell.
      Throws:
      ParseException - if the string is not formatted in valid BNG notation.
    • bngXY2Bng

      public String bngXY2Bng(ILcdPoint aBngXYPoint, int aNumberOfDigits, boolean aIncludeSpaces) throws TLcdOutOfBoundsException
      Transforms a grid point in the BNG reference system into BNG notation. For example "439668,1175316" to "HU 396 753".
      Parameters:
      aBngXYPoint - coordinate in BNG reference system.
      aNumberOfDigits - defines the number of digits per coordinate in the formatted string.
      aIncludeSpaces - defines whether or not a space will be placed after the letters and between the two numbers in the formatted string.
      Returns:
      a string representing the coordinates in british national grid notation. This string contains two letters followed by two decimal numbers with aNumberOfDigits digits each.
      Throws:
      TLcdOutOfBoundsException - if the coordinate is outside the valid area of the British grid reference system.
    • bng2BngXY

      public void bng2BngXY(String aBng, ILcd2DEditablePoint a2DPointSFCT) throws ParseException
      Finds the numeric coordinates in the BNG reference system given a string in BNG notation. For example "HU 396 753" to "439668,1175316".
      Parameters:
      aBng - the string in BNG notation. The string must contain two letters followed by two numbers which must both have the same amount of digits.
      a2DPointSFCT - a point that will be set to the coordinates in the BNG reference system.
      Throws:
      ParseException - if the string is not formatted in valid BNG notation.