我对Android编程相当陌生,但我越来越擅长它(我认为:))
我正在做的是构建一个位置故事应用程序。这是一个应用程序,它将音频文件放置在某些GPS标记处,并使用户能够在特定位置收听它们。移动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);
}
谢谢!在编辑的帖子中发布了我的功能。 – Tony 2012-03-05 16:17:24