aviation

package
v0.13.3 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: GPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RadioTransmissionUnknown    = iota
	RadioTransmissionContact    // Messages initiated by the pilot
	RadioTransmissionReadback   // Reading back an instruction
	RadioTransmissionUnexpected // Something urgent or unusual
	RadioTransmissionMixUp      // Pilot confused about who was being addressed
)
View Source
const (
	RouteBasedFix = "route"
	ZoneBasedFix  = "zone"
)
View Source
const (
	PTUndefined = iota
	PTRacetrack
	PTStandard45
)
View Source
const (
	DirectEntryShortTurn = iota
	DirectEntryLongTurn
	ParallelEntry
	TeardropEntry
)
View Source
const (
	AirwayLevelAll = iota
	AirwayLevelLow
	AirwayLevelHigh
)
View Source
const (
	AirwayDirectionAny = iota
	AirwayDirectionForward
	AirwayDirectionBackward
)
View Source
const ARINC424LineLength = 134 // 132 chars + \r + \n
View Source
const MaxRestrictionAreas = 100

This many adapted and then this many user-defined

Variables

View Source
var (
	ErrBadPoolSpecifier           = errors.New("Bad pool specifier")
	ErrInvalidAltitude            = errors.New("Altitude above aircraft's ceiling")
	ErrInvalidController          = errors.New("Invalid controller")
	ErrInvalidFacility            = errors.New("Invalid facility")
	ErrInvalidHeading             = errors.New("Invalid heading")
	ErrInvalidSquawkCode          = errors.New("Invalid squawk code")
	ErrNoAircraftForCallsign      = errors.New("No aircraft exists with specified callsign")
	ErrNoController               = errors.New("No controller with that callsign")
	ErrNoCoordinationFix          = errors.New("No coordination fix found")
	ErrNoERAMFacility             = errors.New("No ERAM facility exists")
	ErrNoFlightPlan               = errors.New("No flight plan has been filed for aircraft")
	ErrNoMatchingFix              = errors.New("No matching fix")
	ErrNoMoreAvailableSquawkCodes = errors.New("No more available squawk codes")
	ErrNoSTARSFacility            = errors.New("No STARS Facility in ERAM computer")
	ErrNoValidArrivalFound        = errors.New("Unable to find a valid arrival")
	ErrNoValidDepartureFound      = errors.New("Unable to find a valid departure")
	ErrNotBeingHandedOffToMe      = errors.New("Aircraft not being handed off to current controller")
	ErrNotPointedOutByMe          = errors.New("Aircraft not being pointed out by current controller")
	ErrNotPointedOutToMe          = errors.New("Aircraft not being pointed out to current controller")
	ErrOtherControllerHasTrack    = errors.New("Another controller is already tracking the aircraft")
	ErrSquawkCodeAlreadyAssigned  = errors.New("Squawk code has already been assigned")
	ErrSquawkCodeNotManagedByPool = errors.New("Squawk code is not managed by this pool")
	ErrSquawkCodeUnassigned       = errors.New("Squawk code has not been assigned")
	ErrUnknownAirport             = errors.New("Unknown airport")
	ErrUnknownRunway              = errors.New("Unknown runway")
)

Functions

func CWTApproachSeparation

func CWTApproachSeparation(front, back string) float32

CWTApproachSeparation returns the required separation between aircraft of the two given CWT categories. If 0 is returned, minimum radar separation should be used.

func CWTDirectlyBehindSeparation

func CWTDirectlyBehindSeparation(front, back string) float32

CWTDirectlyBehindSeparation returns the required separation between aircraft of the two given CWT categories. If 0 is returned, minimum radar separation should be used.

func CheckApproaches

func CheckApproaches(e *util.ErrorLogger, wps []WaypointArray, requireFAF bool, controllers map[ControlPosition]*Controller,
	checkScratchpad func(string) bool)

func DensityRatioAtAltitude

func DensityRatioAtAltitude(alt float32) float32

returns the ratio of air density at the given altitude (in feet) to the air density at sea level, subject to assuming the standard atmosphere.

func FormatAltitude

func FormatAltitude(falt float32) string

func FormatScopeAltitude added in v0.13.0

func FormatScopeAltitude[T ~int | ~float32](alt T) string

func IASToTAS

func IASToTAS(ias, altitude float32) float32

func InAirspace

func InAirspace(p math.Point2LL, alt float32, volumes []ControllerAirspaceVolume) (bool, [][2]int)

func InBravoAirspace

func InBravoAirspace(p math.Point2LL, alt int) bool

func InCharlieAirspace

func InCharlieAirspace(p math.Point2LL, alt int) bool

func InDeltaAirspace

func InDeltaAirspace(p math.Point2LL, alt int) bool

func InitDB

func InitDB()

func PrintCIFPRoutes

func PrintCIFPRoutes(airport string) error

func RandomizeRoute

func RandomizeRoute(w []Waypoint, r *rand.Rand, randomizeAltitudeRange bool, perf AircraftPerformance, nmPerLongitude float32,
	magneticVariation float32, airport string, lg *log.Logger)

func SquawkIsSPC

func SquawkIsSPC(squawk Squawk) (ok bool, code string)

func StringIsSPC

func StringIsSPC(code string) bool

func TASToIAS

func TASToIAS(tas, altitude float32) float32

func TidyRunway

func TidyRunway(r string) string

func UnderBravoShelf

func UnderBravoShelf(grid *AirspaceGrid, p math.Point2LL, alt int) bool

Types

type ADSBCallsign

type ADSBCallsign string

func (ADSBCallsign) String

func (c ADSBCallsign) String() string

type ARINC424Result added in v0.13.0

type ARINC424Result struct {
	Airports      map[string]FAAAirport
	Navaids       map[string]Navaid
	Fixes         map[string]Fix
	Airways       map[string][]Airway
	EnrouteHolds  map[string][]Hold
	TerminalHolds map[string]map[string][]Hold
}

func ParseARINC424

func ParseARINC424(r io.Reader) ARINC424Result

type ARTCC

type ARTCC struct {
	Name string
}

type ATIS

type ATIS struct {
	Airport  string
	AppDep   string
	Code     string
	Contents string
}

type ATPAVolume

type ATPAVolume struct {
	Id                  string `json:"id"`
	ThresholdString     string `json:"runway_threshold"`
	Threshold           math.Point2LL
	Heading             float32  `json:"heading"`
	MaxHeadingDeviation float32  `json:"max_heading_deviation"`
	Floor               float32  `json:"floor"`
	Ceiling             float32  `json:"ceiling"`
	Length              float32  `json:"length"`
	LeftWidth           float32  `json:"left_width"`
	RightWidth          float32  `json:"right_width"`
	FilteredScratchpads []string `json:"filtered_scratchpads"`
	ExcludedScratchpads []string `json:"excluded_scratchpads"`
	Enable25nmApproach  bool     `json:"enable_2.5nm"`
	Dist25nmApproach    float32  `json:"2.5nm_distance"`
}

func (*ATPAVolume) GetRect

func (a *ATPAVolume) GetRect(nmPerLongitude, magneticVariation float32) [4]math.Point2LL

func (*ATPAVolume) Inside

func (a *ATPAVolume) Inside(p math.Point2LL, alt, hdg, nmPerLongitude, magneticVariation float32) bool

type AdaptationFix

type AdaptationFix struct {
	Name         string // not in JSON
	Type         string `json:"type"`
	ToFacility   string `json:"to"`   // controller to handoff to
	FromFacility string `json:"from"` // controller to handoff from
	Altitude     [2]int `json:"altitude"`
}

type AdaptationFixes

type AdaptationFixes []AdaptationFix

type AircraftPerformance

type AircraftPerformance struct {
	Name string `json:"name"`
	ICAO string `json:"icao"`
	// engines, weight class, category
	WeightClass string  `json:"weightClass"`
	Ceiling     float32 `json:"ceiling"`
	Engine      struct {
		AircraftType string `json:"type"`
	} `json:"engines"`
	Rate struct {
		Climb      float32 `json:"climb"` // ft / minute; reduce by 500 after alt 5000 if this is >=2500
		Descent    float32 `json:"descent"`
		Accelerate float32 `json:"accelerate"` // kts / 2 seconds
		Decelerate float32 `json:"decelerate"`
	} `json:"rate"`
	Category struct {
		SRS   int    `json:"srs"`
		LAHSO int    `json:"lahso"`
		CWT   string `json:"cwt"`
	}
	Runway struct {
		Takeoff float32 `json:"takeoff"` // nm
		Landing float32 `json:"landing"` // nm
	} `json:"runway"`
	Speed struct {
		Min        float32 `json:"min"`
		V2         float32 `json:"v2"`
		Landing    float32 `json:"landing"`
		CruiseTAS  float32 `json:"cruise"`
		CruiseMach float32 `json:"cruiseM"`
		MaxTAS     float32 `json:"max"`
		MaxMach    float32 `json:"maxM"`
	} `json:"speed"`
	Turn struct {
		MaxBankAngle float32 `json:"maxBankAngle"`
		MaxBankRate  float32 `json:"maxBankRate"`
	}
	Capacity struct {
		Passengers int `json:"passengers"`
		FuelPounds int `json:"fuel_pounds"`
	} `json:"capacity"`
}

func (AircraftPerformance) ApproachSpeed

func (ap AircraftPerformance) ApproachSpeed(windDirection, windSpeed, windGust float32, runwayHeading float32) float32

ApproachSpeed returns the final approach speed including wind additives. The runway heading is used to compute the headwind component of the provided wind. Jets and turboprops add half the headwind plus the full gust factor (not to exceed 20 knots). Pistons add half the gust factor... I suppose we should also add a max additive but most pistons won't be landing in very windy conditions

type AircraftTypeSnippetFormatter added in v0.13.2

type AircraftTypeSnippetFormatter struct{}

func (AircraftTypeSnippetFormatter) Spoken added in v0.13.2

func (AircraftTypeSnippetFormatter) Validate added in v0.13.2

func (AircraftTypeSnippetFormatter) Validate(arg any) error

func (AircraftTypeSnippetFormatter) Written added in v0.13.2

type Airline

type Airline struct {
	ICAO     string `json:"icao"`
	Name     string `json:"name"`
	Callsign struct {
		Name            string   `json:"name"`
		CallsignFormats []string `json:"callsignFormats"`
	} `json:"callsign"`
	JSONFleets map[string][][2]interface{} `json:"fleets"`
	Fleets     map[string][]FleetAircraft
}

type AirlineSpecifier

type AirlineSpecifier struct {
	ICAO          string   `json:"icao"`
	Fleet         string   `json:"fleet,omitempty"`
	AircraftTypes []string `json:"types,omitempty"`
}

func (AirlineSpecifier) Aircraft

func (a AirlineSpecifier) Aircraft() []FleetAircraft

func (*AirlineSpecifier) Check

func (a *AirlineSpecifier) Check(e *util.ErrorLogger)

func (AirlineSpecifier) SampleAcTypeAndCallsign

func (a AirlineSpecifier) SampleAcTypeAndCallsign(r *rand.Rand, currentCallsigns []ADSBCallsign, uniqueSuffix bool, departureAirport, arrivalAirport string, lg *log.Logger) (actype, callsign string)

currentCallsigns will be empty if we don't care about unique suffixes.

type Airport

type Airport struct {
	Location       math.Point2LL
	TowerListIndex int `json:"tower_list"`

	Name string `json:"name"`

	Approaches map[string]*Approach `json:"approaches,omitempty"`
	Departures []Departure          `json:"departures,omitempty"`

	VFR struct {
		Randoms VFRRandomsSpec `json:"random_routes"`
		Routes  []VFRRouteSpec `json:"routes"`
	} `json:"vfr"`

	// Optional: initial tracking controller, for cases where a virtual
	// controller has the initial track.
	DepartureController ControlPosition `json:"departure_controller"`
	HoldForRelease      bool            `json:"hold_for_release"`

	ExitCategories map[string]string `json:"exit_categories"`

	// runway -> (exit -> route)
	DepartureRoutes map[string]map[string]*ExitRoute `json:"departure_routes"`

	ApproachRegions   map[string]*ApproachRegion `json:"approach_regions"`
	ConvergingRunways []ConvergingRunways        `json:"converging_runways"`

	ATPAVolumes           map[string]*ATPAVolume `json:"atpa_volumes"`
	OmitArrivalScratchpad bool                   `json:"omit_arrival_scratchpad"`
	DepartureRunwaysAsOne []string               `json:"departure_runways_as_one"`
}

func (*Airport) PostDeserialize

func (ap *Airport) PostDeserialize(icao string, loc Locator, nmPerLongitude float32,
	magneticVariation float32, controlPositions map[ControlPosition]*Controller, scratchpads map[string]string,
	facilityAirports map[string]*Airport, checkScratchpad func(string) bool, e *util.ErrorLogger)

func (Airport) VFRRateSum

func (ap Airport) VFRRateSum() int

type AirportSnippetFormatter added in v0.13.2

type AirportSnippetFormatter struct{}

func (AirportSnippetFormatter) Spoken added in v0.13.2

func (AirportSnippetFormatter) Spoken(r *rand.Rand, arg any) string

func (AirportSnippetFormatter) Validate added in v0.13.2

func (AirportSnippetFormatter) Validate(arg any) error

func (AirportSnippetFormatter) Written added in v0.13.2

func (AirportSnippetFormatter) Written(arg any) string

type Airspace

type Airspace struct {
	Boundaries map[string][]math.Point2LL            `json:"boundaries"`
	Volumes    map[string][]ControllerAirspaceVolume `json:"volumes"`
}

type AirspaceGrid

type AirspaceGrid struct {
	// contains filtered or unexported fields
}

AirspaceGrid organizes AirspaceVolume definitions and provides efficient in volume tests via a grid in lat-long space that records which of a potentially large set of volumes overlap grid cells. Grid cells are initialized on demand rather than upfront, which saves storage

func MakeAirspaceGrid

func MakeAirspaceGrid(v []*AirspaceVolume) *AirspaceGrid

func (*AirspaceGrid) Below

func (g *AirspaceGrid) Below(p math.Point2LL, alt int) bool

func (*AirspaceGrid) Inside

func (g *AirspaceGrid) Inside(p math.Point2LL, alt int) bool

type AirspaceVolume

type AirspaceVolume struct {
	Id          string             `json:"id"`
	Description string             `json:"description"`
	Type        AirspaceVolumeType `json:"type"`
	Floor       int                `json:"floor"`
	Ceiling     int                `json:"ceiling"`
	// Polygon
	PolygonBounds *math.Extent2D               // not always set
	VerticesStr   util.OneOf[string, []string] `json:"vertices"`
	Vertices      []math.Point2LL
	Holes         [][]math.Point2LL `json:"holes"`
	// Circle
	Center math.Point2LL `json:"center"`
	Radius float32       `json:"radius"`
}

func (*AirspaceVolume) Below

func (a *AirspaceVolume) Below(p math.Point2LL, alt int) bool

func (*AirspaceVolume) Inside

func (a *AirspaceVolume) Inside(p math.Point2LL, alt int) bool

func (*AirspaceVolume) PostDeserialize

func (a *AirspaceVolume) PostDeserialize(loc Locator, e *util.ErrorLogger)

type AirspaceVolumeType

type AirspaceVolumeType int
const (
	AirspaceVolumeUnknown AirspaceVolumeType = iota
	AirspaceVolumePolygon
	AirspaceVolumeCircle
)

func (*AirspaceVolumeType) MarshalJSON

func (t *AirspaceVolumeType) MarshalJSON() ([]byte, error)

func (*AirspaceVolumeType) UnmarshalJSON

func (t *AirspaceVolumeType) UnmarshalJSON(b []byte) error

type Airway

type Airway struct {
	Name  string
	Fixes []AirwayFix
}

func (Airway) WaypointsBetween

func (a Airway) WaypointsBetween(wp0, wp1 string) ([]Waypoint, bool)

type AirwayDirection

type AirwayDirection int

type AirwayFix

type AirwayFix struct {
	Fix       string
	Level     AirwayLevel
	Direction AirwayDirection
}

type AirwayLevel

type AirwayLevel int

type AltRestrictionSnippetFormatter added in v0.13.2

type AltRestrictionSnippetFormatter struct{}

func (AltRestrictionSnippetFormatter) Spoken added in v0.13.2

func (AltRestrictionSnippetFormatter) Validate added in v0.13.2

func (AltRestrictionSnippetFormatter) Written added in v0.13.2

type AltSnippetFormatter added in v0.13.2

type AltSnippetFormatter struct{}

AltSnippetFormatter formats altitudes, which may be given as ints or float32s.

func (*AltSnippetFormatter) Spoken added in v0.13.2

func (a *AltSnippetFormatter) Spoken(r *rand.Rand, arg any) string

func (*AltSnippetFormatter) Validate added in v0.13.2

func (a *AltSnippetFormatter) Validate(arg any) error

func (*AltSnippetFormatter) Written added in v0.13.2

func (a *AltSnippetFormatter) Written(arg any) string

type AltitudeRestriction

type AltitudeRestriction struct {
	// We treat 0 as "unset", which works naturally for the bottom but
	// requires occasional care at the top.
	Range [2]float32
}

func ParseAltitudeRestriction

func ParseAltitudeRestriction(s string) (*AltitudeRestriction, error)

ParseAltitudeRestriction parses an altitude restriction in the compact text format used in scenario definition files.

func (AltitudeRestriction) ClampRange

func (a AltitudeRestriction) ClampRange(r [2]float32) (c [2]float32, ok bool)

ClampRange limits a range of altitudes to satisfy the altitude restriction; the returned Boolean indicates whether the ranges overlapped.

func (AltitudeRestriction) Encoded

func (a AltitudeRestriction) Encoded() string

Encoded returns the restriction in the encoded form in which it is specified in scenario configuration files, e.g. "5000+" for "at or above 5000".

func (AltitudeRestriction) TargetAltitude

func (a AltitudeRestriction) TargetAltitude(alt float32) float32

func (*AltitudeRestriction) UnmarshalJSON

func (a *AltitudeRestriction) UnmarshalJSON(b []byte) error

type AppControllerSnippetFormatter added in v0.13.2

type AppControllerSnippetFormatter struct{}

func (AppControllerSnippetFormatter) Spoken added in v0.13.2

func (AppControllerSnippetFormatter) Validate added in v0.13.2

func (AppControllerSnippetFormatter) Validate(arg any) error

func (AppControllerSnippetFormatter) Written added in v0.13.2

type Approach

type Approach struct {
	Id        string          `json:"cifp_id"`
	FullName  string          `json:"full_name"`
	Type      ApproachType    `json:"type"`
	Runway    string          `json:"runway"`
	Waypoints []WaypointArray `json:"waypoints"`

	// Set in Airport PostDeserialize()
	Threshold         math.Point2LL
	OppositeThreshold math.Point2LL
}

func (*Approach) ExtendedCenterline

func (ap *Approach) ExtendedCenterline(nmPerLongitude, magneticVariation float32) [2]math.Point2LL

func (*Approach) FAFSegment

func (ap *Approach) FAFSegment(nmPerLongitude, magneticVariation float32) ([]Waypoint, int)

Find the FAF: return the corresponding waypoint array and the index of the FAF within it.

func (*Approach) RunwayHeading

func (ap *Approach) RunwayHeading(nmPerLongitude, magneticVariation float32) float32

type ApproachRegion

type ApproachRegion struct {
	Runway           string  // set during deserialization
	HeadingTolerance float32 `json:"heading_tolerance"`

	ReferenceLineHeading   float32       `json:"reference_heading"`
	ReferenceLineLength    float32       `json:"reference_length"`
	ReferencePointAltitude float32       `json:"reference_altitude"`
	ReferencePoint         math.Point2LL `json:"reference_point"`

	// lateral qualification region
	NearDistance  float32 `json:"near_distance"`
	NearHalfWidth float32 `json:"near_half_width"`
	FarHalfWidth  float32 `json:"far_half_width"`
	RegionLength  float32 `json:"region_length"`

	// vertical qualification region
	DescentPointDistance   float32 `json:"descent_distance"`
	DescentPointAltitude   float32 `json:"descent_altitude"`
	AboveAltitudeTolerance float32 `json:"above_altitude_tolerance"`
	BelowAltitudeTolerance float32 `json:"below_altitude_tolerance"`

	ScratchpadPatterns []string `json:"scratchpad_patterns"`
}

func (*ApproachRegion) FarPoint

func (ar *ApproachRegion) FarPoint(nmPerLongitude, magneticVariation float32) [2]float32

func (*ApproachRegion) GetLateralGeometry

func (ar *ApproachRegion) GetLateralGeometry(nmPerLongitude, magneticVariation float32) (line [2]math.Point2LL, quad [4]math.Point2LL)

func (*ApproachRegion) Inside

func (ar *ApproachRegion) Inside(p math.Point2LL, alt float32, nmPerLongitude, magneticVariation float32) (lateral, vertical bool)

func (*ApproachRegion) NearPoint

func (ar *ApproachRegion) NearPoint(nmPerLongitude, magneticVariation float32) [2]float32

func (*ApproachRegion) TryMakeGhost

func (ar *ApproachRegion) TryMakeGhost(trk RadarTrack, heading float32,
	scratchpad string, forceGhost bool, offset float32, leaderDirection math.CardinalOrdinalDirection,
	runwayIntersection [2]float32, nmPerLongitude float32, magneticVariation float32, other *ApproachRegion) *GhostTrack

type ApproachSnippetFormatter added in v0.13.2

type ApproachSnippetFormatter struct{}

func (ApproachSnippetFormatter) Spoken added in v0.13.2

func (ApproachSnippetFormatter) Spoken(r *rand.Rand, arg any) string

func (ApproachSnippetFormatter) Validate added in v0.13.2

func (ApproachSnippetFormatter) Validate(arg any) error

func (ApproachSnippetFormatter) Written added in v0.13.2

func (ApproachSnippetFormatter) Written(arg any) string

type ApproachType

type ApproachType int
const (
	UnknownApproach ApproachType = iota
	ILSApproach
	RNAVApproach
	ChartedVisualApproach
	LocalizerApproach
	VORApproach
)

func (ApproachType) MarshalJSON

func (at ApproachType) MarshalJSON() ([]byte, error)

func (ApproachType) String

func (at ApproachType) String() string

func (*ApproachType) UnmarshalJSON

func (at *ApproachType) UnmarshalJSON(b []byte) error

type Arrival

type Arrival struct {
	Waypoints       WaypointArray                       `json:"waypoints"`
	RunwayWaypoints map[string]map[string]WaypointArray `json:"runway_waypoints"` // Airport -> runway -> waypoints
	SpawnWaypoint   string                              `json:"spawn"`            // if "waypoints" aren't specified
	CruiseAltitude  float32                             `json:"cruise_altitude"`
	Route           string                              `json:"route"`
	STAR            string                              `json:"star"`

	InitialController   ControlPosition `json:"initial_controller"`
	InitialAltitude     float32         `json:"initial_altitude"`
	AssignedAltitude    float32         `json:"assigned_altitude"`
	InitialSpeed        float32         `json:"initial_speed"`
	SpeedRestriction    float32         `json:"speed_restriction"`
	Scratchpad          string          `json:"scratchpad"`
	SecondaryScratchpad string          `json:"secondary_scratchpad"`
	Description         string          `json:"description"`
	CoordinationFix     string          `json:"coordination_fix"`
	IsRNAV              bool            `json:"is_rnav"`

	ExpectApproach util.OneOf[string, map[string]string] `json:"expect_approach"`

	// Airport -> arrival airlines
	Airlines map[string][]ArrivalAirline `json:"airlines"`
}

func (Arrival) GetRunwayWaypoints

func (ar Arrival) GetRunwayWaypoints(airport, rwy string) WaypointArray

func (*Arrival) PostDeserialize

func (ar *Arrival) PostDeserialize(loc Locator, nmPerLongitude float32, magneticVariation float32,
	airports map[string]*Airport, controlPositions map[ControlPosition]*Controller, checkScratchpad func(string) bool,
	e *util.ErrorLogger)

type ArrivalAirline

type ArrivalAirline struct {
	AirlineSpecifier
	Airport string `json:"airport"`
}

type BasicNumberSnippetFormatter added in v0.13.2

type BasicNumberSnippetFormatter struct{}

func (BasicNumberSnippetFormatter) Spoken added in v0.13.2

func (BasicNumberSnippetFormatter) Validate added in v0.13.2

func (BasicNumberSnippetFormatter) Validate(arg any) error

func (BasicNumberSnippetFormatter) Written added in v0.13.2

func (BasicNumberSnippetFormatter) Written(arg any) string

type BeaconCodeSnippetFormatter added in v0.13.2

type BeaconCodeSnippetFormatter struct{}

func (BeaconCodeSnippetFormatter) Spoken added in v0.13.2

func (BeaconCodeSnippetFormatter) Spoken(r *rand.Rand, arg any) string

func (BeaconCodeSnippetFormatter) Validate added in v0.13.2

func (BeaconCodeSnippetFormatter) Validate(arg any) error

func (BeaconCodeSnippetFormatter) Written added in v0.13.2

func (BeaconCodeSnippetFormatter) Written(arg any) string

type BeaconCodeTable

type BeaconCodeTable struct {
	VFRCodes [][2]Squawk
}

type BeaconCodeTableSpecifier

type BeaconCodeTableSpecifier struct {
	VFRCodes []string `json:"vfr_codes"` // Array of squawk code ranges

}

type CallsignArg added in v0.13.3

type CallsignArg struct {
	Callsign           ADSBCallsign
	IsEmergency        bool
	AlwaysFullCallsign bool
}

CallsignArg provides additional context for formatting callsigns.

type CallsignSnippetFormatter added in v0.13.2

type CallsignSnippetFormatter struct{}

func (CallsignSnippetFormatter) Spoken added in v0.13.2

func (CallsignSnippetFormatter) Spoken(r *rand.Rand, arg any) string

func (CallsignSnippetFormatter) Validate added in v0.13.2

func (CallsignSnippetFormatter) Validate(arg any) error

func (CallsignSnippetFormatter) Written added in v0.13.2

func (CallsignSnippetFormatter) Written(arg any) string

type ControlPosition added in v0.13.3

type ControlPosition string

ControlPosition identifies a controller position in either STARS or ERAM. For STARS, this is the TCP (Terminal Control Position) like "2K" or "4P". For ERAM, this is the sector identifier like "N56" or "W05". This is the generic type used throughout the codebase for any controller position.

type Controller

type Controller struct {
	Position           string    // This is the key in the controllers map in JSON
	RadioName          string    `json:"radio_name"`
	Frequency          Frequency `json:"frequency"`
	SectorID           string    `json:"sector_id"`       // e.g. N56, 2J, ...
	Scope              string    `json:"scope_char"`      // Optional. If unset, facility id is used for external, last char of sector id for local.
	FacilityIdentifier string    `json:"facility_id"`     // For example the "N" in "N4P" showing the N90 TRACON
	ERAMFacility       bool      `json:"eram_facility"`   // To weed out N56 and N4P being the same fac
	Facility           string    `json:"facility"`        // So we can get the STARS facility from a controller
	DefaultAirport     string    `json:"default_airport"` // only required if CRDA is a thing
}

func (Controller) ERAMID added in v0.13.0

func (c Controller) ERAMID() string

func (Controller) IsExternal

func (c Controller) IsExternal() bool

func (Controller) PositionId added in v0.13.3

func (c Controller) PositionId() ControlPosition

type ControllerAirspaceVolume

type ControllerAirspaceVolume struct {
	LowerLimit    int               `json:"lower"`
	UpperLimit    int               `json:"upper"`
	Boundaries    [][]math.Point2LL `json:"boundary_polylines"` // not in JSON
	BoundaryNames []string          `json:"boundaries"`
	Label         string            `json:"label"`
	LabelPosition math.Point2LL     `json:"label_position"`
}

type ConvergingRunways

type ConvergingRunways struct {
	Runways                [2]string                        `json:"runways"`
	TieSymbol              string                           `json:"tie_symbol"`
	StaggerSymbol          string                           `json:"stagger_symbol"`
	TieOffset              float32                          `json:"tie_offset"`
	LeaderDirectionStrings [2]string                        `json:"leader_directions"`
	LeaderDirections       [2]math.CardinalOrdinalDirection // not in JSON, set during deserialize
	RunwayIntersection     math.Point2LL                    // not in JSON, set during deserialize
}

type DMEArc

type DMEArc struct {
	Fix            string
	Center         math.Point2LL
	Radius         float32
	Length         float32
	InitialHeading float32
	Clockwise      bool
}

Can either be specified with (Fix,Radius), or (Length,Clockwise); the remaining fields are then derived from those.

type DepControllerSnippetFormatter added in v0.13.2

type DepControllerSnippetFormatter struct{}

func (DepControllerSnippetFormatter) Spoken added in v0.13.2

func (DepControllerSnippetFormatter) Validate added in v0.13.2

func (DepControllerSnippetFormatter) Validate(arg any) error

func (DepControllerSnippetFormatter) Written added in v0.13.2

type Departure

type Departure struct {
	Exit string `json:"exit"`

	Destination         string                  `json:"destination"`
	Altitudes           util.SingleOrArray[int] `json:"altitude,omitempty"`
	Route               string                  `json:"route"`
	RouteWaypoints      WaypointArray           // not specified in user JSON
	Airlines            []DepartureAirline      `json:"airlines"`
	Scratchpad          string                  `json:"scratchpad"`           // optional
	SecondaryScratchpad string                  `json:"secondary_scratchpad"` // optional
	Description         string                  `json:"description"`
}

type DepartureAirline

type DepartureAirline struct {
	AirlineSpecifier
}

type ERAMAdaptation

type ERAMAdaptation struct {
	ARTCC             string                     // not in JSON
	CoordinationFixes map[string]AdaptationFixes `json:"coordination_fixes"`
}

type EnrouteSquawkCodePool

type EnrouteSquawkCodePool struct {
	Available *util.IntRangeSet

	// Initial is maintained as a read-only snapshot of the initial set of
	// available codes; it allows us to catch cases where the caller tries
	// to return code that is inside the range we cover but was removed
	// from the pool when it was first initialized.
	Initial *util.IntRangeSet
}

func MakeEnrouteSquawkCodePool

func MakeEnrouteSquawkCodePool(loc *LocalSquawkCodePool) *EnrouteSquawkCodePool

func (*EnrouteSquawkCodePool) Get

func (p *EnrouteSquawkCodePool) Get(r *rand.Rand) (Squawk, error)

func (*EnrouteSquawkCodePool) InInitialPool

func (p *EnrouteSquawkCodePool) InInitialPool(code Squawk) bool

func (*EnrouteSquawkCodePool) IsAssigned

func (p *EnrouteSquawkCodePool) IsAssigned(code Squawk) bool

func (*EnrouteSquawkCodePool) NumAvailable

func (p *EnrouteSquawkCodePool) NumAvailable() int

func (*EnrouteSquawkCodePool) Return

func (p *EnrouteSquawkCodePool) Return(code Squawk) error

func (*EnrouteSquawkCodePool) Take

func (p *EnrouteSquawkCodePool) Take(code Squawk) error

type ExitRoute

type ExitRoute struct {
	SID              string        `json:"sid"`
	AssignedAltitude int           `json:"assigned_altitude"`
	ClearedAltitude  int           `json:"cleared_altitude"`
	SpeedRestriction int           `json:"speed_restriction"`
	Waypoints        WaypointArray `json:"waypoints"`
	Description      string        `json:"description"`
	IsRNAV           bool          `json:"is_rnav"`
	// optional, control position to handoff to at a /ho
	HandoffController ControlPosition `json:"handoff_controller"`
	// optional, the initial tracking controller for the departure.
	DepartureController ControlPosition `json:"departure_controller"`
}

type FAAAirport

type FAAAirport struct {
	Id         string
	Name       string
	Country    string
	Elevation  int
	Location   math.Point2LL
	Runways    []Runway
	Approaches map[string]Approach
	STARs      map[string]STAR
	ARTCC      string
}

func (FAAAirport) SelectBestRunway

func (ap FAAAirport) SelectBestRunway(windDir float32, magneticVariation float32) (*Runway, *Runway)

func (FAAAirport) ValidRunways

func (ap FAAAirport) ValidRunways() string

type Fix

type Fix struct {
	Id       string
	Location math.Point2LL
}

type FixSnippetFormatter added in v0.13.2

type FixSnippetFormatter struct{}

func (FixSnippetFormatter) Spoken added in v0.13.2

func (f FixSnippetFormatter) Spoken(r *rand.Rand, arg any) string

func (FixSnippetFormatter) Validate added in v0.13.2

func (FixSnippetFormatter) Validate(arg any) error

func (FixSnippetFormatter) Written added in v0.13.2

func (FixSnippetFormatter) Written(arg any) string

type FleetAircraft

type FleetAircraft struct {
	ICAO  string
	Count int
}

type FlightPlan

type FlightPlan struct {
	Rules            FlightRules
	AircraftType     string
	CruiseSpeed      int
	DepartureAirport string
	Altitude         int
	ArrivalAirport   string
	AlternateAirport string
	Exit             string
	Route            string
	Remarks          string
}

FlightPlan represents the flight plan from the perspective of the Aircraft: who they are, what they're doing, how they're going to get there.

type FlightRules

type FlightRules int
const (
	FlightRulesUnknown FlightRules = iota
	FlightRulesIFR
	FlightRulesVFR
	FlightRulesDVFR
	FlightRulesSVFR
)

func (FlightRules) String

func (f FlightRules) String() string

type FlightStrip

type FlightStrip struct {
	Callsign string
}

type Frequency

type Frequency int

Frequencies are scaled by 1000 and then stored in integers.

func NewFrequency

func NewFrequency(f float32) Frequency

func (Frequency) String

func (f Frequency) String() string

type FrequencySnippetFormatter added in v0.13.2

type FrequencySnippetFormatter struct{}

func (FrequencySnippetFormatter) Spoken added in v0.13.2

func (FrequencySnippetFormatter) Spoken(r *rand.Rand, arg any) string

func (FrequencySnippetFormatter) Validate added in v0.13.2

func (FrequencySnippetFormatter) Validate(arg any) error

func (FrequencySnippetFormatter) Written added in v0.13.2

func (FrequencySnippetFormatter) Written(arg any) string

type GhostTrack

type GhostTrack struct {
	ADSBCallsign        ADSBCallsign
	Position            math.Point2LL
	Groundspeed         int
	LeaderLineDirection math.CardinalOrdinalDirection
	TrackId             string
}

type GroupFormSnippetFormatter added in v0.13.2

type GroupFormSnippetFormatter struct{}

func (GroupFormSnippetFormatter) Spoken added in v0.13.2

func (GroupFormSnippetFormatter) Spoken(r *rand.Rand, arg any) string

func (GroupFormSnippetFormatter) Validate added in v0.13.2

func (GroupFormSnippetFormatter) Validate(arg any) error

func (GroupFormSnippetFormatter) Written added in v0.13.2

func (GroupFormSnippetFormatter) Written(arg any) string

type HeadingSnippetFormatter added in v0.13.2

type HeadingSnippetFormatter struct{}

func (HeadingSnippetFormatter) Spoken added in v0.13.2

func (HeadingSnippetFormatter) Spoken(r *rand.Rand, arg any) string

func (HeadingSnippetFormatter) Validate added in v0.13.2

func (HeadingSnippetFormatter) Validate(arg any) error

func (HeadingSnippetFormatter) Written added in v0.13.2

func (HeadingSnippetFormatter) Written(arg any) string

type Hold added in v0.13.0

type Hold struct {
	Fix             string  // Fix identifier where hold is located
	InboundCourse   float32 // Inbound magnetic course to the fix
	TurnDirection   TurnDirection
	LegLengthNM     float32 // Distance-based leg length (nautical miles), 0 if time-based
	LegMinutes      float32 // Time-based leg duration (minutes), 0 if distance-based
	MinimumAltitude int     // Minimum altitude for hold (feet)
	MaximumAltitude int     // Maximum altitude for hold (feet), 0 if no maximum
	HoldingSpeed    int     // Speed limit in hold (knots), 0 if not specified
	Procedure       string  // Associated procedure (e.g., "ILS06 (IAP)", "CAMRN5", "ENROUTE HIGH")
}

Hold represents a charted holding pattern from CIFP or HPF

func (Hold) DisplayName added in v0.13.0

func (h Hold) DisplayName() string

func (Hold) Entry added in v0.13.0

func (h Hold) Entry(headingToFix float32) HoldEntry

func (Hold) Speed added in v0.13.0

func (h Hold) Speed(alt float32) float32

Speed returns the holding speed in knots for the given altitude. If the hold has a published holding speed, that is returned. Otherwise, standard holding speeds are applied based on altitude: ≤6000 ft: 200 knots, ≤14000 ft: 230 knots, >14000 ft: 265 knots.

type HoldEntry added in v0.13.0

type HoldEntry int
const (
	HoldEntryDirect HoldEntry = iota
	HoldEntryParallel
	HoldEntryTeardrop
)

func (HoldEntry) String added in v0.13.0

func (e HoldEntry) String() string

type InboundFlow

type InboundFlow struct {
	Arrivals    []Arrival    `json:"arrivals"`
	Overflights []Overflight `json:"overflights"`
}

func (InboundFlow) HasHumanHandoff added in v0.13.3

func (f InboundFlow) HasHumanHandoff() bool

HasHumanHandoff returns true if any arrival or overflight in the flow has a waypoint with HumanHandoff set.

func (InboundFlow) InitialControllers added in v0.13.3

func (f InboundFlow) InitialControllers() []ControlPosition

InitialControllers returns a list of all initial controllers specified for arrivals and overflights in this flow.

type LetterSnippetFormatter added in v0.13.2

type LetterSnippetFormatter struct{}

func (LetterSnippetFormatter) Spoken added in v0.13.2

func (LetterSnippetFormatter) Spoken(r *rand.Rand, arg any) string

func (LetterSnippetFormatter) Validate added in v0.13.2

func (LetterSnippetFormatter) Validate(arg any) error

func (LetterSnippetFormatter) Written added in v0.13.2

func (LetterSnippetFormatter) Written(arg any) string

type LocalPool

type LocalPool struct {
	Initial     *util.IntRangeSet
	Available   *util.IntRangeSet
	Ranges      [][2]Squawk
	Backups     string
	FlightRules FlightRules
}

type LocalSquawkCodePool

type LocalSquawkCodePool struct {
	Pools           map[string]LocalPool
	BeaconCodeTable BeaconCodeTable
}

func (*LocalSquawkCodePool) Get

func (p *LocalSquawkCodePool) Get(spec string, rules FlightRules, r *rand.Rand) (Squawk, FlightRules, error)

inbound rules are only used to choose a VFR/IFR pool if spec == ""

func (*LocalSquawkCodePool) InInitialPool

func (p *LocalSquawkCodePool) InInitialPool(code Squawk) bool

func (*LocalSquawkCodePool) IsAssigned

func (p *LocalSquawkCodePool) IsAssigned(code Squawk) bool

func (*LocalSquawkCodePool) IsReservedVFRCode

func (p *LocalSquawkCodePool) IsReservedVFRCode(sq Squawk) bool

func (*LocalSquawkCodePool) Return

func (p *LocalSquawkCodePool) Return(sq Squawk) error

type LocalSquawkCodePoolSpecifier

type LocalSquawkCodePoolSpecifier struct {
	Pools           map[string]PoolSpecifier `json:"auto_assignable_codes"`
	BeaconCodeTable BeaconCodeTableSpecifier `json:"beacon_code_table"`
}

SSR Codes Windows

func (*LocalSquawkCodePoolSpecifier) PostDeserialize

func (s *LocalSquawkCodePoolSpecifier) PostDeserialize(e *util.ErrorLogger)

type Locator

type Locator interface {
	// Locate returns the lat-long coordinates of the named point if they
	// are available; the bool indicates whether the point was known.
	Locate(fix string) (math.Point2LL, bool)

	// If Locate fails, Similar can be called to get alternatives that are
	// similarly-spelled to be offered in error messages.
	Similar(fix string) []string
}

Locator is a simple interface to abstract looking up the location of a named thing (e.g. a fix). This is mostly present so that the route code can call back into the ScenarioGroup to resolve locations accounting for fixes defined in a scenario, without exposing Scenario-related types to the aviation package.

type MVA

type MVA struct {
	MinimumLimit          int                      `xml:"minimumLimit"`
	MinimumLimitReference string                   `xml:"minimumLimitReference"`
	Proj                  *MVAHorizontalProjection `xml:"horizontalProjection"`
	Bounds                math.Extent2D
	ExteriorRing          [][2]float32
	InteriorRings         [][][2]float32
}

func (*MVA) Inside

func (m *MVA) Inside(p [2]float32) bool

type MVAExterior

type MVAExterior struct {
	LinearRing MVALinearRing `xml:"LinearRing"`
}

type MVAHorizontalProjection

type MVAHorizontalProjection struct {
	Surface MVASurface `xml:"Surface"`
}

type MVAInterior

type MVAInterior struct {
	LinearRing MVALinearRing `xml:"LinearRing"`
}

type MVALinearRing

type MVALinearRing struct {
	PosList string `xml:"posList"`
}

func (MVALinearRing) Vertices

func (r MVALinearRing) Vertices() [][2]float32

type MVAPatches

type MVAPatches struct {
	PolygonPatch MVAPolygonPatch `xml:"PolygonPatch"`
}

type MVAPolygonPatch

type MVAPolygonPatch struct {
	Exterior  MVAExterior   `xml:"exterior"`
	Interiors []MVAInterior `xml:"interior"`
}

type MVASurface

type MVASurface struct {
	Patches MVAPatches `xml:"patches"`
}

type MagneticGrid

type MagneticGrid struct {
	MinLatitude, MaxLatitude   float32
	MinLongitude, MaxLongitude float32
	LatLongStep                float32
	Samples                    []float32
}

func (*MagneticGrid) Lookup

func (mg *MagneticGrid) Lookup(p math.Point2LL) (float32, error)
type Navaid struct {
	Id       string
	Type     string
	Name     string
	Location math.Point2LL
}

type Overflight

type Overflight struct {
	Waypoints           WaypointArray           `json:"waypoints"`
	InitialAltitudes    util.SingleOrArray[int] `json:"initial_altitude"`
	CruiseAltitude      float32                 `json:"cruise_altitude"`
	AssignedAltitude    float32                 `json:"assigned_altitude"`
	InitialSpeed        float32                 `json:"initial_speed"`
	AssignedSpeed       float32                 `json:"assigned_speed"`
	SpeedRestriction    float32                 `json:"speed_restriction"`
	InitialController   ControlPosition         `json:"initial_controller"`
	Scratchpad          string                  `json:"scratchpad"`
	SecondaryScratchpad string                  `json:"secondary_scratchpad"`
	Description         string                  `json:"description"`
	IsRNAV              bool                    `json:"is_rnav"`
	Airlines            []OverflightAirline     `json:"airlines"`
}

func (*Overflight) PostDeserialize

func (of *Overflight) PostDeserialize(loc Locator, nmPerLongitude float32, magneticVariation float32,
	airports map[string]*Airport, controlPositions map[ControlPosition]*Controller, checkScratchpad func(string) bool,
	e *util.ErrorLogger)

type OverflightAirline

type OverflightAirline struct {
	AirlineSpecifier
	DepartureAirport string `json:"departure_airport"`
	ArrivalAirport   string `json:"arrival_airport"`
}

type PTType

type PTType int

func (PTType) String

func (pt PTType) String() string

type PhraseFormatString added in v0.13.2

type PhraseFormatString string

PhraseFormatString is a string that potentially includes

func (PhraseFormatString) Spoken added in v0.13.2

func (s PhraseFormatString) Spoken(r *rand.Rand, args []any) string

func (PhraseFormatString) Validate added in v0.13.2

func (s PhraseFormatString) Validate(args []any, lg *log.Logger) bool

func (PhraseFormatString) Written added in v0.13.2

func (s PhraseFormatString) Written(r *rand.Rand, args []any) string

type PoolSpecifier

type PoolSpecifier struct {
	Ranges  []string `json:"ranges"`
	Rules   string   `json:"flight_rules"`
	Backups string   `json:"backup_pool_list"`
}

type ProcedureTurn

type ProcedureTurn struct {
	Type         PTType
	RightTurns   bool
	ExitAltitude int     `json:",omitempty"`
	MinuteLimit  float32 `json:",omitempty"`
	NmLimit      float32 `json:",omitempty"`
	Entry180NoPT bool    `json:",omitempty"`
}

func (*ProcedureTurn) SelectRacetrackEntry

func (pt *ProcedureTurn) SelectRacetrackEntry(inboundHeading float32, aircraftFixHeading float32) RacetrackPTEntry

type RacetrackPTEntry

type RacetrackPTEntry int

func (RacetrackPTEntry) MarshalJSON

func (e RacetrackPTEntry) MarshalJSON() ([]byte, error)

func (RacetrackPTEntry) String

func (e RacetrackPTEntry) String() string

func (*RacetrackPTEntry) UnmarshalJSON

func (e *RacetrackPTEntry) UnmarshalJSON(b []byte) error

type RadarSite

type RadarSite struct {
	Char           string        `json:"char"`
	PositionString string        `json:"position"`
	Position       math.Point2LL // not in JSON, set during deserialize

	Elevation      int32   `json:"elevation"`
	PrimaryRange   int32   `json:"primary_range"`
	SecondaryRange int32   `json:"secondary_range"`
	SlopeAngle     float32 `json:"slope_angle"`
	SilenceAngle   float32 `json:"silence_angle"`
}

func (*RadarSite) CheckVisibility

func (rs *RadarSite) CheckVisibility(p math.Point2LL, altitude int) (primary, secondary bool, distance float32)

type RadarTrack

type RadarTrack struct {
	ADSBCallsign        ADSBCallsign
	Squawk              Squawk
	Mode                TransponderMode
	Ident               bool
	TrueAltitude        float32
	TransponderAltitude float32
	Location            math.Point2LL
	Heading             float32
	Groundspeed         float32
	TypeOfFlight        TypeOfFlight
}

type RadioTransmission added in v0.13.2

type RadioTransmission struct {
	Strings    []PhraseFormatString
	Args       [][]any // each slice contains values passed to the corresponding PhraseFormatString
	Controller string
	Type       RadioTransmissionType
}

RadioTransmission holds components that together represent a single radio transmission by a pilot; they may be built up from multiple instructions provided in a single controller command.

func MakeContactTransmission added in v0.13.2

func MakeContactTransmission(s string, args ...any) *RadioTransmission

MakeContactRadioTransmission is a helper function to make a pilot transmission for initial contact from a single formatting string and set of arguments.

func MakeMixedUpTransmission added in v0.13.2

func MakeMixedUpTransmission(s string, args ...any) *RadioTransmission

MakeMixedUpTransmission creates a pilot transmission when the pilot is confused about who is being addressed.

func MakeReadbackTransmission added in v0.13.2

func MakeReadbackTransmission(s string, args ...any) *RadioTransmission

MakeReadbackTransmission is a helper function to make a pilot transmission of a readback from a single formatting string and set of arguments.

func MakeUnexpectedTransmission added in v0.13.2

func MakeUnexpectedTransmission(s string, args ...any) *RadioTransmission

MakeUnexpectedTransmission similarly makes a single pilot transmission from the provided format string and arguments, but also marks the transmission as unexpected.

func (*RadioTransmission) Add added in v0.13.2

func (rt *RadioTransmission) Add(s string, args ...any)

Add is a convenience function to add a transmission snippet to the RadioTransmission. It's more or less equivalent to calling Merge(MakeRadioTransmission(...)).

func (*RadioTransmission) Merge added in v0.13.2

func (rt *RadioTransmission) Merge(r *RadioTransmission)

Merge takes a separately-constructed RadioTransmission and merges its contents with the current one.

func (RadioTransmission) Spoken added in v0.13.2

func (rt RadioTransmission) Spoken(r *rand.Rand) string

Spoken returns a string corresponding to how the transmission should be spoken, which appropriate phonetic substitutions made (e.g. "9" -> "niner").

func (*RadioTransmission) Validate added in v0.13.2

func (rt *RadioTransmission) Validate(lg *log.Logger)

Validate ensures that the types of arguments match with the formatting directives in the PhraseFormatStrings; errors are logged to the provided logger.

func (RadioTransmission) Written added in v0.13.2

func (rt RadioTransmission) Written(r *rand.Rand) string

Written returns a string corresponding to how the transmission should be displayed as text on the screen.

type RadioTransmissionType

type RadioTransmissionType int

func (RadioTransmissionType) String

func (r RadioTransmissionType) String() string

type ReportingPoint

type ReportingPoint struct {
	Fix      string
	Location math.Point2LL
}

type RestrictionArea

type RestrictionArea struct {
	Title        string        `json:"title"`
	Text         [2]string     `json:"text"`
	BlinkingText bool          `json:"blinking_text"`
	HideId       bool          `json:"hide_id"`
	TextPosition math.Point2LL `json:"text_position"`
	CircleCenter math.Point2LL `json:"circle_center"`
	CircleRadius float32       `json:"circle_radius"`
	VerticesUser WaypointArray `json:"vertices"`
	Vertices     [][]math.Point2LL
	Closed       bool `json:"closed"`
	Shaded       bool `json:"shade_region"`
	Color        int  `json:"color"`

	Tris    [][3]math.Point2LL
	Deleted bool
}

func RestrictionAreaFromTFR

func RestrictionAreaFromTFR(tfr TFR) RestrictionArea

func (*RestrictionArea) AverageVertexPosition

func (ra *RestrictionArea) AverageVertexPosition() math.Point2LL

func (*RestrictionArea) MoveTo

func (ra *RestrictionArea) MoveTo(p math.Point2LL)

func (*RestrictionArea) UpdateTriangles

func (ra *RestrictionArea) UpdateTriangles()

type RouteGenerator

type RouteGenerator struct {
	// contains filtered or unexported fields
}

RouteGenerator is a utility class for describing lateral routes with respect to a local coordinate system. The user provides two points (generally the endpoints of a runway) which are then at (-1,0) and (1,0) in the coordinate system. The y axis is perpendicular to the vector between the two points and points to the left of it. (Thus, note that lengths in the two dimensions are different.)

func MakeRouteGenerator

func MakeRouteGenerator(p0ll, p1ll math.Point2LL, nmPerLongitude float32) RouteGenerator

func (RouteGenerator) Waypoint

func (rg RouteGenerator) Waypoint(name string, dx, dy float32) Waypoint

type Runway

type Runway struct {
	Id                         string
	Heading                    float32
	Threshold                  math.Point2LL
	ThresholdCrossingHeight    int // delta from elevation
	Elevation                  int
	DisplacedThresholdDistance float32 // in nm
}

func LookupOppositeRunway

func LookupOppositeRunway(icao, rwy string) (Runway, bool)

func LookupRunway

func LookupRunway(icao, rwy string) (Runway, bool)

type SIDSnippetFormatter added in v0.13.2

type SIDSnippetFormatter struct{}

func (SIDSnippetFormatter) Spoken added in v0.13.2

func (SIDSnippetFormatter) Spoken(r *rand.Rand, arg any) string

func (SIDSnippetFormatter) Validate added in v0.13.2

func (SIDSnippetFormatter) Validate(arg any) error

func (SIDSnippetFormatter) Written added in v0.13.2

func (s SIDSnippetFormatter) Written(arg any) string

type SPC

type SPC struct {
	Squawk Squawk
	Code   string
}

SPC (Special Purpose Code) is a unique beacon code, indicate an emergency or non-standard operation.

type STAR

type STAR struct {
	Transitions     map[string]WaypointArray
	RunwayWaypoints map[string]WaypointArray
}

func MakeSTAR

func MakeSTAR() *STAR

func (STAR) Check

func (s STAR) Check(e *util.ErrorLogger)

func (STAR) Print

func (s STAR) Print(name string)

type STARSnippetFormatter added in v0.13.2

type STARSnippetFormatter struct{}

func (STARSnippetFormatter) Spoken added in v0.13.2

func (STARSnippetFormatter) Spoken(r *rand.Rand, arg any) string

func (STARSnippetFormatter) Validate added in v0.13.2

func (STARSnippetFormatter) Validate(arg any) error

func (STARSnippetFormatter) Written added in v0.13.2

func (s STARSnippetFormatter) Written(arg any) string

type SnippetFormatter added in v0.13.2

type SnippetFormatter interface {
	// Written
	Written(arg any) string
	Spoken(r *rand.Rand, arg any) string
	Validate(arg any) error
}

SnippetFormatter defines an interface for formatting short text snippets corresponding to various aviation-related concepts into both speech and text. Each is takes a single value specifying the value of the corresponding thing (altitude, speed, etc.)

type SpeedSnippetFormatter added in v0.13.2

type SpeedSnippetFormatter struct{}

func (SpeedSnippetFormatter) Spoken added in v0.13.2

func (SpeedSnippetFormatter) Spoken(r *rand.Rand, arg any) string

func (SpeedSnippetFormatter) Validate added in v0.13.2

func (SpeedSnippetFormatter) Validate(arg any) error

func (SpeedSnippetFormatter) Written added in v0.13.2

func (SpeedSnippetFormatter) Written(arg any) string

type Squawk

type Squawk int

func ParseSquawk

func ParseSquawk(s string) (Squawk, error)

func ParseSquawkOrBlock

func ParseSquawkOrBlock(s string) (Squawk, error)

func (Squawk) IsSPC

func (sq Squawk) IsSPC() (ok bool, code string)

IsSPC returns true if the given squawk code is an SPC. The second return value is a string giving the two-letter abbreviated SPC it corresponds to.

func (Squawk) String

func (sq Squawk) String() string

type StaticDatabase

type StaticDatabase struct {
	Navaids             map[string]Navaid
	Airports            map[string]FAAAirport
	Fixes               map[string]Fix
	Airways             map[string][]Airway
	EnrouteHolds        map[string][]Hold            // Fix -> Holds
	TerminalHolds       map[string]map[string][]Hold // Airport ICAO -> Fix -> Holds
	Callsigns           map[string]string            // 3 letter -> callsign
	AircraftTypeAliases map[string]string
	AircraftPerformance map[string]AircraftPerformance
	Airlines            map[string]Airline
	MagneticGrid        MagneticGrid
	ARTCCs              map[string]ARTCC
	ERAMAdaptations     map[string]ERAMAdaptation
	TRACONs             map[string]TRACON
	MVAs                map[string][]MVA // TRACON -> MVAs
	BravoAirspace       map[string][]AirspaceVolume
	CharlieAirspace     map[string][]AirspaceVolume
	DeltaAirspace       map[string][]AirspaceVolume
}
var DB *StaticDatabase

func (StaticDatabase) LookupAirport added in v0.13.3

func (d StaticDatabase) LookupAirport(name string) (FAAAirport, bool)

func (StaticDatabase) LookupWaypoint

func (d StaticDatabase) LookupWaypoint(f string) (math.Point2LL, bool)

type TFR

type TFR struct {
	ARTCC     string
	Type      string // VIP, SECURITY, EVENT, etc.
	LocalName string // Short string summarizing it.
	Effective time.Time
	Expire    time.Time
	Points    [][]math.Point2LL // One or more line loops defining its extent.
}

TFR represents an FAA-issued temporary flight restriction.

type TFRCache

type TFRCache struct {
	TFRs map[string]TFR // URL -> TFR
	// contains filtered or unexported fields
}

TFRCache stores active TFRs that have been retrieved previously; we save it out on the config so that we don't download all of them each time vice is launched.

func MakeTFRCache

func MakeTFRCache() TFRCache

func (*TFRCache) Sync

func (t *TFRCache) Sync(timeout time.Duration, lg *log.Logger)

Sync synchronizes the cache, adding any newly-downloaded TFRs. It returns after the given timeout passes if we haven't gotten results back yet.

func (*TFRCache) TFRsForTRACON

func (t *TFRCache) TFRsForTRACON(tracon string, lg *log.Logger) []TFR

TFRsForTRACON returns all TFRs that apply to the given TRACON. (It currently return all of the ones for the TRACON's ARTCC, which is overkill; we should probably cull them based on distance to the center of the TRACON.)

func (*TFRCache) UpdateAsync

func (t *TFRCache) UpdateAsync(lg *log.Logger)

UpdateAsync kicks off an update of the TFRCache; it runs asynchronously with synchronization happening when Sync or TFRsForTRACON is called.

type TFRListJSON

type TFRListJSON struct {
	Notam_id string `json:"notam_id"`
}

type TRACON

type TRACON struct {
	Name      string
	ARTCC     string
	Latitude  float32
	Longitude float32
	Radius    float32
}

func (TRACON) Center

func (t TRACON) Center() math.Point2LL

type TransponderMode

type TransponderMode int
const (
	TransponderModeStandby  TransponderMode = iota /* off */
	TransponderModeAltitude                        /* mode C */
	TransponderModeOn                              /* mode A */
)

func (TransponderMode) String

func (t TransponderMode) String() string

type TurnDirection added in v0.13.0

type TurnDirection int

TurnDirection specifies the direction of turns in a holding pattern

const (
	TurnLeft TurnDirection = iota
	TurnRight
)

func (TurnDirection) String added in v0.13.0

func (t TurnDirection) String() string

type TypeOfFlight

type TypeOfFlight int
const (
	FlightTypeUnknown TypeOfFlight = iota
	FlightTypeDeparture
	FlightTypeArrival
	FlightTypeOverflight
)

type VFRRandomsSpec

type VFRRandomsSpec struct {
	Rate  int    `json:"rate"`
	Fleet string `json:"fleet"`
}

type VFRReportingPoint

type VFRReportingPoint struct {
	Description string        `json:"description"`
	Location    math.Point2LL `json:"location"`
}

func (*VFRReportingPoint) PostDeserialize

func (rp *VFRReportingPoint) PostDeserialize(loc Locator, controllers map[ControlPosition]*Controller, e *util.ErrorLogger)

type VFRRouteSpec

type VFRRouteSpec struct {
	Name        string        `json:"name"`
	Rate        int           `json:"rate"`
	Fleet       string        `json:"fleet"`
	Waypoints   WaypointArray `json:"waypoints"`
	Destination string        `json:"destination"`
	Description string        `json:"description"`
}

type Waypoint

type Waypoint struct {
	Fix                      string               `json:"fix"`
	Location                 math.Point2LL        // not provided in scenario JSON; derived from fix
	AltitudeRestriction      *AltitudeRestriction `json:"altitude_restriction,omitempty"`
	Speed                    int                  `json:"speed,omitempty"`
	Heading                  int                  `json:"heading,omitempty"` // outbound heading after waypoint
	PresentHeading           bool                 `json:",omitempty"`
	ProcedureTurn            *ProcedureTurn       `json:"pt,omitempty"`
	NoPT                     bool                 `json:"nopt,omitempty"`
	HumanHandoff             bool                 `json:"human_handoff,omitempty"` // Handoff to human controller
	HandoffController        ControlPosition      `json:"tcp_handoff,omitempty"`   // Controller position for handoff
	PointOut                 ControlPosition      `json:"pointout,omitempty"`
	ClearApproach            bool                 `json:"clear_approach,omitempty"` // used for distractor a/c, clears them for the approach passing the wp.
	FlyOver                  bool                 `json:"flyover,omitempty"`
	Delete                   bool                 `json:"delete,omitempty"`
	Land                     bool                 `json:"land,omitempty"`
	Arc                      *DMEArc              `json:"arc,omitempty"`
	IAF, IF, FAF             bool                 `json:",omitempty"` // not provided in scenario JSON; derived from fix
	Airway                   string               `json:",omitempty"` // when parsing waypoints, this is set if we're on an airway after the fix
	OnSID, OnSTAR            bool                 `json:",omitempty"` // set during deserialization
	OnApproach               bool                 `json:",omitempty"` // set during deserialization
	AirworkRadius            int                  `json:",omitempty"` // set during deserialization
	AirworkMinutes           int                  `json:",omitempty"` // set during deserialization
	Radius                   float32              `json:",omitempty"`
	Shift                    float32              `json:",omitempty"`
	PrimaryScratchpad        string               `json:",omitempty"`
	ClearPrimaryScratchpad   bool                 `json:",omitempty"`
	SecondaryScratchpad      string               `json:",omitempty"`
	ClearSecondaryScratchpad bool                 `json:",omitempty"`
	TransferComms            bool                 `json:",omitempty"`
	ClimbAltitude            *int                 `json:",omitempty"` // altitude in feet to climb to when passing waypoint
	DescendAltitude          *int                 `json:",omitempty"` // altitude in feet to descend to when passing waypoint
}

func AppendVFRLanding

func AppendVFRLanding(wps []Waypoint, perf AircraftPerformance, airport string, windDir float32, nmPerLongitude float32,
	magneticVariation float32, lg *log.Logger) []Waypoint

Takes waypoints up to the one with the Land specifier. Rewrite that one and then append the landing route.

func (*Waypoint) ETA

func (wp *Waypoint) ETA(p math.Point2LL, gs float32, nmPerLongitude float32) time.Duration

func (Waypoint) LogValue

func (wp Waypoint) LogValue() slog.Value

type WaypointArray

type WaypointArray []Waypoint

func (WaypointArray) CheckArrival

func (wa WaypointArray) CheckArrival(e *util.ErrorLogger, ctrl map[ControlPosition]*Controller, approachAssigned bool,
	checkScratchpad func(string) bool)

func (WaypointArray) CheckDeparture

func (wa WaypointArray) CheckDeparture(e *util.ErrorLogger, controllers map[ControlPosition]*Controller, checkScratchpads func(string) bool)

func (WaypointArray) CheckOverflight

func (wa WaypointArray) CheckOverflight(e *util.ErrorLogger, ctrl map[ControlPosition]*Controller, checkScratchpads func(string) bool)

func (WaypointArray) Encode

func (wa WaypointArray) Encode() string

func (WaypointArray) HasHumanHandoff added in v0.13.3

func (wa WaypointArray) HasHumanHandoff() bool

HasHumanHandoff returns true if any waypoint has HumanHandoff set.

func (WaypointArray) InitializeLocations

func (wa WaypointArray) InitializeLocations(loc Locator, nmPerLongitude float32, magneticVariation float32,
	allowSlop bool, e *util.ErrorLogger) WaypointArray

func (WaypointArray) RouteString

func (wa WaypointArray) RouteString() string

func (*WaypointArray) UnmarshalJSON

func (wa *WaypointArray) UnmarshalJSON(b []byte) error

type XNOTAMUpdate

type XNOTAMUpdate struct {
	Group struct {
		Add struct {
			Not struct {
				NotUid struct {
					TxtLocalName string `xml:"txtLocalName"`
				} `xml:"NotUid"`
				DateEffective          string `xml:"dateEffective"`
				DateExpire             string `xml:"dateExpire"`
				CodeTimeZone           string `xml:"codeTimeZone"`
				CodeExpirationTimeZone string `xml:"codeExpirationTimeZone"`
				CodeFacility           string `xml:"codeFacility"`
				TfrNot                 struct {
					CodeType     string `xml:"codeType"`
					TFRAreaGroup []struct {
						AbdMergedArea struct {
							Avx []struct {
								Text      string `xml:",chardata"`
								CodeDatum string `xml:"codeDatum"`
								CodeType  string `xml:"codeType"`
								GeoLat    string `xml:"geoLat"`
								GeoLong   string `xml:"geoLong"`
							} `xml:"Avx"`
						} `xml:"abdMergedArea"`
					} `xml:"TFRAreaGroup"`
				} `xml:"TfrNot"`
			} `xml:"Not"`
		} `xml:"Add"`
	} `xml:"Group"`
}

XNOTAMUpdate was generated 2024-09-23 07:39:34 by https://xml-to-go.github.io/, using https://github.com/miku/zek. Then manually chopped down to the parts we care about...

Jump to

Keyboard shortcuts

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