aeroapi

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsFlightIdsArtifactFilename

func IsFlightIdsArtifactFilename(fn string) bool

func IsTrackArtifactFilename

func IsTrackArtifactFilename(fn string) bool

func MakeFlightIdsArtifactFilename

func MakeFlightIdsArtifactFilename(queryId string) string

func MakeTrackArtifactFilename

func MakeTrackArtifactFilename(flightId string) string

Types

type Api

type Api interface {
	GetFlightIds(tailNumber string, cutoffTime time.Time) ([]string, error)
	GetTrackForFlightId(flightId string) (*Track, error)
}

type ArtifactLocator

type ArtifactLocator interface {
	// GetFlightIdsRef returns a reference used to obtain the flight identifier(s) for the desired track(s).
	// The return value is an address (such as a URL or file name) used within context to obtain the desired list.
	GetFlightIdsRef(tailNumber string, cutoffTime time.Time) (string, error)
	// GetTrackForFlightRef returns a reference (such as a URL or file name) used to obtain the desired track data.
	GetTrackForFlightRef(flightId string) string
}

type ArtifactRetriever

type ArtifactRetriever interface {
	ArtifactLocator
	persistence.Loader
}

type ArtifactSaver

type ArtifactSaver interface {
	ArtifactLocator
	persistence.Saver
}

type Degrees

type Degrees float64

type FileAeroApi

type FileAeroApi struct {
	ArtifactsDir      string
	FlightIdsFileName string
	persistence.FileLoader
	persistence.FileSaver
}

func (*FileAeroApi) GetFlightIdsRef

func (c *FileAeroApi) GetFlightIdsRef(tailNumber string, cutoffTime time.Time) (string, error)

func (*FileAeroApi) GetTrackForFlightRef

func (c *FileAeroApi) GetTrackForFlightRef(flightId string) string

type Flight

type Flight struct {
	FlightId string `json:"fa_flight_id"`
}

type FlightsResponse

type FlightsResponse struct {
	Flights []Flight `json:"flights"`
}

func FlightsFromJson

func FlightsFromJson(flightsBytes []byte) (*FlightsResponse, error)

type HttpAeroApi

type HttpAeroApi struct {
	Verbose bool
	ApiKey  string
	ApiUrl  string
}

func (*HttpAeroApi) GetFlightIdsRef

func (c *HttpAeroApi) GetFlightIdsRef(tailNumber string, cutoffTime time.Time) (string, error)

func (*HttpAeroApi) GetTrackForFlightRef

func (c *HttpAeroApi) GetTrackForFlightRef(flightId string) string

func (*HttpAeroApi) Load

func (c *HttpAeroApi) Load(endpoint string) ([]byte, error)

type Math

type Math struct {
	Debug bool
}

func (*Math) GetBankAngle

func (u *Math) GetBankAngle(fromPosition, toPosition Position) Degrees

GetBankAngle calculates and reports, using a loose heuristic, a reasonable "bank angle" that could be used by a general aviation aircraft to achieve the observed change in heading between one reported position and another.

func (*Math) GetGeoBearing

func (u *Math) GetGeoBearing(fromPosition, toPosition Position) Degrees

GetGeoBearing calculates and reports the apparent compass bearing (0 <= bearing < 360) needed to arrive at a new geolocation

func (*Math) GetGeoGsKnots

func (u *Math) GetGeoGsKnots(fromPosition, toPosition Position) float64

GetGeoGsKnots calculates and reports the apparent average ground speed used navigate the straight line distance between two geolocations

type MockArtifactRetriever

type MockArtifactRetriever struct {
	Err                error
	Contents           []byte
	RequestedEndpoints []string
}

func (*MockArtifactRetriever) GetFlightIdsRef

func (*MockArtifactRetriever) GetFlightIdsRef(tailNumber string, _ time.Time) (string, error)

func (*MockArtifactRetriever) GetTrackForFlightRef

func (*MockArtifactRetriever) GetTrackForFlightRef(flightId string) string

func (*MockArtifactRetriever) Load

func (r *MockArtifactRetriever) Load(requestEndpoint string) ([]byte, error)

type Position

type Position struct {
	// 230811 Changed "AltAglD100" to "AltMslD100" per updated understanding
	// based upon post: "https://discussions.flightaware.com/t/aero-api-altitude/82883/4"
	// which reads: "None of our aircraft altitudes will ever be reported in AGL, if that helps."
	// and also based upon observed results for Virgin Galactic flight
	AltMslD100 float64   `json:"altitude"`    // feet / 100 (MSL)
	GsKnots    float64   `json:"groundspeed"` // knots
	Heading    float64   `json:"heading"`     // 0..359
	Latitude   float64   `json:"latitude"`    // -90..90
	Longitude  float64   `json:"longitude"`   // -180..180
	Timestamp  time.Time `json:"timestamp"`
}

type Radians

type Radians float64

type ResponseSaver

type ResponseSaver func(string, []byte) (string, error)

type RetrieverSaverApiImpl

type RetrieverSaverApiImpl struct {
	Retriever ArtifactRetriever
	Saver     ArtifactSaver
}

func (*RetrieverSaverApiImpl) GetFlightIds

func (a *RetrieverSaverApiImpl) GetFlightIds(tailNumber string, cutoffTime time.Time) ([]string, error)

GetFlightIds returns the AeroAPI identifier(s) of the flight(s) specified by the parameters cutoffTime (optional) - most recent time for a flight to be considered

func (*RetrieverSaverApiImpl) GetTrackForFlightId

func (a *RetrieverSaverApiImpl) GetTrackForFlightId(flightId string) (*Track, error)

GetTrackForFlightId retrieves the track for the given flight given its AeroAPI identifier

type Track

type Track struct {
	FlightId  string
	Positions []Position `json:"positions"`
}

func TrackFromJson

func TrackFromJson(aeroApiTrackJson []byte) (*Track, error)

Jump to

Keyboard shortcuts

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