Documentation ¶
Overview ¶
Package gtfs provides functionality for reading and manipulating General Transit Feed Specification files.
It supports all files and fields described in the GTFS specification.
Index ¶
- Constants
- type Agency
- type BikesAllowed
- type DropoffType
- type Fare
- type FeedInfo
- type GTFS
- type LocationType
- type ParsingOptions
- type PaymentMethod
- type PickupType
- type Route
- type RouteType
- type Service
- type Shape
- type ShapePoint
- type Stop
- type StopTime
- type TimepointType
- type Transfer
- type TransferType
- type Translation
- type Trip
- type WheelchairAccessible
Constants ¶
const DefaultRouteColor = "FFFFFF"
DefaultRouteColor is the default color for a route with no specified color.
const DefaultRouteTextColor = "000000"
DefaultRouteTextColor is the default text color for a route with no specified text color.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agency ¶
type Agency struct { ID string Name string URL string Timezone string Lang string Phone string FareURL string Email string }
An Agency is a single agency from a GTFS file.
Fields correspond directly to columns in agency.txt.
type BikesAllowed ¶
type BikesAllowed int
BikesAllowed indicates whether bikes are allowed on a trip.
const ( // BikesAllowedUnknown means that no information on whether bikes are // allowed is available. BikesAllowedUnknown BikesAllowed = iota // BikesAllowedYes means that at least one bike may be brought on this trip. BikesAllowedYes // BikesAllowedNo means that no bikes are allowed on this trip. BikesAllowedNo )
type DropoffType ¶
type DropoffType int
DropoffType indicates the type of dropoff available at a stop.
const ( // DropoffTypeRegular indicates that regularly scheduled dropoffs are // available. DropoffTypeRegular DropoffType = iota // DropoffTypeNone indicates that no dropoffs are available. DropoffTypeNone // DropoffTypePhoneAgency indicates that riders must phone the transit // agency to schedule dropoffs. DropoffTypePhoneAgency // DropoffTypeCoordinateWithDriver indicates that riders must coordinate // with the vehicle driver to schedule dropoffs. DropoffTypeCoordinateWithDriver )
type Fare ¶
type Fare struct { ID string Price string CurrencyType string PaymentMethod PaymentMethod Transfers uint64 TransferDuration uint64 Routes []*Route OriginZones []string DestinationZones []string ContainsZones []string }
A Fare is a single fare type.
Fields correspond directly to columns in fares.txt.
type FeedInfo ¶
type FeedInfo struct { PublisherName string PublisherURL string Lang string StartDate string EndDate string Version string ContactEmail string ContactURL string }
FeedInfo specifies global information about a GTFS feed.
Fields correspond directly to columns in feed_info.txt.
type GTFS ¶
type GTFS struct { Agencies []*Agency Stops []*Stop Routes []*Route Services []*Service Shapes []*Shape Trips []*Trip Fares []*Fare Transfers []*Transfer FeedInfo FeedInfo Translations []*Translation // contains filtered or unexported fields }
GTFS represents a single GTFS feed.
func Load ¶
Load reads a GTFS feed, which is expected to be contained within a ZIP file, from filePath.
This function loads a GTFS file as permissively as possible (i.e. all errors that can be ignored are ignored). For full control over options used when parsing, use LoadWithOptions instead.
func LoadFromReader ¶
LoadFromReader reads a GTFS feed from a *zip.Reader.
This function loads a GTFS file as permissively as possible (i.e. all errors that can be ignored are ignored). For full control over options used when parsing, use LoadWithOptions instead.
func LoadFromReaderWithOptions ¶
func LoadFromReaderWithOptions(r *zip.Reader, opts ParsingOptions) (*GTFS, error)
LoadFromReaderWithOptions reads a GTFS feed from a *zip.Reader using the specified options when parsing.
func LoadWithOptions ¶
func LoadWithOptions(filePath string, opts ParsingOptions) (*GTFS, error)
LoadWithOptions reads a GTFS feed, which is expected to be contained within a ZIP file, from filePath using the specified options when parsing.
type LocationType ¶
type LocationType int
LocationType specifies the specific type of a stop.
const ( // LocationTypeStop is a stop where passengers board or exit a vehicle. LocationTypeStop LocationType = iota // LocationTypeStation is a station containing at least one stop. LocationTypeStation // LocationTypeStationEntrance is the entrance to a station. LocationTypeStationEntrance )
type ParsingOptions ¶
type ParsingOptions struct {
StrictMode bool
}
ParsingOptions specifies options used when parsing GTFS files.
type PaymentMethod ¶
type PaymentMethod int
A PaymentMethod indicates where fares are paid.
const ( // PaymentMethodOnBoard indicates that fares are paid on board the vehicle. PaymentMethodOnBoard PaymentMethod = iota //PaymentMethodBeforeBoarding indicates that fares are paid prior to // boarding the vehicle. PaymentMethodBeforeBoarding )
type PickupType ¶
type PickupType int
PickupType indicates the type of pickup available at a stop.
const ( // PickupTypeRegular indicates that regularly scheduled pickups are // available. PickupTypeRegular PickupType = iota // PickupTypeNone indicates that no pickups are available. PickupTypeNone // PickupTypePhoneAgency indicates that riders must phone the transit agency // to schedule pickups. PickupTypePhoneAgency // PickupTypeCoordinateWithDriver indicates that riders must coordinate with // the vehicle driver to schedule pickups. PickupTypeCoordinateWithDriver )
type Route ¶
type Route struct { ID string Agency *Agency ShortName string LongName string Description string Type RouteType URL string Color string TextColor string SortOrder uint64 }
A Route is a single route.
Fields correspond directly to columns in routes.txt.
type RouteType ¶
type RouteType int
RouteType specifies the type of vehicles operating on a route.
const ( // RouteTypeNotSpecified indicates that no route type was specified. RouteTypeNotSpecified RouteType = iota // RouteTypeLightRail indicates that the route is a light rail route. RouteTypeLightRail // RouteTypeSubway indicates that the route is a subway or metro route. RouteTypeSubway // RouteTypeRail indicates that the route is an intercity/long-distance rail // route. RouteTypeRail // RouteTypeBus indicates that the route is a bus route. RouteTypeBus // RouteTypeFerry indicates that the route is a ferry route. RouteTypeFerry // RouteTypeCableCar indicates that the route is a cable car route. RouteTypeCableCar // RouteTypeGondola indicates that the route is an aerial gondola route. RouteTypeGondola // RouteTypeFunicular indicates that the route is a funicular route. RouteTypeFunicular // RouteTypeTrolleybus indicates that the route is a trolleybus route. RouteTypeTrolleybus // RouteTypeMonorail indicates that the route is a monorail route. RouteTypeMonorail RouteTypeExtendedRailwayService RouteTypeExtendedHighSpeedRail RouteTypeExtendedLongDistanceRail RouteTypeExtendedInterRegionalRail RouteTypeExtendedCarTransportRail RouteTypeExtendedSleeperRail RouteTypeExtendedRegionalRail RouteTypeExtendedTouristRail RouteTypeExtendedRailShuttle RouteTypeExtendedSuburbanRail RouteTypeExtendedReplacementRail RouteTypeExtendedSpecialRail RouteTypeExtendedLorryTransportRail RouteTypeExtendedAllRail RouteTypeExtendedCrossCountryRail RouteTypeExtendedVehicleTransportRail RouteTypeExtendedRackAndPinionRail RouteTypeExtendedAdditionalRail RouteTypeExtendedCoachService RouteTypeExtendedInternationalCoach RouteTypeExtendedNationalCoach RouteTypeExtendedShuttleCoach RouteTypeExtendedRegionalCoach RouteTypeExtendedSpecialCoach RouteTypeExtendedSightseeingCoach RouteTypeExtendedTouristCoach RouteTypeExtendedCommuterCoach RouteTypeExtendedAllCoach RouteTypeExtendedUrbanRailService RouteTypeExtendedMetro RouteTypeExtendedUnderground RouteTypeExtendedUrbanRail RouteTypeExtendedAllUrbanRail RouteTypeExtendedMonorail RouteTypeExtendedBusService RouteTypeExtendedRegionalBusService RouteTypeExtendedExpressBusService RouteTypeExtendedStoppingBusService RouteTypeExtendedLocalBusService RouteTypeExtendedNightBusService RouteTypeExtendedPostBusService RouteTypeExtendedSpecialNeedsBusService RouteTypeExtendedMobilityBusService RouteTypeExtendedMobilityBusForRegisteredDisabledService RouteTypeExtendedSightseeingBus RouteTypeExtendedShuttleBus RouteTypeExtendedSchoolBus RouteTypeExtendedSchoolAndPublicServiceBus RouteTypeExtendedRailReplacementBusService RouteTypeExtendedDemandAndResponseBusService RouteTypeExtendedAllBusServices RouteTypeExtendedTrolleybusService RouteTypeExtendedTramService RouteTypeExtendedCityTramService RouteTypeExtendedLocalTramService RouteTypeExtendedRegionalTramService RouteTypeExtendedSightseeingTramService RouteTypeExtendedShuttleTramService RouteTypeExtendedAllTramServices RouteTypeExtendedWaterTransportService RouteTypeExtendedAirService RouteTypeExtendedFerryService RouteTypeExtendedAerialLiftService RouteTypeExtendedTelecabinService RouteTypeExtendedCableCarService RouteTypeExtendedElevatorService RouteTypeExtendedChairLiftService RouteTypeExtendedDragLiftService RouteTypeExtendedSmallTelecabinService RouteTypeExtendedAllTelecabinServices RouteTypeExtendedFunicularService RouteTypeExtendedTaxiService RouteTypeExtendedCommunalTaxiService RouteTypeExtendedWaterTaxiService RouteTypeExtendedRailTaxiService RouteTypeExtendedBikeTaxiService RouteTypeExtendedLicensedTaxiService RouteTypeExtendedPrivateHireServiceVehicle RouteTypeExtendedAllTaxiServices RouteTypeExtendedMiscellaneousService RouteTypeExtendedHorseDrawnCarriage )
type Service ¶
type Service struct { ID string Monday bool Tuesday bool Wednesday bool Thursday bool Friday bool Saturday bool Sunday bool StartDate string EndDate string AdditionalDates []string ExceptDates []string }
A Service is a schedule of service over one or more routes.
Fields correspond to columns in calendar.txt and calendar_dates.txt.
type Shape ¶
type Shape struct { ID string Points []*ShapePoint }
A Shape is a collection of points describing a trip's path.
type ShapePoint ¶
A ShapePoint is a single point in a larger shape.
type Stop ¶
type Stop struct { ID string Code string Name string Description string Latitude float64 Longitude float64 ZoneID string URL string LocationType LocationType ParentStation *Stop Timezone string WheelchairBoarding string // TODO: parse me // Extensions: PlatformCode string VehicleType RouteType // contains filtered or unexported fields }
A Stop is a single stop served by an agency referenced in a GTFS feed.
Fields correspond directly to columns in stops.txt.
type StopTime ¶
type StopTime struct { Stop *Stop ArrivalTime string DepartureTime string Sequence uint64 Headsign string PickupType PickupType DropoffType DropoffType ShapeDistanceTraveled float64 Timepoint TimepointType }
StopTime provides details on a specific stop in a trip.
type TimepointType ¶
type TimepointType int
TimepointType specifies whether stop times are exact or approximate.
const ( // TimepointTypeExact means that stop times are exact. TimepointTypeExact TimepointType = iota // TimepointTypeApproximate means that stop times are approximate. TimepointTypeApproximate )
type Transfer ¶
type Transfer struct { From *Stop To *Stop Type TransferType MinimumTransferTime uint64 }
A Transfer is specific transfer between two stops.
Fields correspond to columns in transfers.txt.
type TransferType ¶
type TransferType int
TransferType specifies the specific type of a transfer.
const ( // TransferTypeRecommended indicates a recommended transfer point between // two routes. TransferTypeRecommended TransferType = iota // TransferTypeTimed indicates that departures will wait for arriving // passengers. TransferTypeTimed // TransferTypeMinimumTime indicates that a minimum amount of time is // needed to transfer. // // Transfers with this type will have MinimumTransferTime set. TransferTypeMinimumTime // TransferTypeNone indicates that a transfer between those two stops is not // possible. TransferTypeNone )
type Translation ¶
A Translation is a single translation between an original string and another language.
For example, the following Translation:
Translation{ ID: "station-001", Language: "en", Translation: "City Center", }
would translate "station-001" to "City Center" in English.
Fields correspond directly to columns in translations.txt.
type Trip ¶
type Trip struct { ID string Route *Route Service *Service Shape *Shape Headsign string ShortName string DirectionID string BlockID string WheelchairAccessible WheelchairAccessible BikesAllowed BikesAllowed AbsoluteTimes bool StartTime string EndTime string HeadwaySeconds uint64 ExactTimes bool Stops []*StopTime Exceptional bool }
A Trip is a trip along a route with schedule information.
Fields correspond directly to columns in trips.txt, stop_times.txt, and frequencies.txt.
type WheelchairAccessible ¶
type WheelchairAccessible int
WheelchairAccessible indicates whether a trip is accessible to passengers in wheelchairs.
const ( // WheelchairAccessibleUnknown means that no wheelchair accessibility // information is available. WheelchairAccessibleUnknown WheelchairAccessible = iota // WheelchairAccessibleYes means that at least one passenger in a wheelchair // may be accommodated. WheelchairAccessibleYes // WheelchairAccessibleNo means that no passengers in wheelchairs may be // accommodated. WheelchairAccessibleNo )