igc

package module
v0.0.0-...-c795ea7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2025 License: MIT Imports: 10 Imported by: 0

README

go-igc

PkgGoDev

Package igc handles IGC files.

Features

  • Robust, flexible parser for real IGC files, including common deviations from the IGC specification.
  • Support for all IGC record types.
  • Support for B record additions.
  • Support for K record additions.
  • Support for N record additions.
  • Support for sub-second resolution timestamps with the TDS B record addition.
  • Support for high-resolution coordinates with the LAD and LOD B record additions.
  • Support for UTC midnight rollover.
  • Support for CIVL's Open Validation Server.

Validation

A simple command line client for CIVL's Open Validation server is included. Install and run it with:

$ go install github.com/twpayne/go-igc/cmd/validate-igc@latest
$ validate-igc filename.igc
filename.igc: Valid
$ echo $?
0

The exit code is 0 if the IGC file is valid, 1 if it is invalid, or 2 if it could not be validated.

License

MIT

Documentation

Overview

Package igc parses IGC files.

See https://www.fai.org/sites/default/files/igc_fr_specification_with_al8_2023-2-1_0.pdf.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ApprovedManufacturersByTLC is a map of three-letter codes to approved manufacturers.
	ApprovedManufacturersByTLC map[string]*Manufacturer

	// ManufacturersByTLC is a map of three-letter codes to approved or non-approved manufacturers.
	ManufacturersByTLC map[string]*Manufacturer
)
View Source
var ApprovedManufacturers = []Manufacturer{
	{TLC: "ACT", SCC: 'I', Name: "Aircotec"},
	{TLC: "AVX", Name: "Avionix"},
	{TLC: "CAM", SCC: 'C', Name: "Cambridge Aero Instruments"},
	{TLC: "CNI", Name: "ClearNav Instruments"},
	{TLC: "DSX", SCC: 'D', Name: "Data Swan/DSX"},
	{TLC: "EWA", SCC: 'E', Name: "EW Avionics"},
	{TLC: "FIL", SCC: 'F', Name: "Filser"},
	{TLC: "FLA", SCC: 'G', Name: "Flarm (Flight Alarm)"},
	{TLC: "FLY", Name: "Flytech"},
	{TLC: "GCS", SCC: 'A', Name: "Garrecht"},
	{TLC: "IMI", SCC: 'M', Name: "IMI Gliding Equipment"},
	{TLC: "LGS", Name: "Logstream"},
	{TLC: "LXN", SCC: 'L', Name: "LX Navigation"},
	{TLC: "LXV", SCC: 'V', Name: "LXNAV d.o.o."},
	{TLC: "NAV", Name: "Naviter"},
	{TLC: "NTE", SCC: 'N', Name: "New Technologies s.r.l."},
	{TLC: "NKL", SCC: 'K', Name: "Nielsen Kellerman"},
	{TLC: "PES", SCC: 'P', Name: "Peschges"},
	{TLC: "PFE", Name: "PressFinish Electronics"},
	{TLC: "PRT", SCC: 'R', Name: "Print Technik"},
	{TLC: "RCE", Name: "RC Electronics"},
	{TLC: "SCH", SCC: 'H', Name: "Scheffel"},
	{TLC: "SDI", SCC: 'S', Name: "Streamline Data Instruments"},
	{TLC: "TRI", SCC: 'T', Name: "Triadis Engineering GmbH"},
	{TLC: "ZAN", SCC: 'Z', Name: "Zander"},
}

ApprovedManufacturers is the list of approved manufacturers.

View Source
var NonApprovedManufacturers = []Manufacturer{
	{TLC: "XAH", SCC: 'X', Name: "Ascent"},
	{TLC: "XBM", SCC: 'X', Name: "Burnair"},
	{TLC: "XCM", SCC: 'X', Name: "Naviter"},
	{TLC: "XCS", SCC: 'X', Name: "XCSoar"},
	{TLC: "XCT", SCC: 'X', Name: "XC Track"},
	{TLC: "XGD", SCC: 'X', Name: "GpsDump"},
	{TLC: "XFH", SCC: 'X', Name: "Flyskyhy"},
	{TLC: "XFL", SCC: 'X', Name: "FlyMe"},
	{TLC: "XFM", SCC: 'X', Name: "Flymaster"},
	{TLC: "XLK", SCC: 'X', Name: "LK8000"},
	{TLC: "XNA", SCC: 'X', Name: "Naviter"},
	{TLC: "XSD", SCC: 'X', Name: "Stodeus"},
	{TLC: "XSE", SCC: 'X', Name: "Syride"},
	{TLC: "XSR", SCC: 'X', Name: "Syride"},
	{TLC: "XSX", SCC: 'X', Name: "Skytraxx"},
	{TLC: "XTR", SCC: 'X', Name: "XC Tracer"},
	{TLC: "XTT", SCC: 'X', Name: "LiveTrack24"},
	{TLC: "XVB", SCC: 'X', Name: "VairBration"},
	{TLC: "XVV", SCC: 'V', Name: "Vector Vario"},
}

NonApprovedManufacturers is an unofficial list of non-approved manufacturers.

Functions

This section is empty.

Types

type ARecord

type ARecord struct {
	ManufacturerID         string
	UniqueFlightRecorderID string
	AdditionalData         string
}

An ARecord is an A record, which identifies the flight recorder.

func (*ARecord) Type

func (r *ARecord) Type() byte

func (*ARecord) Valid

func (r *ARecord) Valid() bool

type BRecord

type BRecord struct {
	Time          time.Time
	Lat           float64
	Lon           float64
	Validity      Validity
	AltWGS84      float64
	AltBarometric float64
	Additions     map[string]int
}

A BRecord is a B record, which contains a fix.

func (*BRecord) Type

func (r *BRecord) Type() byte

func (*BRecord) Valid

func (r *BRecord) Valid() bool

type CRecordDeclaration

type CRecordDeclaration struct {
	DeclarationTime    time.Time
	FlightYear         int
	FlightMonth        int
	FlightDay          int
	TaskNumber         int
	NumberOfTurnpoints int
	Text               string
}

A CRecordDeclaration is a first C record, which contains the first line of a pre-declared task.

func (*CRecordDeclaration) Type

func (r *CRecordDeclaration) Type() byte

func (*CRecordDeclaration) Valid

func (r *CRecordDeclaration) Valid() bool

type CRecordWaypoint

type CRecordWaypoint struct {
	Lat  float64
	Lon  float64
	Text string
}

A CRecordWaypoint is a C record, which contains a waypoint in a declared task.

func (*CRecordWaypoint) Type

func (r *CRecordWaypoint) Type() byte

func (*CRecordWaypoint) Valid

func (r *CRecordWaypoint) Valid() bool

type DRecord

type DRecord struct {
	GPSQualifier  GPSQualifier
	DGPSStationID int
}

A DRecord is a D record, which contains differential GPS information.

func (*DRecord) Type

func (r *DRecord) Type() byte

func (*DRecord) Valid

func (r *DRecord) Valid() bool

type ERecord

type ERecord struct {
	Time time.Time
	TLC  string
	Text string
}

An ERecord is an E record, which contains an event.

func (*ERecord) Type

func (r *ERecord) Type() byte

func (*ERecord) Valid

func (r *ERecord) Valid() bool

type ERecordWithoutTLC

type ERecordWithoutTLC struct {
	Time time.Time
	Text string
}

An ERecordWithoutTLC is an E record without a three-letter code, which contains an event.

func (*ERecordWithoutTLC) Type

func (r *ERecordWithoutTLC) Type() byte

func (*ERecordWithoutTLC) Valid

func (r *ERecordWithoutTLC) Valid() bool

type Error

type Error struct {
	Line int
	Err  error
}

An Error is an error at a line.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type FRecord

type FRecord struct {
	Time         time.Time
	SatelliteIDs []int
}

An FRecord is an F record, which contains satellite constellation information.

func (*FRecord) Type

func (r *FRecord) Type() byte

func (*FRecord) Valid

func (r *FRecord) Valid() bool

type GPSQualifier

type GPSQualifier byte

A GPSQualifier is a GPS qualifier.

const (
	GPSQualifierGPS  GPSQualifier = '1'
	GPSQualifierDGPS GPSQualifier = '2'
)

GPSQualifiers.

type GRecord

type GRecord struct {
	Text string
}

A GRecord is a G record, which is a security record.

func (*GRecord) Type

func (r *GRecord) Type() byte

func (*GRecord) Valid

func (r *GRecord) Valid() bool

Valid returns whether the G record does not have any syntax errors. Since G records have freeform text, they never contain syntax errors, so this function always returns true.

To determine whether a G record is valid cryptographically, use github.com/twpayne/go-igc/civlovs instead.

type HFDTERecord

type HFDTERecord struct {
	HRecord
	Date         time.Time
	FlightNumber int
}

An HFDTERecord is an HFDTE record, which is a header containing the date.

type HRecord

type HRecord struct {
	Source   Source
	TLC      string
	LongName string
	Value    string
}

An HRecord is an H record, which is a header.

func (*HRecord) Type

func (r *HRecord) Type() byte

func (*HRecord) Valid

func (r *HRecord) Valid() bool

type HRecordWithInvalidSource

type HRecordWithInvalidSource struct {
	Source   string
	TLC      string
	LongName string
	Value    string
}

An HRecordWithInvalidSource is an H record, which is a header.

func (*HRecordWithInvalidSource) Type

func (r *HRecordWithInvalidSource) Type() byte

func (*HRecordWithInvalidSource) Valid

func (r *HRecordWithInvalidSource) Valid() bool

type IGC

type IGC struct {
	Records       []Record
	BRecords      []*BRecord
	HRecordsByTLC map[string]*HRecord
	KRecords      []*KRecord
	Errs          []error
}

An IGC is a parsed IGC file.

func Parse

func Parse(r io.Reader, options ...ParseOption) (*IGC, error)

Parse parses an IGC from r.

func ParseLines

func ParseLines(lines []string, options ...ParseOption) (*IGC, error)

Parse parses an IGC from lines.

type IRecord

type IRecord struct {
	Additions []RecordAddition
}

An IRecord is an I record, which contains additions to B records.

func (*IRecord) Type

func (r *IRecord) Type() byte

func (*IRecord) Valid

func (r *IRecord) Valid() bool

type JRecord

type JRecord struct {
	Additions []RecordAddition
}

A JRecord is a J record, which contains additions to K records.

func (*JRecord) Type

func (r *JRecord) Type() byte

func (*JRecord) Valid

func (r *JRecord) Valid() bool

type KRecord

type KRecord struct {
	Time      time.Time
	Additions map[string]int
}

A KRecord is a K record, which contains information needed less frequently than fixes.

func (*KRecord) Type

func (r *KRecord) Type() byte

func (*KRecord) Valid

func (r *KRecord) Valid() bool

type LRecord

type LRecord struct {
	Input string
	Text  string
}

An LRecord is an L record, which contains a log message.

func (*LRecord) Type

func (r *LRecord) Type() byte

func (*LRecord) Valid

func (r *LRecord) Valid() bool

type LRecordWithoutTLC

type LRecordWithoutTLC struct {
	Text string
}

An LRecordWithoutTLC is an L record without a three-letter code, which contains a log message.

func (*LRecordWithoutTLC) Type

func (r *LRecordWithoutTLC) Type() byte

func (*LRecordWithoutTLC) Valid

func (r *LRecordWithoutTLC) Valid() bool

type MRecord

type MRecord struct {
	Additions []RecordAddition
}

An MRecord is an M record, which contains additions to N records.

func (*MRecord) Type

func (r *MRecord) Type() byte

func (*MRecord) Valid

func (r *MRecord) Valid() bool

type Manufacturer

type Manufacturer struct {
	Name string
	TLC  string
	SCC  byte
}

A Manufacturer is a manufacturer.

func (*Manufacturer) Approved

func (m *Manufacturer) Approved() bool

Approved returns whether m is approved.

type NRecord

type NRecord struct {
	Time      time.Time
	Additions map[string]int
}

A NRecord is a N record, which contains data not signed by the security signature.

func (*NRecord) Type

func (r *NRecord) Type() byte

func (*NRecord) Valid

func (r *NRecord) Valid() bool

type ParseOption

type ParseOption func(*parser)

func WithAllowInvalidChars

func WithAllowInvalidChars(allowInvalidChars bool) ParseOption

type Record

type Record interface {
	Type() byte
	Valid() bool
}

A Record is a record.

type RecordAddition

type RecordAddition struct {
	TLC          string
	StartColumn  int
	FinishColumn int
}

An RecordAddition is an addition to a B, K, or N record.

type Source

type Source byte

A Source is the data source of an H record.

const (
	SourceFlightRecorder Source = 'F'
	SourceOther          Source = 'O'
	SourcePilot          Source = 'P'
)

Sources.

type Validity

type Validity byte

A Validity is a GPS fix validity.

const (
	Validity2D Validity = 'V'
	Validity3D Validity = 'A'
)

Validities.

Directories

Path Synopsis
Package civlovs provides a client interface to CIVL's Open Validation Server.
Package civlovs provides a client interface to CIVL's Open Validation Server.
cmd
parse-all command
summarize-igc command
validate-igc command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL