the_paragliding_app

IGC Data Trimming Architecture

Core Principle: Single Source of Truth for Flight Data

The fundamental rule: ALL app code must work with trimmed data (takeoff to landing). Untrimmed data exists only in the source IGC file for archival purposes.

Data Flow Architecture

IGC File (Full/Archival) → Detection → Store Full Indices → Load Trimmed → App Uses Zero-Based
  1. IGC File Storage: Store complete, unmodified IGC files for archival
  2. Detection: Automatically detect takeoff/landing points using speed and climb rate thresholds
  3. Database Storage: Store detection indices relative to full IGC file coordinates
  4. Runtime Loading: FlightTrackLoader provides trimmed data with zero-based indices to all app code
  5. App Operations: All calculations, visualizations, and analysis work on trimmed data only

Implementation

FlightTrackLoader (Single Source of Truth)

Index Coordinate Systems

Detection Data Storage

Flight model stores detection results:

class Flight {
  int? takeoffIndex;    // Index in full IGC file
  int? landingIndex;    // Index in full IGC file  
  DateTime? detectedTakeoffTime;
  DateTime? detectedLandingTime;
  bool get hasDetectionData => takeoffIndex != null && landingIndex != null;
}

Best Practices

For App Code

For New Features

Deprecated Patterns

Key Services

Example Usage

// ✅ Correct: Use FlightTrackLoader
final igcFile = await FlightTrackLoader.loadFlightTrack(flight);
// igcFile.trackPoints is already trimmed and zero-based

// ✅ Correct: Calculate on trimmed data
final distance = igcFile.calculateGroundTrackDistance(); 
final triangleData = igcFile.calculateFaiTriangle();

// ✅ Correct: Store index relative to full IGC file
if (closingPointIndex != null && flight.hasDetectionData) {
  final fullCoordinateIndex = closingPointIndex + flight.takeoffIndex!;
  // Store fullCoordinateIndex to database
}

This architecture ensures: