gtfs

package module
v0.0.0-...-8ab50a6 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2016 License: MIT Imports: 8 Imported by: 0

README

Go.GTFS

Simple Go library for loading and using static GTFS data.


GoDoc Go Report Card


Install with:

go get "github.com/DanielOaks/go.gtfs"

Use with:

import "github.com/DanielOaks/go.gtfs"

Examples

Examples assume you have directory called sf_muni containing GTFS files.

feed := gtfs.Load("sf_muni")
route := feed.RouteByShortName("N")
coords := route.Shapes()[0].Coords

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CalendarEntry

type CalendarEntry struct {
	ServiceID string
	Days      []string
}

type Coord

type Coord struct {
	Lat float64
	Lon float64
	Seq int
}

Coord represents a coordinate.

type CoordBySeq

type CoordBySeq []Coord

CoordBySeq is used to sort Coords by their sequence number.

func (CoordBySeq) Len

func (a CoordBySeq) Len() int

func (CoordBySeq) Less

func (a CoordBySeq) Less(i, j int) bool

func (CoordBySeq) Swap

func (a CoordBySeq) Swap(i, j int)

type Feed

type Feed struct {
	Dir             string
	Routes          map[string]*Route
	Shapes          map[string]*Shape
	Stops           map[string]*Stop
	Trips           map[string]*Trip
	CalendarEntries map[string]CalendarEntry
}

Feed represents a collection of GTFS information.

func Load

func Load(feedPath string, loadStopTimes bool) Feed

Load retrieves data from the given directory path and returns a Feed containing that data.

func (Feed) Calendar

func (feed Feed) Calendar() []string

func (*Feed) RouteByShortName

func (feed *Feed) RouteByShortName(shortName string) *Route

RouteByShortName searches for and returns a route based on its short name, if it exists.

type Headsign

type Headsign struct {
	Direction string
	Text      string
}

Headsign is the text representing a trip that appears on a sign, such as a bus or train display.

type Route

type Route struct {
	ID          string
	AgencyID    *string
	ShortName   string
	LongName    string
	Description *string
	VehicleType RouteType
	URL         *string
	Color       *string
	TextColor   *string
	Trips       []*Trip
}

Route represents a single "line", and is made up of one or more trips.

func (Route) Headsigns

func (route Route) Headsigns() []string

Headsigns returns the two headsigns for this route.

func (Route) LongestShape

func (route Route) LongestShape() *Shape

LongestShape returns the longest shape in the route.

func (Route) Shapes

func (route Route) Shapes() []*Shape

Shapes returns all shapes for a route.

func (Route) Stops

func (route Route) Stops() []*Stop

Stops returns all the stops on this route.

type RouteType

type RouteType int

RouteType describes the type of vehicle uses a particular route.

const (
	LightRail RouteType = 0
	Subway    RouteType = 1
	Rail      RouteType = 2
	Bus       RouteType = 3
	Ferry     RouteType = 4
	CableCar  RouteType = 5
	Gondola   RouteType = 6
	Funicular RouteType = 7
)

type Shape

type Shape struct {
	ID     string
	Coords []Coord
}

Shape describes the physical path that a vehicle takes along a Trip.

type Stop

type Stop struct {
	ID    string
	Name  string
	Coord Coord
}

Stop represents a location where vehicles stop to pick up or drop off passengers.

type StopTime

type StopTime struct {
	Stop *Stop
	Trip *Trip
	Time int
	Seq  int
}

StopTime defines when a vehicle arrives at a location, how long it stays there, and when it departs.

type StopTimeBySeq

type StopTimeBySeq []StopTime

StopTimeBySeq is used to sort StopTimes by their sequence number.

func (StopTimeBySeq) Len

func (a StopTimeBySeq) Len() int

func (StopTimeBySeq) Less

func (a StopTimeBySeq) Less(i, j int) bool

func (StopTimeBySeq) Swap

func (a StopTimeBySeq) Swap(i, j int)

type Trip

type Trip struct {
	ID        string
	Shape     *Shape
	Route     *Route
	Service   string
	Direction string
	Headsign  string

	// may not be loaded
	StopTimes []StopTime
}

Trip reprents a journey taken by a vehicle through stops.

Jump to

Keyboard shortcuts

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