sfomuseum

package
v0.6.8 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: BSD-3-Clause Imports: 18 Imported by: 1

Documentation

Index

Constants

View Source
const DATA_GITHUB string = "https://raw.githubusercontent.com/sfomuseum/go-sfomuseum-airfield/main/data/airlines-sfomuseum.json"
View Source
const DATA_JSON string = "airlines-sfomuseum.json"

Variables

This section is empty.

Functions

func NewSFOMuseumLookup

func NewSFOMuseumLookup(ctx context.Context, uri string) (airlines.AirlinesLookup, error)

NewLookup will return an `airlines.AirlinesLookup` instance. By default the lookup table is derived from precompiled (embedded) data in `data/sfomuseum.json` by passing in `sfomuseum://` as the URI. It is also possible to create a new lookup table with the following URI options:

`sfomuseum://github`

This will cause the lookup table to be derived from the data stored at https://raw.githubusercontent.com/sfomuseum/go-sfomuseum-airlines/main/data/sfomuseum.json. This might be desirable if there have been updates to the underlying data that are not reflected in the locally installed package's pre-compiled data.

`sfomuseum://iterator?uri={URI}&source={SOURCE}`

This will cause the lookup table to be derived, at runtime, from data emitted by a `whosonfirst/go-whosonfirst-iterate` instance. `{URI}` should be a valid `whosonfirst/go-whosonfirst-iterate/iterator` URI and `{SOURCE}` is one or more URIs for the iterator to process.

func NewSFOMuseumLookupFromIterator

func NewSFOMuseumLookupFromIterator(ctx context.Context, iterator_uri string, iterator_sources ...string) (airlines.AirlinesLookup, error)

func NewSFOMuseumLookupWithLookupFunc

func NewSFOMuseumLookupWithLookupFunc(ctx context.Context, lookup_func SFOMuseumLookupFunc) (airlines.AirlinesLookup, error)

NewLookupWithLookupFunc will return an `airlines.AirlinesLookup` instance derived by data compiled using `lookup_func`.

Types

type Airline

type Airline struct {
	WhosOnFirstId int64  `json:"wof:id"`
	Name          string `json:"wof:name"`
	Role          string `json:"sfomuseum:airline_role"`
	SFOMuseumId   int64  `json:"sfomuseum:airline_id"`
	IATACode      string `json:"iata:code,omitempty"`
	ICAOCode      string `json:"icao:code,omitempty"`
	ICAOCallsign  string `json:"icao:callsign,omitempty"`
	WikidataId    string `json:"wd:id,omitempty"`
	IsCurrent     int64  `json:"mz:is_current"`
}

func CompileAirlinesData

func CompileAirlinesData(ctx context.Context, iterator_uri string, iterator_sources ...string) ([]*Airline, error)

func FindAirlinesCurrent added in v0.0.4

func FindAirlinesCurrent(ctx context.Context, code string) ([]*Airline, error)

Returns all Airline instances matching 'code' that are marked as current.

func FindAirlinesCurrentWithLookup added in v0.0.4

func FindAirlinesCurrentWithLookup(ctx context.Context, lookup airfield.Lookup, code string) ([]*Airline, error)

Returns all Airline instances matching 'code' that are marked as current with a custom airfield.Lookup instance.

func FindCurrentAirline added in v0.0.4

func FindCurrentAirline(ctx context.Context, code string, roles ...string) (*Airline, error)

Return the current Airline matching 'code'. Multiple matches throw an error.

func FindCurrentAirlineWithLookup added in v0.0.4

func FindCurrentAirlineWithLookup(ctx context.Context, lookup airfield.Lookup, code string, roles ...string) (*Airline, error)

Return the current Airline matching 'code' with a custom airfield.Lookup instance. Multiple matches throw an error.

func (*Airline) String

func (a *Airline) String() string

type SFOMuseumLookup

type SFOMuseumLookup struct {
	airlines.AirlinesLookup
}

func (*SFOMuseumLookup) Append

func (l *SFOMuseumLookup) Append(ctx context.Context, data interface{}) error

func (*SFOMuseumLookup) Find

func (l *SFOMuseumLookup) Find(ctx context.Context, code string) ([]interface{}, error)

type SFOMuseumLookupFunc

type SFOMuseumLookupFunc func(context.Context)

func NewSFOMuseumLookupFuncWithAirlines

func NewSFOMuseumLookupFuncWithAirlines(ctx context.Context, airlines_list []*Airline) SFOMuseumLookupFunc

NewLookup will return an `SFOMuseumLookupFunc` function instance that, when invoked, will populate an `airlines.AirlinesLookup` instance with data stored in `airlines_list`.

func NewSFOMuseumLookupFuncWithReader

func NewSFOMuseumLookupFuncWithReader(ctx context.Context, r io.ReadCloser) SFOMuseumLookupFunc

NewLookup will return an `SFOMuseumLookupFunc` function instance that, when invoked, will populate an `airlines.AirlinesLookup` instance with data stored in `r`. `r` will be closed when the `SFOMuseumLookupFunc` function instance is invoked. It is assumed that the data in `r` will be formatted in the same way as the procompiled (embedded) data stored in `data/sfomuseum.json`.

Jump to

Keyboard shortcuts

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