[英]Calculate new gps coordinates from 1 set of coordinates and distance?
所以我想知道是否有现有的代码/库可以让我计算给定的一对新的GPS坐标:距离,一对纬度,经度和方位。
我希望你们能给我洞察力。
干杯!
给我的答案来自此链接:stackoverflow.com/questions/37348207/find-location-1-km-away-in-180-south-from-my-location/37349396#37349396
使用以下库: https : //github.com/JavadocMD/simplelatlng但是执行计算的方法如下:
/**
* <p>
* Calculate the end point of traveling along a great-circle path from a
* given starting point with a given intitial bearing for a known distance.
* </p>
*
* @param start
* the starting point.
* @param initialBearing
* the initial bearing.
* @param distance
* the distance to travel.
* @param unit
* the unit in which distance is measured.
* @return the end point.
*/
public static LatLng travel(LatLng start, double initialBearing, double distance,
LengthUnit unit) {
double bR = Math.toRadians(initialBearing);
double lat1R = Math.toRadians(start.getLatitude());
double lon1R = Math.toRadians(start.getLongitude());
double dR = distance / LatLngConfig.getEarthRadius(unit);
double a = Math.sin(dR) * Math.cos(lat1R);
double lat2 = Math.asin(Math.sin(lat1R) * Math.cos(dR) + a * Math.cos(bR));
double lon2 = lon1R
+ Math.atan2(Math.sin(bR) * a, Math.cos(dR) - Math.sin(lat1R) * Math.sin(lat2));
return new LatLng(Math.toDegrees(lat2), Math.toDegrees(lon2));
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.