创建使用半正矢公式,Android的V2的方法 [英] Creating a method using Haversine Formula, Android V2
本文介绍了创建使用半正矢公式,Android的V2的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不是真的很好用的数学,但我需要计算的标记两个不同位置的距离。事情是这样的:
I'm not really good with mathematics but I need to calculate the distance of two different locations of the markers. Something like this:
public double CalculationByDistance(double initialLat, double initialLong, double finalLat, double finalLong){
return distance;
}
或者是有,我可以计算出两个标记的距离的任何其他方法,我也尝试过谷歌的答案..但找不到任何。
Or is there any alternative ways that I can calculate the distance of two markers, also I tried to google for answers.. but couldn't find any.
参考: http://en.wikipedia.org/wiki/Haversine_formula
注释是AP preciated :)谢谢!
Comments are appreciated :) Thanks!!
推荐答案
试试这个,比半正矢简单多了!
Try this, much simpler than Haversine!
Location me = new Location("");
Location dest = new Location("");
me.setLatitude(myLat);
me.setLongitude(myLong);
dest.setLatitude(destLat);
dest.setLongitude(destLong);
float dist = me.distanceTo(dest);
这篇关于创建使用半正矢公式,Android的V2的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文