From 343b7389e756f56c04b7cdc846011498381bcdc0 Mon Sep 17 00:00:00 2001 From: ske087 Date: Sat, 9 Aug 2025 15:49:26 +0300 Subject: [PATCH] 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 and 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 --- app/utils/gpx_processor.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/app/utils/gpx_processor.py b/app/utils/gpx_processor.py index 17b469b..7941490 100644 --- a/app/utils/gpx_processor.py +++ b/app/utils/gpx_processor.py @@ -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]