api

package
v0.0.0-...-a87e50c Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2025 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SearchStopMaxResults = 25
)

Variables

View Source
var (
	ErrServerUnavailable      = errors.New("server unavailable")
	ErrServerInternalError    = errors.New("internal error")
	ErrServerNotAuthenticated = errors.New("not authenticated")
)

Functions

func SanitiseSeach

func SanitiseSeach(search string) string

used in tests, useless export

Types

type AffectedItems

type AffectedItems struct {
	Lines []AffectedLines `json:"lines"`
	Stops []AffectedStops `json:"stops"`
}

type AffectedLines

type AffectedLines struct {
	ID     string `json:"id"`
	Name   string `json:"name"`
	Number string `json:"number"`
}

type AffectedStops

type AffectedStops struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Type string `json:"type"`
}

type Alert

type Alert struct {
	Content  string        `json:"content"`
	ID       string        `json:"id"`
	Priority string        `json:"priority"`
	URL      string        `json:"url"`
	URLText  string        `json:"urlText"`
	Type     string        `json:"type"`
	Affected AffectedItems `json:"affected"`
}

type Destination

type Destination struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type GtfsShapePoint

type GtfsShapePoint struct {
	ShapeID          string
	Lat              float64
	Lon              float64
	Sequence         int
	DistanceTraveled float64
}

type GtfsStopTime

type GtfsStopTime struct {
	TripID           string
	StopID           string
	Sequence         int
	DistanceTraveled float64
}

type GtfsTrip

type GtfsTrip struct {
	TripID  string
	RouteID string
	ShapeID string
}

type Journey

type Journey struct {
	IsAdditional bool  `json:"isAdditional"` // indicates it's not the "preferred" journey
	Legs         []Leg `json:"legs"`
	Rating       int   `json:"rating"`
}

type JourneyStop

type JourneyStop struct {
	ID                   string    `json:"id"`
	Name                 string    `json:"name"`
	DisassembledName     string    `json:"disassembledName"`
	ArrivalTimePlanned   string    `json:"arrivalTimePlanned"`
	DepartureTimePlanned string    `json:"departureTimePlanned"`
	Coord                []float64 `json:"coord"`
	Type                 string    `json:"type"`
}

type Leg

type Leg struct {
	Origin               Location        `json:"origin"`
	Destination          Location        `json:"destination"`
	Duration             int             `json:"duration"`
	Distance             int             `json:"distance"`
	Transportation       *Transportation `json:"transportation"`
	StopSequence         []JourneyStop   `json:"stopSequence"`
	IsRealtimeControlled bool            `json:"isRealtimeControlled"`
}

type Location

type Location struct {
	ID                     string    `json:"id"`
	Name                   string    `json:"name"`
	DisassembledName       string    `json:"disassembledName"`
	ArrivalTimePlanned     string    `json:"arrivalTimePlanned"`
	ArrivalTimeEstimated   string    `json:"arrivalTimeEstimated"`
	DepartureTimePlanned   string    `json:"departureTimePlanned"`
	DepartureTimeEstimated string    `json:"departureTimeEstimated"`
	Coord                  []float64 `json:"coord"`
	Type                   string    `json:"type"`
}

type Stop

type Stop struct {
	ID           string `json:"id"`
	Name         string `json:"disassembledName"`
	MatchQuality int    `json:"matchQuality"`
	Modes        []int  `json:"modes"`
}

type StopSearchResult

type StopSearchResult struct {
	ID   string
	Name string
	Lat  float64
	Lon  float64
}

type Transportation

type Transportation struct {
	ID               string      `json:"id"`
	Name             string      `json:"name"`
	Number           string      `json:"number"`
	Description      string      `json:"description"`
	DisassembledName string      `json:"disassembledName"`
	Destination      Destination `json:"destination"`
	IconID           int         `json:"iconId"`
}

type TripClient

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

TripClientV1, for v1 of the API

func NewClient

func NewClient(db *sql.DB) *TripClient

func (*TripClient) FindStop

func (tc *TripClient) FindStop(search string) []StopSearchResult

this should never fail

func (*TripClient) FindStopFirstOrPanic

func (tc *TripClient) FindStopFirstOrPanic(search string) StopSearchResult

func (*TripClient) GetCurrentAlerts

func (tc *TripClient) GetCurrentAlerts(ctx context.Context) ([]Alert, error)

gets only current alerts at the current time for the current day

func (*TripClient) GetJourneyLeg

func (tc *TripClient) GetJourneyLeg(originStopID, destStopID string) ([][2]float64, error)

func (*TripClient) TripPlan

func (tc *TripClient) TripPlan(ctx context.Context, origin string, destination string) ([]Journey, error)

Jump to

Keyboard shortcuts

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