【问题标题】:Geo Coordinates (Long,Lat) to Meters (x,y)地理坐标 (Long,Lat) 到米 (x,y)
【发布时间】:2018-03-04 11:35:23
【问题描述】:

我的工作坐标系如下图:

x 和 y 以米为单位。我只对正的 x,y 感兴趣。我想将 (x,y) 转换为 (lat,lon),反之亦然。

我认为这很简单,我认为下面的解决方案没有问题。但我没有得到非常正确的结果。

我的解决方案:

如下图所示,我将纬度和经度视为 2 个圆的角度:

1. (x,y) 到 (lat,lon)

我在两者上都应用了如下所示的弧长公式 (here); x 和 y

因此,我的职能是:

private static double calculateLat(float x) {
    int earthRadius = 6371000;
    return REF_LOC.getLatitude() + x*360/(2*PI*earthRadius);
}

private static double calculateLong(float y) {
    int earthRadius = 6371000;
    return REF_LOC.getLongitude() + y*360/(2*PI*earthRadius);
}

REF_LOC 是 (x,y) 为 (0,0) 的参考地理位置。它可以是地球上的任何一点。

2。 (lat,lon) 到 (x,y)

为此,我只是使用这个:

int calculateX(double longitude){
        Location.distanceBetween(REF_LOC.getLatitude(), REF_LOC.getLongitude(),
                REF_LOC.getLatitude(), lonDeg, results);
        return results[0];
}

int calculateY(double latitude){
        Location.distanceBetween(REF_LOC.getLatitude(), REF_LOC.getLongitude(),
                latDeg, REF_LOC.getLongitude(), results);
        return results[0];
}

但我得到的结果不一致。首先,我使用解决方案 1 并将一些值 (x,y) 转换为 (lat,long)。但是当我使用解决方案 2 使用相同的 (lat,long) 回到 (x,y) 时,我在 x 处得到大约 2 米的差异,在 y 处得到大约 10 米的差异。谁能帮我找出问题所在?

【问题讨论】:

  • 我估计差异导致您的 (1) 正在对球体进行建模,而 (2)(使用 Location.distanceBetween)正在对椭圆体进行建模,其中定义了椭圆体的轴如:double a = 6378137.0; // WGS84 major axis double b = 6356752.3142; // WGS84 semi-major axis
  • 另请查看gis.stackexchange.com/questions/25494/… 以了解错误幅度的说明。

标签: android google-maps coordinates


【解决方案1】:

提到我对球面与椭圆计算的评论,另一种查看球面与椭圆距离计算差异的方法是使用 2 个可用的实用程序:

// For REF_LOC = (70, 20)

// Compute a lat/lng due east of a REF_LOC and compute distance using both
// available methods.

LatLng P = SphericalUtil.computeOffsetOrigin(REF_LOC, 20000, 90.0);

// And then compute a distance 
d = SphericalUtil.computeDistanceBetween(REF_LOC, P);
Location.distanceBetween(REF_LOC.latitude, REF_LOC.longitude, P.latitude, P.longitude, results);

// d = 20000.000000000036
// results[0] = 20081.818


// and for a REF_LOC = (0, 20)
// d = 20000.000000000127
// results[0] = 20022.377

同样有趣的是 SphericalUtil.computeOffsetOrigin() 产生错误 从赤道到两极的纬度增加,使其不对称。然而,由此产生的距离基本上是精确的。

我建议使用 SphericalUtil.computeOffsetOrigin 来计算 X/Y 断裂 正如你所做的那样,将其转换为纬度和经度偏移量。

最后演示 SphericalUtil 解决方案:

// Start with some arbitrary x/y relative to REF_LOC
double Rx = 125.0;
double Ry = 73.0;

// Compute a lat/lon from REF_LOC to the point
LatLng Rll = new LatLng(SphericalUtil.computeOffsetOrigin(REF_LOC, Ry, 180).latitude,
            SphericalUtil.computeOffsetOrigin(REF_LOC, Rx, 270).longitude);

// And recompute the x/y components of the lat/lon

double Rxx = SphericalUtil.computeDistanceBetween(REF_LOC, new LatLng(REF_LOC.latitude, Rll.longitude));
double Ryy = SphericalUtil.computeDistanceBetween(REF_LOC, new LatLng(Rll.latitude, REF_LOC.longitude));

导致:

Rx/Ry   = (125.0, 73.0)
Rxx/Ryy = (125.00000004545973, 73.00000000137051)

我认为是可接受的错误。

所以分开的问题是 - x/y 真正代表什么?

参考这两个实用程序的源代码以获取更多信息:

Location

SphericalUtil

【讨论】:

  • 这已经奏效了!虽然如果我在你的解决方案中使用 Location.distanceBetween() 而不是 SphericalUtil.computeDistanceBetween(),它会给出不正确的结果。可能cz他们使用不同的半径值。好吧,转换是一致的(后退),但我还没有在地面上对其进行测试,看看它是否给出了正确的结果。非常感谢!
  • 我刚刚发现我必须反转角度(0 -> 180 和 90 ->270)才能使其工作。否则,该位置处于不利的一面。
  • 是的,computeOffsetOrigin 是“TO”,因此在球形解决方案中,它应该是您指示的将点放在第一象限的标题。代码已更新 - 谢谢。
猜你喜欢
  • 1970-01-01
  • 2016-07-23
  • 2019-07-02
  • 1970-01-01
  • 2011-03-31
  • 1970-01-01
  • 1970-01-01
  • 2019-12-29
  • 1970-01-01
相关资源
最近更新 更多