Class DMSOrdinate


  • public final class DMSOrdinate
    extends java.lang.Object
    DMSOrdinate represents all the various fields a WGS84 cartesian coordinate could have. degree/minute/second, as well as fractional minutes and fractional seconds. Patterns may have symbols which further indicate if a pattern is a literal decimal number (e.g., 33-44, 33.44, 33.444, 33-4444) of if the numbers are in minutes/seconds units (33:44).
    Author:
    ubaldino
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  DMSOrdinate.Resolution
      Resolution field for DMS.ms
    • Constructor Summary

      Constructors 
      Constructor Description
      DMSOrdinate​(int deg, int min, int sec, boolean islat, int hemi_sign)
      Deprecated.
      For XCoord purposes use the DMSOrdinate(map, map, boolean, text) form.
      DMSOrdinate​(int deg, int min, int sec, int msec, boolean islat, int hemi_sign)
      Deprecated.
      For XCoord purposes use the DMSOrdinate(map, map, boolean, text) form.
      DMSOrdinate​(java.lang.String deg, java.lang.String min, java.lang.String sec, boolean islat, int hemi_sign)
      Deprecated.
      For XCoord purposes use the DMSOrdinate(map, map, boolean, text) form.
      DMSOrdinate​(java.util.Map<java.lang.String,​TextEntity> fieldMatches, java.util.Map<java.lang.String,​java.lang.String> fieldVals, boolean islat, java.lang.String t)
      DMS ordinates can be made up of degrees, minutes, seconds and then decimal minutes and decimal seconds fractional minutes dddd are formatted as ".dddd" then parsed; ADD to existing minutes fractional seconds dddd are formatted as ".dddd" then parsed; ADD to existing seconds decimal minutes d.ddd..
    • Method Summary

      Modifier and Type Method Description
      boolean digest_latitude_match()
      This should cascade.
      boolean digest_longitude_match()
      This is a copy of the logic for digest_latitude_match; All I replace is "Lat" with "Lon"
      static int get_hemisphere_sign​(java.lang.String val)  
      static java.lang.String get_hemisphere_symbol​(int hemi)  
      int getLatHemisphereSign​(java.util.Map<java.lang.String,​java.lang.String> elements)  
      int getLonHemisphereSign​(java.util.Map<java.lang.String,​java.lang.String> elements)
      Given a list of match groups find the first Longitude Hemisphere group hemiLon W, E group used mostly for DMS, DM, DD formats hemiLonSign +, - group allowed only for specific formats; +/- may appear before any number not just coords.
      double getValue()
      Get the cartesian value for this ordinate
      boolean hasDegrees()  
      boolean hasHemisphere()  
      boolean hasMinutes()  
      boolean hasSeconds()  
      boolean hasSubDegrees()  
      boolean hasSubMinutes()  
      boolean hasSubSeconds()  
      boolean hasSymbols()  
      protected void set_normalized_text()
      Get back a normalized version of what you found.
      void setRelativeOffsets​(int matchStart)
      offsets for degree and hemisphere until this point are likely absolute within a document Reset them using this relative offset.
      double toDecimal()
      toDD() Return the decimal value to the extent it makes sense.
      boolean validate()
      Unused
      • Methods inherited from class java.lang.Object

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

      • offsetDeg

        protected int offsetDeg
        Where does the Degree value begin in text?
      • offsetMatch

        protected int offsetMatch
      • offsetOrdinate

        protected int offsetOrdinate
      • has_hemi

        public boolean has_hemi
      • specificity

        public DMSOrdinate.Resolution specificity
         Specificity is a field resolution, that is how many fields were specified in the match?
          Ex. D:M:S.ss  match is pretty fine -- sub-second
          Versus absolute resolution which looks at the significant-figures in the absolute value.
          Ex. D.dddddddddddd  is very fine, too. This can either be coarse or super-fine.
        
          Lat/Lon specificity mismatches indicate false-positives, lat(DEG) with a lon(SUBMIN)
          its unlikely they are valid pair.
         
      • text

        public java.lang.String text
      • has_degrees

        public boolean has_degrees
      • has_minutes

        public boolean has_minutes
      • has_seconds

        public boolean has_seconds
      • degLatFields

        public static final java.lang.String[] degLatFields
      • degLonFields

        public static final java.lang.String[] degLonFields
      • COORDINATE_SYMBOLS

        public static final java.lang.String[] COORDINATE_SYMBOLS
      • HEMI_MAP

        public static final java.util.Map<java.lang.String,​java.lang.Integer> HEMI_MAP
      • hemiLatFields

        public static final java.lang.String[] hemiLatFields
      • hemiLonFields

        public static final java.lang.String[] hemiLonFields
      • offsetHemi

        protected int offsetHemi
    • Constructor Detail

      • DMSOrdinate

        public DMSOrdinate​(java.util.Map<java.lang.String,​TextEntity> fieldMatches,
                           java.util.Map<java.lang.String,​java.lang.String> fieldVals,
                           boolean islat,
                           java.lang.String t)
                    throws NormalizationException
        DMS ordinates can be made up of degrees, minutes, seconds and then decimal minutes and decimal seconds fractional minutes dddd are formatted as ".dddd" then parsed; ADD to existing minutes fractional seconds dddd are formatted as ".dddd" then parsed; ADD to existing seconds decimal minutes d.ddd.. are parsed as float, divide by 60 to get # of degrees decimal seconds d.ddd.. "" "" , divide by 3600 to get # of degrees All Constructors must set is_latitude from a given flag. This is used for range validation.
        Parameters:
        fieldMatches - the field matches
        fieldVals - the field vals
        islat - true if matched part is for latitude
        t - the raw text of the matched coordinate
        Throws:
        NormalizationException - if coordinate is not valid or unable to normalize
      • DMSOrdinate

        @Deprecated
        public DMSOrdinate​(int deg,
                           int min,
                           int sec,
                           boolean islat,
                           int hemi_sign)
        Deprecated.
        For XCoord purposes use the DMSOrdinate(map, map, boolean, text) form.
        Only used for literal decimal degrees that require little parsing.
        Parameters:
        deg - degrees
        min - minutes
        sec - seconds
        islat - true if match is latitude
        hemi_sign - polarity of hemisphere
      • DMSOrdinate

        @Deprecated
        public DMSOrdinate​(int deg,
                           int min,
                           int sec,
                           int msec,
                           boolean islat,
                           int hemi_sign)
        Deprecated.
        For XCoord purposes use the DMSOrdinate(map, map, boolean, text) form.
        Construct a lat or lon ordinate from given values.
        Parameters:
        deg - degrees
        min - minutes
        sec - seconds
        msec - millis
        islat - true if match is latitude
        hemi_sign - polarity of hemisphere
      • DMSOrdinate

        @Deprecated
        public DMSOrdinate​(java.lang.String deg,
                           java.lang.String min,
                           java.lang.String sec,
                           boolean islat,
                           int hemi_sign)
                    throws java.text.ParseException
        Deprecated.
        For XCoord purposes use the DMSOrdinate(map, map, boolean, text) form.
        Construct a lat or lon ordinate from given values.
        Parameters:
        deg - degrees
        min - minutes
        sec - seconds
        islat - isLat
        hemi_sign - polarity
        Throws:
        java.text.ParseException - on parsing error or if values are null
    • Method Detail

      • setRelativeOffsets

        public void setRelativeOffsets​(int matchStart)
        offsets for degree and hemisphere until this point are likely absolute within a document Reset them using this relative offset. Offsets will then be relative to text.
        Parameters:
        matchStart - offset of match into doc
      • hasHemisphere

        public boolean hasHemisphere()
        Returns:
        true if match has Hemisphere
      • getValue

        public double getValue()
        Get the cartesian value for this ordinate
        Returns:
        double
      • set_normalized_text

        protected void set_normalized_text()
        Get back a normalized version of what you found. Yield zero-padded version of coordinate, e.g., if DMS xdeg M' SS" is parsed we want xxx:MM:SS fully padded 45 33N-00811 given 45:33.00811 normalized, DEG:MIN.mmmmm Full format should be: hDDD.ddd hDDD:MM.mmm hDDD:MM.mmm:SS.sss unlikely -- if this happens -- both fractional minutes and fractional seconds, pattern has errors hDDD:MM:SS.sss .ddd, .mmm, .sss --- as many decimal places as there are h --- +/- hemisphere
      • digest_latitude_match

        public boolean digest_latitude_match()
        This should cascade.
         IF Degrees specified,
            then if minutes,
               then if seconds...
         
        It would be difficult to skip minutes if DEG and SEC are only fields present.
        Returns:
        true if Latitude fields parse properly
      • digest_longitude_match

        public boolean digest_longitude_match()
        This is a copy of the logic for digest_latitude_match; All I replace is "Lat" with "Lon"
        Returns:
        true if longitude fields parse properly
      • hasSymbols

        public boolean hasSymbols()
        Returns:
        true if match has symbols
      • get_hemisphere_symbol

        public static java.lang.String get_hemisphere_symbol​(int hemi)
        Parameters:
        hemi - pos/neg number 1 or -1
        Returns:
        +/- symbol
      • get_hemisphere_sign

        public static int get_hemisphere_sign​(java.lang.String val)
        Parameters:
        val - +/- sign
        Returns:
        1 or -1 polarity
      • getLatHemisphereSign

        public int getLatHemisphereSign​(java.util.Map<java.lang.String,​java.lang.String> elements)
        Parameters:
        elements - list of trimmed components of the match
        Returns:
        polarity of hemisphere from fields
        See Also:
        getLonHemisphereSign(Map)
      • getLonHemisphereSign

        public int getLonHemisphereSign​(java.util.Map<java.lang.String,​java.lang.String> elements)
        Given a list of match groups find the first Longitude Hemisphere group hemiLon W, E group used mostly for DMS, DM, DD formats hemiLonSign +, - group allowed only for specific formats; +/- may appear before any number not just coords. hemiLonPre W, E, +, -
        Parameters:
        elements - list of trimmed components of the match
        Returns:
        polarity of hemisphere from fields
      • validate

        public boolean validate()
        Unused
        Returns:
      • toDecimal

        public double toDecimal()
        toDD() Return the decimal value to the extent it makes sense. That is, calculating minutes or seconds where MIN or SEC fields are out of bounds for those units does not make sense, return at least Deg or Deg/Min. Validation of the ordinate is a second step to be done by caller.
        Returns:
      • hasDegrees

        public boolean hasDegrees()
      • hasSubDegrees

        public boolean hasSubDegrees()
      • hasMinutes

        public boolean hasMinutes()
      • hasSubMinutes

        public boolean hasSubMinutes()
      • hasSeconds

        public boolean hasSeconds()
      • hasSubSeconds

        public boolean hasSubSeconds()