Fix GPX route processing to support GPX routes (not just tracks)

- Updated create_map_route_from_gpx function to parse GPX routes
- Added support for <rte> and <rtept> elements in addition to tracks
- This fixes the map not showing routes from GPX files that contain route data instead of track data
- Routes from applications like gpxplanner.app now work correctly
This commit is contained in:
ske087
2025-08-09 15:49:26 +03:00
parent f2530a1c5b
commit 343b7389e7

View File

@@ -325,7 +325,26 @@ def create_map_route_from_gpx(gpx_file_id: int) -> bool:
total_distance += distance
prev_point = point
# If no track points, try waypoints
# If no track points, try routes
if not all_coordinates:
for route in gpx.routes:
prev_point = None
for point in route.points:
coord = [point.latitude, point.longitude]
all_coordinates.append(coord)
if point.elevation is not None:
elevations.append(point.elevation)
# Calculate distance
if prev_point:
distance = prev_point.distance_2d(point)
if distance:
total_distance += distance
prev_point = point
# If no track or route points, try waypoints
if not all_coordinates:
for waypoint in gpx.waypoints:
coord = [waypoint.latitude, waypoint.longitude]