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.
Copyright The ezgliding Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
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 ¶
- Constants
- Variables
- func DecimalFromDMD(dmd string) float64
- func DecimalFromDMS(dms string) float64
- func Distance(task Task) float64
- type CirclingType
- type Crawler
- type Event
- type Flight
- type FlightID
- type Header
- type K
- type Manufacturer
- type Optimizer
- type Phase
- type PhaseType
- type Point
- type Satellite
- type Score
- type Task
- type Track
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 ( // MinTurnRate is the min rate to consider circling MinTurnRate = 6.5 // MaxTurnRate is the max rate considered for valid turns MaxTurnRate = 22.5 // MinCirclingTime is used to decide when a switch to circling occurs. // This value is used when calculating flight phases to switch from // PossibleCircling to Circling. MinCirclingTime = 15 // MinCruisingTime is used to decide when a switch to cruising occurs. // This value is used when calculating flight phases to switch from // PossibleCruising to Cruising. MinCruisingTime = 10 )
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"},
"XCS": {' ', "XCS", "XCSoar"},
"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 CirclingType ¶ added in v0.3.0
type CirclingType int
CirclingType indicates Left, Right or Mixed circling.
const ( Mixed CirclingType = 0 Left CirclingType = 1 Right CirclingType = 2 )
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 Flight ¶ added in v0.4.0
type Flight struct { URL string ID string Pilot string Club string Date time.Time Takeoff string Region string Country string Distance float64 Points float64 Glider string Type string TrackURL string TrackID string CompetitionID string CompetitionURL string Speed float64 Comments string }
Flight represents a flight submission in an online competition.
It includes all the flight metadata available in the online competition, including computed data like speed or distance. It also includes a url to the flight track file (usually in IGC format).
type Header ¶
type Header struct { Manufacturer string UniqueID string AdditionalData string Date time.Time Site string FixAccuracy int64 Pilot string PilotBirth time.Time Crew string GliderType string GliderID string Observation string GPSDatum string FirmwareVersion string HardwareVersion string SoftwareVersion string // for non-igc flight recorders Specification string FlightRecorder string GPS string GNSSModel string PressureModel string PressureSensor string AltimeterPressure float64 CompetitionID string CompetitionClass string Timezone int MOPSensor string }
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 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 Phase ¶ added in v0.3.0
type Phase struct { Type PhaseType CirclingType CirclingType Start Point StartIndex int End Point EndIndex int AvgVario float64 TopVario float64 AvgGndSpeed float64 TopGndSpeed float64 Distance float64 LD float64 Centroid s2.LatLng CellID s2.CellID }
Phase is a flight phase (towing, cruising, circling).
type PhaseType ¶ added in v0.3.0
type PhaseType int
PhaseType represents a flight phase.
Possible values include Towing, PossibleCruising/Cruising, PossibleCircling/Circling, Unknown.
type Point ¶
type Point struct { s2.LatLng Time time.Time FixValidity byte PressureAltitude int64 GNSSAltitude int64 IData map[string]string NumSatellites int Description string // contains filtered or unexported fields }
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 ID string Points []Point K []K Events []Event Satellites []Satellite Logbook []string Task Task DGPSStationID string Signature string // contains filtered or unexported fields }
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.