【发布时间】: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