Class MGRSParser


  • public class MGRSParser
    extends java.lang.Object
    Author:
    ubaldino
    • Constructor Summary

      Constructors 
      Constructor Description
      MGRSParser()  
    • Method Summary

      Modifier and Type Method Description
      protected static boolean isValidEastingNorthing​(java.lang.String ne, boolean oddLength)
      A hueuristic from looking at real data, real text artifacts - typos, line endings, whitespace wrapping, etc.
      protected static int parseInt​(java.lang.String x)  
      static org.opensextant.geodesy.MGRS[] parseMGRS​(java.lang.String rawtext, java.lang.String _text, java.util.Map<java.lang.String,​java.lang.String> elements)
      Given the match parse MGRS as best as can be done.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MGRSParser

        public MGRSParser()
    • Method Detail

      • parseMGRS

        public static org.opensextant.geodesy.MGRS[] parseMGRS​(java.lang.String rawtext,
                                                               java.lang.String _text,
                                                               java.util.Map<java.lang.String,​java.lang.String> elements)
        Given the match parse MGRS as best as can be done. TODO: provide level of confidence. Items that match MGRS scheme perfectly are more likely to be MGRS than those that are not perfect matches, e.g. typos, inadvertent text wrapping, whitespace etc.
        Parameters:
        rawtext - the rawtext
        _text - text normalized, optionally
        elements - matched groups within regex pattern
        Returns:
        array of possible MGRS interpretations.
      • isValidEastingNorthing

        protected static boolean isValidEastingNorthing​(java.lang.String ne,
                                                        boolean oddLength)
        A hueuristic from looking at real data, real text artifacts - typos, line endings, whitespace wrapping, etc. Acceptable Northing/Eastings: dd dd dddd dddd typos: (odd number of digits; whitespace or not.) ddd dd ddddd Not valid: dd dd\nd odd digits and has line endings
        Parameters:
        ne - NE string, e.g,. 56789 01234
        oddLength - if len is odd
        Returns:
        if easting/northing is valid
      • parseInt

        protected static int parseInt​(java.lang.String x)
        Parameters:
        x - an integer string
        Returns:
        int for the string