经纬度坐标转换度分秒
function changeToDFM(du) {
const arr1 = du.split(".");
const d = arr1[0];
let tp = "0." + arr1[1]
tp = String(tp * 60); //这里进行了强制类型转换
const arr2 = tp.split(".");
const f = arr2[0];
tp = "0." + arr2[1];
tp = tp * 60;
const m = tp;
const dfm = d + "°" + f + "'" + m + "\"";
return dfm;
}
console.log(changeToDFM('113.211'))
//113°12'39.6"
经纬度度分秒转换坐标系
function changeToDu(dfm) {
const arr1 = dfm.split('°');
const d = arr1[0];
const arr2 = arr1[1].split("'")
let f = arr2[0] || 0;
const m = arr2[1] || 0;
f = parseFloat(f) + parseFloat(m / 60);
var du = parseFloat(f / 60) + parseFloat(d);
return du;
}
console.log(changeToDu("113°12'39.6"))
//113.211
博客主要围绕经纬度坐标展开,介绍了经纬度坐标与度分秒之间的转换,以及经纬度度分秒与坐标系的转换,聚焦于信息技术领域的坐标转换相关内容。

5053

被折叠的 条评论
为什么被折叠?



