Bugfixing

This commit is contained in:
Michal Kváček
2024-05-07 08:24:29 +02:00
parent a706303155
commit 62e46f37ce
5 changed files with 21 additions and 12 deletions
+8 -4
View File
@@ -1,7 +1,6 @@
import asyncio
import sys
from sqlalchemy import select
sys.path.insert(0, "/app/src")
from paths import FLIGHT_GPX_TRACK_PATH # noqa
from database import async_session, models # noqa
@@ -46,13 +45,18 @@ async def add_elevation_to_tracks():
for flight in flights:
gpx_file = f"{FLIGHT_GPX_TRACK_PATH}/{flight.gpx_track_filename}"
gpx = GPXParser(gpx_file)
try:
gpx = GPXParser(gpx_file)
except OSError:
print(f"ERROR, cannot open {gpx_file=}, skipping")
continue
coordinates = await gpx.get_coordinates()
coordinates = await gpx.get_coordinates_all()
elevation = await elevation_api.get_elevation_for_points(coordinates)
gpx_with_elevation = gpx.add_terrain_elevation(elevation)
output_name = f"terrain_{flight.gpx_track_filename[30:]}"
output_name = f"terrain_{flight.gpx_track_filename[-30:]}"
gpx.write(gpx_with_elevation, output=f"{FLIGHT_GPX_TRACK_PATH}/{output_name}")
await models.Flight.update(
db_session=session, obj=flight, data={