您好,登錄后才能下訂單哦!
本文介紹了java 地心坐標系(ECEF)和WGS-84坐標系(WGS84)互轉(zhuǎn)的實現(xiàn),分享給大家,具體如下:
public static String WGS84toECEF(double latitude, double longitude, double height) { double X; double Y; double Z; double a = 6378137; double b = 6356752.314245; double E = (a * a - b * b) / (a * a); double COSLAT = Math.cos(latitude * Math.PI / 180); double SINLAT = Math.sin(latitude * Math.PI / 180); double COSLONG = Math.cos(longitude * Math.PI / 180); double SINLONG = Math.sin(longitude * Math.PI / 180); double N = a / (Math.sqrt(1 - E * SINLAT * SINLAT)); double NH = N + height; X = NH * COSLAT * COSLONG; Y = NH * COSLAT * SINLONG; Z = (b * b * N / (a * a) + height) * SINLAT; return X + "," + Y + "," + Z; } public static String ECEFtoWGS84(double x, double y, double z) { double a, b, c, d; double Longitude;//經(jīng)度 double Latitude;//緯度 double Altitude;//海拔高度 double p, q; double N; a = 6378137.0; b = 6356752.31424518; c = Math.sqrt(((a * a) - (b * b)) / (a * a)); d = Math.sqrt(((a * a) - (b * b)) / (b * b)); p = Math.sqrt((x * x) + (y * y)); q = Math.atan2((z * a), (p * b)); Longitude = Math.atan2(y, x); Latitude = Math.atan2((z + (d * d) * b * Math.pow(Math.sin(q), 3)), (p - (c * c) * a * Math.pow(Math.cos(q), 3))); N = a / Math.sqrt(1 - ((c * c) * Math.pow(Math.sin(Latitude), 2))); Altitude = (p / Math.cos(Latitude)) - N; Longitude = Longitude * 180.0 / Math.PI; Latitude = Latitude * 180.0 / Math.PI; return Longitude + "," + Latitude + "," + Altitude; }
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持億速云。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。