Class DMSOrdinate

java.lang.Object
org.opensextant.extractors.xcoord.DMSOrdinate

public final class DMSOrdinate extends 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
  • Field Details

    • LAT_MAX

      public static final int LAT_MAX
      See Also:
    • LON_MAX

      public static final int LON_MAX
      See Also:
    • offsetDeg

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

      protected int offsetOrdinate
    • hemisphere

      public Hemisphere hemisphere
    • 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 String text
    • has_degrees

      public boolean has_degrees
    • has_minutes

      public boolean has_minutes
    • has_seconds

      public boolean has_seconds
    • degLatFields

      public static final String[] degLatFields
    • degLonFields

      public static final String[] degLonFields
    • COORDINATE_SYMBOLS

      public static final String[] COORDINATE_SYMBOLS
    • WEST

      public static final String WEST
      See Also:
    • SOUTH

      public static final String SOUTH
      See Also:
    • NORTH

      public static final String NORTH
      See Also:
    • EAST

      public static final String EAST
      See Also:
    • NEGATIVE

      public static final String NEGATIVE
      See Also:
    • POSITIVE

      public static final String POSITIVE
      See Also:
    • NO_HEMISPHERE

      public static final int NO_HEMISPHERE
      See Also:
    • NO_HEMISPHERE_VALUE

      public static final int NO_HEMISPHERE_VALUE
      See Also:
    • POS_HEMI

      public static final int POS_HEMI
      See Also:
    • NEG_HEMI

      public static final int NEG_HEMI
      See Also:
    • HEMI_MAP

      public static final Map<String,Integer> HEMI_MAP
    • hemiLatFields

      public static final String[] hemiLatFields
    • hemiLonFields

      public static final String[] hemiLonFields
    • offsetHemi

      protected int offsetHemi
  • Constructor Details

    • DMSOrdinate

      public DMSOrdinate(Map<String,TextEntity> fieldMatches, Map<String,String> fieldVals, boolean islat, 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(String deg, String min, String sec, boolean islat, int hemi_sign) throws 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:
      ParseException - on parsing error or if values are null
  • Method Details

    • 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 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(String val)
      Parameters:
      val - +/- sign
      Returns:
      1 or -1 polarity
    • getLatHemisphereSign

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

      public int getLonHemisphereSign(Map<String,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
    • 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()