广州驾照四必考注意事项

2013-05-02上午参加广州驾照四必,我们有好几个挂了,我总结一下,

1:通过第一项(斜坡起步)后,一直在等,过了30s 超时。挂了

2:紧张连续死火2次,挂了

3:侧方位停车时压线,或者车屁股出线,这里有2个人挂了,

4:最后的直角转弯是压线。挂了

import requests import numpy as np import time from itertools import combinations # ========== 配置参数 ========== BAIDU_KEY = "您的百度API密钥" # 需注册百度开发者 CITY_COORDINATES = { "北京": (39.9042, 116.4074), "上海": (31.2304, 121.4737), "广州": (23.1291, 113.2644), "成都": (30.5728, 104.0668) } # ========== 坐标系转换函数(WGS84转BD09)========== def wgs84_to_bd09(lat, lng): """ 将WGS84坐标转换为百度BD09坐标系 注意:简单计算可能存在百米级误差,精确转换需使用官方API """ x_pi = 3.14159265358979324 * 3000.0 / 180.0 x = lng y = lat z = np.sqrt(x**2 + y**2) + 0.00002 * np.sin(y * x_pi) theta = np.arctan2(y, x) + 0.000003 * np.cos(x * x_pi) return z * np.sin(theta) + 0.006, z * np.cos(theta) + 0.0065 # ========== 路网距离计算核心函数 ========== def get_baidu_distance(origin, destination, retry=3): """ 通过百度API获取实际驾驶距离 参数: origin : 起点坐标元组 (lat, lng) WGS84 destination : 终点坐标元组 (lat, lng) WGS84 返回: 道路距离(公里),失败返回None """ url = "http://api.map.baidu.com/direction/v2/driving" # 转换坐标系 orig_bd = wgs84_to_bd09(*origin) dest_bd = wgs84_to_bd09(*destination) params = { "ak": BAIDU_KEY, "origin": f"{orig_bd[0]},{orig_bd[1]}", # 纬度,经度 "destination": f"{dest_bd[0]},{dest_bd[1]}", "tactics": 13, # 13=最短距离 "coord_type": "bd09ll" # 指定输入坐标系 } for attempt in range(retry): try: response = requests.get(url, params=params, timeout=15) data = response.json() if data.get("status") == 0: return data["result"]["routes"][0]["distance"] / 1000 # 米转公里 else: print(f"错误代码 {data['status']}: {data.get('message')}") time.sleep(2**attempt) # 指数退避 except Exception as e: print(f"请求失败:{str(e)}") time.sleep(3) return None # ========== 生成距离矩阵 ========== def generate_baidu_matrix(coords_dict, delay=1): cities = list(coords_dict.keys()) n = len(cities) matrix = np.full((n, n), np.nan) for (i, j) in combinations(range(n), 2): distance = get_baidu_distance( coords_dict[cities[i]], coords_dict[cities[j]] ) matrix[i][j] = matrix[j][i] = distance or np.nan time.sleep(delay) # 遵守百度API频率限制 return matrix, cities # ========== 主程序 ========== if __name__ == "__main__": distance_matrix, city_order = generate_baidu_matrix(CITY_COORDINATES) print("\n城市顺序:", city_order) print("\n百度路网距离矩阵(公里):") print(np.round(distance_matrix, 1)) 给我优化一下,加快运行速度
03-29
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值