gtfs

package module
v0.0.0-...-17a4606 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2013 License: MIT Imports: 13 Imported by: 0

README

GoGTFS

GTFS Package and webapp in Go. For now it imports GTFS data in memory, it's fairly fast given that some level of linking is done on the data. A few methods allow to query the data. A webapp is also included, it is intended to be capable of editing the loaded data, but for now only shows the shapes on a google map.

License

GoGTFS is released licensed under the MIT License.

Documentation

Overview

gtfs - Google Transit Feed Specification Reader and Writer for Go

Package quadtree implements methods for a quadtree spatial partitioning data structure.

Code is based on the Wikipedia article http://en.wikipedia.org/wiki/Quadtree.

Adapted from github.com/foolusion/quadtree

Index

Constants

View Source
const (
	CalendarExceptionAddedService   // A value of 1 indicates that service has been added for the specified date.
	CalendarExceptionRemovedService // A value of 2 indicates that service has been removed for the specified date.
)

CalendarDate.ExceptionType possible values:

View Source
const (
	PayementOnBoard        = iota // 0 - Fare is paid on board.
	PayementBeforeBoarding        // 1 - Fare must be paid before boarding.
)

FareAttribute.PaymentMethod possible values:

View Source
const (
	TransfersNone      = iota // 0 - No transfers permitted on this fare.
	TransfersOnce             // 1 - Passenger may transfer once.
	TransfersTwice            // 2 - Passenger may transfer twice.
	TransfersUnlimited        // (empty) - If this field is empty, unlimited transfers are permitted.
)
View Source
const (
	Tram      = iota // 0 - Tram, Streetcar, Light rail. Any light rail or street level system within a metropolitan area.
	Subway           // 1 - Subway, Metro. Any underground rail system within a metropolitan area.
	Rail             // 2 - Rail. Used for intercity or long-distance travel.
	Bus              // 3 - Bus. Used for short- and long-distance bus routes.
	Ferry            // 4 - Ferry. Used for short- and long-distance boat service.
	CableCar         // 5 - Cable car. Used for street-level cable cars where the cable runs beneath the car.
	Gondola          // 6 - Gondola, Suspended cable car. Typically used for aerial cable cars where the car is suspended from the cable.
	Funicular        // 7 - Funicular. Any rail system designed for steep inclines.
)

Route.Type possible values:

View Source
const (
	LocationTypeStop    = iota // 0 - Stop. A location where passengers board or disembark from a transit vehicle.
	LocationTypeStation        // 1 - Station. A physical structure or area that contains one or more stop.
)

Stop.LocationType possible values:

View Source
const (
	PickupRegular     = iota // 0 - Regularly scheduled pickup
	PickupUnavailable        // 1 - No pickup available
	PickupThePhone           // 2 - Must phone agency to arrange pickup
	PickupTheDriver          // 3 - Must coordinate with driver to arrange pickup
)

StopTime.PickupType possible values:

View Source
const (
	DropOffRegular     = iota // 0 - Regularly scheduled drop off
	DropOffUnavailable        // 1 - No drop off available
	DropOffThePhone           // 2 - Must phone agency to arrange drop off
	DropOffTheDriver          // 3 - Must coordinate with driver to arrange drop off
)

StopTime.DropOffType possible values:

View Source
const (
	// 0 or (empty) - This is a recommended transfer point between two routes.
	TransferRecommended = iota

	// 1 - This is a timed transfer point between two routes. The departing vehicle is expected to wait for the arriving one,
	// with sufficient time for a passenger to transfer between routes
	TransferDepartingWaitsForArriving

	// 2 - This transfer requires a minimum amount of time between arrival and departure to ensure a connection.
	// The time required to transfer is specified by min_transfer_time.
	TransferRequiresMinTransferTime

	// 3 - Transfers are not possible between routes at this location.
	TransferImpossible
)

Transfert.TransferType possible values:

View Source
const (
	DirectionOut = iota // 0 - travel in one direction (e.g. outbound travel)
	DirectionIn         //  1 - travel in the opposite direction (e.g. inbound travel)
)

Trip.Direction possible values: (There is no "in" or "out" directions, they symbolize two opposite directions)

Variables

View Source
var AllFiles = []string{"agency.txt", "stops.txt", "routes.txt", "trips.txt", "stop_times.txt", "calendar.txt", "calendar_dates.txt", "fare_attributes.txt", "fare_rules.txt", "shapes.txt", "frequencies.txt", "transfers.txt"}
View Source
var RequiredEitherCalendarFiles = []string{"calendar.txt", "calendar_dates.txt"}
View Source
var RequiredFiles = []string{"agency.txt", "stops.txt", "routes.txt", "trips.txt", "stop_times.txt"}

Functions

func StringDateToTime

func StringDateToTime(date string) (time.Time, error)

func TimeToStringDate

func TimeToStringDate(time *time.Time) string

Types

type AABB

type AABB struct {
	// contains filtered or unexported fields
}

AABB represents an Axis-Aligned bounding box structure with center and half dimension

func NewAABB

func NewAABB(centerX, centerY, halfDimX, halfDimY float64) *AABB

NewAABB creates a new axis-aligned bounding box and returns its address

func (*AABB) ContainsPoint

func (aabb *AABB) ContainsPoint(p *Stop) bool

ContainsPoint returns true when the AABB contains the point given

func (*AABB) IntersectsAABB

func (aabb *AABB) IntersectsAABB(other *AABB) bool

IntersectsAABB returns true when the AABB intersects another AABB

type Agency

type Agency struct {

	// agency_id - Optional. The agency_id field is an ID that uniquely identifies a transit agency.
	// A transit feed may represent data from more than one agency. The agency_id is dataset unique.
	// This field is optional for transit feeds that only contain data for a single agency.
	Id string

	// agency_name - Required. The agency_name field contains the full name of the transit agency. Google Maps will display this name.
	Name string

	// agency_url - Required. The agency_url field contains the URL of the transit agency.
	// The value must be a fully qualified URL that includes http:// or https://, and any special
	// characters in the URL must be correctly escaped. See http://www.w3.org/Addressing/URL/4_URI_Recommentations.html
	// for a description of how to create fully qualified URL values.
	Url string

	// agency_timezone - Required. The agency_timezone field contains the timezone where the transit agency is located.
	// Timezone names never contain the space character but may contain an underscore.
	// Please refer to http://en.wikipedia.org/wiki/List_of_tz_zones for a list of valid values.
	Timezone string

	// agency_lang - Optional. The agency_lang field contains a two-letter ISO 639-1 code for the primary
	// language used by this transit agency. The language code is case-insensitive (both en and EN are accepted).
	// This setting defines capitalization rules and other language-specific settings for all text contained in this transit agency's feed.
	// Please refer to http://www.loc.gov/standards/iso639-2/php/code_list.php for a list of valid values.
	Lang string

	// agency_phone - Optional. The agency_phone field contains a single voice telephone number for the specified agency.
	// This field is a string value that presents the telephone number as typical for the agency's service area.
	// It can and should contain punctuation marks to group the digits of the number.
	// Dialable text (for example, TriMet's "503-238-RIDE") is permitted, but the field must not contain any other descriptive text.
	Phone string
	// contains filtered or unexported fields
}

agency.txt

type Block

type Block string

type Calendar

type Calendar struct {

	// monday - Required. The monday field contains a binary value that indicates whether the service is valid for all Mondays.
	// 	 A value of 1 indicates that service is available for all Mondays in the date range. (The date range is specified using the start_date and end_date fields.)
	// 	 A value of 0 indicates that service is not available on Mondays in the date range.
	// Note: You may list exceptions for particular dates, such as holidays, in the calendar_dates.txt file.
	Monday bool

	// tuesday	- Required. The tuesday field contains a binary value that indicates whether the service is valid for all Tuesdays.
	// 	 A value of 1 indicates that service is available for all Tuesdays in the date range. (The date range is specified using the start_date and end_date fields.)
	// 	 A value of 0 indicates that service is not available on Tuesdays in the date range.
	// Note: You may list exceptions for particular dates, such as holidays, in the calendar_dates.txt file.
	Tuesday bool

	// wednesday - Required. The wednesday field contains a binary value that indicates whether the service is valid for all Wednesdays.
	// 	 A value of 1 indicates that service is available for all Wednesdays in the date range. (The date range is specified using the start_date and end_date fields.)
	// 	 A value of 0 indicates that service is not available on Wednesdays in the date range.
	// Note: You may list exceptions for particular dates, such as holidays, in the calendar_dates.txt file.
	Wednesday bool

	// thursday - Required. The thursday field contains a binary value that indicates whether the service is valid for all Thursdays.
	// 	 A value of 1 indicates that service is available for all Thursdays in the date range. (The date range is specified using the start_date and end_date fields.)
	// 	 A value of 0 indicates that service is not available on Thursdays in the date range.
	// Note: You may list exceptions for particular dates, such as holidays, in the calendar_dates.txt file.
	Thursday bool

	// friday - Required. The friday field contains a binary value that indicates whether the service is valid for all Fridays.
	// 	 A value of 1 indicates that service is available for all Fridays in the date range. (The date range is specified using the start_date and end_date fields.)
	// 	 A value of 0 indicates that service is not available on Fridays in the date range.
	// Note: You may list exceptions for particular dates, such as holidays, in the calendar_dates.txt file
	Friday bool

	// saturday - Required. The saturday field contains a binary value that indicates whether the service is valid for all Saturdays.
	// 	 A value of 1 indicates that service is available for all Saturdays in the date range. (The date range is specified using the start_date and end_date fields.)
	// 	 A value of 0 indicates that service is not available on Saturdays in the date range.
	// Note: You may list exceptions for particular dates, such as holidays, in the calendar_dates.txt file.
	Saturday bool

	// sunday - Required. The sunday field contains a binary value that indicates whether the service is valid for all Sundays.
	// 	 A value of 1 indicates that service is available for all Sundays in the date range. (The date range is specified using the start_date and end_date fields.)
	// 	 A value of 0 indicates that service is not available on Sundays in the date range.
	// Note: You may list exceptions for particular dates, such as holidays, in the calendar_dates.txt file.
	Sunday bool

	// start_date - Required. The start_date field contains the start date for the service.
	// The start_date field's value should be in YYYYMMDD format.
	StartDate int

	// end_date - Required. The end_date field contains the end date for the service. This date is included in the service interval.
	// The end_date field's value should be in YYYYMMDD format.
	EndDate int
	// contains filtered or unexported fields
}

calendar.txt

func (*Calendar) ValidOn

func (c *Calendar) ValidOn(intday int, t *time.Time) bool
func (c *Calendar) ValidOn(date string) bool {
	if stringDayDateComp(c.StartDate, date) <= 0 && stringDayDateComp(c.EndDate, date) >= 0 {

type CalendarDate

type CalendarDate struct {

	// date - Required. The date field specifies a particular date when service availability is different than the norm.
	// You can use the exception_type field to indicate whether service is available on the specified date.
	// The date field's value should be in YYYYMMDD format.
	Date int

	// exception_type - Required. The exception_type indicates whether service is available on the date specified in the date field.
	// 	 A value of 1 indicates that service has been added for the specified date.
	// 	 A value of 2 indicates that service has been removed for the specified date.
	// For example, suppose a route has one set of trips available on holidays and another set of trips available on all other days.
	// You could have one service_id that corresponds to the regular service schedule and another service_id that corresponds to the
	// holiday schedule. For a particular holiday, you would use the calendar_dates file to add the holiday to the holiday service_id
	// and to remove the holiday from the regular service_id schedule.
	// See CalendarException constants
	ExceptionType byte
	// contains filtered or unexported fields
}

calendar_dates.txt This file is optional. The calendar_dates table allows you to explicitly activate or disable service IDs by date. You can use it in two ways. Recommended: Use calendar_dates.txt in conjunction with calendar.txt, where calendar_dates.txt defines any exceptions to the default service categories defined in the calendar.txt file. If your service is generally regular, with a few changes on explicit dates (for example, to accomodate special event services, or a school schedule), this is a good approach. Alternate: Omit calendar.txt, and include ALL dates of service in calendar_dates.txt. If your schedule varies most days of the month, or you want to programmatically output service dates without specifying a normal weekly schedule, this approach may be preferable.

func (*CalendarDate) ExceptionOn

func (cd *CalendarDate) ExceptionOn(intday int) (exceptionalDate, shouldRun bool)
func (cd *CalendarDate) ExceptionOn(date string) (exceptionalDate, shouldRun bool) {
	exceptionalDate, shouldRun = false, false
	if stringDayDateComp(cd.Date, date) == 0 {

type DayRange

type DayRange struct {
	// contains filtered or unexported fields
}

func (*DayRange) Add

func (a *DayRange) Add(b *DayRange)

func (*DayRange) Contains

func (a *DayRange) Contains(b *DayRange) bool

func (*DayRange) Intersects

func (a *DayRange) Intersects(b *DayRange) bool

type FareAttribute

type FareAttribute struct {
	// fare_id - Required. The fare_id field contains an ID that uniquely identifies a fare class. The fare_id is dataset unique.
	Id string

	// price - Required. The price field contains the fare price, in the unit specified by currency_type.
	Price float64

	// currency_type - Required. The currency_type field defines the currency used to pay the fare. Please use the ISO 4217 alphabetical
	// currency codes which can be found at the following URL: http://www.iso.org/iso/en/prods-services/popstds/currencycodeslist.html.
	CurrencyType float64

	// payment_method - Required. The payment_method field indicates when the fare must be paid. Valid values for this field are:
	// 	 0 - Fare is paid on board.
	// 	 1 - Fare must be paid before boarding.
	// See Payment constants
	PaymentMethod byte

	// transfers - Required. The transfers field specifies the number of transfers permitted on this fare. Valid values for this field are:
	// 	 0 - No transfers permitted on this fare.
	// 	 1 - Passenger may transfer once.
	// 	 2 - Passenger may transfer twice.
	// 	 (empty) - If this field is empty, unlimited transfers are permitted.
	// See Transfers constants
	Transfers byte

	// transfer_duration - Optional. The transfer_duration field specifies the length of time in seconds before a transfer expires.
	// When used with a transfers value of 0, the transfer_duration field indicates how long a ticket is valid for a fare where no transfers
	// are allowed. Unless you intend to use this field to indicate ticket validity, transfer_duration should be omitted or empty when transfers
	// is set to 0.
	TransferDuration int
	// contains filtered or unexported fields
}

type FareRule

type FareRule struct {
	// fare_id	- Required. The fare_id field contains an ID that uniquely identifies a fare class. This value is referenced from the fare_attributes.txt file.
	Id string

	// route_id - Optional. The route_id field associates the fare ID with a route. Route IDs are referenced from the
	// routes.txt file. If you have several routes with the same fare attributes, create a row in fare_rules.txt for each route.
	// For example, if fare class "b" is valid on route "TSW" and "TSE", the fare_rules.txt file would contain these rows for the fare class:
	// 		b,TSW
	// 		b,TSE
	RouteId string

	// origin_id - Optional. The origin_id field associates the fare ID with an origin zone ID. Zone IDs are referenced from
	// the stops.txt file. If you have several origin IDs with the same fare attributes, create a row in fare_rules.txt for each origin ID.
	// For example, if fare class "b" is valid for all travel originating from either zone "2" or zone "8", the fare_rules.txt file would
	// contain these rows for the fare class:
	// 		b, , 2
	// 		b, , 8
	OriginId string // Zone

	// destination_id - Optional. The destination_id field associates the fare ID with a destination zone ID. Zone IDs are referenced
	// from the stops.txt file. If you have several destination IDs with the same fare attributes, create a row in fare_rules.txt for
	// each destination ID.
	// For example, you could use the origin_ID and destination_ID fields together to specify that fare class "b" is valid for travel
	// between zones 3 and 4, and for travel between zones 3 and 5, the fare_rules.txt file would contain these rows for the fare class:
	// 		b, , 3,4
	// 		b, , 3,5
	DestinationId string // Zone

	// contains_id - Optional. The contains_id field associates the fare ID with a zone ID, referenced from the stops.txt file.
	// The fare ID is then associated with itineraries that pass through every contains_id zone.
	// For example, if fare class "c" is associated with all travel on the GRT route that passes through zones 5, 6, and 7 the
	// fare_rules.txt would contain these rows:
	// 		c,GRT,,,5
	// 		c,GRT,,,6
	// 		c,GRT,,,7
	// Because all contains_id zones must be matched for the fare to apply, an itinerary that passes through zones 5 and 6 but
	// not zone 7 would not have fare class "c". For more detail, see FareExamples in the GoogleTransitDataFeed project wiki.
	ContainsId string // Zone
	// contains filtered or unexported fields
}

fare_rules.txt This file is optional. The fare_rules table allows you to specify how fares in fare_attributes.txt apply to an itinerary. Most fare structures use some combination of the following rules:

  • Fare depends on origin or destination stations.
  • Fare depends on which zones the itinerary passes through.
  • Fare depends on which route the itinerary uses.

For examples that demonstrate how to specify a fare structure with fare_rules.txt and fare_attributes.txt, see FareExamples in the GoogleTransitDataFeed open source project wiki: http://code.google.com/p/googletransitdatafeed/wiki/FareExamples

type Feed

type Feed struct {
	Agencies map[string]*Agency
	// Stops          map[string]*Stop
	StopCollection
	Routes           map[string]*Route
	Trips            map[string]*Trip
	Services         map[string]*Service
	Shapes           map[string]*Shape
	Calendars        map[string]*Calendar
	CalendarDates    map[string][]*CalendarDate
	Loaded           bool
	StopTimesCount   int
	TranfersCount    int
	FrequenciesCount int
	// contains filtered or unexported fields
}

func NewFeed

func NewFeed(path string) (*Feed, error)

func (*Feed) Load

func (f *Feed) Load() error

func (*Feed) Reload

func (f *Feed) Reload() error

func (*Feed) TripsForDay

func (feed *Feed) TripsForDay(date *time.Time) []*Trip

func (*Feed) TripsForDayAndDayRange

func (feed *Feed) TripsForDayAndDayRange(date *time.Time, dayrange *DayRange) []*Trip

func (*Feed) TripsForDayAndDayRangeAndStop

func (feed *Feed) TripsForDayAndDayRangeAndStop(date *time.Time, dayrange *DayRange, stop *Stop) []*Trip

type Frequency

type Frequency struct {

	// trip_id	- Required. The trip_id contains an ID that identifies a trip on which the specified frequency of service applies.
	// Trip IDs are referenced from the trips.txt file.
	Trip *Trip

	// start_time - Required. The start_time field specifies the time at which service begins with the specified frequency.
	// The time is measured from "noon minus 12h" (effectively midnight, except for days on which daylight savings time changes occur)
	// at the beginning of the service date. For times occurring after midnight, enter the time as a value greater than 24:00:00 in
	// HH:MM:SS local time for the day on which the trip schedule begins. E.g. 25:35:00.
	StartTime uint

	// end_time - Required. The end_time field indicates the time at which service changes to a different frequency (or ceases)
	// at the first stop in the trip. The time is measured from "noon minus 12h" (effectively midnight, except for days on which
	// daylight savings time changes occur) at the beginning of the service date. For times occurring after midnight, enter the
	// time as a value greater than 24:00:00 in HH:MM:SS local time for the day on which the trip schedule begins. E.g. 25:35:00.
	EndTime uint

	// headway_secs - Required. The headway_secs field indicates the time between departures from the same stop (headway) for this
	// trip type, during the time interval specified by start_time and end_time. The headway value must be entered in seconds.
	//
	// Periods in which headways are defined (the rows in frequencies.txt) shouldn't overlap for the same trip, since it's hard to
	// determine what should be inferred from two overlapping headways. However, a headway period may begin at the exact same time
	// that another one ends, for instance:
	// 		A, 05:00:00, 07:00:00, 600
	// 		B, 07:00:00, 12:00:00, 1200
	HeadwaySecs uint

	DayRange
	// contains filtered or unexported fields
}

frequencies.txt The frequencies file is optional. This table is intended to represent schedules that don't have a fixed list of stop times. When trips are defined in frequencies.txt, the trip planner ignores the absolute values of the arrival_time and departure_time fields for those trips in stop_times.txt. Instead, the stop_times table defines the sequence of stops and the time difference between each stop.

type Itinerary

type Itinerary struct {
	From *Stop
	To   *Stop

	MaxTransfers            uint // Default: 3
	MaxDuration             uint // In seconds. Default: 60*60*3 (3 hours)
	MaxWaitDuration         uint // In seconds. Default: 60*15 (15 min)
	DefaultTransferDuration uint // In seconds. Default: 60*5 (5 min)

	Departure *time.Time
	Arrival   *time.Time
	// contains filtered or unexported fields
}

func NewItinerary

func NewItinerary(f *Feed) (i *Itinerary)

func (*Itinerary) Run

func (i *Itinerary) Run()

func (*Itinerary) Walk

func (i *Itinerary) Walk(step *Step, stepped chan *Step, walked chan bool, found chan *Step)

type ParseError

type ParseError struct {
	Message    string
	LineNumber int
	FileName   string
}

func (*ParseError) Error

func (pe *ParseError) Error() string

type Parser

type Parser string

type QuadTree

type QuadTree struct {
	// contains filtered or unexported fields
}

QuadTree represents the quadtree data structure.

func CreateQuadtree

func CreateQuadtree(minLat, maxLat, minLon, maxLon float64) *QuadTree

New creates a new quadtree node that is bounded by boundary and contains node_capacity points.

func NewQuadtree

func NewQuadtree(boundary AABB) *QuadTree

func (*QuadTree) Insert

func (qt *QuadTree) Insert(p *Stop) bool

Insert adds a point to the quadtree. It returns true if it was successful and false otherwise.

func (*QuadTree) SearchArea

func (qt *QuadTree) SearchArea(a *AABB) []*Stop

func (*QuadTree) SearchByProximity

func (qt *QuadTree) SearchByProximity(lat, lng, radius float64) (results []*Stop)

type Route

type Route struct {

	// route_id - Required. The route_id field contains an ID that uniquely identifies a route. The route_id is dataset unique.
	Id string

	// agency_id - Optional. The agency_id field defines an agency for the specified route. This value is referenced from the
	// agency.txt file. Use this field when you are providing data for routes from more than one agency.
	Agency *Agency

	// route_short_name - Required. The route_short_name contains the short name of a route. This will often be a short,
	// abstract identifier like "32", "100X", or "Green" that riders use to identify a route, but which doesn't give any
	// indication of what places the route serves. If the route does not have a short name, please specify a route_long_name
	// and use an empty string as the value for this field.
	// See a Google Maps screenshot highlighting the route_short_name:
	// http://code.google.com/transit/spec/transit_feed_specification.html#transitShortNameScreenshot
	ShortName string

	// route_long_name - Required. The route_long_name contains the full name of a route. This name is generally more
	// descriptive than the route_short_name and will often include the route's destination or stop. If the route does
	// not have a long name, please specify a route_short_name and use an empty string as the value for this field.
	// See a Google Maps screenshot highlighting the route_long_name:
	// http://code.google.com/transit/spec/transit_feed_specification.html#transitLongNameScreenshot
	LongName string

	// route_desc - Optional. The route_desc field contains a description of a route. Please provide useful, quality
	// information. Do not simply duplicate the name of the route. For example, "A trains operate between Inwood-207 St,
	// Manhattan and Far Rockaway-Mott Avenue, Queens at all times. Also from about 6AM until about midnight, additional
	// A trains operate between Inwood-207 St and Lefferts Boulevard (trains typically alternate between Lefferts Blvd and Far Rockaway)."
	Desc string

	// route_type - Required. The route_type field describes the type of transportation used on a route. Valid values for this field are:
	// 		0 - Tram, Streetcar, Light rail. Any light rail or street level system within a metropolitan area.
	// 		1 - Subway, Metro. Any underground rail system within a metropolitan area.
	// 		2 - Rail. Used for intercity or long-distance travel.
	// 		3 - Bus. Used for short- and long-distance bus routes.
	// 		4 - Ferry. Used for short- and long-distance boat service.
	// 		5 - Cable car. Used for street-level cable cars where the cable runs beneath the car.
	// 		6 - Gondola, Suspended cable car. Typically used for aerial cable cars where the car is suspended from the cable.
	// 		7 - Funicular. Any rail system designed for steep inclines.
	// See a Google Maps screenshot highlighting the route_type:
	// http://code.google.com/transit/spec/transit_feed_specification.html#transitRouteTypeScreenshot
	Type byte

	// route_url - Optional. The route_url field contains the URL of a web page about that particular route. This should be
	// different from the agency_url.
	// The value must be a fully qualified URL that includes http:// or https://, and any special characters in the URL must
	// be correctly escaped. See http://www.w3.org/Addressing/URL/4_URI_Recommentations.html for a description of how to
	// create fully qualified URL values.
	Url string

	// route_color	- Optional. In systems that have colors assigned to routes, the route_color field defines a color that
	// corresponds to a route. The color must be provided as a six-character hexadecimal number, for example, 00FFFF. If no
	// color is specified, the default route color is white (FFFFFF).
	// The color difference between route_color and route_text_color should provide sufficient contrast when viewed on a
	// black and white screen. The W3C Techniques for Accessibility Evaluation And Repair Tools document offers a useful
	// algorithm for evaluating color contrast. There are also helpful online tools for choosing contrasting colors, including
	// the snook.ca Color Contrast Check application: http://snook.ca/technical/colour_contrast/colour.html
	Color string

	// route_text_color - Optional. The route_text_color field can be used to specify a legible color to use for text drawn
	// against a background of route_color. The color must be provided as a six-character hexadecimal number, for example,
	// FFD700. If no color is specified, the default text color is black (000000).
	// The color difference between route_color and route_text_color should provide sufficient contrast when viewed on a
	// black and white screen.
	TextColor string
	// contains filtered or unexported fields
}

routes.txt

type Segment

type Segment struct {
	From          *Stop
	To            *Stop
	DepartureTime *time.Time
	ArrivalTime   *time.Time
	Steps         []Step
}

type Service

type Service string

type Shape

type Shape struct {

	// Copy of first ShapePoint in Points
	Id string

	Points []*ShapePoint

	// Copy of Route.Color for json export
	Color string
}

type ShapePoint

type ShapePoint struct {
	// shape_id - Required. The shape_id field contains an ID that uniquely identifies a shape.
	Id string

	// shape_pt_lat - Required. The shape_pt_lat field associates a shape point's latitude with a shape ID.
	// The field value must be a valid WGS 84 latitude. Each row in shapes.txt represents a shape point in your shape definition.
	// For example, if the shape "A_shp" has three points in its definition, the shapes.txt file might contain these rows to define the shape:
	// 		A_shp,37.61956,-122.48161,0
	// 		A_shp,37.64430,-122.41070,6
	// 		A_shp,37.65863,-122.30839,11
	Lat float64

	// shape_pt_lon - Required. The shape_pt_lon field associates a shape point's longitude with a shape ID. The field value must be a
	// valid WGS 84 longitude value from -180 to 180. Each row in shapes.txt represents a shape point in your shape definition.
	// For example, if the shape "A_shp" has three points in its definition, the shapes.txt file might contain these rows to define the shape:
	// 		A_shp,37.61956,-122.48161,0
	// 		A_shp,37.64430,-122.41070,6
	// 		A_shp,37.65863,-122.30839,11
	Lon float64

	// shape_pt_sequence - Required. The shape_pt_sequence field associates the latitude and longitude of a shape point with its sequence
	// order along the shape. The values for shape_pt_sequence must be non-negative integers, and they must increase along the trip.
	// For example, if the shape "A_shp" has three points in its definition, the shapes.txt file might contain these rows to define the shape:
	// 		A_shp,37.61956,-122.48161,0
	// 		A_shp,37.64430,-122.41070,6
	// 		A_shp,37.65863,-122.30839,11
	PointSequence int

	// shape_dist_traveled - Optional. When used in the shapes.txt file, the shape_dist_traveled field positions a shape point as a distance traveled along a shape
	// from the first shape point. The shape_dist_traveled field represents a real distance traveled along the route in units such as feet
	// or kilometers. This information allows the trip planner to determine how much of the shape to draw when showing part of a trip on the map.
	//
	// The values used for shape_dist_traveled must increase along with shape_pt_sequence: they cannot be used to show reverse travel along a route.
	//
	// The units used for shape_dist_traveled in the shapes.txt file must match the units that are used for this field in the stop_times.txt file.
	// For example, if a bus travels along the three points defined above for A_shp, the additional shape_dist_traveled values
	// (shown here in kilometers) would look like this:
	// 		A_shp,37.61956,-122.48161,0,0
	// 		A_shp,37.64430,-122.41070,6,6.8310
	// 		A_shp,37.65863,-122.30839,11,15.8765
	DistanceTraveled float64
	// contains filtered or unexported fields
}

shapes.txt

type Step

type Step struct {
	To       *StopTime // stop time index in trip
	Previous *Step
	Cost     int
	Changes  int
	// contains filtered or unexported fields
}

func (*Step) ToString

func (s *Step) ToString() string

type Stop

type Stop struct {

	// stop_id - Required. The stop_id field contains an ID that uniquely identifies a stop or station.
	// Multiple routes may use the same stop. The stop_id is dataset unique.
	Id string

	// stop_code - Optional. The stop_code field contains short text or a number that uniquely identifies
	// the stop for passengers. Stop codes are often used in phone-based transit information systems or printed
	// on stop signage to make it easier for riders to get a stop schedule or real-time arrival information
	// for a particular stop.
	// The stop_code field should only be used for stop codes that are displayed to passengers.
	// For internal codes, use stop_id. This field should be left blank for stops without a code.
	Code string

	// stop_name - Required. The stop_name field contains the name of a stop or station.
	// Please use a name that people will understand in the local and tourist vernacular.
	Name string

	// stop_desc - Optional. The stop_desc field contains a description of a stop.
	// Please provide useful, quality information. Do not simply duplicate the name of the stop.
	Desc string

	// stop_lat - Required. The stop_lat field contains the latitude of a stop or station.
	// The field value must be a valid WGS 84 latitude.
	Lat float64

	// stop_lon - Required. The stop_lon field contains the longitude of a stop or station.
	// The field value must be a valid WGS 84 longitude value from -180 to 180.
	Lon float64

	// zone_id - Optional. The zone_id field defines the fare zone for a stop ID.
	// Zone IDs are required if you want to provide fare information using fare_rules.txt.
	// If this stop ID represents a station, the zone ID is ignored.
	ZoneId string

	// stop_url - Optional. The stop_url field contains the URL of a web page about a particular stop.
	// This should be different from the agency_url and the route_url fields.
	// The value must be a fully qualified URL that includes http:// or https://, and any special characters
	// in the URL must be correctly escaped. See http://www.w3.org/Addressing/URL/4_URI_Recommentations.html
	// for a description of how to create fully qualified URL values.
	Url string

	// location_type - ptional. The location_type field identifies whether this stop ID represents a stop or station.
	// If no location type is specified, or the location_type is blank, stop IDs are treated as stops. Stations may
	// have different properties from stops when they are represented on a map or used in trip planning.
	// The location type field can have the following values:
	// 		0 or blank - Stop. A location where passengers board or disembark from a transit vehicle.
	// 		1 - Station. A physical structure or area that contains one or more stop.
	LocationType byte

	// parent_station - Optional. For stops that are physically located inside stations, the parent_station field
	// identifies the station associated with the stop. To use this field, stops.txt must also contain a row where
	// this stop ID is assigned location type=1.
	// 	 This stop ID represents...      	This entry's location type...	This entry's parent_station field contains...
	// 	 A stop located inside a station.	0 or blank                   	The stop ID of the station where this stop is located.
	// 	                                 	                             	The stop referenced by parent_station must have location_type=1.
	// 	 A stop located outside a station.	0 or blank                   	A blank value. The parent_station field doesn't apply to this stop.
	// 	 A station.                       	1                            	A blank value. Stations can't contain other stations.
	ParentStationId string

	Transfers map[string]*Transfer

	StopTimes []*StopTime
	// contains filtered or unexported fields
}

stops.txt

func NewStop

func NewStop() *Stop

func (*Stop) DistanceToCoordinate

func (s *Stop) DistanceToCoordinate(lat, lon float64) float64

func (*Stop) NextStopTimes

func (s *Stop) NextStopTimes(time *time.Time, count int) (stopTimes []*StopTime)

func (*Stop) ParentStation

func (s *Stop) ParentStation() *Stop

type StopCollection

type StopCollection struct {
	Stops map[string]*Stop
	// contains filtered or unexported fields
}

func NewStopCollection

func NewStopCollection() StopCollection

func (*StopCollection) Length

func (c *StopCollection) Length() int

func (*StopCollection) RandomStop

func (c *StopCollection) RandomStop() (stopX *Stop)

func (*StopCollection) SetStop

func (c *StopCollection) SetStop(id string, stop *Stop)

func (*StopCollection) Stop

func (c *StopCollection) Stop(id string) (stop *Stop)

func (*StopCollection) StopDistancesByProximity

func (c *StopCollection) StopDistancesByProximity(lat, lng, radius float64) (results StopDistanceResults)

func (*StopCollection) StopsByName

func (c *StopCollection) StopsByName(name string) (results []*Stop)

func (*StopCollection) StopsByProximity

func (c *StopCollection) StopsByProximity(lat, lng, radius float64) (results []*Stop)

type StopDistanceResult

type StopDistanceResult struct {
	Stop     *Stop
	Distance float64
}

type StopDistanceResults

type StopDistanceResults []*StopDistanceResult

func (StopDistanceResults) Len

func (s StopDistanceResults) Len() int

func (StopDistanceResults) Less

func (s StopDistanceResults) Less(i, j int) bool

func (StopDistanceResults) Swap

func (s StopDistanceResults) Swap(i, j int)

type StopTime

type StopTime struct {

	// Required. The trip_id field contains an ID that identifies a trip. This value is referenced from the trips.txt file.
	Trip *Trip

	// arrival_time - Required. The arrival_time specifies the arrival time at a specific stop for a specific trip on a route.
	// The time is measured from "noon minus 12h" (effectively midnight, except for days on which daylight savings time changes occur)
	// at the beginning of the service date. For times occurring after midnight on the service date, enter the time as a value greater
	// than 24:00:00 in HH:MM:SS local time for the day on which the trip schedule begins. If you don't have separate times for arrival
	// and departure at a stop, enter the same value for arrival_time and departure_time.
	//
	// You must specify arrival times for the first and last stops in a trip. If this stop isn't a time point, use an empty string value
	// for the arrival_time and departure_time fields. Stops without arrival times will be scheduled based on the nearest preceding timed
	// stop. To ensure accurate routing, please provide arrival and departure times for all stops that are time points.
	// Do not interpolate stops.
	//
	// Times must be eight digits in HH:MM:SS format (H:MM:SS is also accepted, if the hour begins with 0). Do not pad times with spaces.
	// The following columns list stop times for a trip and the proper way to express those times in the arrival_time field:
	// 		Time         	arrival_time value
	// 		08:10:00 A.M.	08:10:00 or 8:10:00
	// 		01:05:00 P.M.	13:05:00
	// 		07:40:00 P.M.	19:40:00
	// 		01:55:00 A.M.	25:55:00
	//
	// Note: Trips that span multiple dates will have stop times greater than 24:00:00. For example, if a trip begins at 10:30:00 p.m.
	// and ends at 2:15:00 a.m. on the following day, the stop times would be 22:30:00 and 26:15:00. Entering those stop times as 22:30:00
	// and 02:15:00 would not produce the desired results.
	ArrivalTime uint

	// departure_time - Required. The departure_time specifies the departure time from a specific stop for a specific trip on a route.
	// The time is measured from "noon minus 12h" (effectively midnight, except for days on which daylight savings time changes occur)
	// at the beginning of the service date. For times occurring after midnight on the service date, enter the time as a value greater
	// than 24:00:00 in HH:MM:SS local time for the day on which the trip schedule begins. If you don't have separate times for arrival
	// and departure at a stop, enter the same value for arrival_time and departure_time.
	//
	// You must specify departure times for the first and last stops in a trip. If this stop isn't a time point, use an empty string value
	// for the arrival_time and departure_time fields. Stops without arrival times will be scheduled based on the nearest preceding timed
	// stop. To ensure accurate routing, please provide arrival and departure times for all stops that are time points.
	// Do not interpolate stops.
	// Times must be eight digits in HH:MM:SS format (H:MM:SS is also accepted, if the hour begins with 0). Do not pad times with spaces.
	// The following columns list stop times for a trip and the proper way to express those times in the departure_time field:
	// => See ArrivalTime Table and Note.
	DepartureTime uint

	// stop_id - Required. The stop_id field contains an ID that uniquely identifies a stop. Multiple routes may use the same stop.
	// The stop_id is referenced from the stops.txt file. If location_type is used in stops.txt, all stops referenced in stop_times.txt
	// must have location_type of 0.
	// Where possible, stop_id values should remain consistent between feed updates. In other words, stop A with stop_id 1 should have
	// stop_id 1 in all subsequent data updates. If a stop is not a time point, enter blank values for arrival_time and departure_time.
	Stop *Stop

	// stop_sequence - Required. The stop_sequence field identifies the order of the stops for a particular trip. The values for
	// stop_sequence must be non-negative integers, and they must increase along the trip.
	// For example, the first stop on the trip could have a stop_sequence of 1, the second stop on the trip could have a stop_sequence
	// of 23, the third stop could have a stop_sequence of 40, and so on.
	StopSequence uint

	// stop_headsign - Optional. The stop_headsign field contains the text that appears on a sign that identifies the trip's destination
	// to passengers. Use this field to override the default trip_headsign when the headsign changes between stops. If this headsign is
	// associated with an entire trip, use trip_headsign instead.
	// See a Google Maps screenshot highlighting the headsign:
	// http://code.google.com/transit/spec/transit_feed_specification.html#transitTripHeadsignScreenshot
	Headsign string

	// pickup_type - Optional. The pickup_type field indicates whether passengers are picked up at a stop as part of the normal schedule
	// or whether a pickup at the stop is not available. This field also allows the transit agency to indicate that passengers must call
	// the agency or notify the driver to arrange a pickup at a particular stop. Valid values for this field are:
	// 		0 - Regularly scheduled pickup
	// 		1 - No pickup available
	// 		2 - Must phone agency to arrange pickup
	// 		3 - Must coordinate with driver to arrange pickup
	// The default value for this field is 0.
	// See Pickup constants
	PickupType byte

	// drop_off_type - Optional. The drop_off_type field indicates whether passengers are dropped off at a stop as part of the normal
	// schedule or whether a drop off at the stop is not available. This field also allows the transit agency to indicate that passengers
	// must call the agency or notify the driver to arrange a drop off at a particular stop. Valid values for this field are:
	// 		0 - Regularly scheduled drop off
	// 		1 - No drop off available
	// 		2 - Must phone agency to arrange drop off
	// 		3 - Must coordinate with driver to arrange drop off
	// The default value for this field is 0.
	// See DropOff constants
	DropOffType byte

	// shape_dist_traveled - Optional. When used in the stop_times.txt file, the shape_dist_traveled field positions a stop as a distance
	// from the first shape point. The shape_dist_traveled field represents a real distance traveled along the route in units such as feet
	// or kilometers. For example, if a bus travels a distance of 5.25 kilometers from the start of the shape to the stop, the shape_dist_traveled
	// for the stop ID would be entered as "5.25". This information allows the trip planner to determine how much of the shape to draw when showing
	// part of a trip on the map. The values used for shape_dist_traveled must increase along with stop_sequence: they cannot be used to show
	// reverse travel along a route.
	// The units used for shape_dist_traveled in the stop_times.txt file must match the units that are used for this field in the shapes.txt file.
	ShapeDistTraveled float64
	// contains filtered or unexported fields
}

stop_times.txt

type TmpTrace

type TmpTrace struct {
	// contains filtered or unexported fields
}

type Transfer

type Transfer struct {
	// from_stop_id - Required. The from_stop_id field contains a stop ID that identifies a stop or station where a connection
	// between routes begins. Stop IDs are referenced from the stops.txt file. If the stop ID refers to a station that contains
	// multiple stops, this transfer rule applies to all stops in that station.
	FromStopId string

	// to_stop_id - Required. The to_stop_id field contains a stop ID that identifies a stop or station where a connection between
	// routes ends. Stop IDs are referenced from the stops.txt file. If the stop ID refers to a station that contains multiple stops,
	// this transfer rule applies to all stops in that station.
	ToStopId string

	// transfer_type - Required. The transfer_type field specifies the type of connection for the specified (from_stop_id, to_stop_id)
	// pair. Valid values for this field are:
	// 		0 or (empty) - This is a recommended transfer point between two routes.
	//  	1 - This is a timed transfer point between two routes. The departing vehicle is expected to wait for the arriving one,
	// 			with sufficient time for a passenger to transfer between routes
	//  	2 - This transfer requires a minimum amount of time between arrival and departure to ensure a connection. The time required
	// 			to transfer is specified by min_transfer_time.
	//  	3 - Transfers are not possible between routes at this location.
	// See Transfer constants
	TransferType byte

	// min_transfer_time - Optional. When a connection between routes requires an amount of time between arrival and departure
	// (transfer_type=2), the min_transfer_time field defines the amount of time that must be available in an itinerary to permit a
	// transfer between routes at these stops. The min_transfer_time must be sufficient to permit a typical rider to move between
	// the two stops, including buffer time to allow for schedule variance on each route.
	// The min_transfer_time value must be entered in seconds, and must be a non-negative integer.
	MinTransferTime int
	// contains filtered or unexported fields
}

transfers.txt The transfers file is optional. Trip planners normally calculate transfer points based on the relative proximity of stops in each route. For potentially ambiguous stop pairs, or transfers where you want to specify a particular choice, use transfers.txt to define additional rules for making connections between routes.

type Trip

type Trip struct {

	// route_id - Required. The route_id field contains an ID that uniquely identifies a route.
	// This value is referenced from the routes.txt file.
	Route *Route

	// trip_id	- Required. The trip_id field contains an ID that identifies a trip. The trip_id is dataset unique.
	Id string

	// trip_headsign - Optional. The trip_headsign field contains the text that appears on a sign that identifies the
	// trip's destination to passengers. Use this field to distinguish between different patterns of service in the
	// same route. If the headsign changes during a trip, you can override the trip_headsign by specifying values
	// for the the stop_headsign field in stop_times.txt.
	// See a Google Maps screenshot highlighting the headsign:
	// http://code.google.com/transit/spec/transit_feed_specification.html#transitTripHeadsignScreenshot
	Headsign string

	// trip_short_name	- Optional. The trip_short_name field contains the text that appears in schedules and sign boards
	// to identify the trip to passengers, for example, to identify train numbers for commuter rail trips. If riders do
	// not commonly rely on trip names, please leave this field blank.
	// A trip_short_name value, if provided, should uniquely identify a trip within a service day; it should not be used
	// for destination names or limited/express designations.
	ShortName string

	// direction_id - Optional. The direction_id field contains a binary value that indicates the direction of travel for
	// a trip. Use this field to distinguish between bi-directional trips with the same route_id. This field is not used
	// in routing; it provides a way to separate trips by direction when publishing time tables. You can specify names for
	// each direction with the trip_headsign field.
	// 		0 - travel in one direction (e.g. outbound travel)
	// 		1 - travel in the opposite direction (e.g. inbound travel)
	// For example, you could use the trip_headsign and direction_id fields together to assign a name to travel in each
	// direction on trip "1234", the trips.txt file would contain these rows for use in time tables:
	//
	// 		trip_id, ... ,trip_headsign,direction_id
	// 		1234, ... , to Airport,0
	// 		1505, ... , to Downtown,1
	//
	// See DirectionIn/Out constants
	Direction byte

	// block_id - Optional. The block_id field identifies the block to which the trip belongs. A block consists of two
	// or more sequential trips made using the same vehicle, where a passenger can transfer from one trip to the next just
	// by staying in the vehicle. The block_id must be referenced by two or more trips in trips.txt.
	BlockId string

	// shape_id - Optional. The shape_id field contains an ID that defines a shape for the trip. This value is referenced
	// from the shapes.txt file. The shapes.txt file allows you to define how a line should be drawn on the map to represent a trip.
	ShapeId string

	//
	DayRange

	StopTimes []*StopTime

	Frequencies []Frequency
	// contains filtered or unexported fields
}

trips.txt

func (*Trip) AddStopTime

func (t *Trip) AddStopTime(newStopTime *StopTime)

AddStopTime adds StopTime to trip.StopTimes with respect to the stop_sequence order

func (*Trip) HasShape

func (t *Trip) HasShape() bool

func (*Trip) NextStopTimeWithTransfer

func (t *Trip) NextStopTimeWithTransfer(fromstop, after *Stop) (stopTime *StopTime, cost int, doesRun bool)

func (*Trip) RunsAccross

func (t *Trip) RunsAccross(stop *Stop) bool

func (*Trip) RunsFromTo

func (t *Trip) RunsFromTo(fromstop, tostop *Stop) (stopTime *StopTime, cost int, doesRun bool)

func (*Trip) RunsOn

func (t *Trip) RunsOn(date *time.Time) (runs bool)

type Zone

type Zone string

Directories

Path Synopsis
bin

Jump to

Keyboard shortcuts

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