如何找到两个geopoints之间的距离? [英] how to find the distance between two geopoints?

查看:100
本文介绍了如何找到两个geopoints之间的距离?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

double distance;  

Location locationA = new Location("point A");  

locationA.setLatitude(latA);  
locationA.setLongitude(lngA);  

Location locationB = new Location("point B");  

locationB.setLatitude(latB);  
LocationB.setLongitude(lngB);  

distance = locationA.distanceTo(locationB);  

以上code不工作,我得到0.0公里的距离是多少? 另外在位置类的构造函数,什么是字符串提供商的意思。 在上述$ C $词现在用PointA和PointB作为供应商。

the above code is not working and i am getting 0.0 Km as distance? Also in the constructor of the location class, what does the string provider mean. In the above code i am using PointA and PointB as the providers.

为什么上面的code不工作?

why is the above code not working?

感谢你在前进。

的logcat     05-09 17:48:56.144:信息/电流LOC(1573):北纬0.0 LNG 0.0     05-09 17:48:56.155:信息/ checklocation LOC(1573):纬度54.4288665 LNG 10.169366

LOGCAT 05-09 17:48:56.144: INFO/current loc(1573): lat 0.0 lng 0.0 05-09 17:48:56.155: INFO/checklocation loc(1573): lat 54.4288665 lng 10.169366

推荐答案

尝试<一href="http://developer.android.com/reference/android/location/Location.html#distanceBetween%28double,%20double,%20double,%20double,%20float%5B%5D%29">Location.distanceBetween(..)

更新:

如果您是从的GeoPoint越来越纬度/经度,然后他们在microdegrees。您必须通过1e6个繁殖。

If you are getting lat/lon from GeoPoint then they are in microdegrees. You must multiply by 1e6.

这篇关于如何找到两个geopoints之间的距离?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆