首页 > 其他 > 详细

经纬度转换成十进制

时间:2015-01-23 12:54:24      阅读:284      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!