首页 > 代码库 > 经纬度转换成十进制

经纬度转换成十进制

public class TestJingWeiDU {    public static void main(String[] args) {        TestJingWeiDU t = new TestJingWeiDU();                String lat = "35.37.39.55324";        String lon = "139.44.13.1546";        t.countLatLon(lat);        t.countLatLon(lon);        t.countLatLon("35.681123");    }        /** * 将平面坐标转成十进制 * @param dushu 35°37′39.55324″ * @return */    public double countLatLon(String dushu)    {        double tmpd = 0.0 ;        if( dushu != null && !"".equals(dushu) )        {            //<Latitude>35.37.39.55324</Latitude>            //<Longitude>139.44.13.1546</Longitude>            String[] tmp = dushu.split("\\.");            if(tmp.length==4){                tmpd = Double.parseDouble(tmp[0]);                tmpd = tmpd + Double.parseDouble(tmp[1])/60;                tmpd = tmpd + Double.parseDouble(tmp[2]+"."+tmp[3])/3600;            }            else            {                tmpd = Double.parseDouble(dushu) ;            }        }        System.out.println(tmpd);        return tmpd;    }}

 

经纬度转换成十进制