terminals

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Overview

package terminals provides methods for working with boarding terminals at SFO.

Index

Constants

View Source
const DATA_JSON string = "terminals.json"

Variables

This section is empty.

Functions

func IsMultipleCandidates

func IsMultipleCandidates(e error) bool

func IsNotFound

func IsNotFound(e error) bool

func NewLookup

func NewLookup(ctx context.Context, uri string) (architecture.Lookup, error)

NewLookup will return an `architecture.Lookup` instance. By default the lookup table is derived from precompiled (embedded) data in `data/terminals.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-architecture/main/data/terminals.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 NewLookupFromIterator

func NewLookupFromIterator(ctx context.Context, iterator_uri string, iterator_sources ...string) (architecture.Lookup, error)

func NewLookupWithLookupFunc

func NewLookupWithLookupFunc(ctx context.Context, lookup_func TerminalsLookupFunc) (architecture.Lookup, error)

NewLookupWithLookupFunc will return an `architecture.Lookup` instance derived by data compiled using `lookup_func`.

Types

type MultipleCandidates

type MultipleCandidates struct {
	// contains filtered or unexported fields
}

func (MultipleCandidates) Error

func (e MultipleCandidates) Error() string

func (MultipleCandidates) String

func (e MultipleCandidates) String() string

type NotFound

type NotFound struct {
	// contains filtered or unexported fields
}

func (NotFound) Error

func (e NotFound) Error() string

func (NotFound) String

func (e NotFound) String() string

type Terminal

type Terminal struct {
	// The Who's On First ID associated with this terminal.
	WhosOnFirstId int64 `json:"wof:id"`
	// The SFO Museum name/label for this terminal
	SFOMuseumId string `json:"sfomuseum:terminal_id,omityempty"`
	// The name of this terminal.
	Name string `json:"wof:name"`
	// A Who's On First "existential" (`KnownUnknownFlag`) flag signaling the terminal's status
	IsCurrent int64 `json:"mz:is_current"`
	// The list of name:{LANG}_x_preferred names for this terminal
	PreferredNames []string `json:"name:preferred,omitempty"`
	// The list of name:{LANG}_x_variant names for this terminal
	VariantNames []string `json:"name:variant,omitempty"`
}

type Terminal is a struct representing a passenger terminal at SFO.

func CompileTerminalsData

func CompileTerminalsData(ctx context.Context, iterator_uri string, iterator_sources ...string) ([]*Terminal, error)

CompileTerminalsData will generate a list of `Terminal` struct to be used as the source data for an `SFOMuseumLookup` instance. The list of terminal 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 FindCurrentTerminal

func FindCurrentTerminal(ctx context.Context, code string) (*Terminal, error)

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

func FindCurrentTerminalWithLookup

func FindCurrentTerminalWithLookup(ctx context.Context, lookup architecture.Lookup, code string) (*Terminal, error)

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

func FindTerminalsCurrent

func FindTerminalsCurrent(ctx context.Context, code string) ([]*Terminal, error)

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

func FindTerminalsCurrentWithLookup

func FindTerminalsCurrentWithLookup(ctx context.Context, lookup architecture.Lookup, code string) ([]*Terminal, error)

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

func (*Terminal) String

func (g *Terminal) String() string

String() will return the name of the terminal.

type TerminalsLookup

type TerminalsLookup struct {
	architecture.Lookup
}

func (*TerminalsLookup) Append

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

func (*TerminalsLookup) Find

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

type TerminalsLookupFunc

type TerminalsLookupFunc func(context.Context)

func NewLookupFuncWithReader

func NewLookupFuncWithReader(ctx context.Context, r io.ReadCloser) TerminalsLookupFunc

NewLookupWithReader will return an `TerminalsLookupFunc` function instance that, when invoked, will populate an `architecture.Lookup` instance with data stored in `r`. `r` will be closed when the `TerminalsLookupFunc` 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`.

func NewLookupFuncWithTerminals

func NewLookupFuncWithTerminals(ctx context.Context, terminals_list []*Terminal) TerminalsLookupFunc

NewLookupFuncWithTerminals will return an `TerminalsLookupFunc` function instance that, when invoked, will populate an `architecture.Lookup` instance with data stored in `terminals_list`.

Jump to

Keyboard shortcuts

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