java 80转84_java 地心坐标系(ECEF)和WGS-84坐标系(WGS84)互转的实现

本文提供了Java实现地心坐标系(ECEF)与WGS-84坐标系(WGS84)相互转换的代码示例,包括wgs84toecef和eceftowgs84两个方法,涉及数学公式和坐标计算。
摘要由CSDN通过智能技术生成

本文介绍了java 地心坐标系(ecef)和wgs-84坐标系(wgs84)互转的实现,分享给大家,具体如下:

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;//经度

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;

}

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持萬仟网。

希望与广大网友互动??

点此进行留言吧!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值