MCPcopy Create free account
hub / github.com/Tong89/smartNode / get_orbit_tracks

Function get_orbit_tracks

backend/api.py:1424–1492  ·  view source on GitHub ↗

返回所有 LEO/MEO 卫星在当前时刻起的一个轨道周期内的位置采样点。 用于前端在 Cesium 中绘制空间轨道折线与地面星下点轨迹。 查询参数: - steps (int): 每颗卫星的采样点数量,范围 [20, 360],默认 90。 返回格式: { "time": <仿真时刻>, "tracks": [ { "id": "LEO-001", "type": "LEO", "orbit_period": 5760

()

Source from the content-addressed store, hash-verified

1422
1423@app.route('/api/orbit_tracks')
1424def get_orbit_tracks():
1425 """返回所有 LEO/MEO 卫星在当前时刻起的一个轨道周期内的位置采样点。
1426
1427 用于前端在 Cesium 中绘制空间轨道折线与地面星下点轨迹。
1428
1429 查询参数:
1430 - steps (int): 每颗卫星的采样点数量,范围 [20, 360],默认 90。
1431
1432 返回格式:
1433 {
1434 "time": <仿真时刻>,
1435 "tracks": [
1436 {
1437 "id": "LEO-001",
1438 "type": "LEO",
1439 "orbit_period": 5760.0,
1440 "orbit_points": [{"lat": ..., "lon": ..., "alt": ...}, ...],
1441 "ground_points": [{"lat": ..., "lon": ..., "alt": 0}, ...]
1442 },
1443 ...
1444 ]
1445 }
1446 """
1447 try:
1448 raw_steps = request.args.get('steps', '90')
1449 try:
1450 steps = int(raw_steps)
1451 except (ValueError, TypeError):
1452 steps = 90
1453 steps = max(20, min(360, steps))
1454
1455 with simulation_engine.lock:
1456 current_time = simulation_engine.current_time
1457 leo_sats = list(simulation_engine.leo_satellites)
1458 meo_sats = list(simulation_engine.meo_satellites)
1459
1460 tracks = []
1461 all_sats = [(sat, 'LEO') for sat in leo_sats] + [(sat, 'MEO') for sat in meo_sats]
1462
1463 for sat, sat_type in all_sats:
1464 period = sat.get_orbital_period()
1465 dt = period / steps
1466
1467 orbit_points = []
1468 ground_points = []
1469 for i in range(steps):
1470 t = current_time + i * dt
1471 lat, lon, alt = sat.propagate(t)
1472 orbit_points.append({'lat': round(lat, 4), 'lon': round(lon, 4), 'alt': round(alt, 0)})
1473 ground_points.append({'lat': round(lat, 4), 'lon': round(lon, 4), 'alt': 0})
1474
1475 # 闭合轨道:加入起始点
1476 if orbit_points:
1477 orbit_points.append(orbit_points[0])
1478 ground_points.append(ground_points[0])
1479
1480 tracks.append({
1481 'id': sat.sat_id,

Callers

nothing calls this directly

Calls 6

okFunction · 0.90
error_responseFunction · 0.90
get_orbital_periodMethod · 0.80
appendMethod · 0.80
getMethod · 0.45
propagateMethod · 0.45

Tested by

no test coverage detected