我正在使用如下的坐标系:
x和y的单位为米。我只对正向的x和y感兴趣。我想要将(x,y)转换成(lat,lon),反之亦然。
我认为这很简单,并且我认为我的解决方案没有问题。但是,我得到的结果并不完全正确。
我的解决方案:
如下图所示,我将纬度和经度作为两个圆的角度考虑:
1. (x,y)转换为(lat,lon)
我对x和y都应用了弧长公式(这里),如下所示:
![enter image description here](https://istack.dev59.com/0XcgD.webp)
![enter image description here](https://istack.dev59.com/z0p2E.webp)
因此,我的函数为:
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. (纬度,经度) 转 (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)。但是,当我使用相同的(lat,long)使用方案2将其还原为(x,y)时,我在x和y方向上大约有2米和10米的差异。请问有谁能帮我确定问题所在吗?
double a = 6378137.0; // WGS84 主轴 double b = 6356752.3142; // WGS84 半长轴
- user2711811