Repository navigation
Add sending tracks to Garmin Connect as courses - #962
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unescaped Garmin error responses create an XSS risk, while uncoordinated concurrent sends can lose course mappings and create duplicate courses.
5 open issues
Escape upstream errors before rendering them as HTML · New Coordinate course creation and persist mappings without lost updates · New Show an error when the upload request fails · New Interpolate antimeridian crossings along the short spherical arc · New Preserve destination elevation on the final interpolated point · New
What changed in this PR
Adds Garmin Connect course export to Mapforge’s track workflow, with account linking and send actions in the feature modal.
Changes:
- Links Garmin accounts through OAuth 2.0 PKCE and refreshes stored access tokens.
- Converts tracks into courses, updates previously sent courses, and recreates deleted courses.
- Adds upload feedback with course links, German translations, and request/model specs.
| File | Description |
|---|---|
spec/requests/maps_controller_spec.rb |
Tests course creation, updates, recreation, and API errors. |
spec/models/feature_spec.rb |
Tests course geometry, elevation totals, and activity types. |
locale/de/app.po |
Adds German Garmin messages. |
locale/app.pot |
Adds Garmin translation entries and refreshes source references. |
config/routes.rb |
Adds the Garmin upload endpoint. |
config/initializers/omniauth.rb |
Configures Garmin OAuth with PKCE. |
app/views/maps/modals/_feature.haml |
Adds Garmin connection and send controls. |
app/models/user.rb |
Includes Garmin account functionality. |
app/models/feature.rb |
Converts track geometry into Garmin course payloads. |
app/models/concerns/garmin_account.rb |
Handles tokens, course uploads, and saved course IDs. |
app/javascript/maplibre/feature/details.js |
Shows Garmin export for tracks and sets its URL. |
app/javascript/controllers/feature/modal_controller.js |
Sends uploads and displays results with course links. |
app/controllers/sessions_controller.rb |
Links Garmin credentials to the signed-in user. |
app/controllers/maps_controller.rb |
Handles upload requests, metrics, and Garmin errors. |
Review effort: Balanced
| status(window.__('Garmin Connect login expired, reload the page to connect again'), 'error') | ||
| } else { | ||
| const error = (await response.json().catch(() => ({}))).error | ||
| status(window.__('Error sending to Garmin Connect') + (error ? ': ' + error : ''), 'error') |
Comment on lines
+16
to
+19
| course_id = garmin_course_ids[feature.id.to_s] | ||
| return :updated if course_id && update_garmin_course(token, course_id, course) | ||
| created = token.post(COURSE_PATH, course_request(course)).parsed | ||
| update!(garmin_course_ids: garmin_course_ids.merge(feature.id.to_s => created["courseId"])) |
| segment = va.distance(vb) | ||
| steps = (segment / 100).ceil | ||
| (1..steps).each do |i| | ||
| points << garmin_point(a.zip(b).map { |x, y| x && y && x + (y - x) * i.fdiv(steps) }) |
| segment = va.distance(vb) | ||
| steps = (segment / 100).ceil | ||
| (1..steps).each do |i| | ||
| points << garmin_point(a.zip(b).map { |x, y| x && y && x + (y - x) * i.fdiv(steps) }) |
Users link a Garmin account through OAuth 2.0 PKCE and send a track from the feature modal. A repeated send updates the same course, and Mapforge creates it again if the user deleted it. The success message links to the course in Garmin Connect.
digitaltom
force-pushed
the
garmin_connect_upload
branch
from
November 15, 2026 22:49
718591d to
19f1b2a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Users link a Garmin account through OAuth 2.0 PKCE and send a track from the feature modal. A repeated send updates the same course, and Mapforge creates it again if the user deleted it. The success message links to the course in Garmin Connect.