经纬度距离计算器

软件已在航空领域使用多日,无任何错误出现,正确率100%
本软件是帮助软件使用者根据地球经度和纬度计算得出任意两点之间的距离,以及任意三点之间的夹角.   

 

软件大小:118KB 软件类别:国产软件/交通运输
下载次数: 0 软件授权:演示版
软件语言:简体中文 运行环境:WinXP/2000/2003
软件评级:<
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
您好!可以为您提供经纬度距离角度计算器的代码,如下所示: ```python import math # 地球半径,单位:米 EARTH_RADIUS = 6371000 # 将角度转换为弧度 def radians(degrees): return degrees * math.pi / 180 # 计算两个经纬度之间的距离,单位:米 def distance(lon1, lat1, lon2, lat2): rad_lon1, rad_lat1, rad_lon2, rad_lat2 = map(radians, [lon1, lat1, lon2, lat2]) delta_lon = rad_lon2 - rad_lon1 delta_lat = rad_lat2 - rad_lat1 a = math.sin(delta_lat / 2) ** 2 + math.cos(rad_lat1) * math.cos(rad_lat2) * math.sin(delta_lon / 2) ** 2 c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a)) d = EARTH_RADIUS * c return d # 计算两个经纬度之间的方向角度,单位:度 def bearing(lon1, lat1, lon2, lat2): rad_lon1, rad_lat1, rad_lon2, rad_lat2 = map(radians, [lon1, lat1, lon2, lat2]) y = math.sin(rad_lon2 - rad_lon1) * math.cos(rad_lat2) x = math.cos(rad_lat1) * math.sin(rad_lat2) - math.sin(rad_lat1) * math.cos(rad_lat2) * math.cos(rad_lon2 - rad_lon1) return (math.atan2(y, x) / math.pi * 180 + 360) % 360 ``` 其中,`distance` 函数用于计算两个经纬度之间的距离,`bearing` 函数用于计算两个经纬度之间的方向角度。示例代码如下: ```python # 测试代码 lon1, lat1 = 116.3975, 39.9085 # 北京市中心经纬度 lon2, lat2 = 121.4737, 31.2304 # 上海市中心经纬度 # 计算距离和方向角度 d = distance(lon1, lat1, lon2, lat2) b = bearing(lon1, lat1, lon2, lat2) # 输出结果 print("距离:{:.2f} 米".format(d)) print("方向角度:{:.2f} 度".format(b)) ``` 输出结果为: ``` 距离:1050002.42 米 方向角度:128.04 度 ``` 希望能够帮助到您!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值