Add GPX file support for activity imports
This commit adds comprehensive GPX file support alongside existing FIT file support, enabling users to import activities from Strava, Komoot, and other GPS apps. ## Key Features ### Core Components - **GpxParser**: Full GPX 1.1 parsing with Garmin TrackPointExtension support - **GpxFileValidator**: Validation for GPX file format and structure - **ActivityFileService**: Unified service with automatic format detection (FIT/GPX) - **ParsedActivityData**: Common data structure for both FIT and GPX files ### GPX Parsing Capabilities - GPS track point extraction (latitude, longitude, elevation, timestamp) - Garmin extension data (heart rate, cadence, temperature) - Activity type detection from GPX metadata - Distance calculation using Haversine formula - Elevation gain/loss calculation - Speed calculation from consecutive GPS points - Speed smoothing to remove GPS artifacts - Timezone detection from GPS coordinates - Moving time vs. stopped time analysis ### Database Changes - Migration V15: Renamed raw_fit_file → raw_activity_file - Added source_file_format column (FIT/GPX) with constraint - Index on source_file_format for performance - Updated Activity entity with new fields ### Controller & UI Updates - ActivityController: Now handles both FIT and GPX uploads - Upload form: Updated to accept .fit and .gpx files - Help text: Clarified both formats are supported ### Testing - GpxParserIntegrationTest: 9 comprehensive tests with real GPX file - Tests cover: parsing, validation, heart rate extraction, distance calculation, elevation metrics, speed calculation, chronological ordering, smoothing - Fixed TrainingLoadServiceTest date issue (testDate outside 30-day window) - All 97 unit tests passing (integration tests require Docker) ### Technical Details - Supports GPX 1.0 and 1.1 specifications - Handles multiple track segments - Processes Garmin TrackPointExtension v1 and v2 - Same track simplification as FIT (Douglas-Peucker algorithm) - Consistent JSONB storage format for track points - Compatible with existing analytics, heatmaps, and image generation ## Testing Summary - ✅ 9/9 GpxParserIntegrationTest tests passing - ✅ 4/4 FitParserIntegrationTest tests passing - ✅ 14/14 FitFileServiceTest tests passing - ✅ 97/97 total unit tests passing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
66b14ebf7f
commit
f4be439002
21 changed files with 7466 additions and 160 deletions
|
|
@ -37,27 +37,27 @@
|
|||
<!-- File Upload Area -->
|
||||
<div class="mb-4">
|
||||
<label class="form-label fw-bold">
|
||||
FIT File <span class="text-danger">*</span>
|
||||
Activity File <span class="text-danger">*</span>
|
||||
</label>
|
||||
<div class="file-upload-area" id="fileUploadArea">
|
||||
<input type="file"
|
||||
id="fitFile"
|
||||
name="file"
|
||||
accept=".fit"
|
||||
accept=".fit,.gpx"
|
||||
class="d-none"
|
||||
required>
|
||||
<div class="file-upload-icon">
|
||||
<i class="bi bi-cloud-arrow-up"></i>
|
||||
</div>
|
||||
<p class="mb-2"><strong>Drop your FIT file here</strong></p>
|
||||
<p class="mb-2"><strong>Drop your FIT or GPX file here</strong></p>
|
||||
<p class="text-muted mb-2">or click to browse</p>
|
||||
<p class="file-upload-label text-primary fw-bold" id="fileLabel">
|
||||
No file selected
|
||||
</p>
|
||||
<small class="text-muted">Supported: .fit files from Garmin, Wahoo, etc. (Max 50MB)</small>
|
||||
<small class="text-muted">Supported: .fit, .gpx files (Max 50MB)</small>
|
||||
</div>
|
||||
<div class="invalid-feedback">
|
||||
Please select a FIT file to upload.
|
||||
Please select a FIT or GPX file to upload.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -164,7 +164,8 @@
|
|||
<div class="card-body">
|
||||
<h6><i class="bi bi-lightbulb text-warning"></i> Upload Tips</h6>
|
||||
<ul class="mb-0 small">
|
||||
<li>FIT files can be exported from Garmin Connect, Strava, Wahoo, and most GPS devices</li>
|
||||
<li>FIT files from Garmin, Wahoo, and most GPS devices</li>
|
||||
<li>GPX files exported from Strava, Komoot, or other apps</li>
|
||||
<li>The activity will be processed to extract GPS tracks, metrics, and statistics</li>
|
||||
<li>You can add a title and description after uploading</li>
|
||||
<li>Public activities will appear in your followers' timelines on the Fediverse</li>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue