metar

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoASCIIString    = &FormatError{Wrapping: errors.New("the given string has non-ASCII characters")}
	ErrMETARIncomplete  = &FormatError{Wrapping: errors.New("the METAR is incomplete (end of string reached before time was found)")}
	ErrInvalidMETARTime = &FormatError{Wrapping: errors.New("the METAR's issuing time is formatted incorrectly (expected 'ddddddZ')")}
)

Functions

This section is empty.

Types

type Filter

type Filter struct {
	StationID    *string
	IssuedBefore *int64
	IssuedAfter  *int64
}

Filter is used to query METARs based on a filter

type FormatError

type FormatError struct {
	Wrapping error
	Index    int
}

FormatError represents an error in a METAR format

func (*FormatError) Error

func (err *FormatError) Error() string

type METAR

type METAR struct {
	ID        uuid.UUID `json:"id"`
	StationID string    `json:"station_id"`
	IssuedAt  int64     `json:"issued_at"`
	Raw       string    `json:"raw"`
}

METAR represents a stored METAR data point

func OfString

func OfString(raw string) (*METAR, error)

OfString tries to decode a raw METAR string into a METAR object. This method is no replacement to a fully-featured METAR decoder & validator as it only reads and validates the METAR until the timestamp was decoded successfully.

type Repository

type Repository interface {
	// GetByFilter retrieves multiple METARs following a filter, ordered by their issuing date (descending).
	// If limit <= 0, a default limit value of 10 is used.
	GetByFilter(ctx context.Context, filter *Filter, limit uint64) ([]*METAR, uint64, error)

	// GetByID retrieves a METAR by its ID
	GetByID(ctx context.Context, id uuid.UUID) (*METAR, error)

	// Create creates new METARs based on their raw text representation.
	// All raw strings are sanitized (leading and trailing spaces are trimmed).
	// This method also returns the indexes of the METARs that already exist in the database and thus were not inserted.
	Create(ctx context.Context, raw []string) ([]*METAR, []uint, error)

	// Delete deletes a METAR by its ID
	Delete(ctx context.Context, id uuid.UUID) error
}

Repository defines the METAR repository API

Jump to

Keyboard shortcuts

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