Package mil.nga.mgrs

Class MGRS


  • public class MGRS
    extends Object
    Military Grid Reference System Coordinate
    Author:
    wnewman, osbornb
    • Constructor Detail

      • MGRS

        public MGRS​(int zone,
                    char band,
                    char column,
                    char row,
                    long easting,
                    long northing)
        Constructor
        Parameters:
        zone - zone number
        band - band letter
        column - column letter
        row - row letter
        easting - easting
        northing - northing
      • MGRS

        public MGRS​(int zone,
                    char band,
                    long easting,
                    long northing)
        Constructor
        Parameters:
        zone - zone number
        band - band letter
        easting - easting
        northing - northing
    • Method Detail

      • create

        public static MGRS create​(int zone,
                                  char band,
                                  char column,
                                  char row,
                                  long easting,
                                  long northing)
        Create
        Parameters:
        zone - zone number
        band - band letter
        column - column letter
        row - row letter
        easting - easting
        northing - northing
        Returns:
        MGRS
      • create

        public static MGRS create​(int zone,
                                  char band,
                                  long easting,
                                  long northing)
        Create
        Parameters:
        zone - zone number
        band - band letter
        easting - easting
        northing - northing
        Returns:
        MGRS
      • getZone

        public int getZone()
        Get the zone number
        Returns:
        zone number
      • getBand

        public char getBand()
        Get the band letter
        Returns:
        band letter
      • getColumn

        public char getColumn()
        Get the column letter
        Returns:
        column letter
      • getRow

        public char getRow()
        Get the row letter
        Returns:
        row letter
      • getEasting

        public long getEasting()
        Get the easting
        Returns:
        easting
      • getNorthing

        public long getNorthing()
        Get the northing
        Returns:
        northing
      • getHemisphere

        public Hemisphere getHemisphere()
        Get the hemisphere
        Returns:
        hemisphere
      • coordinate

        public String coordinate()
        Get the MGRS coordinate with one meter precision
        Returns:
        MGRS coordinate
      • coordinate

        public String coordinate​(GridType type)
        Get the MGRS coordinate with specified grid precision
        Parameters:
        type - grid type precision
        Returns:
        MGRS coordinate
      • getEastingAndNorthing

        public String getEastingAndNorthing​(GridType type)
        Get the easting and northing concatenated value in the grid type precision
        Parameters:
        type - grid type precision
        Returns:
        easting and northing value
      • coordinate

        public String coordinate​(int accuracy)
        Get the MGRS coordinate with the accuracy number of digits in the easting and northing values. Accuracy must be inclusively between 0 (GridType.HUNDRED_KILOMETER) and 5 (GridType.METER).
        Parameters:
        accuracy - accuracy digits between 0 (inclusive) and 5 (inclusive)
        Returns:
        MGRS coordinate
      • precision

        public GridType precision()
        Get the MGRS coordinate grid precision
        Returns:
        grid type precision
      • accuracy

        public int accuracy()
        Get the MGRS coordinate accuracy number of digits
        Returns:
        accuracy digits
      • getColumnRowId

        public String getColumnRowId()
        Get the two letter column and row 100k designator
        Returns:
        the two letter column and row 100k designator
      • getGridZone

        public GridZone getGridZone()
        Get the GZD grid zone
        Returns:
        GZD grid zone
      • toPoint

        public Point toPoint()
        Convert to a point
        Returns:
        point
      • toUTM

        public UTM toUTM()
        Convert to UTM coordinate
        Returns:
        UTM
      • getUTMEasting

        public double getUTMEasting()
        Get the UTM easting
        Returns:
        UTM easting
      • getUTMNorthing

        public double getUTMNorthing()
        Get the UTM northing
        Returns:
        UTM northing
      • isMGRS

        public static boolean isMGRS​(String mgrs)
        Return whether the given string is valid MGRS string
        Parameters:
        mgrs - potential MGRS string
        Returns:
        true if MGRS string is valid, false otherwise
      • from

        public static MGRS from​(Point point)
        Encodes a point as a MGRS string
        Parameters:
        point - point
        Returns:
        MGRS
      • from

        public static MGRS from​(double longitude,
                                double latitude)
        Convert the coordinate to MGRS
        Parameters:
        longitude - longitude
        latitude - latitude
        Returns:
        MGRS
        Since:
        2.1.1
      • parse

        public static MGRS parse​(String mgrs)
                          throws ParseException
        Parse a MGRS string
        Parameters:
        mgrs - MGRS string
        Returns:
        MGRS
        Throws:
        ParseException - upon failure to parse the MGRS string
      • precision

        public static GridType precision​(String mgrs)
                                  throws ParseException
        Parse the MGRS string for the precision
        Parameters:
        mgrs - MGRS string
        Returns:
        grid type precision
        Throws:
        ParseException - upon failure to parse the MGRS string
      • accuracy

        public static int accuracy​(String mgrs)
                            throws ParseException
        Get the MGRS coordinate accuracy number of digits
        Parameters:
        mgrs - MGRS string
        Returns:
        accuracy digits
        Throws:
        ParseException - upon failure to parse the MGRS string
      • getColumnRowId

        public static String getColumnRowId​(double easting,
                                            double northing,
                                            int zoneNumber)
        Get the two letter column and row 100k designator for a given UTM easting, northing and zone number value
        Parameters:
        easting - easting
        northing - northing
        zoneNumber - zone number
        Returns:
        the two letter column and row 100k designator
      • getColumnLetter

        public static char getColumnLetter​(UTM utm)
        Get the column letter from the UTM
        Parameters:
        utm - UTM
        Returns:
        column letter
      • getColumnLetter

        public static char getColumnLetter​(int zoneNumber,
                                           double easting)
        Get the column letter from the zone number and easting
        Parameters:
        zoneNumber - zone number
        easting - easting
        Returns:
        column letter
      • getRowLetter

        public static char getRowLetter​(UTM utm)
        Get the row letter from the UTM
        Parameters:
        utm - UTM
        Returns:
        row letter
      • getRowLetter

        public static char getRowLetter​(int zoneNumber,
                                        double northing)
        Get the row letter from the zone number and northing
        Parameters:
        zoneNumber - zone number
        northing - northing
        Returns:
        row letter