地理坐标(长,纬)到米(x,y)

问题描述 投票:2回答:1

我正在工作坐标系统如下图所示:

enter image description here

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

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

我的解决方案

正如我们在下图中看到的,我将纬度和经度视为2个圆的角度:

enter image description here

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

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

因此,我的职能是:

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.(年,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)。但是当我使用相同(纬度,长度)回到(x,y)使用解决方案2时,我得到的差异大约是2米x和10米y。任何人都可以帮我找出问题吗?

android google-maps coordinates
1个回答
1
投票

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

// 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

© www.soinside.com 2019 - 2024. All rights reserved.