gtfs

package
v0.0.0-...-bb3eb04 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RouteTypeLRT is a route served by an LRT or streetcar
	RouteTypeLRT RouteType = 0
	// RouteTypeSubway is a route served by a subway
	RouteTypeSubway = 1
	// RouteTypeRail is a route served by a heavy rail system
	RouteTypeRail = 2
	// RouteTypeBus is a route served by a bus
	RouteTypeBus = 3
	// RouteTypeFerry is a route served by a ferry
	RouteTypeFerry = 4
	// RouteTypeCableTram is a route served by a cable-driven tram system
	RouteTypeCableTram = 5
	// RouteTypeAerialLift is a route served by an aerial lift system
	RouteTypeAerialLift = 6
	// RouteTypeFunicular is a route served by a funicular system
	RouteTypeFunicular = 7
)
View Source
const (
	// LocationTypeStop is a standard stop
	LocationTypeStop LocationType = 0
	// LocationTypeStation is a transit station
	LocationTypeStation = 1
	// LocationTypeStationEntranceExit is the entrance/exit of a station.
	LocationTypeStationEntranceExit = 2
)
View Source
const (
	// DateFormat is the GTFS-described date format
	DateFormat = "20060102"
)

Variables

View Source
var (
	// ErrInvalidBoolField is returned if a boolean field has invalid data
	ErrInvalidBoolField = errors.New("invalid boolean field supplied")
	// ErrInvalidTimeField is returned if a time field has invalid data
	ErrInvalidTimeField = errors.New("invalid time field supplied")
)
View Source
var (
	// ErrUnknownFileName is returned if an unknown file is encountered during parsing.
	ErrUnknownFileName = errors.New("unknown file name encountered")
)

Functions

This section is empty.

Types

type Agency

type Agency struct {
	ID            string `csv:"agency_id"`
	Name          string `csv:"agency_name"`
	URL           string `csv:"agency_url"`
	TZ            string `csv:"agency_timezone"`
	Language      string `csv:"agency_language"`
	ContactNumber string `csv:"agency_phone"`
	FareURL       string `csv:"agency_fare_url"`
	ContactEmail  string `csv:"agency_email"`
}

Agency represents the transit agency supplying service.

type CSVBool

type CSVBool bool

CSVBool is a CSV marshalable boolean value

func (*CSVBool) MarshalCSV

func (b *CSVBool) MarshalCSV() (string, error)

MarshalCSV marshals the value into a string format

func (*CSVBool) UnmarshalCSV

func (b *CSVBool) UnmarshalCSV(csv string) error

UnmarshalCSV takes the string representation from a CSV file and attempts to convert it to a int32.

type CSVDate

type CSVDate struct {
	time.Time
}

CSVDate is a GTFS date parsed from CSV

func (*CSVDate) MarshalCSV

func (d *CSVDate) MarshalCSV() (string, error)

MarshalCSV marshals the value into a string format

func (*CSVDate) UnmarshalCSV

func (d *CSVDate) UnmarshalCSV(csv string) (err error)

UnmarshalCSV takes the string representation from a CSV file and attempts to convert it to a time.Time.

type CSVFloat

type CSVFloat float64

CSVFloat is a CSV marshalable float64 value

func (CSVFloat) MarshalCSV

func (f CSVFloat) MarshalCSV() (string, error)

MarshalCSV marshals the value into a string format

func (*CSVFloat) UnmarshalCSV

func (f *CSVFloat) UnmarshalCSV(csv string) error

UnmarshalCSV takes the string representation from a CSV file and attempts to convert it to a float64.

type CSVInt

type CSVInt int

CSVInt is a CSV marshalable int32 value

func (*CSVInt) MarshalCSV

func (i *CSVInt) MarshalCSV() (string, error)

MarshalCSV marshals the value into a string format

func (*CSVInt) UnmarshalCSV

func (i *CSVInt) UnmarshalCSV(csv string) error

UnmarshalCSV takes the string representation from a CSV file and attempts to convert it to a int32.

type CSVTime

type CSVTime struct {
	Hour   int
	Minute int
	Second int
}

CSVTime is a GTFS time parsed from CSV

func NewCSVTime

func NewCSVTime(t time.Time) *CSVTime

NewCSVTime creates a new CSVTime from the supplied time.

func (*CSVTime) MarshalCSV

func (t *CSVTime) MarshalCSV() (string, error)

MarshalCSV marshals the value into a string format

func (*CSVTime) String

func (t *CSVTime) String() string

String returns a printable version of this type

func (*CSVTime) UnmarshalCSV

func (t *CSVTime) UnmarshalCSV(csv string) (err error)

UnmarshalCSV takes the string representation from a CSV file and attempts to convert it to a time.Time.

type Calendar

type Calendar struct {
	ServiceID string  `csv:"service_id"`
	Monday    CSVBool `csv:"monday"`
	Tuesday   CSVBool `csv:"tuesday"`
	Wednesday CSVBool `csv:"wednesday"`
	Thursday  CSVBool `csv:"thursday"`
	Friday    CSVBool `csv:"friday"`
	Saturday  CSVBool `csv:"saturday"`
	Sunday    CSVBool `csv:"sunday"`
	StartDate CSVDate `csv:"start_date"`
	EndDate   CSVDate `csv:"end_date"`
}

Calendar is a set of days that the specified service is available.

type CalendarDate

type CalendarDate struct {
	ServiceID     string  `csv:"service_id"`
	Date          CSVDate `csv:"date"`
	ExceptionType string  `csv:"exception_type"`
}

CalendarDate represents a service override on the specified date.

type Dataset

type Dataset struct {
	Agencies     []*Agency
	Stops        []*Stop
	Routes       []*Route
	Trips        []*Trip
	StopTimes    []*StopTime
	Calendar     []*Calendar
	CalendarDate []*CalendarDate
	// contains filtered or unexported fields
}

Dataset represents all the data available in a GTFS-exposed dataset.

func NewDataset

func NewDataset(logger *zap.Logger) *Dataset

NewDataset creates a new dataset structure.

func (*Dataset) LoadFromFSPath

func (ds *Dataset) LoadFromFSPath(ctx context.Context, path string) error

LoadFromFSPath loads the contents of the specified path into this dataset.

func (*Dataset) LoadFromURL

func (ds *Dataset) LoadFromURL(ctx context.Context, url string) error

LoadFromURL loads the contents of the specified URL into this dataset.

type LocationType

type LocationType int

LocationType represents the possible set of location types

func (*LocationType) MarshalCSV

func (lt *LocationType) MarshalCSV() (string, error)

MarshalCSV converts this enum into a string for CSV writing.

func (*LocationType) String

func (lt *LocationType) String() string

String presents the caller with a human readable version of this enum.

func (*LocationType) UnmarshalCSV

func (lt *LocationType) UnmarshalCSV(csv string) error

UnmarshalCSV attempts to convert a string value from a CSV file into the enum value.

type Route

type Route struct {
	ID          string    `csv:"route_id"`
	AgencyID    string    `csv:"agency_id"`
	ShortName   string    `csv:"route_short_name"`
	LongName    string    `csv:"route_long_name"`
	Description string    `csv:"route_desc"`
	Type        RouteType `csv:"route_type"`
	URL         string    `csv:"route_url"`
	Color       string    `csv:"route_color"`
	TextColor   string    `csv:"route_text_color"`
	SortOrder   CSVInt    `csv:"route_sort_order"`
}

Route represents a logical run of a vehicle.

type RouteType

type RouteType int

RouteType represents the possible set of route types

func (*RouteType) MarshalCSV

func (rt *RouteType) MarshalCSV() (string, error)

MarshalCSV converts this enum into a string for CSV writing.

func (*RouteType) String

func (rt *RouteType) String() string

String presents the caller with a human readable version of this enum.

func (*RouteType) UnmarshalCSV

func (rt *RouteType) UnmarshalCSV(csv string) error

UnmarshalCSV attempts to convert a string value from a CSV file into the enum value.

type Stop

type Stop struct {
	ID                 string       `csv:"stop_id"`
	Code               string       `csv:"stop_code"`
	Name               string       `csv:"stop_name"`
	Description        string       `csv:"stop_desc"`
	Latitude           CSVFloat     `csv:"stop_lat"`
	Longitude          CSVFloat     `csv:"stop_lon"`
	ZoneID             string       `csv:"zone_id"`
	StopURL            string       `csv:"stop_url"`
	LocationType       LocationType `csv:"location_type"`
	ParentStation      string       `csv:"parent_station"`
	StopTZ             string       `csv:"stop_timezone"`
	WheelchairBoarding string       `csv:"wheelchair_boarding"`
}

Stop represents a single point that one or more trips may visit.

type StopTime

type StopTime struct {
	TripID                string   `csv:"trip_id"`
	ArrivalTime           CSVTime  `csv:"arrival_time"`
	DepartureTime         CSVTime  `csv:"departure_time"`
	StopID                string   `csv:"stop_id"`
	Sequence              CSVInt   `csv:"stop_sequence"`
	Headsign              string   `csv:"stop_headsign"`
	PickupType            string   `csv:"pickup_type"`
	DropOffType           string   `csv:"drop_off_type"`
	ShapeDistanceTraveled CSVFloat `csv:"shape_dist_traveled"`
	Timepoint             string   `csv:"timepoint"`
}

StopTime represents the time a specific stop is visited on a specific trip.

type Trip

type Trip struct {
	ID                   string `csv:"trip_id"`
	RouteID              string `csv:"route_id"`
	ServiceID            string `csv:"service_id"`
	Headsign             string `csv:"trip_headsign"`
	ShortName            string `csv:"trip_short_name"`
	DirectionID          string `csv:"direction_id"`
	BlockID              string `csv:"block_id"`
	ShapeID              string `csv:"shape_id"`
	WheelchairAccessible string `csv:"wheelchair_accessible"`
	BikesAllowed         string `csv:"bikes_allowed"`
}

Trip contains information about a trip.

Jump to

Keyboard shortcuts

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