IGC Flight Log Parser

2.0.0 · active · verified Tue Apr 21

igc-parser is a JavaScript/TypeScript library designed for parsing IGC flight log files, a standard format used for recording flights in gliders, balloons, and other unpowered aircraft. The current stable version is 2.0.0. The project maintains an active development pace, with releases occurring periodically to introduce enhancements and address breaking changes, as seen with versions 0.5.0, 1.0.0, 1.1.0, and 2.0.0. Key differentiators include its robust handling of various IGC record types (such as A, B, H, L records), support for specific extensions like LAD/LOD for B records, GeoDatum handling, and parsing of TZN timezone headers. It also offers a `lenient` parsing option, allowing processing of files even with minor errors. The library ships with comprehensive TypeScript type definitions, making it well-suited for modern TypeScript projects.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to parse an IGC flight log string, including reading from a temporary file, handling the parsing options (e.g., `lenient` mode), and logging key extracted information like flight date, pilot, glider type, and fix details.

import { parse } from 'igc-parser';
import { readFileSync, writeFileSync } from 'fs';
import { join } from 'path';

// Example IGC content (simplified for brevity, typically much longer)
const igcContent = `AXXXLXNAV;LX8000,FW:2.0\nHFDTE150717\nHFCIDJohn Doe\nHOTYPESHW-222\nHOREGISTRATIOND-2019\nI013638FXA\nB1018265101070N00701006E00049000-42\nB1018275101071N00701007E00050000-43\nLGC-2023-01-01T12:00:00Z\n60DC059E2D2F6CAD2E889224E355DBDDB805CAB100000639B49FC5F280A292C990F554789F12381380720000`;

// Create a temporary file to demonstrate reading from disk
const tempFilePath = join(__dirname, 'temp.igc');
writeFileSync(tempFilePath, igcContent, 'utf8');

try {
  const fileContent = readFileSync(tempFilePath, 'utf8');
  // Parse the IGC file content, allowing for minor errors with lenient mode
  const result = parse(fileContent, { lenient: true });

  console.log('Successfully parsed IGC file:');
  console.log(`Date: ${result.date}`);
  console.log(`Pilot: ${result.pilot}`);
  console.log(`Glider Type: ${result.gliderType}`);
  console.log(`Number of Fixes: ${result.fixes.length}`);
  console.log(`First Fix Time: ${result.fixes[0]?.time}`);
  console.log(`Last Fix Time: ${result.fixes[result.fixes.length - 1]?.time}`);

} catch (error) {
  console.error('Error parsing IGC file:', error);
} finally {
  // In a production application, you might remove the temporary file here.
  // import { unlinkSync } from 'fs';
  // unlinkSync(tempFilePath);
}

view raw JSON →