如何将纬度或经度转换为米? [英] How to convert latitude or longitude to meters?
问题描述
如果我有标准NMEA格式的经纬度读数,有没有简单的方法/公式可以将读数转换为米,然后我可以用Java(J9)实现?
编辑:
好吧,我想要做的事情不是很容易 ,但是我真正想要做的是:
假设我有一个经纬度点,一个经纬度和一个用户有一个简单的方法来比较它们以决定何时告诉用户他们在合理地之内路途点的近距离?我知道合理的主题,但这是容易实现的还是过度的数学运算-y?
以下是一个javascript函数:
函数measure(lat1,lon1,lat2,lon2){//通常使用的地理测量函数
var R = 6378.137; // KM中的地球半径b $ b var dLat = lat2 * Math.PI / 180 - lat1 * Math.PI / 180;
var dLon = lon2 * Math.PI / 180 - lon1 * Math.PI / 180;
var a = Math.sin(dLat / 2)* Math.sin(dLat / 2)+
Math.cos(lat1 * Math.PI / 180)* Math.cos(lat2 * Math。 PI / 180)*
Math.sin(dLon / 2)* Math.sin(dLon / 2);
var c = 2 * Math.atan2(Math.sqrt(a),Math.sqrt(1-a));
var d = R * c;
return d * 1000; //米
}
说明:
https://en.wikipedia.org/wiki/Haversine_formula
If I have a latitude or longitude reading in standard NMEA format is there an easy way / formula to convert that reading to meters, which I can then implement in Java (J9)?
Edit: Ok seems what I want to do is not possible easily, however what I really want to do is:
Say I have a lat and long of a way point and a lat and long of a user is there an easy way to compare them to decide when to tell the user they are within a reasonably close distance of the way point? I realise reasonable is subject but is this easily do-able or still overly maths-y?
Here is a javascript function:
function measure(lat1, lon1, lat2, lon2){ // generally used geo measurement function
var R = 6378.137; // Radius of earth in KM
var dLat = lat2 * Math.PI / 180 - lat1 * Math.PI / 180;
var dLon = lon2 * Math.PI / 180 - lon1 * Math.PI / 180;
var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.cos(lat1 * Math.PI / 180) * Math.cos(lat2 * Math.PI / 180) *
Math.sin(dLon/2) * Math.sin(dLon/2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
var d = R * c;
return d * 1000; // meters
}
Explanation:
https://en.wikipedia.org/wiki/Haversine_formula
这篇关于如何将纬度或经度转换为米?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!