我想将gps坐标(纬度,经度)转换为ENU(est,north,up)坐标。
我知道关于这个问题的理论,但是我没有时间实现它,所以我问是否存在java代码来做它!
由于
答案 0 :(得分:4)
答案 1 :(得分:0)
答案 2 :(得分:0)
答案 3 :(得分:0)
使用goGPS library,Coordinates.java
/**
* @param origin
* @return Local (ENU) coordinates
*/
public void computeLocal(Coordinates target) {
if(this.geod==null) computeGeodetic();
SimpleMatrix R = rotationMatrix(this);
enu = R.mult(target.minusXYZ(this));
}
public void computeTopocentric(Coordinates origin, Coordinates target) {
origin.computeLocal(target);
double E = origin.getE();//enu.get(0);
double N = origin.getN();//enu.get(1);
double U = origin.getU();//enu.get(2);
答案 4 :(得分:0)
只需用Java简单实现,即可将GPS坐标转换为ENU坐标。
public List<Double> convertGpsToECEF(double lat, double longi, float alt) {
double a=6378.1;
double b=6356.8;
double N;
double e= 1-(Math.pow(b, 2)/Math.pow(a, 2));
N= a/(Math.sqrt(1.0-(e*Math.pow(Math.sin(Math.toRadians(lat)), 2))));
double cosLatRad=Math.cos(Math.toRadians(lat));
double cosLongiRad=Math.cos(Math.toRadians(longi));
double sinLatRad=Math.sin(Math.toRadians(lat));
double sinLongiRad=Math.sin(Math.toRadians(longi));
double x =(N+0.001*alt)*cosLatRad*cosLongiRad;
double y =(N+0.001*alt)*cosLatRad*sinLongiRad;
double z =((Math.pow(b, 2)/Math.pow(a, 2))*N+0.001*alt)*sinLatRad;
List<Double> ecef= new ArrayList<>();
ecef.add(x);
ecef.add(y);
ecef.add(z);
return ecef;
}
public List<Double> convertECEFtoENU(List<Double> ecefUser, List<Double> ecefPOI, double lat, double longi){
double cosLatRad=Math.cos(Math.toRadians(lat));
double cosLongiRad=Math.cos(Math.toRadians(longi));
double sinLatRad=Math.sin(Math.toRadians(lat));
double sinLongiRad=Math.sin(Math.toRadians(longi));
List<Double> vector = new ArrayList<>();
vector.add(ecefUser.get(0)-ecefPOI.get(0));
vector.add(ecefUser.get(1)-ecefPOI.get(1));
vector.add(ecefUser.get(2)-ecefPOI.get(2));
double e= vector.get(0)*(-sinLongiRad)+vector.get(0)*(cosLongiRad);
double n= vector.get(0)*(-sinLatRad)*(cosLongiRad)+vector.get(1)*(-sinLatRad)*(sinLongiRad)+vector.get(2)*cosLatRad;
double u= vector.get(0)*(cosLatRad)*(cosLongiRad)+vector.get(1)*(cosLatRad)*(sinLongiRad)+vector.get(2)*sinLatRad;
List<Double> enu= new ArrayList<>();
enu.add(e);
enu.add(n);
enu.add(u);
return enu;
}
答案 5 :(得分:-2)
其他解决方案是:
public static double[] fatCoordinates(double lat,double lon){
double phi = Math.toRadians(lat);
double lambda = Math.toRadians(lon);
double e2 = Math.pow(WGS_E,2);
double Rn = WGS_A / Math.sqrt(1 - e2 * Math.pow(Math.sin(phi), 2));
double[] XYZ = new double[3];
XYZ[0] = Rn * Math.cos(phi) * Math.cos(lambda);
XYZ[1] = Rn * Math.cos(phi) * Math.sin(lambda);
XYZ[2] = Rn * (1 - e2) * Math.sin(phi);
return XYZ;
}
带
public static final double WGS_A = 6378137.0;
public static final double WGS_E = 0.0818191908426;