行走的蓑衣客

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
统计
 

 

复制代码
 
# 根据经度、纬度计算两地距离:
def get_distance2(lat1, lon1, lat2, lon2):
    """获取地理坐标系下的两点间距离"""
    # GetDistanceInGeographyCoordinate, return two point distance
    radius_lat1 = lat1 * math.pi / 180
    radius_lat2 = lat2 * math.pi / 180
    radius_lon1 = lon1 * math.pi / 180
    radius_lon2 = lon2 * math.pi / 180
    a = radius_lat1 - radius_lat2
    b = radius_lon1 - radius_lon2
    distance = 2 * math.asin(math.sqrt(
        pow(math.sin(a / 2.0), 2) +
        math.cos(radius_lat1) * math.cos(radius_lat2) *
        pow(math.sin(b / 2.0), 2)))
 
    distance = distance * 6378137
    distance = distance - (distance * 0.0011194)
    return distance

#方位角
def get_bearing(lat1, lon1, lat2, lon2):
    dlon = lon2 - lon1
 
    y = math.sin(dlon) * math.cos(lat2)
    x = math.cos(lat1) * math.sin(lat2) - math.sin(lat1) * math.cos(lat2) * math.cos(dlon)
 
    bearing = math.atan2(y, x)
    bearing = np.degrees(bearing)
    bearing = (bearing + 360) % 360
 
    return bearing
复制代码

 

posted on   行走的蓑衣客  阅读(485)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
 
点击右上角即可分享
微信分享提示