aviation

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: GPL-3.0 Imports: 36 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
	RadioTransmissionNoId       // No callsign included (e.g. to say "blocked")
)
View Source
const (
	RouteBasedFix = "route"
	ZoneBasedFix  = "zone"
)
View Source
const (

	// FlightDataDirectory is where historical flight data lives in the resources.
	FlightDataDirectory = "traffic/flights"

	// FlightDataExtension is the suffix of a flight data cell file.
	FlightDataExtension = ".flt"

	// FlightDataMetadataName is the file in FlightDataDirectory holding what the
	// cells have in common.
	FlightDataMetadataName = "metadata.json"
)
View Source
const (
	VFRPhaseNone       uint8 = 0
	VFRPhaseRollout    uint8 = 1
	VFRPhaseUpwind     uint8 = 2
	VFRPhaseCrosswind  uint8 = 3
	VFRPhaseDownwind   uint8 = 4
	VFRPhaseBase       uint8 = 5
	VFRPhaseFinal      uint8 = 6
	VFRPhaseStraightIn uint8 = 7
	VFRPhaseOrbit      uint8 = 8
)

VFRPhase constants identify which leg of the VFR traffic pattern a waypoint belongs to.

View Source
const (
	PTUndefined = iota
	PTRacetrack
	PTStandard45
)
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 MaxAltitude float32 = 100000

MaxAltitude is used as the upper bound for "at or above" restrictions. This lets the invariant Range[0] <= Range[1] always hold, eliminating sentinel checks in clamping/bounding code.

View Source
const MaxRestrictionAreas = 100

This many adapted and then this many user-defined

View Source
const MaxRestrictionSpeed float32 = 1000

MaxRestrictionSpeed is the sentinel value used as the upper bound for "at or above" speed restrictions. It is not a real airspeed limit; compare against aircraft performance for actual maxima.

View Source
const ScrapedRoutesPath = "scraped-routes.json"

ScrapedRoutesPath is where the scraped route database lives in the resources, keyed by "KSFO-KPDX"-style directed city pairs.

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")
)
View Source
var FlightDataSubstitutes = map[string]string{
	"KAAC": "KEWR",
	"KBRT": "KBED",
	"KJKE": "KWRI",
	"4Y3":  "KTEB",
	"4V4":  "KOXC",
}

FlightDataSubstitutes gives the real airport whose traffic each made-up airport borrows. The FAA Academy scenarios fly fictional airports that the source data knows nothing about, so each one stands on the flights of a real airport with the traffic rate and character it wants. Donors must be four-character ICAO codes: that is all the source data's airport lists hold.

View Source
var NATOPhonetic = map[string]string{
	"A": "alpha", "B": "bravo", "C": "charlie", "D": "delta",
	"E": "echo", "F": "foxtrot", "G": "golf", "H": "hotel",
	"I": "india", "J": "juliet", "K": "kilo", "L": "lima",
	"M": "mike", "N": "november", "O": "oscar", "P": "papa",
	"Q": "quebec", "R": "romeo", "S": "sierra", "T": "tango",
	"U": "uniform", "V": "victor", "W": "whiskey", "X": "x-ray",
	"Y": "yankee", "Z": "zulu",
}

NATOPhonetic maps uppercase letters to their standard NATO phonetic alphabet words.

View Source
var RenamedAirports = map[string]string{
	"KPBI": "KDJT",
}

RenamedAirports maps airport identifiers the FAA has retired to the ones that replaced them. The historical data vice imports goes on using the old identifier long after the change, so the import tools canonicalize through this; scenarios and timetables must use the current one.

Functions

func AirportHasRunway added in v0.14.1

func AirportHasRunway(airport string, runway RunwayID) bool

AirportHasRunway returns true if the given runway exists at the airport (from DB).

func ApproachTelephonyComponents added in v0.15.0

func ApproachTelephonyComponents(approach string) (types []string, runway string)

ApproachTelephonyComponents returns the spoken units of an approach name separately: the type-related words (e.g., "I L S", "r-nav", "x-ray") and the spoken runway (e.g., "two two left"; empty if the name doesn't include one).

func CWTApproachSeparation

func CWTApproachSeparation(frontCWT, backCWT string, eligible25nm bool) float32

CWTApproachSeparation returns the required approach separation between aircraft of the given CWT categories. When the CWT table specifies no extra wake turbulence separation (0), minimum radar separation applies: 2.5 NM on eligible runways, 3 NM otherwise.

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 CallsignClashesWithExisting added in v0.14.1

func CallsignClashesWithExisting(currentCallsigns []ADSBCallsign, proposed string, uniqueSuffix bool) bool

func CheckAirport added in v0.15.0

func CheckAirport(role, id string) error

CheckAirport returns an error unless id names an airport in the database. role describes the airport's part in whatever is being validated, as in "destination" or "arrival". A retired identifier names its replacement: historical data keeps using the old one, so it turns up in scenario edits made from a stale copy.

func CheckApproaches

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

func CurrentAirportId added in v0.15.0

func CurrentAirportId(id string) string

CurrentAirportId returns the identifier now in use for an airport that has been re-identified; any other id is returned unchanged.

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 EncodeFlightDataMetadata added in v0.15.0

func EncodeFlightDataMetadata(intervals []util.TimeInterval) ([]byte, error)

EncodeFlightDataMetadata renders the contents of metadata.json.

func EncodeFlights added in v0.15.0

func EncodeFlights(flights []Flight) ([]byte, error)

EncodeFlights encodes a facility's flight data. Flights must be in the order SortFlights puts them in.

func ExitRoutesForAircraft added in v0.15.0

func ExitRoutesForAircraft(routes map[ExitID]ExitRoutes, acType string) map[ExitID]*ExitRoute

ExitRoutesForAircraft returns the route to each exit that the given aircraft type flies, leaving out the exits it has no route to.

func FlightDataCell added in v0.15.0

func FlightDataCell(p math.Point2LL) string

FlightDataCell names the flight data file an airport's flights are stored in: the cell of latitude and longitude holding it, named for the cell's southwest corner. Import and runtime both go through here, so that they always agree on where an airport's flights are.

func FlightDataCells added in v0.15.0

func FlightDataCells(airports ...map[string]bool) []string

FlightDataCells returns the cells holding the given airports' flights, with no repeats. Airports the database doesn't know are left out: there can be no flight data for an airport with no position.

func FlightDataDate added in v0.15.0

func FlightDataDate(day uint16) time.Time

FlightDataDate is the inverse of FlightDataDayNumber.

func FlightDataDayNumber added in v0.15.0

func FlightDataDayNumber(t time.Time) uint16

FlightDataDayNumber returns the number of days from 1970-01-01 to t's UTC calendar date; the time of day is dropped here.

func FlightDataIntervals added in v0.15.0

func FlightDataIntervals(resources fs.FS) ([]util.TimeInterval, error)

FlightDataIntervals returns the stretches of time the flight data covers; it has a gap wherever the list does. They come from metadata.json rather than from the cells, since the source data goes down for everywhere at once. The result is empty when there is no flight data at all.

func FlightDataPath added in v0.15.0

func FlightDataPath(cell string) string

FlightDataPath is where a cell's flight data lives in the resources.

func FlightIntervals added in v0.15.0

func FlightIntervals(flights []Flight) []util.TimeInterval

FlightIntervals returns the stretches of time a set of flights covers, splitting wherever they go a full day without one.

func FormatAltitude

func FormatAltitude(falt float32) string

func GetACTypePronunciations added in v0.14.0

func GetACTypePronunciations(acType string) []string

GetACTypePronunciations returns all pronunciation variants for an aircraft type. For example, "C172" might return ["skyhawk", "cessna one seventy-two"]. Returns nil if the type is not found in sayactype.json.

func GetAirportTelephonyVariants added in v0.14.0

func GetAirportTelephonyVariants(icao string) []string

GetAirportTelephonyVariants returns all spoken name variants for an airport. This is used by STT for matching spoken airport names to ICAO codes. Returns all variants from sayairport.json if available, otherwise returns a slice with just the database name (if available), or nil if not found.

func GetApproachTelephony added in v0.14.0

func GetApproachTelephony(approach string) string

GetApproachTelephony returns the spoken form of an approach name. For example, "RNAV X Runway 22L" becomes "r-nav x-ray runway two two left".

func GetCallsignSpoken added in v0.14.0

func GetCallsignSpoken(callsign string, cwtCategory string) string

GetCallsignSpoken returns the spoken telephony string for a callsign, formatted as it would be pronounced. It is the speech-to-text spelling: it feeds the whisper initial prompt and keys the command parser's aircraft context, so it uses the plain telephony name rather than sayAirlineMap's voice-synthesis respellings. Example: "JBU520" → "jetblue five 20", "BAW22J" → "speedbird 22 juliet"

func GetFixTelephony added in v0.14.0

func GetFixTelephony(fix string) string

GetFixTelephony returns the spoken name for a fix (navaid, airport, or waypoint). It uses pronunciations from sayfix.json when available, falls back to database lookups for navaids/airports, and uses StopShouting for other fixes.

func GetSIDTelephony added in v0.14.0

func GetSIDTelephony(sid string) string

GetSIDTelephony returns the spoken form of a SID name. For example, "MERIT5" becomes "merit five".

func GetSTARTelephony added in v0.14.0

func GetSTARTelephony(star string) string

GetSTARTelephony returns the spoken form of a STAR name. For example, "CAMRN4" becomes "cameron four".

func GetTrailing3Spoken added in v0.14.0

func GetTrailing3Spoken(callsign string) string

GetTrailing3Spoken returns the trailing 3 characters of a callsign as spoken phonetics. For "N123AB", returns "3 alpha bravo". For callsigns shorter than 3 chars (excluding N prefix), returns the whole number.

func IASToTAS

func IASToTAS(ias, altitude float32) float32

func InAirspace

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

func InitDB

func InitDB()

InitDB ensures the aviation database is initialized and blocks until it is ready. Safe to call multiple times; only the first call does work. Prefer StartInitDB if you want to kick off loading without waiting.

func IntersectingRunways added in v0.14.0

func IntersectingRunways(airport string, rwy RunwayID, nmPerLongitude, maxDistNM float32) []string

IntersectingRunways returns all runways at airport that physically intersect the given runway. It checks if runway centerlines cross and the intersection point is within maxDistNM of both runway segments (threshold to threshold). Use maxDistNM=0 for strict threshold-to-threshold intersection, or a small value (e.g., 0.5) to account for pavement extending past thresholds. Returns both directions for each intersecting runway (e.g., both "13L" and "31R").

func IsNamedFix added in v0.15.0

func IsNamedFix(fix string) bool

IsNamedFix reports whether a waypoint name is a published fix or navaid identifier someone could say on the radio, as opposed to one of the points routes are built out of: scenario helper fixes ("_EWR4_22Ra"), runway thresholds and midpoints ("22R", "1-mid"), lat/long waypoints, and CIFP procedure fixes ("CF13L", "RW22L"). Published identifiers are three to five letters and never contain a digit.

func MachToTAS added in v0.14.1

func MachToTAS(mach float32, temp Temperature) float32

func MergeFlightIntervals added in v0.15.0

func MergeFlightIntervals(intervals []util.TimeInterval) []util.TimeInterval

MergeFlightIntervals combines the intervals of several sets of flights into the intervals of all of them together, joining any two that are less than a full day apart. Computing the intervals a cell at a time and merging here gives the same answer as gathering every flight's time at once, without holding tens of millions of them in memory to sort.

func OppositeRunwayId added in v0.14.0

func OppositeRunwayId(rwy string) string

OppositeRunwayId returns the runway ID for the opposite end of the given runway. E.g., "13L" -> "31R", "22R" -> "4L", "9" -> "27".

func ParseDistanceDirection added in v0.14.3

func ParseDistanceDirection(s string) (int, math.CardinalOrdinalDirection, error)

ParseDistanceDirection parses strings like "5W" or "10NE" into a distance in miles and a cardinal/ordinal direction.

func ParseSyntheticCrossingFix added in v0.14.3

func ParseSyntheticCrossingFix(fix string) (string, int, math.CardinalOrdinalDirection, bool)

ParseSyntheticCrossingFix parses a synthetic cross-distance waypoint name like "_DETGY/5W" and returns the named fix, distance, and direction.

func ParseSyntheticDMEFix added in v0.14.3

func ParseSyntheticDMEFix(fix string) (string, int, bool)

ParseSyntheticDMEFix parses a synthetic cross-DME waypoint name like "_04L_10DME" and returns the runway and distance (in nm) from the threshold.

func PrintCIFPRoutes

func PrintCIFPRoutes(airport string) error

func PrintMapLibrary added in v0.14.4

func PrintMapLibrary(path string, e *util.ErrorLogger)

PrintMapLibrary prints a table of the maps in the given file.

func ProcedureBase added in v0.15.0

func ProcedureBase(name string) string

ProcedureBase strips a SID or STAR's revision number: CUUDA3 and CUUDA4 are revisions of the same arrival.

func RandomizeRoute

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

func ReadFlightData added in v0.15.0

func ReadFlightData(resources fs.FS, cell string) ([]byte, error)

ReadFlightData returns a cell's flight data file, or nil if there is none for it. Most cells have no flights at all, but a file that is there and can't be read is an error like any other.

func ReadScrapedRoutes added in v0.15.0

func ReadScrapedRoutes(resources fs.StatFS) (map[string]ScrapedRouteSet, error)

ReadScrapedRoutes parses the scraped route database, or returns an empty map if none has been written yet.

func RegisterIntentMerger added in v0.14.0

func RegisterIntentMerger(fn any)

RegisterIntentMerger registers a merge function. fn must have signature: func(IntentType1, IntentType2, ...) ([]CommandIntent, bool) where all parameter types implement CommandIntent. Panics if signature is invalid or duplicate type sequence exists.

func RouteSTAR added in v0.15.0

func RouteSTAR(route, icao string) (star, entry string)

RouteSTAR returns the STAR a filed route into the airport ends with, under the name the current CIFP charts it, along with the fix filed ahead of it on the route, or empty strings if it names none. A route may carry a stale revision--CUUDA3 where the cycle has CUUDA4--so procedures match on their base names.

func RunwayIntersectionPoint added in v0.15.0

func RunwayIntersectionPoint(airport string, a, b RunwayID, nmPerLongitude, maxDistNM float32) (math.Point2LL, bool)

RunwayIntersectionPoint returns the point at which the centerlines of the two given runways cross, if that point is within maxDistNM of both runway segments (threshold to threshold). It returns false for same or opposite-direction runway pairs and for parallel runways.

func SaveMapLibrary added in v0.14.4

func SaveMapLibrary(w io.Writer, lib *MapLibrary) error

SaveMapLibrary encodes a library to the wire format and writes it to w. Iteration order over the input maps is deterministic (sorted by name) so files re-import bit-stable across runs.

func SortFlights added in v0.15.0

func SortFlights(flights []Flight)

SortFlights orders flights the way the encoding wants them: by airport, then by callsign and direction, then by time. Grouping each airport's flights together and then each callsign's is what makes the encoding compact.

func SplitCallsign added in v0.14.0

func SplitCallsign(callsign string) (prefix, number string)

SplitCallsign splits a callsign into ICAO prefix and flight number. For "UAL123" returns ("UAL", "123"). For "N12345" returns ("N", "12345").

func SquawkIsSPC

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

func StartInitDB added in v0.14.4

func StartInitDB()

StartInitDB kicks off aviation database loading on a background goroutine without blocking. Subsequent callers of InitDB() will wait until that load completes.

func StringIsSPC

func StringIsSPC(code string) bool

func TASToIAS

func TASToIAS(tas, altitude float32) float32

func TASToMach added in v0.14.1

func TASToMach(tas float32, temp Temperature) float32

func TokenNamesAirport added in v0.15.0

func TokenNamesAirport(token, icao string) bool

TokenNamesAirport reports whether a route token names the airport, as either its ICAO id or its domestic name.

func TokenNamesProcedure added in v0.15.0

func TokenNamesProcedure(token string) bool

TokenNamesProcedure reports whether a route token names a SID or a STAR: it ends with a revision digit and isn't an airway.

func TrimICAOPrefix added in v0.15.0

func TrimICAOPrefix(icao string) string

TrimICAOPrefix returns the domestic name of an airport's ICAO id, dropping the leading region letter. Ids from elsewhere are returned unchanged.

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 = Facility

ARTCC is a type alias for Facility representing an Air Route Traffic Control Center.

type ATCT added in v0.14.1

type ATCT TRACON

type ATISIntent added in v0.14.1

type ATISIntent struct {
	Letter string
}

ATISIntent represents the pilot's acknowledgment of the ATIS letter.

func (ATISIntent) Render added in v0.14.1

func (a ATISIntent) Render(rt *RadioTransmission, r *rand.Rand)

type ATPAVolume

type ATPAVolume struct {
	Id                  string `json:"id"`
	ThresholdString     string `json:"runway_threshold"`
	Threshold           math.Point2LL
	Heading             math.MagneticHeading `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 float32, hdg math.MagneticHeading, 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 AircraftClass added in v0.15.0

type AircraftClass uint8

AircraftClass is a bitmask selecting aircraft for route matching: by engine type, or for jets by weight, since heavies are routed differently at some facilities. In JSON it is a string or array of strings among "prop", "turboprop", "jet", "heavy", and "nonheavy", where "jet" covers both jet classes; the zero value admits every aircraft.

const (
	AircraftClassProp AircraftClass = 1 << iota
	AircraftClassTurboprop
	AircraftClassHeavyJet
	AircraftClassNonheavyJet
)

func AircraftClassOf added in v0.15.0

func AircraftClassOf(acType string) AircraftClass

AircraftClassOf returns the class an aircraft type falls in, or zero if the type is unknown.

func (*AircraftClass) CheckJSON added in v0.15.0

func (c *AircraftClass) CheckJSON(json any) bool

CheckJSON implements util.JSONChecker; class values are validated during unmarshaling.

func (AircraftClass) MarshalJSON added in v0.15.0

func (c AircraftClass) MarshalJSON() ([]byte, error)

func (AircraftClass) Matches added in v0.15.0

func (c AircraftClass) Matches(acType string) bool

Matches reports whether the aircraft type falls in the class; an unrestricted class matches every type and an unknown type matches no restricted class.

func (*AircraftClass) UnmarshalJSON added in v0.15.0

func (c *AircraftClass) UnmarshalJSON(b []byte) error

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 is "P" for piston, "T" for turboprop, "J" for jet, and
		// "H" for rotorcraft.
		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]any `json:"fleets"`
	Fleets     map[string][]FleetAircraft
}

type AirlineSpecifier

type AirlineSpecifier struct {
	ICAO          string   `json:"icao"`
	Callsign      string   `json:"callsign,omitempty"`
	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) SampleAcType added in v0.14.1

func (a AirlineSpecifier) SampleAcType(r *rand.Rand, departureAirport, arrivalAirport string, lg *log.Logger) string

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"`

	Approaches map[string]*Approach `json:"approaches,omitempty"`
	// Departures is optional: an airport that only ever sees published
	// traffic needs no more than its "departure_routes" to fly it.
	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[ExitID]string `json:"exit_categories"`

	// runway -> (exit -> routes)
	DepartureRoutes map[RunwayID]map[ExitID]ExitRoutes `json:"departure_routes"`

	// TrafficRoutes gives the routes published traffic between this airport
	// and specific other airports flies.
	TrafficRoutes TrafficRoutes `json:"traffic_routes"`

	CRDARegions map[string]*CRDARegion `json:"crda_regions"`
	CRDAPairs   []CRDAPair             `json:"crda_pairs"`

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

func (Airport) HasIFROperations added in v0.15.0

func (ap Airport) HasIFROperations() bool

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() float32

type AirportPair added in v0.15.0

type AirportPair struct {
	From, To string
}

AirportPair keys the city-pair route database by ICAO airport codes.

type AirportPairRoute added in v0.15.0

type AirportPairRoute struct {
	Route        string // e.g. "NEION J223 CORDS J132 ULW BENEE"
	DepartureFix string // explicit for coded departure routes, empty otherwise
	Type         string // TEC, H, L, NAR, SHD, HSD, SLD, or CDR
	Aircraft     string // "jet", "prop", or empty for no restriction
	RNAVRequired bool
}

AirportPairRoute is one real-world route between two airports, taken from the FAA preferred-route and coded-departure-route databases by cmd/importroutes.

func (AirportPairRoute) LowAltitude added in v0.15.0

func (r AirportPairRoute) LowAltitude() bool

LowAltitude reports whether the route is a low-altitude one, flown by aircraft that stay out of the flight levels.

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 AltitudeDirection added in v0.14.0

type AltitudeDirection int
const (
	AltitudeClimb AltitudeDirection = iota
	AltitudeDescend
	AltitudeMaintain
)

type AltitudeIntent added in v0.14.0

type AltitudeIntent struct {
	Altitude          float32
	Direction         AltitudeDirection
	AfterFix          string   // altitude change conditional on passing this fix
	AfterSpeed        *float32 // changing altitude only after reaching a speed
	Expedite          bool
	GoodRate          bool
	RateThrough       *float32 // "through/to" altitude for expedite or good rate
	AlreadyExpediting bool
	ThenSpeed         *float32 // speed once we reach the altitude
	ThenSpeedType     SpeedType
}

AltitudeIntent represents climb/descend/maintain altitude commands

func (AltitudeIntent) Render added in v0.14.0

func (a AltitudeIntent) Render(rt *RadioTransmission, r *rand.Rand)

type AltitudeRestriction

type AltitudeRestriction struct {
	NavigationRestriction
}

func MakeAtAltitudeRestriction added in v0.14.2

func MakeAtAltitudeRestriction(alt float32) AltitudeRestriction

func MakeAtOrAboveAltitudeRestriction added in v0.14.2

func MakeAtOrAboveAltitudeRestriction(alt float32) AltitudeRestriction

func MakeAtOrBelowAltitudeRestriction added in v0.14.2

func MakeAtOrBelowAltitudeRestriction(alt float32) AltitudeRestriction

func MakeRangeAltitudeRestriction added in v0.14.2

func MakeRangeAltitudeRestriction(low, high float32) AltitudeRestriction

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) Encoded

func (a AltitudeRestriction) Encoded() string

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

func (AltitudeRestriction) TargetAltitude

func (a AltitudeRestriction) TargetAltitude(alt float32) float32

TargetAltitude clamps alt into the restriction's range.

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) InitializeWaypoints added in v0.14.3

func (ap *Approach) InitializeWaypoints(icao string, loc Locator, nmPerLongitude float32,
	magneticVariation float32, e *util.ErrorLogger)

InitializeWaypoints resolves waypoint locations and adds the runway threshold waypoint to each route. It also sets the OnApproach flag, Threshold, and OppositeThreshold fields.

func (*Approach) RunwayHeading

func (ap *Approach) RunwayHeading(nmPerLongitude float32) math.TrueHeading

type ApproachIntent added in v0.14.0

type ApproachIntent struct {
	Type         ApproachIntentType
	ApproachName string // full name of the approach (e.g., "ILS Runway 22L")
	Fix          string // for AtFixCleared
	LAHSORunway  string // runway to hold short of (for LAHSO operations)
	HasLocalizer bool
	StraightIn   bool
}

ApproachIntent represents approach-related commands

func (ApproachIntent) Render added in v0.14.0

func (a ApproachIntent) Render(rt *RadioTransmission, r *rand.Rand)

type ApproachIntentType added in v0.14.0

type ApproachIntentType int
const (
	ApproachExpect ApproachIntentType = iota
	ApproachIntercept
	ApproachJoin // for non-ILS approaches
	ApproachAtFixCleared
	ApproachAtFixIntercept
	ApproachCancel
)

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
	VisualApproach
	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
	CruiseAltitudes util.SingleOrArray[int]             `json:"cruise_altitude"`
	STAR            string                              `json:"star"`

	// STARFeeds are the STARs whose traffic the arrival takes; this is useful e.g. for getting
	// real-world traffic wired up for finals scenarios since we generally get traffic after they've
	// flown STARs in that case.
	STARFeeds []string `json:"star_feeds"`

	// Note: this is *only* used for flight strips displayed to the user; it should not in any way
	// be referenced for an aircraft's route: Waypoints should always be used for that.
	FlightStripDisplayRoute string `json:"route"`

	// DerivedSTAR is the STAR the arrival's waypoints run along, worked out at
	// load for an arrival that spells them out instead of naming a STAR to take
	// them from. Not specified in user JSON.
	DerivedSTAR string

	InitialController   ControlPosition         `json:"initial_controller"`
	InitialAltitudes    util.SingleOrArray[int] `json:"initial_altitude"`
	AssignedAltitude    float32                 `json:"assigned_altitude"`
	ClearedAltitude     float32                 `json:"cleared_altitude"`
	InitialSpeed        float32                 `json:"initial_speed"`
	SpeedRestriction    SpeedRestriction        `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"`

	// Aircraft restricts which types of flights the arrival carries; it's
	// used when selecting arrivals with real-world traffic.
	Aircraft AircraftClass `json:"aircraft,omitempty"`

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

	// Airports the arrival brings traffic to, in sorted order. Required,
	// except for an arrival that names a STAR the FAA CIFP charts for some of
	// the scenario's airports: it takes those. Every airport in Airlines must
	// be named here.
	Airports []string `json:"airports"`

	// Airport -> arrival airlines. Optional: without it the scenario can't
	// generate its own arrivals here, but published traffic still can.
	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)

func (Arrival) ServedSTARs added in v0.15.0

func (ar Arrival) ServedSTARs() []string

ServedSTARs returns the STARs whose traffic the arrival takes, in the order they were given.

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 CRDAPair added in v0.14.1

type CRDAPair struct {
	SourceRegion             string  `json:"source_region"`
	GhostRegion              string  `json:"ghost_region"`
	SourceLeaderDirectionStr string  `json:"source_leader_direction"`
	GhostLeaderDirectionStr  string  `json:"ghost_leader_direction"`
	TieSymbol                string  `json:"tie_symbol"`
	StaggerSymbol            string  `json:"stagger_symbol"`
	TieOffset                float32 `json:"tie_offset"`

	// Set during deserialize.
	SourceLeaderDirection math.CardinalOrdinalDirection
	GhostLeaderDirection  math.CardinalOrdinalDirection
	ConvergencePoint      math.Point2LL
}

CRDAPair describes a one-directional ghosting relationship between two CRDA regions. Aircraft flying through SourceRegion's qualification volume have ghost data blocks plotted on GhostRegion's centerline; to ghost in both directions, define two pairs with the roles swapped.

type CRDARegion added in v0.14.1

type CRDARegion struct {
	Name             string  // set during deserialization from map key
	HeadingTolerance float32 `json:"heading_tolerance"`

	// Straight-line reference (mutually exclusive with ReferenceRoute)
	ReferenceLineHeading   math.MagneticHeading `json:"reference_heading"`
	ReferenceLineLength    float32              `json:"reference_length"`
	ReferencePointAltitude float32              `json:"reference_altitude"`
	ReferencePoint         math.Point2LL        `json:"reference_point"`

	// Route-based reference (mutually exclusive with straight-line fields)
	ReferenceRoute string `json:"reference_route"`

	// 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"`

	// Computed during PostDeserialize
	Path              Path
	DistToConvergence float32 // distance from path end to convergence point
}

func (*CRDARegion) CourseLine added in v0.14.1

func (ar *CRDARegion) CourseLine(nmPerLongitude float32) []math.Point2LL

CourseLine returns a polyline for drawing the course line of this CRDA region.

func (*CRDARegion) Inside added in v0.14.1

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

func (*CRDARegion) QualificationPolygon added in v0.14.1

func (ar *CRDARegion) QualificationPolygon(nmPerLongitude float32) []math.Point2LL

QualificationPolygon returns the polygon outline of the qualification region for drawing.

func (*CRDARegion) TryMakeGhost added in v0.14.1

func (ar *CRDARegion) TryMakeGhost(trk RadarTrack, heading float32,
	scratchpad string, forceGhost bool, offset float32, leaderDirection math.CardinalOrdinalDirection,
	nmPerLongitude float32, other *CRDARegion) *GhostTrack

type CRDARoutePoint added in v0.14.1

type CRDARoutePoint struct {
	Fix      string
	Location math.Point2LL
	Arc      *DMEArc
}

CRDARoutePoint represents a single point in a CRDA reference route. Only fix names and /arc qualifiers are supported.

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 CautionWakeTurbulenceIntent added in v0.14.3

type CautionWakeTurbulenceIntent struct{}

CautionWakeTurbulenceIntent represents a pilot's acknowledgment of a wake turbulence advisory.

func (CautionWakeTurbulenceIntent) Render added in v0.14.3

type ClearedApproachIntent added in v0.14.0

type ClearedApproachIntent struct {
	Approach    string
	StraightIn  bool
	CancelHold  bool
	LAHSORunway string
}

ClearedApproachIntent represents approach clearance

func (ClearedApproachIntent) Render added in v0.14.0

type CommandIntent added in v0.14.0

type CommandIntent interface {
	// Render adds the appropriate text for this intent to the transmission.
	Render(rt *RadioTransmission, r *rand.Rand)
}

CommandIntent represents the semantic meaning of a pilot readback. Instead of generating RadioTransmission text directly, commands return intents that are later rendered together for coherent multi-command responses.

type CompoundSpeedIntent added in v0.14.3

type CompoundSpeedIntent struct {
	Segments []CompoundSpeedSegment
}

CompoundSpeedIntent represents a compound speed assignment readback, e.g., "speed 250 until FIX1, then 210 until FIX2, then 180".

func (CompoundSpeedIntent) Render added in v0.14.3

func (c CompoundSpeedIntent) Render(rt *RadioTransmission, r *rand.Rand)

type CompoundSpeedSegment added in v0.14.3

type CompoundSpeedSegment struct {
	Speed    *SpeedRestriction
	UntilFix string // empty for last (open-ended) segment
}

CompoundSpeedSegment represents one segment of a compound speed assignment.

type ContactIntent added in v0.14.0

type ContactIntent struct {
	Type         ContactType
	ToController *Controller // the controller being contacted
	Frequency    Frequency
	IsDeparture  bool // affects rendering (departure vs approach controller)
}

ContactIntent represents contact/handoff commands

func (ContactIntent) Render added in v0.14.0

func (c ContactIntent) Render(rt *RadioTransmission, r *rand.Rand)

type ContactTowerIntent added in v0.14.0

type ContactTowerIntent struct {
	Frequency Frequency
}

ContactTowerIntent represents contact tower command. Frequency is optional (zero means "not given"); when set, the pilot readback sometimes includes the tower frequency.

func (ContactTowerIntent) Render added in v0.14.0

func (c ContactTowerIntent) Render(rt *RadioTransmission, r *rand.Rand)

type ContactType added in v0.14.0

type ContactType int
const (
	ContactController ContactType = iota
	ContactGoodbye
	ContactRadarTerminated
)

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 (now the sector ID, e.g. "1N", "4P")
	Callsign           string    `json:"callsign,omitempty"` // Human-readable callsign (e.g. "PHL_NA_APP")
	RadioName          string    `json:"radio_name"`
	Frequency          Frequency `json:"frequency"`
	Scope              string    `json:"scope_char"`     // Optional. If unset, facility id is used for external, last char of position for local.
	FacilityIdentifier string    `json:"-"`              // Set programmatically by loadNeighborControllers (e.g. "N" in "N4P")
	ERAMFacility       bool      `json:"-"`              // Set at runtime from facility type; true for ARTCC controllers
	Facility           string    `json:"facility"`       // So we can get the STARS facility from a controller
	Area               string    `json:"area,omitempty"` // For TRACON: auto-derived from first digit of Position. For ERAM: must be manually specified.
}

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"`
}

func (*ControllerAirspaceVolume) ContainsPoint added in v0.14.4

func (v *ControllerAirspaceVolume) ContainsPoint(p math.Point2LL) bool

ContainsPoint reports whether p is laterally inside the volume, applying the odd-winding (xor) rule across boundary rings. Altitude is ignored.

type DMEArc

type DMEArc struct {
	Fix            string
	Center         math.Point2LL
	Radius         float32
	Length         float32
	InitialHeading math.MagneticHeading
	Direction      DMEArcDirection
}

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

func (*DMEArc) Initialize added in v0.14.1

func (arc *DMEArc) Initialize(loc Locator, startLoc, endLoc math.Point2LL, nmPerLongitude, magneticVariation float32, e *util.ErrorLogger) bool

Initialize resolves the arc's center, radius, and initial heading from its specification. Direction must be set before calling. startLoc and endLoc are the waypoint positions at each end of the arc. Returns true on success; returns false if the arc should be dropped (either due to error or because it's approximately linear).

type DMEArcDirection added in v0.14.1

type DMEArcDirection int
const (
	DMEArcDirectionUnset            DMEArcDirection = iota
	DMEArcDirectionClockwise                        // right turn
	DMEArcDirectionCounterClockwise                 // left turn
)

func (DMEArcDirection) IsClockwise added in v0.14.1

func (d DMEArcDirection) IsClockwise() bool

type DMELocator added in v0.14.3

type DMELocator interface {
	LocateDME(fix string) (math.Point2LL, int, bool)
}

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 ExitID `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 is optional: without it the scenario can't generate its own
	// departures here, but published traffic still flies the exit and route.
	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 ERAMMap added in v0.14.4

type ERAMMap struct {
	LabelLine1 string
	LabelLine2 string

	Lines   []MapLine
	Symbols []MapSymbol
	Labels  []MapLabel
}

ERAMMap is the runtime representation of a single map within an ERAM filter-menu group. Per-map identity within a group is the pair (LabelLine1, LabelLine2); duplicates are allowed and share state by design.

func (ERAMMap) Bounds added in v0.14.4

func (m ERAMMap) Bounds() math.Extent2D

Bounds returns the lat/lon bounding box covering every feature in the ERAM map (line vertices, symbol positions, and label positions). Returns an empty Extent2D if the map has no features.

func (ERAMMap) IsEmpty added in v0.15.0

func (m ERAMMap) IsEmpty() bool

IsEmpty reports whether m holds no geometry at all.

type ERAMMapGroup added in v0.14.4

type ERAMMapGroup struct {
	Name       string
	LabelLine1 string
	LabelLine2 string
	BCGNames   []string // BCGs in source order; per feature BCGIndex references this.
	Maps       []ERAMMap

	// BaseMap is drawn whenever this group is loaded: the geometry can't be toggled off and
	// consumes no filter-menu slot. BCGIndex resolves against BCGNames as for any other map.
	BaseMap ERAMMap
}

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 ExitID added in v0.14.1

type ExitID string

ExitID is an exit fix identifier that may include a dot-separated suffix (e.g., "COLIN.P"). Use Base() for navaid lookups and display.

func (ExitID) Base added in v0.14.1

func (e ExitID) Base() string

type ExitRoute

type ExitRoute struct {
	SID              string        `json:"sid"`
	AssignedAltitude int           `json:"assigned_altitude"`
	ClearedAltitude  int           `json:"cleared_altitude"`
	Waypoints        WaypointArray `json:"waypoints"`
	Description      string        `json:"description"`
	IsRNAV           bool          `json:"is_rnav"`
	HoldForRelease   bool          `json:"hold_for_release"`
	// 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"`

	// Aircraft restricts which types of flights take the route; it's used
	// when an exit routes them differently.
	Aircraft AircraftClass `json:"aircraft,omitempty"`

	WaitToContactDeparture bool // whether the aircraft waits until a /TC point to contact departure
}

func (ExitRoute) FinalHeading added in v0.14.0

func (er ExitRoute) FinalHeading() int

FinalHeading returns the final heading from the exit route's waypoints. Returns 0 if no heading waypoint is found.

type ExitRoutes added in v0.15.0

type ExitRoutes []*ExitRoute

ExitRoutes gives the ways departures leave via an exit; a bare JSON object is shorthand for a single route open to all aircraft. A departure flies the first route its aircraft type is admitted to, so the routes need not cover every type: one with no route is not launched.

func (*ExitRoutes) CheckJSONErrors added in v0.15.0

func (er *ExitRoutes) CheckJSONErrors(json any, e *util.ErrorLogger)

CheckJSONErrors checks the routes in either form themselves so that a misspelled member is reported as such rather than as an unexpected shape.

func (ExitRoutes) ForAircraft added in v0.15.0

func (er ExitRoutes) ForAircraft(acType string) *ExitRoute

ForAircraft returns the route the given aircraft type flies, or nil if none of the routes takes it.

func (*ExitRoutes) UnmarshalJSON added in v0.15.0

func (er *ExitRoutes) UnmarshalJSON(b []byte) error

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) FAAControlled added in v0.15.0

func (ap FAAAirport) FAAControlled() bool

FAAControlled reports whether the FAA runs air traffic control at the airport. The airport database is worldwide, so this is what tells the airports Vice might one day simulate from the ones that are only ever the far end of somebody else's flight.

func (FAAAirport) SelectBestRunway

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

func (FAAAirport) ValidRunways

func (ap FAAAirport) ValidRunways() string

type Facility added in v0.14.0

type Facility struct {
	Name      string
	Latitude  float32
	Longitude float32
	Radius    float32
}

Facility represents a geographic facility with a center point and radius. Both TRACONs and ARTCCs use this structure for weather data handling.

func (Facility) Center added in v0.14.0

func (f Facility) Center() math.Point2LL

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 Flight added in v0.15.0

type Flight struct {
	Airport      string // the facility airport it departs from or arrives at
	Callsign     string
	Other        string // the airport at the other end
	AircraftType string
	Day          uint16 // UTC date, in days from 1970-01-01
	Minute       int    // minutes after UTC midnight
	Departure    bool
}

Flight is one real-world flight at one of a facility's airports. Times are UTC, as they are everywhere else in Vice; the local time at an airport is a matter for the UI, which is the only place a controller wants to see it.

func DecodeFlights added in v0.15.0

func DecodeFlights(data []byte) ([]Flight, error)

DecodeFlights reads back what EncodeFlights wrote.

func ReadFlightDataCells added in v0.15.0

func ReadFlightDataCells(resources fs.FS, cells []string) ([]Flight, error)

ReadFlightDataCells decodes the flight data for each of the given cells and returns all of it together. Cells with no data contribute nothing.

func SelectFlights added in v0.15.0

func SelectFlights(flights []Flight, departureAirports, arrivalAirports map[string]bool,
	airlines map[string]Airline, start, end time.Time) []Flight

SelectFlights returns the flights at the given airports that take off or touch down between start and end, in time order. This is what a sim is handed when it launches: the flights it needs and nothing else, out of everything its cells hold. Flights whose callsign prefix isn't in airlines (pass DB.Airlines) are left out; the sim can't voice a callsign it has no telephony for.

Decoding a cell costs enough that anything asking about several windows of it--the New Sim dialog previews a fresh one each time the start time moves--wants to do it once and select from the result.

func (Flight) Date added in v0.15.0

func (f Flight) Date() time.Time

Date returns the UTC calendar date the flight operates on.

func (Flight) Time added in v0.15.0

func (f Flight) Time() time.Time

Time returns the instant the flight takes off or touches down.

type FlightPlan

type FlightPlan struct {
	Rules            FlightRules
	AircraftType     string
	CruiseSpeed      int
	DepartureAirport string
	DepartureRunway  string
	Altitude         int
	ArrivalAirport   string
	AlternateAirport string
	Exit             ExitID
	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 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 GACallsignArg added in v0.14.0

type GACallsignArg struct {
	Callsign     ADSBCallsign
	AircraftType string // e.g., "C172"
	UseTypeForm  bool   // If true, use type+trailing3 form
	IsEmergency  bool
}

GACallsignArg provides context for formatting GA callsigns with type-based addressing. When UseTypeForm is true, the callsign is spoken as "aircraft type + trailing 3" (e.g., "skyhawk 3 alpha bravo" instead of "november 1 2 3 alpha bravo").

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 HeadingIntent added in v0.14.0

type HeadingIntent struct {
	Heading    math.MagneticHeading
	Type       HeadingType
	Turn       HeadingTurn // for HeadingAssign: which way to turn
	Degrees    int         // for HeadingTurnLeft/Right: how many degrees
	CancelHold bool        // heading cancels an active hold
}

HeadingIntent represents heading assignment commands

func (HeadingIntent) Render added in v0.14.0

func (h HeadingIntent) Render(rt *RadioTransmission, r *rand.Rand)

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 HeadingTurn added in v0.14.0

type HeadingTurn int
const (
	HeadingTurnClosest HeadingTurn = iota
	HeadingTurnToLeft
	HeadingTurnToRight
)

type HeadingType added in v0.14.0

type HeadingType int
const (
	HeadingAssign HeadingType = iota
	HeadingTurnLeft
	HeadingTurnRight
	HeadingPresent
)

type Hold added in v0.13.0

type Hold struct {
	Fix             string               // Fix identifier where hold is located
	InboundCourse   math.MagneticHeading // 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 math.MagneticHeading) 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 HourRanges added in v0.15.0

type HourRanges uint32

HourRanges is a set of hours of the day, held as a bit per hour and encoded in JSON as ranges like "6-9,22-23".

func (*HourRanges) Add added in v0.15.0

func (h *HourRanges) Add(hour int)

Add puts the hour in the set.

func (HourRanges) Contains added in v0.15.0

func (h HourRanges) Contains(hour int) bool

Contains reports whether the hour is in the set.

func (HourRanges) MarshalJSON added in v0.15.0

func (h HourRanges) MarshalJSON() ([]byte, error)

func (HourRanges) String added in v0.15.0

func (h HourRanges) String() string

func (*HourRanges) UnmarshalJSON added in v0.15.0

func (h *HourRanges) UnmarshalJSON(b []byte) error

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 LineStyle added in v0.14.4

type LineStyle uint8
const (
	LineStyleSolid LineStyle = iota
	LineStyleShortDashed
	LineStyleLongDashed
	LineStyleLongDashShortDash
)

func (LineStyle) String added in v0.14.4

func (s LineStyle) String() 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 LookForFieldIntent added in v0.14.3

type LookForFieldIntent int

LookForFieldIntent represents a pilot's response to an AP (airport advisory) command.

const (
	LookForFieldLooking LookForFieldIntent = iota
	LookForFieldLookingIMC
	LookForFieldLookingObscured
	LookForFieldFound
)

func (LookForFieldIntent) Render added in v0.14.3

func (f LookForFieldIntent) Render(rt *RadioTransmission, r *rand.Rand)

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 MVAGrid added in v0.14.0

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

MVAGrid organizes MVA definitions and provides efficient lookups via a grid in lat-long space that records which MVAs overlap grid cells. Grid cells are initialized on demand rather than upfront.

func MakeMVAGrid added in v0.14.0

func MakeMVAGrid(mvas []MVA) *MVAGrid

func (*MVAGrid) GetMVA added in v0.14.0

func (g *MVAGrid) GetMVA(p [2]float32) int

GetMVA returns the maximum MVA altitude at the given location. Returns 0 if no MVA covers the point.

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 MachSnippetFormatter added in v0.14.1

type MachSnippetFormatter struct{}

func (MachSnippetFormatter) Spoken added in v0.14.1

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

func (MachSnippetFormatter) Validate added in v0.14.1

func (MachSnippetFormatter) Validate(arg any) error

func (MachSnippetFormatter) Written added in v0.14.1

func (MachSnippetFormatter) Written(arg any) string

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 MapLabel added in v0.14.4

type MapLabel struct {
	P         math.Point2LL
	Text      string
	Size      uint8
	XOffset   int8
	YOffset   int8
	Underline bool
	Opaque    bool
	BCGIndex  uint8 // 0 = use the map's group BCG
}

type MapLibrary added in v0.14.4

type MapLibrary struct {
	Maps          map[string]STARSMap
	ERAMMapGroups map[string]ERAMMapGroup
}

MapLibrary is the full in-memory representation of a video map file. STARS maps are keyed by Name (which is unique within a file); ERAM groups are keyed by group name.

func HashCheckLoadMapLibrary added in v0.14.4

func HashCheckLoadMapLibrary(path string, wantHash []byte) (*MapLibrary, error)

HashCheckLoadMapLibrary loads the file only if its hash matches.

func LoadMapLibrary added in v0.14.4

func LoadMapLibrary(path string) (*MapLibrary, error)

type MapLibrarySpec added in v0.14.4

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

MapLibrarySpec carries everything server startup needs to validate scenario references without touching the geometry region. It also remembers the underlying file so callers can compute Hash() lazily.

func LoadMapLibrarySpec added in v0.14.4

func LoadMapLibrarySpec(path string) (*MapLibrarySpec, error)

LoadMapLibrarySpec opens a video map file and decodes only the metadata header, leaving the flate-compressed geometry region untouched.

func (*MapLibrarySpec) HasMap added in v0.14.4

func (s *MapLibrarySpec) HasMap(name string) bool

HasMap returns true if name matches a STARS map's Name, or matches the combined label of any ERAM map within any group. An empty name never matches, so the unlabeled placeholders that hold empty filter-menu slots' positions stay invisible to name lookup.

func (*MapLibrarySpec) HasMapGroup added in v0.14.4

func (s *MapLibrarySpec) HasMapGroup(name string) bool

HasMapGroup returns true if name matches an ERAM group's name.

func (*MapLibrarySpec) Hash added in v0.14.4

func (s *MapLibrarySpec) Hash() ([]byte, error)

Hash returns a hash of the underlying video map file.

func (*MapLibrarySpec) STARSMapId added in v0.14.4

func (s *MapLibrarySpec) STARSMapId(name string) int

STARSMapId returns the STARS DCB Id for the named map. Returns 0 if the name is unknown or the map has no DCB Id assigned (0 is the sentinel for "no Id" since STARS commands reject Id 0 anyway).

type MapLine added in v0.14.4

type MapLine struct {
	Points    []math.Point2LL
	Style     LineStyle
	Thickness uint8
	BCGIndex  uint8 // 0 = use the map's group BCG
}

type MapSymbol added in v0.14.4

type MapSymbol struct {
	P        math.Point2LL
	Style    SymbolStyle
	Size     uint8
	BCGIndex uint8 // 0 = use the map's group BCG
}

type MixUpIntent added in v0.14.0

type MixUpIntent struct {
	Callsign    ADSBCallsign
	IsEmergency bool
}

MixUpIntent represents pilot confusion about who was addressed

func (MixUpIntent) Render added in v0.14.0

func (m MixUpIntent) Render(rt *RadioTransmission, r *rand.Rand)
type Navaid struct {
	Id       string
	Type     string
	Name     string
	Location math.Point2LL

	HasDME          bool
	DMELocation     math.Point2LL
	DMEElevation    int
	HasDMEElevation bool
}
type NavigationIntent struct {
	Type             NavigationType
	Fix              string
	SecondFix        string                        // for DepartFixDirect
	Heading          math.MagneticHeading          // for DepartFixHeading
	Turn             TurnDirection                 // for NavDirectFix / NavDirectFixFromHold
	HoldDirection    string                        // "left" or "right" for holds
	HoldLegLength    string                        // e.g., "2 mile" or "1 minute"
	AltRestriction   *AltitudeRestriction          // for Cross{FixAt,DistanceFromFixAt,DME}
	SpeedRestriction *SpeedRestriction             // for Cross{FixAt,DistanceFromFixAt,DME}
	Distance         float32                       // for Cross{DistanceFromFixAt,DME}
	Direction        math.CardinalOrdinalDirection // for CrossDistanceFromFixAt
}

NavigationIntent represents navigation commands (direct, hold, depart fix, etc.)

func (n NavigationIntent) Render(rt *RadioTransmission, r *rand.Rand)
type NavigationRestriction struct {
	Range [2]float32
}

NavigationRestriction is the shared base for altitude and speed restrictions. Range[0] is the floor, Range[1] is the ceiling. 0 means "no floor" (at or below); the type-specific max constant means "no ceiling" (at or above). Invariant: Range[0] <= Range[1].

func (r NavigationRestriction) ClampRange(rng [2]float32) (c [2]float32, ok bool)

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

func (r NavigationRestriction) ExactValue() (float32, bool)

ExactValue returns the value if this is an "at" restriction (lo == hi), or false if it's a range.

func (r NavigationRestriction) Satisfied(val float32) bool

Satisfied returns true if val complies with the restriction.

func (r NavigationRestriction) Target(val float32) float32

Target clamps val into the restriction's range.

type NavigationType int
const (
	NavDirectFix         NavigationType = iota
	NavDirectFixFromHold                // direct fix that cancels a hold
	NavHold
	NavDepartFixDirect
	NavDepartFixHeading
	NavCrossFixAt
	NavCrossDistanceFromFixAt
	NavCrossDME
	NavResumeOwnNav
	NavAltitudeDiscretion
)

type Overflight

type Overflight struct {
	Waypoints           WaypointArray           `json:"waypoints"`
	InitialAltitudes    util.SingleOrArray[int] `json:"initial_altitude"`
	CruiseAltitudes     util.SingleOrArray[int] `json:"cruise_altitude"`
	AssignedAltitude    float32                 `json:"assigned_altitude"`
	InitialSpeed        float32                 `json:"initial_speed"`
	AssignedSpeed       float32                 `json:"assigned_speed"`
	SpeedRestriction    SpeedRestriction        `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"`
	TypeOfFlightString  string                  `json:"flight_type"`
	TypeOfFlight        TypeOfFlight            // set via TypeOfFlightString
}

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 Path added in v0.14.1

type Path struct {
	Segments []PathSegment
	Length   float32
}

Path represents a piecewise curve (line segments and circular arcs) in NM coordinates. Path direction follows aircraft travel direction: the first point is the far end, the last point is the convergence end (threshold/fix).

func PathFromReferenceLine added in v0.14.1

func PathFromReferenceLine(refPoint math.Point2LL, heading math.MagneticHeading, length, nmPerLongitude, magneticVariation float32) Path

PathFromReferenceLine creates a Path from a straight reference line defined by a reference point, heading, and length. The path goes from far end toward the reference point (matching the aircraft travel direction convention).

func PathFromRoutePoints added in v0.14.1

func PathFromRoutePoints(pts []CRDARoutePoint, nmPerLongitude float32) Path

PathFromRoutePoints creates a Path from resolved CRDA route points. Consecutive point pairs become segments, using pt.Arc for arc segments.

func (*Path) PointAtDistance added in v0.14.1

func (path *Path) PointAtDistance(dist float32) (point [2]float32, heading float32)

PointAtDistance returns the point and heading at a given distance along the path. If dist exceeds the path length, the path is extended linearly along the last segment's final heading. If dist is negative, the path is extended linearly backwards from the first segment.

func (*Path) Polyline added in v0.14.1

func (path *Path) Polyline() [][2]float32

Polyline returns a polyline approximation of the path for drawing. Arc segments are sampled at approximately 1-degree intervals.

func (*Path) Project added in v0.14.1

func (path *Path) Project(p [2]float32) (dist, perpOffset, heading float32)

Project projects a point onto the path, returning the distance along the path, the signed perpendicular offset (positive = left of path direction), and the local path heading (degrees, true north).

type PathArc added in v0.14.1

type PathArc struct {
	Center     [2]float32
	Radius     float32
	StartAngle float32 // angle from center to P0 (radians)
	Sweep      float32 // signed: positive=CCW, negative=CW
}

type PathSegment added in v0.14.1

type PathSegment struct {
	P0, P1    [2]float32 // start/end in NM coordinates
	Arc       *PathArc   // nil for straight segments
	StartDist float32    // cumulative distance at segment start
	Length    float32    // segment length
}

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 ProcedureIntent added in v0.14.0

type ProcedureIntent struct {
	Type ProcedureType
}

ProcedureIntent represents climb via SID / descend via STAR

func (ProcedureIntent) Render added in v0.14.0

func (p ProcedureIntent) Render(rt *RadioTransmission, r *rand.Rand)

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"`
}

type ProcedureType added in v0.14.0

type ProcedureType int
const (
	ProcedureClimbViaSID ProcedureType = iota
	ProcedureDescendViaSTAR
)

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             math.MagneticHeading
	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
	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 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 RenderIntents added in v0.14.0

func RenderIntents(intents []CommandIntent, r *rand.Rand) *RadioTransmission

RenderIntents converts a slice of CommandIntents into a single coherent RadioTransmission. It handles merging related intents (e.g., altitude + expedite), PTACs, etc., for more realistic readbacks.

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 ReportAltitudeIntent added in v0.14.0

type ReportAltitudeIntent struct {
	Current   float32
	Assigned  *float32
	Direction AltitudeDirection // if climbing/descending
}

ReportAltitudeIntent represents "say altitude" responses

func (ReportAltitudeIntent) Render added in v0.14.0

func (r ReportAltitudeIntent) Render(rt *RadioTransmission, rnd *rand.Rand)

type ReportHeadingIntent added in v0.14.0

type ReportHeadingIntent struct {
	Current  math.MagneticHeading
	Assigned *math.MagneticHeading
}

ReportHeadingIntent represents "say heading" responses

func (ReportHeadingIntent) Render added in v0.14.0

func (r ReportHeadingIntent) Render(rt *RadioTransmission, rnd *rand.Rand)

type ReportMachIntent added in v0.14.1

type ReportMachIntent struct {
	Current  float32  // current mach (e.g., 0.78)
	Assigned *float32 // assigned mach, if any
}

ReportMachIntent represents "say mach" or mach-regime "say speed" responses

func (ReportMachIntent) Render added in v0.14.1

func (r ReportMachIntent) Render(rt *RadioTransmission, rnd *rand.Rand)

type ReportSpeedIntent added in v0.14.0

type ReportSpeedIntent struct {
	Current  float32
	Assigned *float32
}

ReportSpeedIntent represents "say speed" responses (IAS)

func (ReportSpeedIntent) Render added in v0.14.0

func (r ReportSpeedIntent) Render(rt *RadioTransmission, rnd *rand.Rand)

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
}

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 RouteRayIntersection added in v0.14.3

type RouteRayIntersection struct {
	math.RayRouteIntersection
	RouteIndex int
}

RouteRayIntersection extends math.RayRouteIntersection with the index of the WaypointArray the hit falls on.

func ClosestRayRouteIntersection added in v0.14.3

func ClosestRayRouteIntersection(origin math.Point2LL, heading math.TrueHeading, routes []WaypointArray) (RouteRayIntersection, bool)

ClosestRayRouteIntersection returns the hit with the smallest distance from origin across all supplied routes.

func IntersectRayWithRoutes added in v0.14.3

func IntersectRayWithRoutes(origin math.Point2LL, heading math.TrueHeading, routes []WaypointArray) []RouteRayIntersection

IntersectRayWithRoutes runs math.IntersectRayWithRoute on each entry in routes and returns all hits. Callers apply their own scoring (closest, earliest, turn-angle tiers, etc.).

type Runway

type Runway struct {
	Id                         string
	Heading                    math.MagneticHeading
	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 RunwayID added in v0.14.1

type RunwayID string

RunwayID is a runway identifier that may include a dot-separated suffix (e.g., "13R.All"). Use Base() for physical runway lookups/comparisons.

func (RunwayID) Base added in v0.14.1

func (r RunwayID) Base() string

func (RunwayID) SameRunway added in v0.14.1

func (r RunwayID) SameRunway(other RunwayID) bool

type RunwaySnippetFormatter added in v0.14.0

type RunwaySnippetFormatter struct{}

func (RunwaySnippetFormatter) Spoken added in v0.14.0

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

func (RunwaySnippetFormatter) Validate added in v0.14.0

func (RunwaySnippetFormatter) Validate(arg any) error

func (RunwaySnippetFormatter) Written added in v0.14.0

func (RunwaySnippetFormatter) Written(arg any) string

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 STARSMap added in v0.14.4

type STARSMap struct {
	Name     string
	Label    string // DCB button label
	Id       int    // user-visible STARS map number; 0 = no DCB id
	Group    int    // 0 = A, 1 = B
	Category int    // -1..9
	Color    int    // 0..8

	Lines   []MapLine
	Symbols []MapSymbol
	Labels  []MapLabel
}

STARSMap is the runtime representation of a single STARS-side video map. Lines/Symbols/Labels are populated by the full library loader and left nil by the metadata-only spec loader.

func (STARSMap) Bounds added in v0.14.4

func (m STARSMap) Bounds() math.Extent2D

Bounds returns the lat/lon bounding box covering every feature in the map (line vertices, symbol positions, and label positions). Returns an empty Extent2D if the map has no features.

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 SayAgainCommandType added in v0.14.0

type SayAgainCommandType int

SayAgainCommandType identifies which type of command the pilot is asking to be repeated.

const (
	SayAgainHeading SayAgainCommandType = iota
	SayAgainAltitude
	SayAgainSpeed
	SayAgainApproach
	SayAgainTurn
	SayAgainSquawk
	SayAgainFix
)

type SayAgainIntent added in v0.14.0

type SayAgainIntent struct {
	CommandType SayAgainCommandType
}

SayAgainIntent represents a pilot requesting the controller repeat part of a clearance. This is used when STT successfully identifies a command keyword but fails to parse the associated value (e.g., "fly heading blark bling five").

func (SayAgainIntent) Render added in v0.14.0

func (s SayAgainIntent) Render(rt *RadioTransmission, r *rand.Rand)

type ScrapedRoute added in v0.15.0

type ScrapedRoute struct {
	Route string `json:"route"`
	// Count is how many times the route was filed over the sampled period.
	Count int `json:"count"`
	// Aircraft is the classes observed flying the route; zero means no one
	// looked.
	Aircraft AircraftClass `json:"aircraft,omitempty"`
	// MinAltitude and MaxAltitude bound the filed cruise altitudes, in feet.
	MinAltitude int `json:"min_altitude,omitempty"`
	MaxAltitude int `json:"max_altitude,omitempty"`
	// Hours is the local hours of day the route has been observed filed at:
	// noise abatement runs some routes only at night.
	Hours HourRanges `json:"hours,omitempty"`
}

ScrapedRoute is one way a city pair has recently been flown, taken from recently filed flight plans by cmd/scraperoutes.

type ScrapedRouteSet added in v0.15.0

type ScrapedRouteSet struct {
	// Updated is the YYYY-MM-DD day the pair was last fetched, which is what
	// cmd/scraperoutes judges staleness by.
	Updated string         `json:"updated"`
	Routes  []ScrapedRoute `json:"routes,omitempty"`
}

ScrapedRouteSet is everything the scraper knows about one city pair. An entry with no routes still records that the pair was looked up, so that it isn't fetched again until it goes stale.

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 SpeedIntent added in v0.14.0

type SpeedIntent struct {
	Speed         float32
	Type          SpeedType
	AfterAltitude *float32    // speed change conditional on reaching this altitude
	AfterFix      string      // speed change conditional on passing this fix
	Until         *SpeedUntil // what the speed restriction is "until"
	Mach          bool
	// UntilFinalDirection is consulted only when Type == SpeedUntilFinal and
	// Until == nil, so the readback can pick reduce/increase/assign-flavored
	// phrasing. Expected values: SpeedReduce, SpeedIncrease, SpeedAssign.
	UntilFinalDirection SpeedType
}

SpeedIntent represents speed assignment commands

func (SpeedIntent) Render added in v0.14.0

func (s SpeedIntent) Render(rt *RadioTransmission, r *rand.Rand)

type SpeedRestriction added in v0.14.3

type SpeedRestriction struct {
	NavigationRestriction
	IsMach bool
}

func MakeAtOrAboveSpeedRestriction added in v0.14.3

func MakeAtOrAboveSpeedRestriction(speed float32) SpeedRestriction

func MakeAtOrBelowSpeedRestriction added in v0.14.3

func MakeAtOrBelowSpeedRestriction(speed float32) SpeedRestriction

func MakeAtSpeedRestriction added in v0.14.3

func MakeAtSpeedRestriction(speed float32) SpeedRestriction

func MakeMachRestriction added in v0.14.3

func MakeMachRestriction(mach float32) SpeedRestriction

func MakeRangeSpeedRestriction added in v0.14.3

func MakeRangeSpeedRestriction(low, high float32) SpeedRestriction

func ParseSpeedRestriction added in v0.14.3

func ParseSpeedRestriction(s string) (*SpeedRestriction, error)

ParseSpeedRestriction parses a speed restriction from compact text form: "210", "210+", "210-", "180-210".

func (SpeedRestriction) CheckJSON added in v0.14.3

func (s SpeedRestriction) CheckJSON(json any) bool

CheckJSON implements util.JSONChecker so the JSON type checker accepts plain numbers and strings in addition to the struct form.

func (SpeedRestriction) Encoded added in v0.14.3

func (s SpeedRestriction) Encoded() string

Encoded returns the restriction in compact text form, e.g. "210+", "250-", "210".

func (SpeedRestriction) IsZero added in v0.14.3

func (s SpeedRestriction) IsZero() bool

IsZero returns true if the speed restriction is unset.

func (*SpeedRestriction) UnmarshalJSON added in v0.14.3

func (s *SpeedRestriction) UnmarshalJSON(b []byte) error

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 SpeedType added in v0.14.0

type SpeedType int
const (
	SpeedAssign SpeedType = iota
	SpeedReduce
	SpeedIncrease
	SpeedCancel
	SpeedSlowestPractical
	SpeedMaximumForward
	SpeedPresentSpeed
	SpeedUntilFinal // speed restriction until 5 mile final
	SpeedAtOrAbove  // "maintain X or greater"
	SpeedAtOrBelow  // "do not exceed X"
)

type SpeedUntil added in v0.14.0

type SpeedUntil struct {
	Fix       string // fix name (e.g., "ROSLY")
	DME       int    // DME distance (e.g., 5 for "5 DME")
	MileFinal int    // mile final (e.g., 6 for "6 mile final")
}

SpeedUntil specifies when a speed restriction ends. Only one field should be set at a time.

type Squawk

type Squawk int

func ParseSquawk

func ParseSquawk(s string) (Squawk, error)

func ParseSquawkOrBlock

func ParseSquawkOrBlock(s string) (Squawk, error)

func (Squawk) IsDiscrete added in v0.15.0

func (sq Squawk) IsDiscrete() bool

IsDiscrete returns true if the code is a discrete beacon code; the non-discrete codes are those ending in "00" (1200, 4000, ...), which are assigned to more than one aircraft at a time.

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
	TRACONs             map[string]TRACON
	ATCTs               map[string]ATCT
	MVAs                map[string][]MVA // TRACON -> MVAs
	AirportPairRoutes   map[AirportPair][]AirportPairRoute
	ScrapedRoutes       map[AirportPair][]ScrapedRoute
	ERAMAdaptations     map[string]ERAMAdaptation
	BravoAirspace       map[string][]AirspaceVolume
	CharlieAirspace     map[string][]AirspaceVolume
	DeltaAirspace       map[string][]AirspaceVolume
}
var DB *StaticDatabase

func (StaticDatabase) ARTCCForFacility added in v0.14.4

func (d StaticDatabase) ARTCCForFacility(fac string) string

ARTCCForFacility returns the ARTCC identifier for the given facility: the id itself if it is an ARTCC, the parent ARTCC for a TRACON or ATCT, or "" if the id is unknown.

func (*StaticDatabase) AirportTimeZone added in v0.15.0

func (d *StaticDatabase) AirportTimeZone(id string) (*time.Location, bool)

AirportTimeZone returns the local time zone at an airport, from where it is. It fails for an airport that isn't in the database or that isn't in any time zone.

func (StaticDatabase) IsARTCC added in v0.14.1

func (d StaticDatabase) IsARTCC(id string) bool

func (StaticDatabase) IsATCT added in v0.14.1

func (d StaticDatabase) IsATCT(id string) bool

func (StaticDatabase) IsFacility added in v0.14.0

func (d StaticDatabase) IsFacility(id string) bool

IsFacility returns true if id is a known ARTCC, TRACON, or ATCT.

func (StaticDatabase) IsTRACON added in v0.14.1

func (d StaticDatabase) IsTRACON(id string) bool

func (StaticDatabase) LookupAirport added in v0.13.3

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

LookupAirport returns the airport with the given id, which may be either an ICAO id or the domestic name of an airport in one of the FAA's regions.

func (StaticDatabase) LookupDME added in v0.14.3

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

func (StaticDatabase) LookupFacility added in v0.14.0

func (d StaticDatabase) LookupFacility(id string) (Facility, bool)

LookupFacility returns a Facility for the given id, checking TRACONs, ATCTs, and ARTCCs.

func (StaticDatabase) LookupWaypoint

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

func (StaticDatabase) RoutesBetween added in v0.15.0

func (d StaticDatabase) RoutesBetween(from, to string) []AirportPairRoute

RoutesBetween returns the real-world routes from one airport to another, ordered preferred-routes first, or nil if the pair isn't in the database.

func (StaticDatabase) ScrapedRoutesBetween added in v0.15.0

func (d StaticDatabase) ScrapedRoutesBetween(from, to string) []ScrapedRoute

ScrapedRoutesBetween returns the recently filed routes from one airport to another, or nil if the pair hasn't been scraped.

type SymbolStyle added in v0.14.4

type SymbolStyle uint8
const (
	SymbolStyleVOR SymbolStyle = iota
	SymbolStyleNDB
	SymbolStyleTACAN
	SymbolStyleVOR_TACAN
	SymbolStyleDME
	SymbolStyleRNAV
	SymbolStyleRNAVOnlyWaypoint
	SymbolStyleAirport
	SymbolStyleSatelliteAirport
	SymbolStyleEmergencyAirport
	SymbolStyleHeliport
	SymbolStyleOtherWaypoints
	SymbolStyleAirwayIntersections
	SymbolStyleIAF
	SymbolStyleObstruction1
	SymbolStyleObstruction2
	SymbolStyleNuclear
	SymbolStyleRadar
)

Symbol style values must be stable across releases — they're written to disk as raw bytes. Add new values at the end; do not renumber.

func (SymbolStyle) String added in v0.14.4

func (s SymbolStyle) String() string

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.
	Regulation string            // Raw FAR code, e.g. "91.137(a)(2)"
	City       string
	State      string
	AltDescr   string // Pre-formatted altitude description, e.g. "SFC - 2500 ft AGL"
	Purpose    string // May be empty; not all TFR types include it.
}

TFR represents an FAA-issued temporary flight restriction.

func DecodeTFRXML added in v0.14.2

func DecodeTFRXML(url string, r io.Reader, lg *log.Logger) (TFR, error)

DecodeTFRXML takes an XML-formatted TFR and converts it to our struct.

func (TFR) ActiveAt added in v0.14.2

func (tfr TFR) ActiveAt(t time.Time) bool

ActiveAt reports whether the TFR is active at time t.

func (TFR) NearPoint added in v0.14.2

func (tfr TFR) NearPoint(center math.Point2LL, rangeNm float32) bool

NearPoint reports whether any vertex of the TFR is within rangeNm of center.

type TRACON

type TRACON struct {
	Facility
	ARTCC string
}

TRACON represents a Terminal Radar Approach Control facility.

type Temperature added in v0.14.2

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

Temperature represents a temperature value with explicit unit safety. Internally stored as Celsius; use Celsius() or Kelvin() to access. JSON and msgpack serialize as a plain float in Celsius for wire compatibility.

func MakeTemperatureFromCelsius added in v0.14.2

func MakeTemperatureFromCelsius(c float32) Temperature

func MakeTemperatureFromKelvin added in v0.14.2

func MakeTemperatureFromKelvin(k float32) Temperature

func (Temperature) Celsius added in v0.14.2

func (t Temperature) Celsius() float32

func (Temperature) Kelvin added in v0.14.2

func (t Temperature) Kelvin() float32

func (Temperature) MarshalJSON added in v0.14.2

func (t Temperature) MarshalJSON() ([]byte, error)

func (Temperature) MarshalMsgpack added in v0.14.2

func (t Temperature) MarshalMsgpack() ([]byte, error)

func (*Temperature) UnmarshalJSON added in v0.14.2

func (t *Temperature) UnmarshalJSON(data []byte) error

func (*Temperature) UnmarshalMsgpack added in v0.14.2

func (t *Temperature) UnmarshalMsgpack(data []byte) error

type TrafficAdvisoryIntent added in v0.14.0

type TrafficAdvisoryIntent struct {
	Response               TrafficAdvisoryResponse
	WillMaintainSeparation bool // If true, add "will maintain visual separation"
}

TrafficAdvisoryIntent represents a pilot's response to a traffic advisory

func (TrafficAdvisoryIntent) Render added in v0.14.0

func (TrafficAdvisoryIntent) String added in v0.14.3

func (t TrafficAdvisoryIntent) String() string

type TrafficAdvisoryResponse added in v0.14.0

type TrafficAdvisoryResponse int

TrafficAdvisoryResponse represents the pilot's response to a traffic advisory

const (
	TrafficResponseIMC          TrafficAdvisoryResponse = iota // In IMC, can't see traffic
	TrafficResponseLooking                                     // No traffic visible, will look
	TrafficResponseTrafficSeen                                 // Traffic is in sight
	TrafficResponseAcknowledged                                // Other traffic is maintaining visual separation
	TrafficResponseWhereWasIt                                  // Pilot asks the controller to repeat the traffic call
)

type TrafficRoute added in v0.15.0

type TrafficRoute struct {
	Route    string        `json:"route"`
	Aircraft AircraftClass `json:"aircraft,omitempty"`
}

TrafficRoute is one route and the aircraft classes it applies to.

type TrafficRouteSet added in v0.15.0

type TrafficRouteSet []TrafficRoute

TrafficRouteSet is the routes for one city pair; a bare JSON string is shorthand for a single route open to all aircraft.

func (TrafficRouteSet) Routes added in v0.15.0

func (ts TrafficRouteSet) Routes(acType string) []string

Routes returns the routes the given aircraft type may fly, in listed order.

func (*TrafficRouteSet) UnmarshalJSON added in v0.15.0

func (ts *TrafficRouteSet) UnmarshalJSON(b []byte) error

type TrafficRoutes added in v0.15.0

type TrafficRoutes struct {
	Departures map[string]TrafficRouteSet `json:"departures"`
	Arrivals   map[string]TrafficRouteSet `json:"arrivals"`
}

TrafficRoutes says how published traffic between an airport and specific other airports is routed, keyed by the other airport's ICAO code.

type TransponderIntent added in v0.14.0

type TransponderIntent struct {
	Code  *Squawk
	Mode  *TransponderMode
	Ident bool
}

TransponderIntent represents squawk/ident/mode commands

func (TransponderIntent) Render added in v0.14.0

func (t TransponderIntent) Render(rt *RadioTransmission, r *rand.Rand)

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 TransponderType added in v0.14.0

type TransponderType int

type TurnDirection added in v0.13.0

type TurnDirection math.TurnDirection

TurnDirection specifies the direction of a turn.

const (
	TurnClosest TurnDirection = TurnDirection(math.TurnClosest) // default: turn the shortest direction
	TurnLeft    TurnDirection = TurnDirection(math.TurnLeft)
	TurnRight   TurnDirection = TurnDirection(math.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 UnableIntent added in v0.14.0

type UnableIntent struct {
	Message string
	Args    []any
}

UnableIntent represents a pilot's "unable" response to a command. It is rendered as RadioTransmissionUnexpected and does not merge with other intents.

func MakeUnableIntent added in v0.14.0

func MakeUnableIntent(message string, args ...any) UnableIntent

func (UnableIntent) Render added in v0.14.0

func (u UnableIntent) Render(rt *RadioTransmission, r *rand.Rand)

type VFRRandomsSpec

type VFRRandomsSpec struct {
	Rate  float32 `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        float32       `json:"rate"`
	Fleet       string        `json:"fleet"`
	Waypoints   WaypointArray `json:"waypoints"`
	Destination string        `json:"destination"`
	Description string        `json:"description"`
}

type VisualSeparationIntent added in v0.14.0

type VisualSeparationIntent struct{}

VisualSeparationIntent represents a pilot's acknowledgment of visual separation responsibility

func (VisualSeparationIntent) Render added in v0.14.0

type Waypoint

type Waypoint struct {
	Fix            string              `json:"fix"`
	Location       math.Point2LL       `json:"location,omitempty"`
	AltRestriction AltitudeRestriction // valid iff WaypointFlagHasAltRestriction set
	SpdRestriction SpeedRestriction    // valid iff WaypointFlagHasSpeedRestriction set
	Extra          *WaypointExtra
	Flags          WaypointFlags
	Heading        int16 // 0 = unset
	VFRPhase       uint8 // VFRPhaseNone for non-VFR-pattern waypoints
}

Waypoint is the core waypoint struct. Most waypoints only use Fix, Location, and a few flags; Extra fields are heap-allocated only when needed. AltRestriction, Heading, and SpdRestriction are inline because they are used by ~48% of waypoints, avoiding a heap allocation for those.

func (Waypoint) ActionEvent added in v0.14.3

func (wp Waypoint) ActionEvent() *WaypointActionEvent

func (Waypoint) ActionGroups added in v0.14.3

func (wp Waypoint) ActionGroups() []WaypointActionGroup

func (Waypoint) Airway

func (wp Waypoint) Airway() string

func (Waypoint) AirworkMinutes

func (wp Waypoint) AirworkMinutes() int

func (Waypoint) AirworkRadius

func (wp Waypoint) AirworkRadius() int

func (*Waypoint) AltitudeRestriction

func (wp *Waypoint) AltitudeRestriction() *AltitudeRestriction

AltitudeRestriction returns a pointer to the inline restriction if the flag is set, else nil.

func (Waypoint) Arc

func (wp Waypoint) Arc() *DMEArc

func (*Waypoint) ClearAltitudeRestriction added in v0.14.3

func (wp *Waypoint) ClearAltitudeRestriction()

ClearAltitudeRestriction removes the inline restriction and clears the flag.

func (Waypoint) ClearApproach

func (wp Waypoint) ClearApproach() bool

func (Waypoint) ClearPrimaryScratchpad

func (wp Waypoint) ClearPrimaryScratchpad() bool

func (Waypoint) ClearSecondaryScratchpad

func (wp Waypoint) ClearSecondaryScratchpad() bool

func (*Waypoint) ClearSpeedRestriction added in v0.14.3

func (wp *Waypoint) ClearSpeedRestriction()

ClearSpeedRestriction removes the inline restriction and clears the flag.

func (Waypoint) ClimbAltitude added in v0.13.0

func (wp Waypoint) ClimbAltitude() int

func (Waypoint) Delete

func (wp Waypoint) Delete() bool

func (Waypoint) DescendAltitude added in v0.13.0

func (wp Waypoint) DescendAltitude() int

func (*Waypoint) ETA

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

func (Waypoint) FAF

func (wp Waypoint) FAF() bool

func (Waypoint) FlyOver

func (wp Waypoint) FlyOver() bool

func (Waypoint) GoAroundContactController added in v0.14.1

func (wp Waypoint) GoAroundContactController() ControlPosition

func (Waypoint) HandoffController added in v0.13.3

func (wp Waypoint) HandoffController() ControlPosition

func (Waypoint) HasAltitudeActions added in v0.15.0

func (wp Waypoint) HasAltitudeActions() bool

HasAltitudeActions reports whether the waypoint has a /c or /d altitude action, either directly or in one of its action groups.

func (Waypoint) HasAltitudeRestriction added in v0.14.3

func (wp Waypoint) HasAltitudeRestriction() bool

func (Waypoint) HasSpeedRestriction added in v0.14.3

func (wp Waypoint) HasSpeedRestriction() bool

func (Waypoint) HasTransferCommsAction added in v0.14.3

func (wp Waypoint) HasTransferCommsAction() bool

func (Waypoint) HeadingIsTrack added in v0.14.2

func (wp Waypoint) HeadingIsTrack() bool

func (Waypoint) HumanHandoff

func (wp Waypoint) HumanHandoff() bool

func (Waypoint) IAF

func (wp Waypoint) IAF() bool

func (Waypoint) IF

func (wp Waypoint) IF() bool

func (*Waypoint) InitExtra added in v0.14.1

func (wp *Waypoint) InitExtra() *WaypointExtra

InitExtra allocates Extra if nil and returns it.

func (Waypoint) InterceptApproach added in v0.14.4

func (wp Waypoint) InterceptApproach() bool

func (Waypoint) Land

func (wp Waypoint) Land() bool

func (Waypoint) LogValue

func (wp Waypoint) LogValue() slog.Value

func (Waypoint) MagneticHeading added in v0.14.2

func (wp Waypoint) MagneticHeading() math.MagneticHeading

MagneticHeading returns the waypoint's heading as MagneticHeading.

func (Waypoint) NoPT

func (wp Waypoint) NoPT() bool

func (Waypoint) OnApproach

func (wp Waypoint) OnApproach() bool

func (Waypoint) OnSID

func (wp Waypoint) OnSID() bool

func (Waypoint) OnSTAR

func (wp Waypoint) OnSTAR() bool

func (Waypoint) PointOut

func (wp Waypoint) PointOut() ControlPosition

func (Waypoint) PresentHeading

func (wp Waypoint) PresentHeading() bool

Flag readers (value receiver)

func (Waypoint) PrimaryScratchpad

func (wp Waypoint) PrimaryScratchpad() string

func (Waypoint) ProcedureTurn

func (wp Waypoint) ProcedureTurn() *ProcedureTurn

Extra field readers (value receiver, nil-safe)

func (Waypoint) Radius

func (wp Waypoint) Radius() float32

func (Waypoint) SecondaryScratchpad

func (wp Waypoint) SecondaryScratchpad() string

func (Waypoint) SequenceVFRLanding added in v0.14.2

func (wp Waypoint) SequenceVFRLanding() bool

func (*Waypoint) SetAltitudeRestriction added in v0.14.1

func (wp *Waypoint) SetAltitudeRestriction(ar AltitudeRestriction)

SetAltitudeRestriction stores the restriction inline and sets the flag.

func (*Waypoint) SetClearApproach added in v0.14.1

func (wp *Waypoint) SetClearApproach(v bool)

func (*Waypoint) SetClearPrimaryScratchpad added in v0.14.1

func (wp *Waypoint) SetClearPrimaryScratchpad(v bool)

func (*Waypoint) SetClearSecondaryScratchpad added in v0.14.1

func (wp *Waypoint) SetClearSecondaryScratchpad(v bool)

func (*Waypoint) SetDelete added in v0.14.1

func (wp *Waypoint) SetDelete(v bool)

func (*Waypoint) SetFAF added in v0.14.1

func (wp *Waypoint) SetFAF(v bool)

func (*Waypoint) SetFlyOver added in v0.14.1

func (wp *Waypoint) SetFlyOver(v bool)

func (*Waypoint) SetHumanHandoff added in v0.14.1

func (wp *Waypoint) SetHumanHandoff(v bool)

func (*Waypoint) SetIAF added in v0.14.1

func (wp *Waypoint) SetIAF(v bool)

func (*Waypoint) SetIF added in v0.14.1

func (wp *Waypoint) SetIF(v bool)

func (*Waypoint) SetInterceptApproach added in v0.14.4

func (wp *Waypoint) SetInterceptApproach(v bool)

func (*Waypoint) SetLand added in v0.14.1

func (wp *Waypoint) SetLand(v bool)

func (*Waypoint) SetNoPT added in v0.14.1

func (wp *Waypoint) SetNoPT(v bool)

func (*Waypoint) SetOnApproach added in v0.14.1

func (wp *Waypoint) SetOnApproach(v bool)

func (*Waypoint) SetOnSID added in v0.14.1

func (wp *Waypoint) SetOnSID(v bool)

func (*Waypoint) SetOnSTAR added in v0.14.1

func (wp *Waypoint) SetOnSTAR(v bool)

func (*Waypoint) SetPresentHeading added in v0.14.1

func (wp *Waypoint) SetPresentHeading(v bool)

func (*Waypoint) SetSequenceVFRLanding added in v0.14.2

func (wp *Waypoint) SetSequenceVFRLanding(v bool)

func (*Waypoint) SetSpeedRestriction added in v0.14.3

func (wp *Waypoint) SetSpeedRestriction(sr SpeedRestriction)

SetSpeedRestriction stores the restriction inline and sets the flag.

func (*Waypoint) SetSyntheticCrossing added in v0.14.3

func (wp *Waypoint) SetSyntheticCrossing(v bool)

func (*Waypoint) SetTransferComms added in v0.14.1

func (wp *Waypoint) SetTransferComms(v bool)

func (*Waypoint) SetTurn added in v0.14.1

func (wp *Waypoint) SetTurn(t TurnDirection)

func (Waypoint) Shift

func (wp Waypoint) Shift() float32

func (*Waypoint) SpeedRestriction added in v0.14.3

func (wp *Waypoint) SpeedRestriction() *SpeedRestriction

SpeedRestriction returns a pointer to the inline restriction if the flag is set, else nil.

func (Waypoint) SyntheticCrossing added in v0.14.3

func (wp Waypoint) SyntheticCrossing() bool

func (Waypoint) TransferComms

func (wp Waypoint) TransferComms() bool

func (Waypoint) Turn added in v0.14.0

func (wp Waypoint) Turn() TurnDirection

func (Waypoint) WaypointActions added in v0.14.3

func (wp Waypoint) WaypointActions() WaypointActions

type WaypointActionEvent added in v0.14.3

type WaypointActionEvent struct {
	Fix     string
	Actions WaypointActions
}

type WaypointActionGroup added in v0.14.3

type WaypointActionGroup struct {
	Actions WaypointActions
	Until   WaypointActionTermination
}

func (WaypointActionGroup) Encoded added in v0.14.3

func (wag WaypointActionGroup) Encoded() string

type WaypointActionTermination added in v0.14.3

type WaypointActionTermination struct {
	Type            WaypointActionTerminationType
	Altitude        int
	DMEFix          string
	DMEDistance     float32
	DMEFixLocation  math.Point2LL
	DMEFixElevation int
}

WaypointActionTermination describes a non-fix condition for advancing to the next waypoint action group.

type WaypointActionTerminationType added in v0.14.3

type WaypointActionTerminationType int

WaypointActionTerminationType indicates when a waypoint action group is complete.

const (
	WaypointActionNoTermination WaypointActionTerminationType = iota
	WaypointActionAltitude
	WaypointActionDME
)

type WaypointActions added in v0.14.3

type WaypointActions struct {
	Heading *WaypointHeadingAction

	HumanHandoff              bool
	HandoffController         ControlPosition
	PointOut                  ControlPosition
	ClearApproach             bool
	GoAroundContactController ControlPosition
	PrimaryScratchpad         string
	ClearPrimaryScratchpad    bool
	SecondaryScratchpad       string
	ClearSecondaryScratchpad  bool
	TransferComms             bool

	ClimbAltitude   int16 // hundreds of feet; 0 = unset
	DescendAltitude int16 // hundreds of feet; 0 = unset
}

WaypointActions describes actions that take effect together after passing a waypoint or after an ordered action group's termination condition is met.

func (WaypointActions) Encoded added in v0.14.3

func (wa WaypointActions) Encoded() string

func (WaypointActions) HasNavActions added in v0.14.3

func (wa WaypointActions) HasNavActions() bool

func (WaypointActions) HasSimActions added in v0.14.3

func (wa WaypointActions) HasSimActions() bool

type WaypointArray

type WaypointArray []Waypoint

func RouteWaypoints added in v0.15.0

func RouteWaypoints(route string) WaypointArray

RouteWaypoints converts a real-world route from the city-pair database into waypoints. An airway name attaches to the fix before it, so InitializeLocations fills in the fixes it passes through. The returned waypoints have no Location: the caller must run InitializeLocations on them, which is also what discards the tokens that aren't fixes at all--SID and STAR names, radial/DME fixes like SLI341/019.

This deliberately doesn't go through the scenario route parser, which understands vice's "/" waypoint modifiers and so can't read the routes that name such fixes.

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, elevation int, 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) HandoffControllers added in v0.15.0

func (wa WaypointArray) HandoffControllers() []ControlPosition

HandoffControllers returns the positions the route names as handoff targets, whether at a waypoint itself or in one of its conditional action groups. These are the /hoXX handoffs, which name where the track goes; the bare /ho of HasHumanHandoff leaves that to whoever is working the flow.

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 WaypointExtra added in v0.14.1

type WaypointExtra struct {
	ProcedureTurn             *ProcedureTurn
	Arc                       *DMEArc
	ActionGroups              []WaypointActionGroup
	HandoffController         ControlPosition
	PointOut                  ControlPosition
	GoAroundContactController ControlPosition
	Airway                    string
	PrimaryScratchpad         string
	SecondaryScratchpad       string
	Radius                    float32
	Shift                     float32
	ClimbAltitude             int16 // hundreds of feet; 0 = unset
	DescendAltitude           int16 // hundreds of feet; 0 = unset
	AirworkRadius             int8
	AirworkMinutes            int8
}

WaypointExtra holds the rarely-used fields, heap-allocated only when needed.

type WaypointFlags added in v0.14.1

type WaypointFlags uint32
const (
	WaypointFlagPresentHeading WaypointFlags = 1 << iota
	WaypointFlagNoPT
	WaypointFlagHumanHandoff
	WaypointFlagClearApproach
	WaypointFlagFlyOver
	WaypointFlagDelete
	WaypointFlagLand
	WaypointFlagIAF
	WaypointFlagIF
	WaypointFlagFAF
	WaypointFlagOnSID
	WaypointFlagOnSTAR
	WaypointFlagOnApproach
	WaypointFlagClearPrimaryScratchpad
	WaypointFlagClearSecondaryScratchpad
	WaypointFlagTransferComms
	WaypointFlagTurnLeft
	WaypointFlagTurnRight
	WaypointFlagSyntheticCrossing
	WaypointFlagHasAltRestriction
	WaypointFlagHasSpeedRestriction
	WaypointFlagSequenceVFRLanding
	WaypointFlagHeadingIsTrack
	WaypointFlagInterceptApproach
)

type WaypointHeadingAction added in v0.14.3

type WaypointHeadingAction struct {
	Heading        int16
	Turn           TurnDirection
	Track          bool
	PresentHeading bool
}

func (WaypointHeadingAction) Encoded added in v0.14.3

func (wha WaypointHeadingAction) Encoded() string

type XNOTAMUpdate

type XNOTAMUpdate struct {
	Group struct {
		Add struct {
			Not struct {
				NotUid struct {
					TxtLocalName string `xml:"txtLocalName"`
					DateIssued   string `xml:"dateIssued"`
				} `xml:"NotUid"`
				DateEffective          string `xml:"dateEffective"`
				DateExpire             string `xml:"dateExpire"`
				CodeTimeZone           string `xml:"codeTimeZone"`
				CodeExpirationTimeZone string `xml:"codeExpirationTimeZone"`
				CodeFacility           string `xml:"codeFacility"`
				TxtDescrPurpose        string `xml:"txtDescrPurpose"`
				AffLocGroup            struct {
					TxtNameCity    string `xml:"txtNameCity"`
					TxtNameUSState string `xml:"txtNameUSState"`
				} `xml:"AffLocGroup"`
				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"`
						AseTFRArea struct {
							CodeDistVerUpper string `xml:"codeDistVerUpper"`
							ValDistVerUpper  string `xml:"valDistVerUpper"`
							UomDistVerUpper  string `xml:"uomDistVerUpper"`
							CodeDistVerLower string `xml:"codeDistVerLower"`
							ValDistVerLower  string `xml:"valDistVerLower"`
							UomDistVerLower  string `xml:"uomDistVerLower"`
						} `xml:"aseTFRArea"`
					} `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