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/aircraft-sfomuseum.json"
View Source
const DATA_JSON string = "aircraft-sfomuseum.json"

Variables

This section is empty.

Functions

func NewSFOMuseumLookup

func NewSFOMuseumLookup(ctx context.Context, uri string) (aircraft.AircraftLookup, error)

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 NewSFOMuseumLookupFromIterator

func NewSFOMuseumLookupFromIterator(ctx context.Context, iterator_uri string, iterator_sources ...string) (aircraft.AircraftLookup, error)

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

func FindAircraftCurrent(ctx context.Context, code string) ([]*Aircraft, error)

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

func FindCurrentAircraft(ctx context.Context, code string) (*Aircraft, error)

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

func FindCurrentAircraftWithLookup added in v0.0.4

func FindCurrentAircraftWithLookup(ctx context.Context, lookup airfield.Lookup, code string) (*Aircraft, error)

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

func (*Aircraft) String

func (a *Aircraft) String() string

type SFOMuseumLookup

type SFOMuseumLookup struct {
	aircraft.AircraftLookup
}

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

Jump to

Keyboard shortcuts

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