getOSGBfromDec method

OSRef getOSGBfromDec(
  1. double lat,
  2. double long, [
  3. dynamic datum
])

Returns the easting and northing values of an OS Grid Reference given the decimal latitude and longitude values

Implementation

OSRef getOSGBfromDec(double lat, double long, [var datum]) {
  if (datum == null) {
    datum = Datums.WGS84;
  }
  //since we are converting from WGS84 lat/long, we need to provide the converter with its datum so it knows what it's converting from
  LatLong latLong = new LatLong(lat, long, 0, datum); //gives the lat and long coordinates to the converter along with the height and the Datum of the lat long coords
  OSRef osRef = latLong.toOsGrid(); //returns an array with 2 elements, the first is the easting and the second is the northing
  return osRef;
}