地理点与位置
这可能是一个菜鸟问题,但我不是 100% 确定。
如何使用地理点制作位置对象?我想用它来获取两点之间的距离。 我已经找到了一个线程,它说
Location loc1 = new Location("Location");
loc.setLatitude(geoPoint.getLatitudeE6);
loc.setLongitude(geoPoint.getLongitudeE6);
Location loc2 = new Location("Location2");
loc2.setLatitude(geoPoint.getLatitudeE6);
loc2.setLongitude(geoPoint.getLongitudeE6);
然后我将使用 distanceTo() 来获取两点之间的距离。
我的问题 提供商名称有何用途? ...新位置(“这是什么???”) 那么我必须先定义一个提供者还是什么? 我想在 for() 中使用此代码来计算更多地理点。 顺便说一句 - 我必须将 E6 值转换回正常值?
This is maybe a noob question but im not 100% sure about it.
How can i make a Location Object using Geo points? I want to use it to get the distance between two points.
I already found a thread where it says
Location loc1 = new Location("Location");
loc.setLatitude(geoPoint.getLatitudeE6);
loc.setLongitude(geoPoint.getLongitudeE6);
Location loc2 = new Location("Location2");
loc2.setLatitude(geoPoint.getLatitudeE6);
loc2.setLongitude(geoPoint.getLongitudeE6);
and then i would use the distanceTo() to get the distance between the two points.
My Questions
What is the Providername for? ...new Location("What is this here???")
So do i have to define a Provider before or something?
I want to use this code in a for() to calaculate between more GeoPoints.
And btw - i have to convert the E6 Values back to normal?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
loc.setLatitude()并不完全
采用双纬度。所以正确的代码是:
Location() 构造函数采用所使用的 GPS 提供商的名称。它可以是 LocationManager.GPS_PROVIDER 或 NETWORK_PROVIDER 以及其他值
Not exactly
loc.setLatitude() takes a double latitude. So the correct code is:
Location() constructor take the name of the GPS provider used. It can be LocationManager.GPS_PROVIDER or NETWORK_PROVIDER among other values
要获取两点之间的距离,您可以使用 Location 类等正是 distanceBetween 静态方法。
该文档非常清楚它的作用,但这里有一个快速代码示例:
要将分钟/秒转换为度数,您可以使用 convert Location 类的方法。
To get the distance between two point you can use the Location class and more precisely the distanceBetween static method.
The doc is quite clear on what it does but here a quick code sample:
To convert from minute/second to degree you can use the convert method of the Location class.
然后
then