gtfs

package
v0.0.0-...-70af2fa Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListGtfsRoutes

func ListGtfsRoutes(gtfs *Gtfs) (routeMap map[string]sort.StringSlice, err error)

ListGtfsRoutes will automatically open the GTFS file from a given source, and try to read routes.txt to extract a mapping route_type → sort.StringSlice[route_id, ...]

Types

type Gtfs

type Gtfs struct {
	Routes   map[string]sort.StringSlice // route_type → [route_id route_id ...]
	Stops    map[string][2]float64       // stop_id → [stop_lat stop_lon]
	Services map[string]bool             // service_id → true (if service is active on g.SyncTime)
	Trips    map[string]routeServicePair // trip_id → [route_id service_id]

	ZipFile  *zip.Reader
	SyncTime time.Time
	// contains filtered or unexported fields
}

Gtfs is an object with access to GTFS data

func NewGtfsFromFile

func NewGtfsFromFile(fname string) (gtfs *Gtfs, err error)

NewGtfsFromFile automatically creates a Gtfs object from a file on disk

func NewGtfsFromReader

func NewGtfsFromReader(r io.Reader) (gtfs *Gtfs, err error)

NewGtfsFromReader automatically creates a Gtfs object from a io.Reader

func NewGtfsFromURL

func NewGtfsFromURL(url string, client *http.Client) (gtfs *Gtfs, err error)

NewGtfsFromURL automatically creates a Gtfs object from a URL

func (*Gtfs) Close

func (g *Gtfs) Close() error

Close closes the underlaying file object

func (*Gtfs) GetZipFileByName

func (g *Gtfs) GetZipFileByName(fileName string) *zip.File

GetZipFileByName will loop over every file in the zip.Reader object, and return the first pointer to zip.File that matches the provided filename. A nil-pointer is returned if no matching file was found.

func (*Gtfs) LoadAll

func (g *Gtfs) LoadAll() error

LoadAll attempts to load all file

func (*Gtfs) LoadRoutes

func (g *Gtfs) LoadRoutes(file *zip.File) (err error)

LoadRoutes loads routes.txt from provided zip.File

func (*Gtfs) LoadServices

func (g *Gtfs) LoadServices(file *zip.File) (err error)

LoadServices loads calendar_dates.txt from provided zip.File

func (*Gtfs) LoadStops

func (g *Gtfs) LoadStops(file *zip.File) (err error)

LoadStops loads stops.txt from provided zip.File

func (*Gtfs) LoadTrips

func (g *Gtfs) LoadTrips(file *zip.File) (err error)

LoadTrips loads trips.txt from provided zip.File

type ReaderAtCloser

type ReaderAtCloser interface {
	io.ReaderAt
	io.Closer
}

ReaderAtCloser is an interface implementing both io.ReaderAt and io.Closer

Jump to

Keyboard shortcuts

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