/**
   * set lat and lon
   *
   * @param strLatNS "N" or "S"
   * @param strLatDeg Degrees of Latitude
   * @param strLatMin Minutes of Latitude
   * @param strLatSec Seconds of Latitude
   * @param strLonEW "E" or "W"
   * @param strLonDeg Degrees of Longitude
   * @param strLonMin Minutes of Longitude
   * @param strLonSec Seconds of Longitude
   * @param format Format: DD, DMM, DMS
   */
  public void set(
      String strLatNS,
      String strLatDeg,
      String strLatMin,
      String strLatSec,
      String strLonEW,
      String strLonDeg,
      String strLonMin,
      String strLonSec,
      int format) {
    switch (format) {
      case DD:
        this.latDec = Common.parseDouble(strLatDeg);
        this.lonDec = Common.parseDouble(strLonDeg);
        break;
      case DMM:
        this.latDec =
            Math.abs(Common.parseDouble(strLatDeg))
                + Math.abs((Common.parseDouble(strLatMin) / 60));
        this.lonDec =
            Math.abs(Common.parseDouble(strLonDeg))
                + Math.abs((Common.parseDouble(strLonMin) / 60));
        break;
      case DMS:
        this.latDec =
            Math.abs(Common.parseDouble(strLatDeg))
                + Math.abs((Common.parseDouble(strLatMin) / 60))
                + Math.abs((Common.parseDouble(strLatSec) / 3600));
        this.lonDec =
            Math.abs(Common.parseDouble(strLonDeg))
                + Math.abs((Common.parseDouble(strLonMin) / 60))
                + Math.abs((Common.parseDouble(strLonSec) / 3600));
        break;

      default:
        this.latDec = 91;
        this.lonDec = 361;
    }
    // makeValid();
    // To avoid changing sign twice if we have something like W -34.2345
    if (strLatNS.trim().equals("S") && this.latDec > 0) this.latDec *= -1;
    if (strLonEW.trim().equals("W") && this.lonDec > 0) this.lonDec *= -1;
    this.utmValid = false;
  }
 /**
  * shift the point
  *
  * @param meters positiv to north (east), negativ to south (west)
  * @param direction 0 north-south, 1 east-west
  */
 public void shift(double meters, int direction) {
   double meters2deglon = 1 / (1000 * (new CWPoint(0, 0)).getDistance(new CWPoint(1, 0)));
   switch (direction) { // TODO use ellipsoid distance calculations for better accuracy
     case 0:
       latDec += meters * meters2deglon;
       return;
     case 1:
       lonDec += meters * (meters2deglon / Math.cos(latDec / 180 * Math.PI));
       return;
   }
 }
 /**
  * Returns the degrees or minutes or seconds (depending on parameter what) formatted as a string
  * To determine the degrees, we need to calculate the minutes (and seconds) just in case rounding
  * errors propagate. Equally we need to know the seconds to determine the minutes value.
  *
  * @param deg The coordinate in degrees
  * @param what 0=deg, 1=min, 2=sec
  * @param format DD,CW,DMM,DMS
  * @return
  */
 private String getDMS(double deg, int what, int format) {
   deg = Math.abs(deg);
   long iDeg = (int) deg;
   double tmpMin, tmpSec;
   tmpMin = (deg - iDeg) * 60.0;
   switch (format) {
     case DD:
       return "";
     case CW:
     case DMM:
       // Need to check if minutes would round up to 60
       if (java.lang.Math.round(tmpMin * 1000.0) == 60000) {
         tmpMin = 0;
         iDeg++;
       }
       switch (what) {
         case 0:
           return MyLocale.formatLong(iDeg, "00");
         case 1:
           return MyLocale.formatDouble(tmpMin, "00.000").replace(',', '.');
         case 2:
           return "";
       }
     case DMS:
       tmpSec = (tmpMin - (int) tmpMin) * 60.0;
       tmpMin = (int) tmpMin;
       // Check if seconds round up to 60
       if (java.lang.Math.round(tmpSec * 10.0) == 600) {
         tmpSec = 0;
         tmpMin = tmpMin + 1.0;
       }
       // Check if minutes round up to 60
       if (java.lang.Math.round(tmpMin) == 60) {
         tmpMin = 0;
         iDeg++;
       }
       switch (what) {
         case 0:
           return MyLocale.formatLong(iDeg, "00");
         case 1:
           return MyLocale.formatDouble(tmpMin, "00");
         case 2:
           return MyLocale.formatDouble(tmpSec, "00.0").replace(',', '.');
       }
   }
   return ""; // Dummy to keep compiler happy
 }
  /**
   * Method to calculate the distance to a waypoint
   *
   * @param dest lat, lon
   * @return distance to waypoint in Rad
   */
  public double getDistanceRad(double latDecD, double lonDecD) {
    double phi1 = this.latDec * PiOver180;
    double lambda0 = this.lonDec * PiOver180;
    double phi = latDecD * PiOver180;
    double lambda = lonDecD * PiOver180;
    double pdiff = Math.sin(((phi - phi1) / 2.0));
    double ldiff = Math.sin((lambda - lambda0) / 2.0);
    double rval = Math.sqrt((pdiff * pdiff) + Math.cos(phi1) * Math.cos(phi) * (ldiff * ldiff));

    return 2.0 * Math.asin(rval);
  }