private Vector addAnchorString(Vector list, String field, double diff) { Vector topIndex = new Vector(); Hashtable topIndexParms, currEntry; double lastValue, currValue; if (list.size() == 0) return null; currEntry = (Hashtable) list.get(0); lastValue = Common.parseDouble((String) currEntry.get(field)) + diff; for (int i = 1; i < list.size(); i++) { currEntry = (Hashtable) list.get(i); currValue = Common.parseDouble((String) currEntry.get(field)); if (currValue >= lastValue) { // Values for navigation line topIndexParms = new Hashtable(); topIndexParms.put("HREF", Convert.toString(i)); topIndexParms.put("TEXT", Convert.toString(lastValue)); topIndex.add(topIndexParms); // add anchor entry to list currEntry.put("ANCHORNAME", Convert.toString(i)); currEntry.put("ANCHORTEXT", Convert.toString(lastValue)); lastValue = currValue + diff; } else { // clear value from previous run currEntry.put("ANCHORNAME", ""); currEntry.put("ANCHORTEXT", ""); } list.set(i, currEntry); } return topIndex; }
/** * 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; } }
public int compare(Object o1, Object o2) { Hashtable hash1 = (Hashtable) o1; Hashtable hash2 = (Hashtable) o2; String str1, str2; double dbl1, dbl2; str1 = hash1.get(compareWhat).toString().toLowerCase(); str2 = hash2.get(compareWhat).toString().toLowerCase(); if (this.compareWhat.equals("WAYPOINT")) { str1 = hash1.get(compareWhat).toString().substring(2).toLowerCase(); str2 = hash2.get(compareWhat).toString().substring(2).toLowerCase(); } if (this.compareWhat.equals("DISTANCE")) { dbl1 = Common.parseDouble(str1.substring(0, str1.length() - 3)); dbl2 = Common.parseDouble(str2.substring(0, str2.length() - 3)); if (dbl1 > dbl2) return 1; if (dbl1 < dbl2) return -1; else return 0; } else { return str1.compareTo(str2); } }
/** * 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; }