Skip to content

Fix support for GPX files without tracks - #1228

Open
aronsky wants to merge 5 commits into
seanmorley15:mainfrom
aronsky:fix-gpx-route
Open

Fix support for GPX files without tracks#1228
aronsky wants to merge 5 commits into
seanmorley15:mainfrom
aronsky:fix-gpx-route

Conversation

@aronsky

@aronsky aronsky commented Jul 31, 2026

Copy link
Copy Markdown

Related Issue

Closes #1229

Fixed the issue right away, before opening an issue in the repo.


Description

Fixes 2 issues:

  1. GPXRoute objects in gpxpy don't have a length_3d/length_2d field, just length. This simply caused a warning and a missing length calculation.
  2. When converting to geojson, only tracks were taken into account; this now uses routes for files without tracks.

Without these fixes, when a GPX file with just a route (no tracks/segments) was added to a Transportation, the distance of the transportation wasn't calculated based on the route, and the route wasn't displayed on the map (contrary to the promise of the UI : )).


Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor / code cleanup
  • Performance improvement
  • Other (please describe)

Checklist

Before submitting this PR, please confirm:

  • I have linked an existing issue
  • The issue is approved or marked as ready
  • My changes follow the existing project structure and coding standards
  • I have tested the changes locally
  • Documentation has been updated if necessary

Screenshots (if applicable)

If this PR includes UI changes, please include screenshots or GIFs.


Thank you for contributing to AdventureLog! Your efforts help make this project better for everyone. We’ll review your PR as soon as we can. 🙌

Fixes 2 issues:

1. GPXRoute in gpxpy doesn't have a length_3d/length_2d field, just length. This simply cause a warning and a missing length calculation.
2. When converting to geojson, only tracks were taken into account; this now uses routes for files without tracks.
@aronsky
aronsky requested a review from seanmorley15 as a code owner July 31, 2026 19:29
@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown

@aronsky is attempting to deploy a commit to the Sean Morley's Projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

Copy link
Copy Markdown

🤖 AdventureLog Bot

🚫 This PR was automatically closed because it does not reference an issue.

Please link an issue using Closes #issue-number.

@github-actions github-actions Bot closed this Jul 31, 2026
@github-actions

Copy link
Copy Markdown

🤖 AdventureLog Bot

🚫 This PR was automatically closed.

Pull requests may only be opened for issues labeled ready.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

Only a minor naming nit remains; no blocking issues were identified.

Pull request overview

Fixes support for GPX files containing routes without tracks, including map rendering and distance calculation.

Changes:

  • Converts GPX routes to GeoJSON when tracks are absent.
  • Uses GPXRoute.length() for route distance calculations.
File summaries
File Summary
backend/server/adventures/utils/geojson.py Adds route-to-GeoJSON conversion; a minor fallback-label nit remains.
backend/server/adventures/serializers.py Corrects GPX route distance calculation.
Review details

Suppressed comments (2)

backend/server/adventures/serializers.py:554

  • This now makes route-only files work, but a GPX can also contain both recorded tracks and planned routes. Because this loop always adds every route after the track lengths, such a file reports the combined track-plus-route distance, while gpx_to_geojson gives tracks precedence. Treat routes as the fallback when no track data is present so the displayed distance and geometry refer to the same path.
            for route in gpx.routes:
                route_length = route.length()
                if route_length:
                    total_meters += route_length

backend/server/adventures/utils/geojson.py:34

  • elif skips every route whenever the GPX contains any track object. GPX permits both tracks and routes, and _parse_gpx_distance_km counts both, so the API can report distance for route data that is missing from the map. Process routes independently (or only fall back when no track features were emitted) so both representations remain consistent.
        elif gpx.routes:
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread backend/server/adventures/utils/geojson.py Outdated
seanmorley15 and others added 2 commits August 22, 2026 16:43
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

@seanmorley15 seanmorley15 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One little thing, do you agree that it should use the existing _gpx_to_feature_collection function instead of replicating that here?

@aronsky

aronsky commented Aug 29, 2026

Copy link
Copy Markdown
Author

Hi,

I'll take a look at this in the coming week or two. Just got back from the trip I planned with AdventureLog, and I'm still getting back on track.

@aronsky

aronsky commented Aug 30, 2026

Copy link
Copy Markdown
Author

One little thing, do you agree that it should use the existing _gpx_to_feature_collection function instead of replicating that here?

OK, checked the code. Agreed - the change should be in the function. I missed it because I based my code on the latest release version, and that function simply wasn't there in 0.12.1.

@github-actions

Copy link
Copy Markdown

🤖 AdventureLog Bot

🚫 This PR was automatically closed.

Pull requests may only be opened for issues labeled ready.

@github-actions github-actions Bot closed this Aug 30, 2026
@seanmorley15 seanmorley15 reopened this Aug 30, 2026
@aronsky

aronsky commented Sep 10, 2026

Copy link
Copy Markdown
Author

Hi Sean,

Just checking in - what's blocking this? It says "changes requested", but I don't see any comments regarding that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GPX routes aren't displayed

3 participants