gtfs

package
v0.0.0-...-f85e0e2 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2024 License: GPL-2.0 Imports: 7 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTypeFromExtended

func GetTypeFromExtended(t int16) int16

Types

type Agency

type Agency struct {
	Id           string
	Name         string
	Url          *url.URL
	Timezone     Timezone
	Lang         LanguageISO6391
	Phone        string
	Fare_url     *url.URL
	Email        *mail.Address
	Attributions []*Attribution
	Translations []*Translation
}

An Agency represents a transit agency in GTFS

type Attribution

type Attribution struct {
	Id                string
	Organization_name string
	Is_producer       bool
	Is_operator       bool
	Is_authority      bool
	Email             *mail.Address
	Url               *url.URL
	Phone             string
}

An Attribution represents attribution parameters

type Date

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

A Date object as used in GTFS

func GetGtfsDateFromTime

func GetGtfsDateFromTime(t time.Time) Date

GetGtfsDateFromTime constructs a GTFS Date object from a Time object

func NewDate

func NewDate(day uint8, month uint8, year uint16) Date

func (Date) Day

func (d Date) Day() uint8

func (Date) GetOffsettedDate

func (d Date) GetOffsettedDate(offset int) Date

GetOffsettedDate returns a date offsetted by a certain number of days

func (Date) GetTime

func (d Date) GetTime() time.Time

GetTime constructs a time object from this date, at 12:00:00 noon

func (Date) IsEmpty

func (d Date) IsEmpty() bool

func (Date) Month

func (d Date) Month() uint8

func (*Date) SetDay

func (d *Date) SetDay(day uint8)

func (*Date) SetYear

func (d *Date) SetYear(year uint16)

func (Date) Year

func (d Date) Year() uint16

type FareAttribute

type FareAttribute struct {
	Id                string
	Price             string
	Currency_type     string
	Payment_method    int
	Transfers         int
	Agency            *Agency
	Transfer_duration int
	Rules             []*FareAttributeRule
}

A FareAttribute is a single fare attribute that applies if certain FareAttributeRules are matched

type FareAttributeRule

type FareAttributeRule struct {
	Route          *Route
	Origin_id      string // connection to Zone_id in Stop
	Destination_id string // connection to Zone_id in Stop
	Contains_id    string // connection to Zone_id in Stop
}

A FareAttributeRule holds rules which describe when a FareAttribute applies

type FeedInfo

type FeedInfo struct {
	Publisher_name string
	Publisher_url  *url.URL
	Lang           string
	Start_date     Date
	End_date       Date
	Version        string
	Contact_email  *mail.Address
	Contact_url    *url.URL
}

FeedInfo holds general information about a GTFS feed

type Frequency

type Frequency struct {
	Start_time   Time
	End_time     Time
	Headway_secs int
	Exact_times  bool
}

A Frequency is used to describe a periodically served trip

type LanguageISO6391

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

A LanguageISO6391 struct describes a language according to the ISO 6391 standard

func NewLanguageISO6391

func NewLanguageISO6391(tofind string) (LanguageISO6391, error)

NewLanguageISO6391 create a new LanguageISO6391 object

func (LanguageISO6391) GetLangString

func (a LanguageISO6391) GetLangString() string

GetLangString returns the two-character string representation of an ISO 6391 language

type Level

type Level struct {
	Id           string
	Index        float32
	Name         string
	Translations []*Translation
}

A Pathway represents a graph of the station layout

type Pathway

type Pathway struct {
	Id                     string
	From_stop              *Stop
	To_stop                *Stop
	Mode                   uint8
	Is_bidirectional       bool
	Length                 float32
	Traversal_time         int
	Stair_count            int
	Max_slope              float32
	Min_width              float32
	Signposted_as          string
	Reversed_signposted_as string
	Translations           []*Translation
}

A Pathway represents a graph of the station layout

type Route

type Route struct {
	Id                  string
	Agency              *Agency
	Short_name          string
	Long_name           string
	Desc                string
	Type                int16
	Url                 *url.URL
	Color               string
	Text_color          string
	Sort_order          int
	Continuous_pickup   int8
	Continuous_drop_off int8
	Attributions        []*Attribution
}

A Route describes a group of trips that are presented to passangers as a single service

type Service

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

A Service object describes exactly on what days a trip is served

func EmptyService

func EmptyService() *Service

func (*Service) Daymap

func (s *Service) Daymap(i int) bool

func (*Service) End_date

func (s *Service) End_date() Date

func (*Service) Equals

func (s *Service) Equals(b *Service) bool

Equals returns true if the service is exactly the same - that is if it is active on exactly the same days

func (*Service) Exceptions

func (s *Service) Exceptions() map[Date]bool

func (*Service) GetExceptionTypeOn

func (s *Service) GetExceptionTypeOn(d Date) int8

GetExceptionTypeOn returns the expection type on a particular day

func (*Service) GetFirstActiveDate

func (s *Service) GetFirstActiveDate() Date

GetFirstActiveDate returns the first active date of this service

func (*Service) GetFirstDefinedDate

func (s *Service) GetFirstDefinedDate() Date

GetFirstDefinedDate returns the first date something is defined (either positively or negatively) in this service

func (*Service) GetLastActiveDate

func (s *Service) GetLastActiveDate() Date

GetLastActiveDate returns the first active date of this service

func (*Service) GetLastDefinedDate

func (s *Service) GetLastDefinedDate() Date

GetLastDefinedDate returns the last date something is defined (either positively or negatively) in this service

func (*Service) Id

func (s *Service) Id() string

func (*Service) IsActiveOn

func (s *Service) IsActiveOn(d Date) bool

IsActiveOn returns true if the service is active on a particular date

func (*Service) IsEmpty

func (d *Service) IsEmpty() bool

func (*Service) RawDaymap

func (s *Service) RawDaymap() uint8

func (*Service) SetDaymap

func (s *Service) SetDaymap(i int, v bool)

func (*Service) SetEnd_date

func (s *Service) SetEnd_date(d Date)

func (*Service) SetExceptionTypeOn

func (s *Service) SetExceptionTypeOn(d Date, t int8)

SetExceptionTypeOn sets the expection type on a particular day

func (*Service) SetExceptions

func (s *Service) SetExceptions(e map[Date]bool)

func (*Service) SetId

func (s *Service) SetId(id string)

func (*Service) SetRawDaymap

func (s *Service) SetRawDaymap(i uint8)

func (*Service) SetStart_date

func (s *Service) SetStart_date(d Date)

func (*Service) Start_date

func (s *Service) Start_date() Date

type Shape

type Shape struct {
	Id     string
	Points ShapePoints
}

A Shape describes the geographical path of one or multiple trips

func (*Shape) String

func (shape *Shape) String() string

Get a string representation of this shape

type ShapePoint

type ShapePoint struct {
	Lat           float32
	Lon           float32
	Sequence      uint32
	Dist_traveled float32
}

A ShapePoint is a single point in a Shape

func (*ShapePoint) HasDistanceTraveled

func (p *ShapePoint) HasDistanceTraveled() bool

HasDistanceTraveled returns true if this ShapePoint has a measurement

func (*ShapePoint) String

func (p *ShapePoint) String() string

Get a string representation of a ShapePoint

type ShapePoints

type ShapePoints []ShapePoint

ShapePoints are multiple ShapePoints

func (ShapePoints) Len

func (shapePoints ShapePoints) Len() int

func (ShapePoints) Less

func (shapePoints ShapePoints) Less(i, j int) bool

func (ShapePoints) Swap

func (shapePoints ShapePoints) Swap(i, j int)

type Stop

type Stop struct {
	Id                  string
	Code                string
	Name                string
	Desc                string
	Lat                 float32
	Lon                 float32
	Location_type       int8
	Wheelchair_boarding int8
	Zone_id             string
	Url                 *url.URL
	Parent_station      *Stop
	Translations        []*Translation
	Level               *Level
	Platform_code       string
	Timezone            Timezone
}

A Stop object describes a single stop location

func (*Stop) HasLatLon

func (s *Stop) HasLatLon() bool

HasLatLon returns true if this Stop has a latitude and longitude

type StopTime

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

A StopTime is a single stop with times on a trip

func (*StopTime) Arrival_time

func (st *StopTime) Arrival_time() Time

func (*StopTime) Continuous_drop_off

func (st *StopTime) Continuous_drop_off() uint8

func (*StopTime) Continuous_pickup

func (st *StopTime) Continuous_pickup() uint8

func (*StopTime) Departure_time

func (st *StopTime) Departure_time() Time

func (*StopTime) Drop_off_type

func (st *StopTime) Drop_off_type() uint8

func (StopTime) HasDistanceTraveled

func (s StopTime) HasDistanceTraveled() bool

HasDistanceTraveled returns true if this ShapePoint has a measurement

func (*StopTime) Headsign

func (st *StopTime) Headsign() *string

func (*StopTime) Pickup_type

func (st *StopTime) Pickup_type() uint8

func (*StopTime) Sequence

func (st *StopTime) Sequence() int

func (*StopTime) SetArrival_time

func (st *StopTime) SetArrival_time(t Time)

func (*StopTime) SetContinuous_drop_off

func (st *StopTime) SetContinuous_drop_off(cdo uint8)

func (*StopTime) SetContinuous_pickup

func (st *StopTime) SetContinuous_pickup(cp uint8)

func (*StopTime) SetDeparture_time

func (st *StopTime) SetDeparture_time(t Time)

func (*StopTime) SetDrop_off_type

func (st *StopTime) SetDrop_off_type(dot uint8)

func (*StopTime) SetHeadsign

func (st *StopTime) SetHeadsign(hs *string)

func (*StopTime) SetPickup_type

func (st *StopTime) SetPickup_type(put uint8)

func (*StopTime) SetSequence

func (st *StopTime) SetSequence(seq int)

func (*StopTime) SetShape_dist_traveled

func (st *StopTime) SetShape_dist_traveled(d float32)

func (*StopTime) SetStop

func (st *StopTime) SetStop(s *Stop)

func (*StopTime) SetTimepoint

func (st *StopTime) SetTimepoint(tp bool)

func (*StopTime) Shape_dist_traveled

func (st *StopTime) Shape_dist_traveled() float32

func (*StopTime) Stop

func (st *StopTime) Stop() *Stop

func (*StopTime) Timepoint

func (st *StopTime) Timepoint() bool

type StopTimes

type StopTimes []StopTime

StopTimes group multiple StopTime objects

func (StopTimes) Len

func (stopTimes StopTimes) Len() int

func (StopTimes) Less

func (stopTimes StopTimes) Less(i, j int) bool

func (StopTimes) Swap

func (stopTimes StopTimes) Swap(i, j int)

type Time

type Time struct {
	Hour   int8
	Minute int8
	Second int8
}

Time is a simple GTFS time type

func (Time) Empty

func (a Time) Empty() bool

Empty returns true if the Time is 'empty' - null

func (Time) Equals

func (a Time) Equals(b Time) bool

Equals returns true if two Time objects are exactly the same

func (Time) GetLocationTime

func (a Time) GetLocationTime(d Date, agency *Agency) time.Time

GetLocationTime returns the time.Time of the gtfs time on a certain date, for a certain agency (which itself holds a timezone)

func (Time) Minus

func (a Time) Minus(b Time) int

Minus subtracts one time from another

func (Time) SecondsSinceMidnight

func (a Time) SecondsSinceMidnight() int

SecondsSinceMidnight returns the number of seconds since midnight

type Timezone

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

A Timezone describes a single timezone in the world

func NewTimezone

func NewTimezone(tofind string) (Timezone, error)

NewTimezone creates a new timezone object

func (Timezone) GetLocation

func (a Timezone) GetLocation() *time.Location

GetLocation constructs a time.Location object from this GTFS timezone

func (Timezone) GetTzString

func (a Timezone) GetTzString() string

GetTzString returns the string representation of a timesone

type TransferKey

type TransferKey struct {
	From_stop  *Stop
	To_stop    *Stop
	From_route *Route
	To_route   *Route
	From_trip  *Trip
	To_trip    *Trip
}

type TransferVal

type TransferVal struct {
	Transfer_type     int
	Min_transfer_time int
}

type Translation

type Translation struct {
	FieldName   string
	Language    LanguageISO6391
	Translation string
	FieldValue  string
}

A Translation holds a single translation for an entity in a GTFS table

type Trip

type Trip struct {
	Route                 *Route
	Service               *Service
	Headsign              *string
	Shape                 *Shape
	Id                    string
	Short_name            *string
	Block_id              *string
	StopTimes             StopTimes
	Frequencies           *[]*Frequency
	Attributions          *[]*Attribution
	Translations          *[]*Translation
	Direction_id          int8
	Wheelchair_accessible int8
	Bikes_allowed         int8
}

A Trip is a single vehicle trip traveling through the network with specific times

Jump to

Keyboard shortcuts

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