【问题标题】:Calculating the angle between the user and POI (Points of Interest) in android在android中计算用户和POI(兴趣点)之间的角度
【发布时间】:2012-05-18 17:25:24
【问题描述】:

我想做一个函数来计算用户和一个兴趣点(POI)之间的角度,参考真北。

我已经有了我的位置和 POI 位置的经度和纬度,现在我需要它们之间的角度。

这是我所拥有的:

private float calcAzimuth1(float lat0, float long0, float lat1, float long1)
{
    //user's latitude and longitude
    float userLat  = (float) ((lat0  * ((float)Math.PI))/180);
    float userLong = (float) ((long0 * ((float)Math.PI))/180);

    //POI's latitude and longitude
    float latT1    = (float) ((lat1  * ((float)Math.PI))/180);
    float longT1   = (float) ((long1 * ((float)Math.PI))/180);

    //angle between them
    float angle=??}

【问题讨论】:

  • 它们之间的角度参考什么?
  • 对不起,我忘了!参考真北!
  • 这实际上相当棘手。经度从赤道的 60 海里到两极的 0 不等,因此转换为局部矩形距离比需要在计算反正切之前考虑到这一点。但是在更长的距离上,进行局部矩形投影不再有效。这在古代的某些地方是经过深思熟虑的,并且是航海时代导航员的常识,所以一个好的导航入门应该能满足你的需要。寻呼纳撒尼尔鲍迪奇...en.wikisource.org/wiki/The_American_Practical_Navigator

标签: android azimuth point-of-interest


【解决方案1】:

检查 Location 类的 BearingTo 函数 http://developer.android.com/reference/android/location/Location.html#bearingTo(android.location.Location) 您可以从 Lat/Longs 创建两个 Location 对象,然后获取它们之间的方位。

您可能需要的另一件事是计算设备方向,然后将它们组合在一起。这需要收听传感器并根据收到的信息计算北方。在这里检查答案: Compass readings on SGS III

【讨论】:

    猜你喜欢
    • 2016-01-28
    • 1970-01-01
    • 2013-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多