Documentation ¶
Index ¶
- Constants
- func NewSFOMuseumLookup(ctx context.Context, uri string) (aircraft.AircraftLookup, error)
- func NewSFOMuseumLookupFromIterator(ctx context.Context, iterator_uri string, iterator_sources ...string) (aircraft.AircraftLookup, error)
- func NewSFOMuseumLookupWithLookupFunc(ctx context.Context, lookup_func SFOMuseumLookupFunc) (aircraft.AircraftLookup, error)
- type Aircraft
- func CompileAircraftData(ctx context.Context, iterator_uri string, iterator_sources ...string) ([]*Aircraft, error)
- func FindAircraftCurrent(ctx context.Context, code string) ([]*Aircraft, error)
- func FindAircraftCurrentWithLookup(ctx context.Context, lookup airfield.Lookup, code string) ([]*Aircraft, error)
- func FindCurrentAircraft(ctx context.Context, code string) (*Aircraft, error)
- func FindCurrentAircraftWithLookup(ctx context.Context, lookup airfield.Lookup, code string) (*Aircraft, error)
- type SFOMuseumLookup
- type SFOMuseumLookupFunc
Constants ¶
const DATA_GITHUB string = "https://raw.githubusercontent.com/sfomuseum/go-sfomuseum-airfield/main/data/aircraft-sfomuseum.json"
const DATA_JSON string = "aircraft-sfomuseum.json"
Variables ¶
This section is empty.
Functions ¶
func NewSFOMuseumLookup ¶
NewSFOMuseumLookup will return an `aircraft.AircraftLookup` instance. By default the lookup table is derived from precompiled (embedded) data in `data/aircraft-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-airfield/main/data/aircraft-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 NewSFOMuseumLookupWithLookupFunc ¶
func NewSFOMuseumLookupWithLookupFunc(ctx context.Context, lookup_func SFOMuseumLookupFunc) (aircraft.AircraftLookup, error)
NewSFOMuseumLookupWithLookupFunc will return an `aircraft.AircraftLookup` instance derived by data compiled using `lookup_func`.
Types ¶
type Aircraft ¶
type Aircraft struct { WhosOnFirstId int64 `json:"wof:id"` Name string `json:"wof:name"` SFOMuseumId int64 `json:"sfomuseum:aircraft_id"` ICAODesignator string `json:"icao:designator,omitempty"` WikidataId string `json:"wd:id,omitempty"` IsCurrent int64 `json:"mz:is_current"` }
func CompileAircraftData ¶
func CompileAircraftData(ctx context.Context, iterator_uri string, iterator_sources ...string) ([]*Aircraft, error)
CompileAircraftData will generate a list of `Aircraft` struct to be used as the source data for an `SFOMuseumLookup` instance. The list of aircraft are compiled by iterating over one or more source. `iterator_uri` is a valid `whosonfirst/go-whosonfirst-iterate` URI and `iterator_sources` are one more (iterator) URIs to process.
func FindAircraftCurrent ¶ added in v0.0.4
Returns all Aircraft instances matching 'code' that are marked as current.
func FindAircraftCurrentWithLookup ¶ added in v0.0.4
func FindAircraftCurrentWithLookup(ctx context.Context, lookup airfield.Lookup, code string) ([]*Aircraft, error)
Returns all Aircraft instances matching 'code' that are marked as current with a custom airfield.Lookup instance.
func FindCurrentAircraft ¶ added in v0.0.4
Return the current Aircraft matching 'code'. Multiple matches throw an error.
type SFOMuseumLookup ¶
type SFOMuseumLookup struct {
aircraft.AircraftLookup
}
type SFOMuseumLookupFunc ¶
func NewSFOMuseumLookupFuncWithAircraft ¶
func NewSFOMuseumLookupFuncWithAircraft(ctx context.Context, aircraft_list []*Aircraft) SFOMuseumLookupFunc
NewSFOMuseumLookup will return an `SFOMuseumLookupFunc` function instance that, when invoked, will populate an `aircraft.AircraftLookup` instance with data stored in `aircraft_list`.
func NewSFOMuseumLookupFuncWithReader ¶
func NewSFOMuseumLookupFuncWithReader(ctx context.Context, r io.ReadCloser) SFOMuseumLookupFunc
NewSFOMuseumLookup will return an `SFOMuseumLookupFunc` function instance that, when invoked, will populate an `aircraft.AircraftLookup` 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`.