相关疑难解决方法(0)

计算两个GPS点之间的距离(x,y)

我正在寻找一种平滑的方法来计算两个GPS点之间的距离,所以我得到的结果如下:"你必须向上走x米,向左走y米 - 所以我可以使用二维坐标系,我的位置为(0,0),其他位置显示距我位置的距离(x,y)(以米为单位).

我的想法是使用半正弦公式计算点之间的距离.(这会返回我的斜边)

除此之外,我正在计算这两点之间的关系.这是我的阿尔法.

有了这两个值,我想使用基本的三角函数来解决我的问题.

所以我试着计算:catheti_1 = sin(alpha) * hypotenuse, catheti_2 = cos(alpha) * hypotenuse.

也许我做错了什么,但目前我的结果毫无用处.

所以我的问题是:如何计算两个GPS点之间x和y方向的距离?

我在以下程序中计算alpha:

public static double bearingTo(GPSBean point1, GPSBean point2) {
    double lat1 = Math.toRadians(point1.latitude);
    double lat2 = Math.toRadians(point2.latitude);
    double lon1 = Math.toRadians(point1.longitude);
    double lon2 = Math.toRadians(point2.longitude);

    double deltaLong = lon2 - lon1;

    double y = Math.sin(deltaLong) * Math.cos(lat2);
    double x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1)
            * Math.cos(lat2) * Math.cos(deltaLong);
    double bearing = Math.atan2(y, x);

    return (Math.toDegrees(bearing) + 360) % 360; …
Run Code Online (Sandbox Code Playgroud)

gps latitude-longitude

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

gps ×1

latitude-longitude ×1