添加到GPS坐标的距离

fgs*_*fgs 27 gps android

我正试图使用​​GPS在固定点的随机距离上生成一些点.

如何以米为单位添加距离?我看过UTM到GPS的转换,但有没有更简单的方法来实现这一目标?

我正在研究Android平台以防万一.

干杯,fgs

Sté*_*ane 51

  • P0(lat0,lon0):初始位置(单位:度)
  • dx,dy:从您的初始位置以米为单位的随机偏移量

您可以使用近似值来计算随机位置的位置:

 lat = lat0 + (180/pi)*(dy/6378137)
 lon = lon0 + (180/pi)*(dx/6378137)/cos(lat0)
Run Code Online (Sandbox Code Playgroud)

只要随机距离偏移低于10-100 km,这就非常精确

编辑:当然在Java Math.cos()中,Math.cos(Math.PI/180.0*lat0)如果lat0的度数如上所述,则使用弧度.

  • 我可能会使用 6371.0 KM 的平均半径而不是赤道处的半径。赔率是您所引用的区域位于长半轴和半短轴之间。如果您需要更高的准确性,请使用椭圆体的 Vincenty 公式,http://www.movable-type.co.uk/scripts/latlong-vincenty.html。 (4认同)
  • 这对我来说不太合适.经度偏移总是应该是原来的两倍.将其更改为以下更正:`lat = lat0 +(180/pi)*(dy/6378137)lon = lon0 +(180/pi/2)*(dx/6378137)/ cos(lat0)` (3认同)
  • 你好,6378137是地球半径吗?谢谢! (2认同)

Bru*_*nto 12

采取正方形,我正在使用这个:

 private double[] getBoundingBox(final double pLatitude, final double pLongitude, final int pDistanceInMeters) {

    final double[] boundingBox = new double[4];

    final double latRadian = Math.toRadians(pLatitude);

    final double degLatKm = 110.574235;
    final double degLongKm = 110.572833 * Math.cos(latRadian);
    final double deltaLat = pDistanceInMeters / 1000.0 / degLatKm;
    final double deltaLong = pDistanceInMeters / 1000.0 / degLongKm;

    final double minLat = pLatitude - deltaLat;
    final double minLong = pLongitude - deltaLong;
    final double maxLat = pLatitude + deltaLat;
    final double maxLong = pLongitude + deltaLong;

    boundingBox[0] = minLat;
    boundingBox[1] = minLong;
    boundingBox[2] = maxLat;
    boundingBox[3] = maxLong;

    return boundingBox;
}
Run Code Online (Sandbox Code Playgroud)

这将返回一个包含4个坐标的数组,您可以使用它们将原始点放在中心的正方形.


Ers*_*har 6

如果你想向东、向北、向西、向南,你可以使用这个:

@SuppressLint("DefaultLocale")
public static double go_mock_loc(double xx_lat,double xx_long,double xx_dinstance,String Direction)
{
//  double xx_lat= 45.815005; 
//  double xx_long= 15.978501;

//  int xx_dinstance=500;

    int equator_circumference=6371000;
    int polar_circumference=6356800;

    double m_per_deg_long =  360 / polar_circumference;
    double rad_lat=(xx_lat* (Math.PI) / 180);
    double m_per_deg_lat = 360 / ( Math.cos(rad_lat) * equator_circumference);

    double deg_diff_long = xx_dinstance * m_per_deg_long;
    double deg_diff_lat  = xx_dinstance * m_per_deg_lat; 


    double xx_north_lat = xx_lat + deg_diff_long;
    //double xx_north_long= xx_long;
    double xx_south_lat = xx_lat - deg_diff_long;
    //double xx_south_long= xx_long;

    //double xx_east_lat = xx_lat;
    double xx_east_long= xx_long + deg_diff_lat;  
    //double xx_west_lat = xx_lat;
    double xx_west_long= xx_long - deg_diff_lat;

    if (Direction.toUpperCase().contains("NORTH")) {
        return xx_north_lat;
    } else if (Direction.toUpperCase().contains("SOUTH"))
    {
        return xx_south_lat;
    } else if (Direction.toUpperCase().contains("EAST"))
    {
        return xx_east_long;
    } else if (Direction.toUpperCase().contains("WEST"))
    {
        return xx_west_long;
    }
    else 
        return 0; 

}
Run Code Online (Sandbox Code Playgroud)


小智 5

详细的概述在http://www.movable-type.co.uk/scripts/latlong.html上给出.

如果您在某处需要将经度/纬度转换为UTM坐标(GPS中使用的坐标),您可能需要查看http://www.uwgb.edu/dutchs/UsefulData/UTMFormulas.htm