Ejemplo n.º 1
0
  /**
   * Construct a lat or lon ordinate from given values.
   *
   * @deprecated For XCoord purposes use the DMSOrdinate(map, map, boolean, text) form.
   * @param deg degrees
   * @param min minutes
   * @param sec seconds
   * @param islat isLat
   * @param hemi_sign polarity
   * @throws java.text.ParseException on parsing error or if values are null
   */
  @Deprecated
  public DMSOrdinate(String deg, String min, String sec, boolean islat, int hemi_sign)
      throws java.text.ParseException {
    if (deg == null) {
      throw new java.text.ParseException("Degrees may not be null", 1);
    }
    degrees = Integer.parseInt(deg);
    text = deg;

    isLatitude = islat;
    hemisphere.polarity = hemi_sign;

    if (hemi_sign < 0) {
      text = "-" + text;
    }

    if (min != null) {
      minutes = Integer.parseInt(min);
      text += ":" + min;
    }

    if (sec != null) {
      seconds = Integer.parseInt(sec);
      text += ":" + sec;
    }

    value = toDecimal();
  }
Ejemplo n.º 2
0
  /**
   * Only used for literal decimal degrees that require little parsing.
   *
   * @deprecated For XCoord purposes use the DMSOrdinate(map, map, boolean, text) form.
   * @param deg degrees
   * @param min minutes
   * @param sec seconds
   * @param islat true if match is latitude
   * @param hemi_sign polarity of hemisphere
   */
  @Deprecated
  public DMSOrdinate(int deg, int min, int sec, boolean islat, int hemi_sign) {
    degrees = deg;
    minutes = min;
    seconds = sec;
    isLatitude = islat;
    hemisphere.polarity = hemi_sign;

    value = toDecimal();
  }
Ejemplo n.º 3
0
  /**
   * Given a list of match groups find the first Longitude Hemisphere group
   *
   * <p>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, +, -
   *
   * @param elements list of trimmed components of the match
   * @return polarity of hemisphere from fields
   */
  protected int getLonHemisphereSign(java.util.Map<String, String> elements) {
    findHemiOffset(hemiLonFields);

    String hemiLon = elements.get("hemiLon");
    String hemiSignLon = elements.get("hemiLonSign");
    String hemiLonPre = elements.get("hemiLonPre");

    if (hemiLonPre != null) {
      hemisphere.symbol = hemiLonPre;
      return get_hemisphere_sign(hemiLonPre);
    } else if (hemiLon != null) {
      hemisphere.symbol = hemiLon;
      return get_hemisphere_sign(hemiLon);
    } else if (hemiSignLon != null) {
      hemisphere.symbol = hemiSignLon;
      return get_hemisphere_sign(hemiSignLon);
    }

    return NO_HEMISPHERE_VALUE;
  }
Ejemplo n.º 4
0
  /**
   * Normalize a hemisphere pattern: +, -, NSEW, which may either be preceeding coordinate or after
   * it. As well, it may be optional, so lack of a hemisphere may match to null. In which case, --
   * NO_HEMISPHERE -- caller should assume POSITIVE hemisphere is implied. further filtering by
   * caller is warranted.
   *
   * @param t raw text of match
   * @param elements fields
   * @param islat true if match represents latitude
   */
  protected void normalize_hemisphere(
      String t, java.util.Map<String, String> elements, boolean islat) {

    int hemi = (islat ? getLatHemisphereSign(elements) : getLonHemisphereSign(elements));

    if (!hemisphere.isAlpha()) {
      coordinateSymbol = hasCoordinateSymbols(t);
    }

    has_hemi = hemi != NO_HEMISPHERE_VALUE;

    if (!has_hemi) {
      hemi = POS_HEMI; // Un-specified hemisphere defaults to POSITIVE
      /*
       * if (hasSymbols()) { hemi = POS_HEMI; // Un-specified hemisphere
       * defaults to POSITIVE } else { hemi = POS_HEMI; }
       */
    }

    hemisphere.polarity = hemi; // -1 or 1 only.
  }