gtfs

package module
v0.0.0-...-67835b2 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2018 License: MIT Imports: 7 Imported by: 0

README

gtfs

Parse a GTFS transit feed

Usage

package main

import (
	"github.com/jroyal/gtfs"
	"fmt"
)

func main() {
	feed := gtfs.LoadFromZip("sample-feed.zip")

	fmt.Printf("There are %d stops on %d routes for %s\n", len(feed.Stops), len(feed.Routes), feed.Agencies[0].Name)
}

Limitations

  • Doesn't validate the incoming feed. It just parses it out.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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"`
	TimeZone string `csv:"agency_timezone"`
	Lang     string `csv:"agency_lang"`
	Phone    string `csv:"agency_phone"`
	FareURL  string `csv:"agency_fare_url"`
	Email    string `csv:"agency_email"`
}

Agency is a transit agency that provides data in this feed

type Calendar

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

type CalendarDate

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

type FareAttribute

type FareAttribute struct {
	FareID           string `csv:"fare_id"`
	Price            string `csv:"price"`
	CurrencyType     string `csv:"currency_type"`
	PaymentMethod    int64  `csv:"payment_method"`
	Transfers        int64  `csv:"transfers"`
	AgencyID         string `csv:"agency_id"`
	TransferDuration string `csv:"transfer_duration"`
}

type FareRule

type FareRule struct {
	FareID        string `csv:"fare_id"`
	RouteID       string `csv:"route_id"`
	OriginID      string `csv:"origin_id"`
	DestinationID string `csv:"destination_id"`
	ContainsID    string `csv:"contains_id"`
}

type Feed

type Feed struct {
	FeedInfo       *FeedInfo
	Stops          []*Stop
	Routes         []*Route
	Shapes         []*Shape
	Agencies       []*Agency
	Trips          []*Trip
	StopTimes      []*StopTimes
	Calendar       []*Calendar
	CalendarDates  []*CalendarDate
	FareAttributes []*FareAttribute
	FareRules      []*FareRule
	Frequencies    []*Frequency
	Transfers      []*Transfer
}

Feed contains all the individual parts of a GTFS Feed

func LoadFromDirectory

func LoadFromDirectory(dir string) Feed

LoadFromDirectory takes a directory that should contain all the required GTFS files

func LoadFromZip

func LoadFromZip(archive string) Feed

LoadFromZip takes a zip file that should contain all the required GTFS files

func NewFeed

func NewFeed() Feed

func (*Feed) GetAgency

func (f *Feed) GetAgency() *Agency

GetAgency will return an Agency if there is only one, nil otherwise

type FeedInfo

type FeedInfo struct {
	PublisherName string `csv:"feed_publisher_name"`
	PublisherURL  string `csv:"feed_publisher_url"`
	Lang          string `csv:"feed_lang"`
	StartDate     string `csv:"feed_start_date"`
	EndDate       string `csv:"feed_end_date"`
	Version       string `csv:"feed_version"`
}

type Frequency

type Frequency struct {
	TripID      string `csv:"trip_id"`
	StartTime   string `csv:"start_time"`
	EndTime     string `csv:"end_time"`
	HeadwaySecs string `csv:"headway_secs"`
	ExactTimes  string `csv:"exact_times"`
}

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"`
	Desc      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 int64     `csv:"route_sort_order"`
}

Route is a group of trips that are displayed to riders as a single service

type RouteType

type RouteType int64

RouteType describes the type of transportation used on a route

var (
	// LightRail Used for Tram, Streetcar, Light rail. Any light rail or street level system within a metropolitan area.
	LightRail RouteType = 0
	//Subway Used for subway, metro. Any underground rail system within a metropolitan area.
	Subway RouteType = 1
	// Rail Used for intercity or long-distance travel
	Rail RouteType = 2
	// Bus Used for short- and long-distance bus routes
	Bus RouteType = 3
	// Ferry Used for short- and long-distance boat service
	Ferry RouteType = 4
	//CableCar Used for street-level cable cars where the cable runs beneath the car
	CableCar RouteType = 5
	//Gondola Used for Gondola, Suspended cable car. Typically used for aerial cable cars where the car is suspended from the cable
	Gondola RouteType = 6
	//Funicular Used for any rail system designed for steep inclines
	Funicular RouteType = 7
)

type Shape

type Shape struct {
	ID           string `csv:"shape_id"`
	Latitude     string `csv:"shape_pt_lat"`
	Longitude    string `csv:"shape_pt_lon"`
	Sequence     string `csv:"shape_pt_sequence"`
	DistTraveled string `csv:"shape_dist_traveled"`
}

type Stop

type Stop struct {
	ID           string `csv:"stop_id"`
	Code         string `csv:"stop_code"`
	Name         string `csv:"stop_name"`
	Desc         string `csv:"stop_desc"`
	Latitude     string `csv:"stop_lat"`
	Longitude    string `csv:"stop_lon"`
	ZoneID       string `csv:"zone_id"`
	URL          string `csv:"stop_url"`
	LocationType string `csv:"location_type"`
}

Stop is an individual location where vehicles pick up or drop off passengers

type StopTimes

type StopTimes struct {
	TripID            string `csv:"trip_id"`
	ArrivalTime       string `csv:"arrival_time"`
	DepartureTime     string `csv:"departure_time"`
	StopID            string `csv:"stop_id"`
	StopSequence      string `csv:"stop_sequence"`
	StopHeadsign      string `csv:"stop_headsign"`
	PickupType        int64  `csv:"pickup_type"`
	DropOffType       int64  `csv:"drop_off_type"`
	ShapeDistTraveled string `csv:"shape_dist_traveled"`
	Timepoint         int64  `csv:"timepoint"`
}

type Transfer

type Transfer struct {
	FromStopID      string `csv:"from_stop_id"`
	ToStopID        string `csv:"to_stop_id"`
	TransferType    int64  `csv:"transfer_type"`
	MinTransferTime int64  `csv:"min_transfer_time"`
}

type Trip

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

Jump to

Keyboard shortcuts

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