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:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user