gpt4 book ai didi

geometry - 计算测地距离时考虑高度

转载 作者:行者123 更新时间:2023-12-04 01:06:38 25 4
gpt4 key购买 nike

我目前正在处理结合精确高度测量的 GPS 数据。
我想计算两个连续点之间的距离。有很多
关于使用 WGS84 椭球等计算两点之间距离的信息。

但是,我没有找到任何需要 的信息。海拔 考虑到这一点的变化
距离计算。

有谁知道一些描述这种方法的网站、论文、书籍等?
谢谢

编辑 : Sql Server 2008 地理扩展在计算距离时也会忽略海拔信息。

最佳答案

我使用起点和终点高度的平均值作为恒定高度实现了 WGS84 距离函数。如果您确定沿您的路径会有相对较小的高度变化,这可以很好地工作(误差与您的两个 LLA 点的高度差有关)。

这是我的代码(C#):

    /// <summary>
/// Gets the geodesic distance between two pathpoints in the current mode's coordinate system
/// </summary>
/// <param name="point1">First point</param>
/// <param name="point2">Second point</param>
/// <param name="mode">Coordinate mode that both points are in</param>
/// <returns>Distance between the two points in the current coordinate mode</returns>
public static double GetGeodesicDistance(PathPoint point1, PathPoint point2, CoordMode mode) {
// calculate proper geodesics for LLA paths
if (mode == CoordMode.LLA) {
// meeus approximation
double f = (point1.Y + point2.Y) / 2 * LatLonAltTransformer.DEGTORAD;
double g = (point1.Y - point2.Y) / 2 * LatLonAltTransformer.DEGTORAD;
double l = (point1.X - point2.X) / 2 * LatLonAltTransformer.DEGTORAD;

double sinG = Math.Sin(g);
double sinL = Math.Sin(l);
double sinF = Math.Sin(f);

double s, c, w, r, d, h1, h2;
// not perfect but use the average altitude
double a = (LatLonAltTransformer.A + point1.Z + LatLonAltTransformer.A + point2.Z) / 2.0;

sinG *= sinG;
sinL *= sinL;
sinF *= sinF;

s = sinG * (1 - sinL) + (1 - sinF) * sinL;
c = (1 - sinG) * (1 - sinL) + sinF * sinL;

w = Math.Atan(Math.Sqrt(s / c));
r = Math.Sqrt(s * c) / w;
d = 2 * w * a;
h1 = (3 * r - 1) / 2 / c;
h2 = (3 * r + 1) / 2 / s;

return d * (1 + (1 / LatLonAltTransformer.RF) * (h1 * sinF * (1 - sinG) - h2 * (1 - sinF) * sinG));
}

PathPoint diff = new PathPoint(point2.X - point1.X, point2.Y - point1.Y, point2.Z - point1.Z, 0);
return Math.Sqrt(diff.X * diff.X + diff.Y * diff.Y + diff.Z * diff.Z);
}

在实践中,我们发现高度差很少会产生很大的差异,我们的路径通常为 1-2 公里长,高度在 100 米左右,与使用未修改的 WGS84 椭球相比,我们看到平均约 5 米的变化。

编辑:

除此之外,如果您确实预计会有较大的高度变化,您可以将 WGS84 坐标转换为 ECEF(地心地球固定)并评估直线路径,如我的函数底部所示。将点转换为 ECEF 很简单:
    /// <summary>
/// Converts a point in the format (Lon, Lat, Alt) to ECEF
/// </summary>
/// <param name="point">Point as (Lon, Lat, Alt)</param>
/// <returns>Point in ECEF</returns>
public static PathPoint WGS84ToECEF(PathPoint point) {
PathPoint outPoint = new PathPoint(0);

double lat = point.Y * DEGTORAD;
double lon = point.X * DEGTORAD;
double e2 = 1.0 / RF * (2.0 - 1.0 / RF);
double sinLat = Math.Sin(lat), cosLat = Math.Cos(lat);

double chi = A / Math.Sqrt(1 - e2 * sinLat * sinLat);
outPoint.X = (chi + point.Z) * cosLat * Math.Cos(lon);
outPoint.Y = (chi + point.Z) * cosLat * Math.Sin(lon);
outPoint.Z = (chi * (1 - e2) + point.Z) * sinLat;

return outPoint;
}

编辑2:

有人问我代码中的其他一些变量:
// RF is the eccentricity of the WGS84 ellipsoid
public const double RF = 298.257223563;

// A is the radius of the earth in meters
public const double A = 6378137.0;
LatLonAltTransformer是我用来将 LatLonAlt 坐标转换为 ECEF 坐标并定义上述常量的类。

关于geometry - 计算测地距离时考虑高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1108965/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com