【问题标题】:Moving GPS coordinate移动 GPS 坐标
【发布时间】:2012-03-21 23:00:46
【问题描述】:

我对 Android 编程还很陌生,但我越来越擅长它(我认为:))
我正在做的是构建一个定位故事应用程序。这是一款将音频文件放置在特定 GPS 标记处并允许用户在特定位置收听的应用。

下一步是移动音频文件。我想要做的是在城市的特定位置设置一个标记。 (完毕)。接下来,我要检查第二个标记的位置,该标记围绕它移动一圈。

到目前为止,我所拥有的是:

public void checkCircularPosition(){
    /*
     * could be a solution?
     * 
    radius = 250; //offset in meters
    gpsLatCenter = 5.1164; //?how can i make this accurate in meters?
    gpsLonCenter = 52.0963; //??how can i make this accurate in meters?

    degree = 0; //should be variable over time (full circle in 1Hr, 3600sec --> 360/3600 =  0,1 deg/s)
    radian;

    radian = (degree/180)*Math.PI;
    gpsCircleLat = gpsLatCenter+Math.cos(radian)*radius;
    gpsCircleLon = gpsLonCenter-Math.sin(radian)*radius;
    */
}

现在,我在 adobe flash 中检查了这段代码,它使影片剪辑在一个圆圈中移动。所以我知道计算有些正确。但是,我无法计算结果坐标的经纬度。

编辑!!

我在下面发布的帮助下找到了解决方案。仍然有很多工作要弄清楚如何使用结果。无论如何,我在下面发布了结果函数。

要完成这项工作,您需要 _radius,即 6371(地球半径)、方位角、距离和起始位置。

非常感谢大家!

public static void destinationPoint(double brng, double dist) {

    dist = dist/_radius;  // convert dist to angular distance in radians
    brng = Math.toRadians(brng);  // 
    double lat1 = Math.toRadians(_lat);
    double lon1 = Math.toRadians(_lon);

    double lat2 = Math.asin( Math.sin(lat1)*Math.cos(dist) + Math.cos(lat1)*Math.sin(dist)*Math.cos(brng) );
    double lon2 = lon1 + Math.atan2(Math.sin(brng)*Math.sin(dist)*Math.cos(lat1), Math.cos(dist)-Math.sin(lat1)*Math.sin(lat2));
    lon2 = (lon2+3*Math.PI) % (2*Math.PI) - Math.PI;  // normalise to -180..+180º

    Log.i(APPTAG, ""+Math.toDegrees(lat2));
    Log.i(APPTAG, ""+Math.toDegrees(lon2));

    Location movLoc = new Location("");
    movLoc.setLatitude(Math.toDegrees(lat2));
    movLoc.setLongitude(Math.toDegrees(lon2));

    Log.i(APPTAG, ""+movLoc);
}

【问题讨论】:

    标签: android gps latitude-longitude


    【解决方案1】:

    您应该在此网站上查看从起点开始的距离和方位角部分:http://www.movable-type.co.uk/scripts/latlong.html

    该网站具有使用起点 (gpsLatCenter/gpsLonCenter) 和方位角(代码中的)计算最终纬度/经度 (gpsCircleLat/gpsCircleLon) 的正确公式。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-28
      • 2023-03-21
      相关资源
      最近更新 更多