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

Variables

This section is empty.

Functions

func NewSFOMuseumLookup

func NewSFOMuseumLookup(ctx context.Context, uri string) (airports.AirportsLookup, error)

NewSFOMuseumLookup will return an `airports.AirportsLookup` instance. By default the lookup table is derived from precompiled (embedded) data in `data/airports-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/airports-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) (airports.AirportsLookup, error)

func NewSFOMuseumLookupWithLookupFunc

func NewSFOMuseumLookupWithLookupFunc(ctx context.Context, lookup_func SFOMuseumLookupFunc) (airports.AirportsLookup, error)

NewSFOMuseumLookupWithLookupFunc will return an `airports.AirportsLookup` instance derived by data compiled using `lookup_func`.

Types

type Airport

type Airport struct {
	WhosOnFirstId int64  `json:"wof:id"`
	Name          string `json:"wof:name"`
	SFOMuseumId   int64  `json:"sfomuseum:airport_id"`
	IATACode      string `json:"iata:code"`
	ICAOCode      string `json:"icao:code"`
	WikidataId    string `json:"wd:id,omitempty"`
	IsCurrent     int64  `json:"mz:is_current"`
}

func CompileAirportsData

func CompileAirportsData(ctx context.Context, iterator_uri string, iterator_sources ...string) ([]*Airport, error)

func FindAirportsCurrent added in v0.0.4

func FindAirportsCurrent(ctx context.Context, code string) ([]*Airport, error)

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

func FindAirportsCurrentWithLookup added in v0.0.4

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

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

func FindCurrentAirport added in v0.0.4

func FindCurrentAirport(ctx context.Context, code string) (*Airport, error)

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

func FindCurrentAirportWithLookup added in v0.0.4

func FindCurrentAirportWithLookup(ctx context.Context, lookup airfield.Lookup, code string) (*Airport, error)

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

func (*Airport) String

func (a *Airport) String() string

type SFOMuseumLookup

type SFOMuseumLookup struct {
	airports.AirportsLookup
}

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 NewSFOMuseumLookupFuncWithAirports

func NewSFOMuseumLookupFuncWithAirports(ctx context.Context, airports_list []*Airport) SFOMuseumLookupFunc

NewSFOMuseumLookup will return an `SFOMuseumLookupFunc` function instance that, when invoked, will populate an `airports.AirportsLookup` instance with data stored in `airports_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 `airports.AirportsLookup` 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