Documentation ¶
Overview ¶
Package igc provides means to parse and analyse files in the IGC format.
This format is defined by the International Gliding Commission (IGC) and was created to set a standard for recording gliding flights.
The full specification is available in Appendix A of the IGC FR Specification: http://www.fai.org/component/phocadownload/category/?download=11005
Calculation of the optimal flight distance considering multiple turnpoints and FAI triangles are available via Optimizers. Available Optimizers include brute force, montecarlo method, genetic algorithms, etc.
Example (Optimize) ¶
Calculate the optimal track distance for the multiple possible tasks using the Brute Force Optimizer:
track, _ := ParseLocation("sample-flight.igc") // In this case we use a brute force optimizer o := NewBruteForceOptimizer(false) r, _ := o.Optimize(track, 1, Distance) fmt.Printf("Optimization result was: %v", r)
Output:
Example (Parse) ¶
Parse and ParseLocation return a Track object.
// We can parse passing a file location track, _ := ParseLocation("sample-flight.igc") // Or similarly giving directly the contents contents := ` AFLA001Some Additional Data HFDTE010203 HFFXA500 HFPLTPilotincharge:EZ PILOT ` track, _ = Parse(contents) // Accessing track metadata fmt.Printf("Track Pilot: %v", track.Pilot) fmt.Printf("Track Points %v", len(track.Pilot))
Output:
Example (Parsecontent) ¶
Parse directly flight contents and get a Track object.
// We could pass here a string with the full contents in IGC format track, _ := Parse(` AFLA001Some Additional Data HFDTE010203 HFFXA500 HFPLTPilotincharge:EZ PILOT `) fmt.Printf("Track Pilot: %v", track.Pilot) fmt.Printf("Track Points %v", len(track.Pilot))
Output:
Example (Parselocation) ¶
Parse a given file and get a Track object.
track, _ := ParseLocation("sample-flight.igc") fmt.Printf("Track Pilot: %v", track.Pilot) fmt.Printf("Track Points %v", len(track.Pilot))
Output:
Example (Totaldistance) ¶
Calculate the total track distance using the Points.
This is not a very useful metric (you should look at one of the Optimizers) instead, but it is a good example of how to use the Point data in the Track.
track, _ := ParseLocation("sample-flight.igc") totalDistance := 0.0 for i := 0; i < len(track.Points)-1; i++ { totalDistance += track.Points[i].Distance(track.Points[i+1]) } fmt.Printf("Distance was %v", totalDistance)
Output:
Index ¶
Examples ¶
Constants ¶
const ( // TimeFormat is the golang time.Parse format for IGC time. TimeFormat = "150405" // DateFormat is the golang time.Parse format for IGC time. DateFormat = "020106" )
const (
// EarthRadius is the average earth radius.
EarthRadius = 6371.0
)
const MaxSpeed float64 = 500.0
MaxSpeed is the maximum theoretical speed for a glider.
It is used to detect bad GPS coordinates, which should be removed from the track.
Variables ¶
var Manufacturers = map[string]Manufacturer{
"GCS": {'A', "GCS", "Garrecht"},
"LGS": {'B', "LGS", "Logstream"},
"CAM": {'C', "CAM", "Cambridge Aero Instruments"},
"DSX": {'D', "DSX", "Data Swan/DSX"},
"EWA": {'E', "EWA", "EW Avionics"},
"FIL": {'F', "FIL", "Filser"},
"FLA": {'G', "FLA", "Flarm (Track Alarm)"},
"SCH": {'H', "SCH", "Scheffel"},
"ACT": {'I', "ACT", "Aircotec"},
"CNI": {'K', "CNI", "ClearNav Instruments"},
"NKL": {'K', "NKL", "NKL"},
"LXN": {'L', "LXN", "LX Navigation"},
"IMI": {'M', "IMI", "IMI Gliding Equipment"},
"NTE": {'N', "NTE", "New Technologies s.r.l."},
"NAV": {'O', "NAV", "Naviter"},
"PES": {'P', "PES", "Peschges"},
"PRT": {'R', "PRT", "Print Technik"},
"SDI": {'S', "SDI", "Streamline Data Instruments"},
"TRI": {'T', "TRI", "Triadis Engineering GmbH"},
"LXV": {'V', "LXV", "LXNAV d.o.o."},
"WES": {'W', "WES", "Westerboer"},
"XYY": {'X', "XYY", "Other manufacturer"},
"ZAN": {'Z', "ZAN", "Zander"},
}
Manufacturers holds the list of available manufacturers.
This list is defined in the IGC specification, section A2.5.6.
Functions ¶
func DecimalFromDMD ¶
DecimalFromDMD returns the decimal representation (in radians) of the given DMD.
DMD is a representation of a coordinate in Decimal,Minutes,100thMinute with an extra character indicating north, south, east, west.
Examples: N512688, W0064364, S342212, E0021275
func DecimalFromDMS ¶
DecimalFromDMS returns the decimal representation (in radians) of the given DMS.
DMS is a representation of a coordinate in Decimal,Minutes,Seconds, with an extra character indicating north, south, east, west.
Examples: N512646, W0064312, S342244, E0021233
Types ¶
type Event ¶
Event holds data records triggered at a given time.
This is the E record in the IGC specification, section A4.2. The events can be pilot initiated (with a PEV code), proximity alerts, etc.
type Header ¶
type Header struct { Manufacturer string UniqueID string AdditionalData string Date time.Time FixAccuracy int64 Pilot string Crew string GliderType string GliderID string GPSDatum string FirmwareVersion string HardwareVersion string FlightRecorder string GPS string PressureSensor string CompetitionID string CompetitionClass string Timezone int }
Header holds the meta information of a track.
This is the H record in the IGC specification, section A3.2.
type K ¶
K holds flight data needed less often than Points.
This is the K record in the IGC specification, section A4.4. Fields is a map between a given content type and its value, with the possible content types being defined in the J record.
Examples of content types include heading true (HDT) or magnetic (HDM), airspeed (IAS), etc.
type LogEntry ¶
LogEntry holds a logbook/comment entry, in free format.
This is the L record in the IGC specification, section A4.5.
type Manufacturer ¶
type Manufacturer struct {
// contains filtered or unexported fields
}
Manufacturer holds manufacturer name, short ID and char identifier.
The list of manufacturers is defined in the IGC specification, section A2.5.6. A map Manufacturers is available in this library.
type Optimizer ¶
Optimizer returns an optimal Task for the given turnpoints and Score function.
Available score functions include MaxDistance and MaxPoints, but it is possible to pass the Optimizer a custom function.
Optimizers might not support a high number of turnpoints. As an example, the BruteForceOptimizer does not perform well with nPoints > 2, and might decide to return an error instead of attempting to finalize the optimization indefinitely.
func NewBruteForceOptimizer ¶
NewBruteForceOptimizer returns a BruteForceOptimizer with the given characteristics.
type Point ¶
type Point struct { s2.LatLng Time time.Time FixValidity byte PressureAltitude int64 GNSSAltitude int64 IData map[string]string NumSatellites int Description string }
Point represents a GPS recording (single point in the track).
It is based on a golang-geo s2 LatLng, adding extra metadata such as the Time the point was recorded, pressure and GNSS altitude, number of satellites available and extra metadata added by the recorder.
You can use all methods available for a s2.LatLng on this struct.
func NewPointFromDMD ¶
NewPointFromDMD returns a Point corresponding to the given string in DMD format.
DecimalFromDMD includes more information regarding this format.
func NewPointFromDMS ¶
NewPointFromDMS returns a Point corresponding to the given string in DMS format.
DecimalFromDMS includes more information regarding this format.
func NewPointFromLatLng ¶
NewPointFromLatLng returns a new Point with the given latitude and longitude.
type Satellite ¶
Satellite holds the IDs of the available satellites at a given Time.
This is the F record in the IGC specification, section A4.3.
type Score ¶
Score functions calculate a score for the given Task.
The main use of these functions is in passing them to the Optimizers, so they can evaluate each Task towards different goals.
Example functions include the total distance between all turn points or an online competition (netcoupe, online contest) score which takes additional metrics of each leg into account.
type Task ¶
type Task struct { DeclarationDate time.Time Date time.Time Number int Takeoff Point Start Point Turnpoints []Point Finish Point Landing Point Description string }
Task holds all the metadata put in a pre-declared task to be performed.
This is the C record in the IGC specification, section A3.5.
type Track ¶
type Track struct { Header Points []Point K []K Events []Event Satellites []Satellite Logbook []LogEntry Task Task DGPSStationID string Signature string }
Track holds all IGC flight data (header and GPS points).
func NewTrack ¶
func NewTrack() Track
NewTrack returns a new instance of Track, with fields initialized to zero.
func Parse ¶
Parse returns a Track object corresponding to the given content.
The value of content should be a text string with all the flight data in the IGC format.
func ParseCleanLocation ¶
ParseCleanLocation returns a cleaned up Track object.
See ParseLocation().
func ParseLocation ¶
ParseLocation returns a Track object corresponding to the given file.
It calls Parse internatlly, so the file content should be in IGC format.