簡體   English   中英

將GPS坐標轉換為ENU坐標的功能?

[英]Function that converts GPS coordinates to ENU coordinates?

我想將gps坐標(緯度,經度)轉換為ENU(est,north,up)坐標。

我知道關於這個問題的理論,但我沒有時間實現它所以我問是否存在java代碼來做到這一點!

謝謝

出版物中,有很多關於主題的信息。 另外還有一個Matlab代碼 - 這是一個很好的起點。

SP Drake的相關部分(從“轉換GPS坐標(Φλh)到導航坐標(ENU)”):

在此輸入圖像描述

只是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;
    }

你在維基找到的公式

從ECEF到ENU

在缺乏公式編輯器的情況下,答案無法在此處發布。

我找到了一個簡單的方法。 它使用的想法是,將地球視為“平坦”可能是一個足夠好的近似值

http://williams.best.vwh.net/avform.htm#flat

方法

使用goGPS庫 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));

}

另請參見TopocentricCoordinates.java

    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);

其他解決方案是:

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;

它取自https://josm.openstreetmap.de/browser/josm/trunk/src/org/openstreetmap/josm/data/projection/Ellipsoid.java?rev=4382

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM