2011-11-21 29 views

回答

3

(未經測試)

double lon = Double.parseDouble(latlon[0]); // contains lon string 
    double lat = Double.parseDouble(latlon[1]); 
    String ew = "";  String ns = ""; 

    if(lon < 0) 
     ew = "W"; 
    else 
     ew = "E"; 

    if(lat < 0) 
    ns = "S"; 
    else 
    ns = "N"; 

    String latitude, longitude;  
    int d = (int)lon; 
    longitude = ew + " " + d + "°";  
    double mm = (lon - d) * 60; 
    int m = (int)mm; 
    String minutes = new Double(m).toString(); 
    double ss = (mm - m)*60; 
    String secs = new Double(ss).toString(); 
    longitude += minutes + "'" + secs + "\""; 

執行相同的緯度。

+0

這是完美的工作,非常感謝! – timoschloesser

相關問題