/** * set lat and lon by using GK coordinates * * @param strEasting Easting component * @param strNorthing Northing component */ public void set(String strEasting, String strNorthing) { GkPoint gk = new GkPoint( Common.parseDouble(strEasting), Common.parseDouble(strNorthing), GkPoint.GERMAN_GK); this.latDec = TransformCoordinates.germanGkToWgs84(gk).latDec; this.lonDec = TransformCoordinates.germanGkToWgs84(gk).lonDec; this.utmValid = false; }
/** * set lat and lon by using UTM coordinates * * @param strZone UTM-zone, e.g. 32U * @param strNorthing Northing component * @param strEasting Easting component */ public void set(String strZone, String strNorthing, String strEasting) { LatLonPoint ll = new LatLonPoint(); utm.zone_letter = strZone.charAt(strZone.length() - 1); utm.zone_number = Convert.toInt(strZone.substring(0, strZone.length() - 1)); utm.northing = (float) Common.parseDouble(strNorthing); utm.easting = (float) Common.parseDouble(strEasting); ll = utm.toLatLonPoint(); // returns null if unvalit UTM-coordinates if (ll != null) { this.utmValid = true; this.latDec = ll.getLatitude(); this.lonDec = ll.getLongitude(); } else { this.latDec = 91; this.lonDec = 361; } }
/** * 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; }