码迷,mamicode.com
首页 > 其他好文 > 详细

经纬度转换成十进制

时间:2015-01-23 12:56:53      阅读:324      评论:0      收藏:0      [点我收藏+]

标签:

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;
    }
}

 

经纬度转换成十进制

标签:

原文地址:http://www.cnblogs.com/chuyuan/p/4243778.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!