com.bbn.openmap.proj.coords
Class MGRSPoint

java.lang.Object
  extended by com.bbn.openmap.proj.coords.UTMPoint
      extended by com.bbn.openmap.proj.coords.ZonedUTMPoint
          extended by com.bbn.openmap.proj.coords.MGRSPoint

public class MGRSPoint
extends ZonedUTMPoint

A class representing a MGRS coordinate that has the ability to provide the decimal degree lat/lon equivalent, as well as the UTM equivalent. This class does not do checks to see if the MGRS coordinates provided actually make sense. It assumes that the values are valid.


Field Summary
static int A
           
protected  int accuracy
          Controls the number of digits that the MGRS coordinate will have, which directly affects the accuracy of the coordinate.
static int ACCURACY_1_METER
          Use 5 digits for northing and easting values, for 1 meter accuracy of coordinate.
static int ACCURACY_10_METER
          Use 4 digits for northing and easting values, for 10 meter accuracy of coordinate.
static int ACCURACY_100_METER
          Use 3 digits for northing and easting values, for 100 meter accuracy of coordinate.
static int ACCURACY_1000_METER
          Use 2 digits for northing and easting values, for 1000 meter accuracy of coordinate.
static int ACCURACY_10000_METER
          Use 1 digits for northing and easting values, for 10000 meter accuracy of coordinate.
static int[] BESSEL_SET_ORIGIN_COLUMN_LETTERS
          The column letters (for easting) of the lower left value, per set,, for Bessel Ellipsoid.
static int[] BESSEL_SET_ORIGIN_ROW_LETTERS
          The row letters (for northing) of the lower left value, per set, for Bessel Ellipsoid.
protected  boolean DEBUG
           
static int I
           
protected static java.util.logging.Logger logger
           
protected  java.lang.String mgrs
          The String holding the MGRS coordinate value.
protected static int NUM_100K_SETS
          UTM zones are grouped, and assigned to one of a group of 6 sets.
static int O
           
protected  int[] originColumnLetters
          The set origin column letters to use.
protected  int[] originRowLetters
          The set origin row letters to use.
static int SET_NORTHING_ROLLOVER
           
static int[] SET_ORIGIN_COLUMN_LETTERS
          The column letters (for easting) of the lower left value, per set.
static int[] SET_ORIGIN_ROW_LETTERS
          The row letters (for northing) of the lower left value, per set.
static int V
           
static int Z
           
 
Fields inherited from class com.bbn.openmap.proj.coords.UTMPoint
easting, northing, zone_letter, zone_number
 
Constructor Summary
MGRSPoint()
          Point to create if you are going to use the static methods to fill the values in.
MGRSPoint(double northing, double easting, int zoneNumber, char zoneLetter)
          Create a MGRSPoint from standard values.
MGRSPoint(LatLonPoint llpoint)
          Construct a MGRSPoint from a LatLonPoint, assuming a WGS_84 ellipsoid.
MGRSPoint(LatLonPoint llpoint, Ellipsoid ellip)
          Construct a MGRSPoint from a LatLonPoint and a particular ellipsoid.
MGRSPoint(MGRSPoint point)
          Constructs a new MGRSPoint instance from values in another MGRSPoint.
MGRSPoint(java.lang.String mgrsString)
          Constructs a new MGRS instance from a MGRS String, validating the string as a MGRS coordinate.
 
Method Summary
protected  char checkZone(char zone)
          Method that provides a check for MGRS zone letters.
protected  void decode(java.lang.String mgrsString)
          Set the MGRS parameters from a MGRS coordinate string.
protected  java.lang.String get100kID(double easting, double northing, int zone_number)
          Get the two letter 100k designator for a given MGRS/UTM easting, northing and zone number value.
protected  java.lang.String get100kID(int setColumn, int setRow, int set)
          Get the two-letter MGRS 100k designator given information translated from the MGRS/UTM northing, easting and zone number.
protected  int get100kSetForZone(int i)
          Given a MGRS/UTM zone number, figure out the MGRS 100K set it is in.
 int getAccuracy()
           
protected  float getEastingFromChar(char e, int set)
          Given the first letter from a two-letter MGRS 100k zone, and given the MGRS table set for the zone number, figure out the easting value that should be added to the other, secondary easting value.
 java.lang.String getMGRS()
          Get the MGRS string value - the honkin' coordinate value.
protected  float getMinNorthing(char zoneLetter)
          The function getMinNorthing returns the minimum northing value of a MGRS zone.
protected  float getNorthingFromChar(char n, int set)
          Given the second letter from a two-letter MGRS 100k zone, and given the MGRS table set for the zone number, figure out the northing value that should be added to the other, secondary northing value.
protected  int[] getOriginColumnLetters()
          Provided so that extensions to this class can provide different origin letters, in case of different ellipsoids.
protected  int[] getOriginRowLetters()
          Provided so that extensions to this class can provide different origin letters, in case of different ellipsoids.
static MGRSPoint LLtoMGRS(LatLonPoint llpoint)
          Converts a LatLonPoint to a MGRS Point, assuming the WGS_84 ellipsoid.
static MGRSPoint LLtoMGRS(LatLonPoint llp, Ellipsoid ellip, MGRSPoint mgrsp)
          Create a MGRSPoint from a LatLonPoint.
static MGRSPoint LLtoMGRS(LatLonPoint llpoint, MGRSPoint mgrsp)
          Converts a LatLonPoint to a MGRS Point.
static void main(java.lang.String[] argv)
           
static LatLonPoint MGRStoLL(Ellipsoid ellip, double northing, double easting, int zoneNumber, char zoneLetter, LatLonPoint llp)
          Create a LatLonPoint from a MGRSPoint.
static LatLonPoint MGRStoLL(MGRSPoint mgrsp, Ellipsoid ellip, LatLonPoint llp)
          Create a LatLonPoint from a MGRSPoint.
static char MGRSZoneToUTMZone(char mgrsZone)
          Convert MGRS zone letter to UTM zone letter, N or S.
protected  void print100kSets()
          Testing method, used to print out the MGRS 100k two letter set tables.
 void resolve()
          Create the mgrs string based on the internal MGRS parameter settings, using the accuracy set in the MGRSPoint.
 void resolve(int digitAccuracy)
          Create the mgrs string based on the internal MGRS parameter settings, should be called if the accuracy changes.
 void setAccuracy(int value)
          Set the number of digits to use for easting and northing numbers in the mgrs string, which reflects the accuracy of the coordinate.
 void setMGRS(java.lang.String mgrsString)
          Set the MGRS value for this Point.
protected  void setOriginColumnLetters(int[] letters)
          Provided so that extensions to this class can provide different origin letters, in case of different ellipsoids.
protected  void setOriginRowLetters(int[] letters)
          Provided so that extensions to this class can provide different origin letters, in case of different ellipsoids.
 LatLonPoint toLatLonPoint()
          Convert this MGRSPoint to a LatLonPoint, and assume a WGS_84 ellipsoid.
 LatLonPoint toLatLonPoint(Ellipsoid ellip)
          Convert this MGRSPoint to a LatLonPoint, and use the given ellipsoid.
 LatLonPoint toLatLonPoint(Ellipsoid ellip, LatLonPoint llpoint)
          Fill in the given LatLonPoint with the converted values of this MGRSPoint, and use the given ellipsoid.
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class com.bbn.openmap.proj.coords.ZonedUTMPoint
getLetterDesignator, ZonedUTMtoLL
 
Methods inherited from class com.bbn.openmap.proj.coords.UTMPoint
equals, getZoneNumber, hashCode, LLtoUTM, LLtoUTM, LLtoUTM, LLtoUTM, UTMtoLL, UTMtoLL, UTMtoLL, UTMtoLL
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NUM_100K_SETS

protected static final int NUM_100K_SETS
UTM zones are grouped, and assigned to one of a group of 6 sets.

See Also:
Constant Field Values

SET_ORIGIN_COLUMN_LETTERS

public static final int[] SET_ORIGIN_COLUMN_LETTERS
The column letters (for easting) of the lower left value, per set.


SET_ORIGIN_ROW_LETTERS

public static final int[] SET_ORIGIN_ROW_LETTERS
The row letters (for northing) of the lower left value, per set.


BESSEL_SET_ORIGIN_COLUMN_LETTERS

public static final int[] BESSEL_SET_ORIGIN_COLUMN_LETTERS
The column letters (for easting) of the lower left value, per set,, for Bessel Ellipsoid.


BESSEL_SET_ORIGIN_ROW_LETTERS

public static final int[] BESSEL_SET_ORIGIN_ROW_LETTERS
The row letters (for northing) of the lower left value, per set, for Bessel Ellipsoid.


SET_NORTHING_ROLLOVER

public static final int SET_NORTHING_ROLLOVER
See Also:
Constant Field Values

ACCURACY_1_METER

public static final int ACCURACY_1_METER
Use 5 digits for northing and easting values, for 1 meter accuracy of coordinate.

See Also:
Constant Field Values

ACCURACY_10_METER

public static final int ACCURACY_10_METER
Use 4 digits for northing and easting values, for 10 meter accuracy of coordinate.

See Also:
Constant Field Values

ACCURACY_100_METER

public static final int ACCURACY_100_METER
Use 3 digits for northing and easting values, for 100 meter accuracy of coordinate.

See Also:
Constant Field Values

ACCURACY_1000_METER

public static final int ACCURACY_1000_METER
Use 2 digits for northing and easting values, for 1000 meter accuracy of coordinate.

See Also:
Constant Field Values

ACCURACY_10000_METER

public static final int ACCURACY_10000_METER
Use 1 digits for northing and easting values, for 10000 meter accuracy of coordinate.

See Also:
Constant Field Values

originColumnLetters

protected int[] originColumnLetters
The set origin column letters to use.


originRowLetters

protected int[] originRowLetters
The set origin row letters to use.


A

public static final int A
See Also:
Constant Field Values

I

public static final int I
See Also:
Constant Field Values

O

public static final int O
See Also:
Constant Field Values

V

public static final int V
See Also:
Constant Field Values

Z

public static final int Z
See Also:
Constant Field Values

DEBUG

protected boolean DEBUG

logger

protected static final java.util.logging.Logger logger

mgrs

protected java.lang.String mgrs
The String holding the MGRS coordinate value.


accuracy

protected int accuracy
Controls the number of digits that the MGRS coordinate will have, which directly affects the accuracy of the coordinate. Default is ACCURACY_1_METER, which indicates that MGRS coordinates will have 10 digits (5 easting, 5 northing) after the 100k two letter code, indicating 1 meter resolution.

Constructor Detail

MGRSPoint

public MGRSPoint()
Point to create if you are going to use the static methods to fill the values in.


MGRSPoint

public MGRSPoint(java.lang.String mgrsString)
          throws java.lang.NumberFormatException
Constructs a new MGRS instance from a MGRS String, validating the string as a MGRS coordinate.

Throws:
java.lang.NumberFormatException

MGRSPoint

public MGRSPoint(MGRSPoint point)
Constructs a new MGRSPoint instance from values in another MGRSPoint.


MGRSPoint

public MGRSPoint(double northing,
                 double easting,
                 int zoneNumber,
                 char zoneLetter)
Create a MGRSPoint from standard values.

Parameters:
northing - northing offset
easting - easting offset
zoneNumber - the MGRS zone number
zoneLetter - the MGRS zone letter.

MGRSPoint

public MGRSPoint(LatLonPoint llpoint)
Construct a MGRSPoint from a LatLonPoint, assuming a WGS_84 ellipsoid.


MGRSPoint

public MGRSPoint(LatLonPoint llpoint,
                 Ellipsoid ellip)
Construct a MGRSPoint from a LatLonPoint and a particular ellipsoid.

Method Detail

setMGRS

public void setMGRS(java.lang.String mgrsString)
             throws java.lang.NumberFormatException
Set the MGRS value for this Point. Will be decoded, and the MGRS values figured out. You can call toLatLonPoint() to translate it to lat/lon decimal degrees.

Throws:
java.lang.NumberFormatException

getMGRS

public java.lang.String getMGRS()
Get the MGRS string value - the honkin' coordinate value.


toLatLonPoint

public LatLonPoint toLatLonPoint()
Convert this MGRSPoint to a LatLonPoint, and assume a WGS_84 ellipsoid.

Overrides:
toLatLonPoint in class UTMPoint

toLatLonPoint

public LatLonPoint toLatLonPoint(Ellipsoid ellip)
Convert this MGRSPoint to a LatLonPoint, and use the given ellipsoid.

Overrides:
toLatLonPoint in class UTMPoint

toLatLonPoint

public LatLonPoint toLatLonPoint(Ellipsoid ellip,
                                 LatLonPoint llpoint)
Fill in the given LatLonPoint with the converted values of this MGRSPoint, and use the given ellipsoid.

Overrides:
toLatLonPoint in class UTMPoint

toString

public java.lang.String toString()
Returns a string representation of the object.

Overrides:
toString in class UTMPoint
Returns:
String representation

MGRStoLL

public static LatLonPoint MGRStoLL(MGRSPoint mgrsp,
                                   Ellipsoid ellip,
                                   LatLonPoint llp)
Create a LatLonPoint from a MGRSPoint.

Parameters:
mgrsp - to convert.
ellip - Ellipsoid for earth model.
llp - a LatLonPoint to fill in values for. If null, a new LatLonPoint will be returned. If not null, the new values will be set in this object, and it will be returned.
Returns:
LatLonPoint with values converted from MGRS coordinate.

MGRStoLL

public static LatLonPoint MGRStoLL(Ellipsoid ellip,
                                   double northing,
                                   double easting,
                                   int zoneNumber,
                                   char zoneLetter,
                                   LatLonPoint llp)
Create a LatLonPoint from a MGRSPoint.

Parameters:
ellip - ellipsoid
northing - northing in meters
easting - easting in meters
zoneNumber - zone number for mgrs
zoneLetter - zone letter for mgrs
llp - LatLonPoint object to use for answer, ok if null.
Returns:
LatLonPoint from MGRSPoint

LLtoMGRS

public static MGRSPoint LLtoMGRS(LatLonPoint llpoint)
Converts a LatLonPoint to a MGRS Point, assuming the WGS_84 ellipsoid.

Returns:
MGRSPoint, or null if something bad happened.

LLtoMGRS

public static MGRSPoint LLtoMGRS(LatLonPoint llpoint,
                                 MGRSPoint mgrsp)
Converts a LatLonPoint to a MGRS Point.

Parameters:
llpoint - the LatLonPoint to convert.
mgrsp - a MGRSPoint to put the results in. If it's null, a MGRSPoint will be allocated.
Returns:
MGRSPoint, or null if something bad happened. If a MGRSPoint was passed in, it will also be returned on a successful conversion.

LLtoMGRS

public static MGRSPoint LLtoMGRS(LatLonPoint llp,
                                 Ellipsoid ellip,
                                 MGRSPoint mgrsp)
Create a MGRSPoint from a LatLonPoint.

Parameters:
llp - LatLonPoint to convert.
ellip - Ellipsoid for earth model.
mgrsp - a MGRSPoint to fill in values for. If null, a new MGRSPoint will be returned. If not null, the new values will be set in this object, and it will be returned.
Returns:
MGRSPoint with values converted from lat/lon.

MGRSZoneToUTMZone

public static char MGRSZoneToUTMZone(char mgrsZone)
Convert MGRS zone letter to UTM zone letter, N or S.

Parameters:
mgrsZone -
Returns:
N of given zone is equal or larger than N, S otherwise.

checkZone

protected char checkZone(char zone)
Method that provides a check for MGRS zone letters. Returns an uppercase version of any valid letter passed in.

Overrides:
checkZone in class UTMPoint

setAccuracy

public void setAccuracy(int value)
Set the number of digits to use for easting and northing numbers in the mgrs string, which reflects the accuracy of the coordinate. From 5 (1 meter) to 1 (10,000 meter).


getAccuracy

public int getAccuracy()

decode

protected void decode(java.lang.String mgrsString)
               throws java.lang.NumberFormatException
Set the MGRS parameters from a MGRS coordinate string.

Parameters:
mgrsString - an UPPERCASE coordinate string is expected.
Throws:
java.lang.NumberFormatException

resolve

public void resolve(int digitAccuracy)
Create the mgrs string based on the internal MGRS parameter settings, should be called if the accuracy changes.

Parameters:
digitAccuracy - The number of digits to use for the northing and easting numbers. 5 digits reflect a 1 meter accuracy, 4 - 10 meter, 3 - 100 meter, 2 - 1000 meter, 1 - 10,000 meter.

resolve

public void resolve()
Create the mgrs string based on the internal MGRS parameter settings, using the accuracy set in the MGRSPoint.


get100kSetForZone

protected int get100kSetForZone(int i)
Given a MGRS/UTM zone number, figure out the MGRS 100K set it is in.


getOriginColumnLetters

protected int[] getOriginColumnLetters()
Provided so that extensions to this class can provide different origin letters, in case of different ellipsoids. The int[] represents all of the first letters in the bottom left corner of each set box, as shown in an MGRS 100K box layout.


setOriginColumnLetters

protected void setOriginColumnLetters(int[] letters)
Provided so that extensions to this class can provide different origin letters, in case of different ellipsoids. The int[] represents all of the first letters in the bottom left corner of each set box, as shown in an MGRS 100K box layout.


getOriginRowLetters

protected int[] getOriginRowLetters()
Provided so that extensions to this class can provide different origin letters, in case of different ellipsoids. The int[] represents all of the second letters in the bottom left corner of each set box, as shown in an MGRS 100K box layout.


setOriginRowLetters

protected void setOriginRowLetters(int[] letters)
Provided so that extensions to this class can provide different origin letters, in case of different ellipsoids. The int[] represents all of the second letters in the bottom left corner of each set box, as shown in an MGRS 100K box layout.


get100kID

protected java.lang.String get100kID(double easting,
                                     double northing,
                                     int zone_number)
Get the two letter 100k designator for a given MGRS/UTM easting, northing and zone number value.


getEastingFromChar

protected float getEastingFromChar(char e,
                                   int set)
Given the first letter from a two-letter MGRS 100k zone, and given the MGRS table set for the zone number, figure out the easting value that should be added to the other, secondary easting value.


getNorthingFromChar

protected float getNorthingFromChar(char n,
                                    int set)
Given the second letter from a two-letter MGRS 100k zone, and given the MGRS table set for the zone number, figure out the northing value that should be added to the other, secondary northing value. You have to remember that Northings are determined from the equator, and the vertical cycle of letters mean a 2000000 additional northing meters. This happens approx. every 18 degrees of latitude. This method does *NOT* count any additional northings. You have to figure out how many 2000000 meters need to be added for the zone letter of the MGRS coordinate.

Parameters:
n - second letter of the MGRS 100k zone
set - the MGRS table set number, which is dependent on the MGRS/UTM zone number.

get100kID

protected java.lang.String get100kID(int setColumn,
                                     int setRow,
                                     int set)
Get the two-letter MGRS 100k designator given information translated from the MGRS/UTM northing, easting and zone number.

Parameters:
setColumn - the column index as it relates to the MGRS 100k set spreadsheet, created from the MGRS/UTM easting. Values are 1-8.
setRow - the row index as it relates to the MGRS 100k set spreadsheet, created from the MGRS/UTM northing value. Values are from 0-19.
set - the set block, as it relates to the MGRS 100k set spreadsheet, created from the MGRS/UTM zone. Values are from 1-60.
Returns:
two letter MGRS 100k code.

print100kSets

protected void print100kSets()
Testing method, used to print out the MGRS 100k two letter set tables.


getMinNorthing

protected float getMinNorthing(char zoneLetter)
                        throws java.lang.NumberFormatException
The function getMinNorthing returns the minimum northing value of a MGRS zone. portted from Geotrans' c Latitude_Band_Value structure table. zoneLetter : MGRS zone (input)

Throws:
java.lang.NumberFormatException

main

public static void main(java.lang.String[] argv)


Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details