使用 Haversine 公式创建方法,Android V2 [英] Creating a method using Haversine Formula, Android V2
本文介绍了使用 Haversine 公式创建方法,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
感谢评论:) 谢谢!!
Comments are appreciated :) Thanks!!
推荐答案
试试这个,比Haversine简单多了!
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);
这篇关于使用 Haversine 公式创建方法,Android V2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文