Skip to content

GTFSLib

The GTFS library parses public-transport feeds in the General Transit Feed Specification (GTFS) format. Use GTFSLib.Feed to read a feed from a directory or a zip file, then work with its agencies, stops, routes, trips, stop times, calendars and shapes as collections.

Example

string zip = CommonLib.Utilities.GetUploadsPath("gtfs.zip");
GTFSLib.Feed feed = GTFSLib.Feed.ParseFromRemoteZip(zip);
var stops = feed.Stops;

Feed


Properties

Name Data Type
Agencies Collection[GTFSLib.Agency]
Stops Collection[GTFSLib.Stop]
Routes Collection[GTFSLib.Route]
Trips Collection[GTFSLib.Trip]
StopTimes Collection[GTFSLib.StopTime]
Calendars Collection[GTFSLib.Calendar]
Shapes Collection[GTFSLib.Shape]
CalendarDates Collection[GTFSLib.CalendarDate]

Methods

Parse(string Location)

Description

Takes the path to the feed directory, parses the files, and returns a new Feed instance.

Return Type : GTFSLib.Feed

Static : Yes

Parameter Data Type Description
Location string The path to the feed directory

Syntax

GTFSLib.Feed myNewFeed= GTFSLib.Feed.Parse("path/to/feed/directory");

ParseFromRemoteZip(string ZipUrl)

Description

Parses the zip that contains the GTFS feed files and returns a new Feed instance.

Return Type : GTFSLib.Feed

Static : Yes

Parameter Data Type Description
ZipUrl string The path to the Zip

Syntax

string zip = CommonLib.Utilities.GetUploadsPath("gtfs.zip");
GTFSLib.Feed myNewFeed= GTFSLib.Feed.ParseFromRemoteZip(zip);

Agency


Properties

Name Data Type
Id string
Name string
URL string
Timezone string
LanguageCode string
Phone string
FareURL string

Stop


Properties

Name Data Type
Id string
Code string
Name string
Description string
Latitude double
Longitude double
Zone string
Url string
ParentStation string
Timezone string
WheelchairBoarding string
LocationType GTFSLib.LocationType

LocationType


Enumeration.

Value
Stop
Station

Route


Properties

Name Data Type
Id string
AgencyId string
ShortName string
LongName string
Description string
Type GTFSLib.RouteType
Url string
Color int
TextColor int

RouteType


Enumeration.

Value
Tram
SubwayMetro
Rail
Bus
Ferry
CableCar
Gondola
Funicular

Trip


Properties

Name Data Type
Id string
RouteId string
ServiceId string
Headsign string
ShortName string
Direction GTFSLib.DirectionType
BlockId string
ShapeId string
AccessibilityType WheelchairAccessibilityType

DirectionType


Enumeration.

Value
OneDirection
OppositeDirection

AccessibilityType


Enumeration.

Value
NoInformation
SomeAccessibility
NoAccessibility

StopTime


Properties

Name Data Type
TripId string
ArrivalTime GTFSLib.TimeOfDay
DepartureTime GTFSLib.TimeOfDay
StopId string
StopSequence int
PickupType GTFSLib.PickupType
DropOffType GTFSLib.DropOffType
ShapeDistTravelled string

TimeOfDay


Properties

Name Data Type
Hours int
Minutes int
Seconds int
TotalSeconds int

PickupType


Enumeration.

Value
Regular
NoPickup
PhoneForPickup
DriverForPickup

DropOffType


Enumeration.

Value
Regular
NoPickup
PhoneForPickup
DriverForPickup

Calendar


Properties

Name Data Type
ServiceId string
Monday bool
Tuesday bool
Wednesday bool
Thursday bool
Friday bool
Saturday bool
Sunday bool
StartDate DateTime
EndDate DateTime

Methods

CoversDate(DateTime date)

Description

Takes a date as input, and check if the given date is between the calendar start date - end date.

Return Type : bool

Static : No

Parameter Data Type Description
date DateTime The date to be checked

Syntax

GTFSLib.Feed myNewFeed= GTFSLib.Feed.ParseFromRemoteZip(zip);
if(myNewFeed.Calendar.CoversDate(DateTime.Create(2019,12,31)))
{
    return;
}

CalendarDate


Properties

Name Data Type
ServiceId string
Date DateTime
ExceptionType GTFSLib.ExceptionType

ExceptionType


Enumeration.

Value
Added
Removed

Shape


Properties

Name Data Type
Id string
Latitude double
Longitude double
Sequence int
DistanceTravelled double