Documentation
¶
Index ¶
- Variables
- func SecondsToString(secs int) string
- func StringToSeconds(value string) (int, error)
- func ValidateShapes(shapes []Shape) []error
- func ValidateStopTimes(stoptimes []StopTime) []error
- type Agency
- type BaseEntity
- func (ent *BaseEntity) AddError(err error)
- func (ent *BaseEntity) AddWarning(err error)
- func (ent *BaseEntity) EntityID() string
- func (ent *BaseEntity) Errors() []error
- func (ent *BaseEntity) Extra() map[string]string
- func (ent *BaseEntity) Filename() string
- func (ent *BaseEntity) GetID() int
- func (ent *BaseEntity) SetExtra(key string, value string)
- func (ent *BaseEntity) SetFeedVersionID(fvid int)
- func (ent *BaseEntity) SetID(id int)
- func (ent *BaseEntity) UpdateKeys(emap *EntityMap) error
- func (ent *BaseEntity) Warnings() []error
- type Calendar
- type CalendarDate
- type Entity
- type EntityError
- type EntityFilter
- type EntityMap
- func (emap *EntityMap) Get(efn string, eid string) (string, bool)
- func (emap *EntityMap) GetEntity(ent Entity) (string, bool)
- func (emap *EntityMap) KeysFor(efn string) []string
- func (emap *EntityMap) Set(efn string, oldid string, newid string) error
- func (emap *EntityMap) SetEntity(ent Entity, oldid string, newid string) error
- func (emap *EntityMap) Update(other EntityMap)
- type FareAttribute
- type FareRule
- type Feed
- type FeedAssociatedFeeds
- type FeedAuthorization
- type FeedInfo
- type FeedLanguages
- type FeedLicense
- type FeedUrls
- type FeedVersion
- type Frequency
- type Level
- type LineString
- type OptionalKey
- type OptionalRelationship
- type OptionalTime
- type Pathway
- type Point
- type Polygon
- type Reader
- type Route
- type Service
- type Shape
- type Stop
- func (ent *Stop) Coordinates() [2]float64
- func (ent *Stop) EntityID() string
- func (ent *Stop) EntityKey() string
- func (ent *Stop) Errors() (errs []error)
- func (ent *Stop) Filename() string
- func (ent *Stop) SetCoordinates(p [2]float64)
- func (ent *Stop) TableName() string
- func (ent *Stop) UpdateKeys(emap *EntityMap) error
- func (ent *Stop) Warnings() (errs []error)
- type StopTime
- func (ent *StopTime) AddError(err error)
- func (ent *StopTime) AddWarning(err error)
- func (ent *StopTime) EntityID() string
- func (ent *StopTime) Errors() []error
- func (ent *StopTime) Extra() map[string]string
- func (ent *StopTime) Filename() string
- func (ent *StopTime) GetString(key string) (string, error)
- func (ent *StopTime) SetExtra(key string, value string)
- func (ent *StopTime) SetFeedVersionID(fvid int)
- func (ent *StopTime) SetString(key, value string) error
- func (ent *StopTime) TableName() string
- func (ent *StopTime) UpdateKeys(emap *EntityMap) error
- func (ent *StopTime) Warnings() []error
- type Timestamps
- type Transfer
- type Trip
- type WideTime
- type Writer
Constants ¶
This section is empty.
Variables ¶
var GTFSVERSION = "fec428e9023a8dabb1a23cbd56ba607fe5e3e96c"
GTFSVERSION is the commit for the spec reference.md file.
var VERSION = "v0.7.1"
VERSION is the current software version.
Functions ¶
func SecondsToString ¶
SecondsToString takes seconds-since-midnight and returns a GTFS-style time.
func StringToSeconds ¶
StringToSeconds parses a GTFS-style time and returns seconds since midnight.
func ValidateShapes ¶
ValidateShapes returns errors for an array of shapes.
func ValidateStopTimes ¶
ValidateStopTimes checks if the trip follows GTFS rules.
Types ¶
type Agency ¶
type Agency struct { AgencyID string `csv:"agency_id"` AgencyName string `csv:"agency_name" required:"true"` AgencyURL string `csv:"agency_url" required:"true"` AgencyTimezone string `csv:"agency_timezone" required:"true"` AgencyLang string `csv:"agency_lang"` AgencyPhone string `csv:"agency_phone"` AgencyFareURL string `csv:"agency_fare_url"` AgencyEmail string `csv:"agency_email"` BaseEntity }
Agency agency.txt
type BaseEntity ¶
type BaseEntity struct { Timestamps ID int FeedVersionID int // contains filtered or unexported fields }
BaseEntity provides default methods.
func (*BaseEntity) AddError ¶
func (ent *BaseEntity) AddError(err error)
AddError adds a loading error to the entity, e.g. from a CSV parse failure
func (*BaseEntity) EntityID ¶
func (ent *BaseEntity) EntityID() string
EntityID returns the entity ID.
func (*BaseEntity) Errors ¶
func (ent *BaseEntity) Errors() []error
Errors returns validation errors.
func (*BaseEntity) Extra ¶
func (ent *BaseEntity) Extra() map[string]string
Extra provides any additional fields that were present.
func (*BaseEntity) Filename ¶
func (ent *BaseEntity) Filename() string
Filename returns the filename for this entity.
func (*BaseEntity) GetID ¶ added in v0.7.1
func (ent *BaseEntity) GetID() int
GetID returns the integer ID.
func (*BaseEntity) SetExtra ¶
func (ent *BaseEntity) SetExtra(key string, value string)
SetExtra adds a string key, value pair to the entity's extra fields.
func (*BaseEntity) SetFeedVersionID ¶
func (ent *BaseEntity) SetFeedVersionID(fvid int)
SetFeedVersionID sets the Entity's FeedVersionID.
func (*BaseEntity) UpdateKeys ¶
func (ent *BaseEntity) UpdateKeys(emap *EntityMap) error
UpdateKeys updates entity referencespdates foreign keys based on an EntityMap.
func (*BaseEntity) Warnings ¶
func (ent *BaseEntity) Warnings() []error
Warnings returns validation warnings.
type Calendar ¶
type Calendar struct { ServiceID string `csv:"service_id" required:"true"` Monday int `csv:"monday" required:"true"` Tuesday int `csv:"tuesday" required:"true"` Wednesday int `csv:"wednesday" required:"true"` Thursday int `csv:"thursday" required:"true"` Friday int `csv:"friday" required:"true"` Saturday int `csv:"saturday" required:"true"` Sunday int `csv:"sunday" required:"true"` StartDate time.Time `csv:"start_date" required:"true"` EndDate time.Time `csv:"end_date" required:"true"` Generated bool `db:"generated"` BaseEntity }
Calendar calendars.txt
type CalendarDate ¶
type CalendarDate struct { ServiceID string `csv:"service_id" required:"true"` Date time.Time `csv:"date" required:"true"` ExceptionType int `csv:"exception_type" required:"true"` BaseEntity }
CalendarDate calendar_dates.txt
func (*CalendarDate) Errors ¶
func (ent *CalendarDate) Errors() (errs []error)
Errors for this Entity.
func (*CalendarDate) Filename ¶
func (ent *CalendarDate) Filename() string
Filename calendar_dates.txt
func (*CalendarDate) TableName ¶
func (ent *CalendarDate) TableName() string
TableName gtfs_calendar_dates
func (*CalendarDate) UpdateKeys ¶
func (ent *CalendarDate) UpdateKeys(emap *EntityMap) error
UpdateKeys updates Entity references.
type Entity ¶
type Entity interface { EntityID() string Filename() string Errors() []error Warnings() []error AddError(error) AddWarning(error) SetExtra(string, string) Extra() map[string]string UpdateKeys(*EntityMap) error }
Entity provides an interface for GTFS entities.
type EntityError ¶
type EntityError interface {
Error() string
}
EntityError is an interface for GTFS Errors
type EntityFilter ¶
EntityFilter provides an interface for modifying an entity, e.g. before writing
type EntityMap ¶
type EntityMap struct {
// contains filtered or unexported fields
}
EntityMap stores correspondances between Entity IDs, e.g. StopID -> Stop's integer ID in a database.
type FareAttribute ¶
type FareAttribute struct { FareID string `csv:"fare_id" required:"true"` Price float64 `csv:"price" required:"true"` CurrencyType string `csv:"currency_type" required:"true"` PaymentMethod int `csv:"payment_method" required:"true"` Transfers sql.NullInt32 `csv:"transfers"` // string, empty is meaningful AgencyID OptionalRelationship `csv:"agency_id" ` TransferDuration int `csv:"transfer_duration"` BaseEntity }
FareAttribute fare_attributes.txt
func (*FareAttribute) EntityID ¶
func (ent *FareAttribute) EntityID() string
EntityID returns the ID or FareID.
func (*FareAttribute) EntityKey ¶ added in v0.7.1
func (ent *FareAttribute) EntityKey() string
EntityKey returns the GTFS identifier.
func (*FareAttribute) Errors ¶
func (ent *FareAttribute) Errors() (errs []error)
Errors for this Entity.
func (*FareAttribute) Filename ¶
func (ent *FareAttribute) Filename() string
Filename fare_attributes.txt
func (*FareAttribute) TableName ¶
func (ent *FareAttribute) TableName() string
TableName gtfs_fare_attributes
func (*FareAttribute) UpdateKeys ¶
func (ent *FareAttribute) UpdateKeys(emap *EntityMap) error
UpdateKeys updates Entity references.
type FareRule ¶
type FareRule struct { FareID string `csv:"fare_id" required:"true"` RouteID OptionalRelationship `csv:"route_id" ` OriginID string `csv:"origin_id"` DestinationID string `csv:"destination_id"` ContainsID string `csv:"contains_id"` BaseEntity }
FareRule fare_rules.txt
func (*FareRule) UpdateKeys ¶
UpdateKeys updates Entity references.
type Feed ¶
type Feed struct { ID int `json:"-"` FeedID string `json:"id" db:"onestop_id"` FeedNamespaceID string `json:"feed_namespace_id"` Spec string `json:"spec"` URLs FeedUrls `json:"urls" db:"urls"` AssociatedFeeds FeedAssociatedFeeds `json:"-"` // `json:"associated_feeds"` Languages FeedLanguages `json:"languages,omitempty"` License FeedLicense `json:"license"` Authorization FeedAuthorization `json:"authorization" db:"auth"` OtherIDs map[string]string `json:"other_ids" db:"-"` IDCrosswalk map[string]string `json:"id_crosswalk" db:"-"` File string `json:"-"` // internal DeletedAt OptionalTime `json:"-"` // internal Timestamps `json:"-"` // internal }
Feed listed in a parsed DMFR file
type FeedAssociatedFeeds ¶
FeedAssociatedFeeds .
func (*FeedAssociatedFeeds) Scan ¶
func (a *FeedAssociatedFeeds) Scan(value interface{}) error
Scan .
type FeedAuthorization ¶
type FeedAuthorization struct { Type string `json:"type,omitempty"` // ["header", "basic_auth", "query_param", "path_segment"] ParamName string `json:"param_name,omitempty"` InfoURL string `json:"info_url,omitempty"` }
FeedAuthorization contains details about how to access a Feed.
type FeedInfo ¶
type FeedInfo struct { FeedPublisherName string `csv:"feed_publisher_name" required:"true"` FeedPublisherURL string `csv:"feed_publisher_url" required:"true"` FeedLang string `csv:"feed_lang" required:"true"` FeedStartDate OptionalTime `csv:"feed_start_date"` FeedEndDate OptionalTime `csv:"feed_end_date"` FeedVersion string `csv:"feed_version" db:"feed_version_name"` BaseEntity }
FeedInfo feed_info.txt
type FeedLicense ¶
type FeedLicense struct { SpdxIdentifier string `json:"spdx_identifier,omitempty"` URL string `json:"url,omitempty"` UseWithoutAttribution string `json:"use_without_attribution,omitempty"` CreateDerivedProduct string `json:"create_derived_product,omitempty"` RedistributionAllowed string `json:"redistribution_allowed,omitempty"` CommercialUseAllowed string `json:"commercial_use_allowed,omitempty"` AttributionText string `json:"attribution_text,omitempty"` AttributionInstructions string `json:"attribution_instructions,omitempty"` }
FeedLicense describes the license and usage information for a Feed.
type FeedUrls ¶
type FeedUrls struct { StaticCurrent string `json:"static_current,omitempty"` StaticHistoric []string `json:"static_historic,omitempty"` StaticPlanned string `json:"static_planner,omitempty"` RealtimeVehiclePositions string `json:"realtime_vehicle_positions,omitempty"` RealtimeTripUpdates string `json:"realtime_trip_updates,omitempty"` RealtimeAlerts string `json:"realtime_alerts,omitempty"` }
FeedUrls contains URL values for a Feed.
type FeedVersion ¶
type FeedVersion struct { ID int FeedID int FeedType string SHA1 string SHA1Dir string File string URL string EarliestCalendarDate time.Time LatestCalendarDate time.Time FetchedAt time.Time Timestamps }
FeedVersion represents a single GTFS data source.
func NewFeedVersionFromReader ¶
func NewFeedVersionFromReader(reader Reader) (FeedVersion, error)
NewFeedVersionFromReader returns a FeedVersion from a Reader.
func (*FeedVersion) TableName ¶
func (ent *FeedVersion) TableName() string
TableName sets the table name prefix.
type Frequency ¶
type Frequency struct { TripID string `csv:"trip_id" required:"true"` StartTime WideTime `csv:"start_time" required:"true"` EndTime WideTime `csv:"end_time" required:"true"` HeadwaySecs int `csv:"headway_secs" required:"true"` ExactTimes int `csv:"exact_times"` BaseEntity }
Frequency frequencies.txt
func (*Frequency) RepeatCount ¶ added in v0.7.1
RepeatCount returns the number of times this trip will be repeated.
func (*Frequency) UpdateKeys ¶
UpdateKeys updates Entity references.
type Level ¶
type Level struct { LevelID string `csv:"level_id" required:"true"` LevelIndex float64 `csv:"level_index" required:"true"` LevelName string `csv:"level_name"` BaseEntity }
Level levels.txt
type LineString ¶
type LineString struct { Valid bool geom.LineString }
LineString is an EWKB/SL encoded LineString
func NewLineStringFromFlatCoords ¶
func NewLineStringFromFlatCoords(coords []float64) LineString
NewLineStringFromFlatCoords returns a new LineString from flat (3) coordinates
func (LineString) MarshalGQL ¶ added in v0.7.2
func (g LineString) MarshalGQL(w io.Writer)
MarshalGQL implements the graphql.Marshaler interface
func (*LineString) UnmarshalGQL ¶ added in v0.7.2
func (g *LineString) UnmarshalGQL(v interface{}) error
UnmarshalGQL implements the graphql.Unmarshaler interface
type OptionalRelationship ¶
OptionalRelationship is a nullable foreign key constraint, similar to sql.NullString
func (*OptionalRelationship) Int ¶
func (r *OptionalRelationship) Int() int
Int try to convert key to int
func (*OptionalRelationship) IsZero ¶
func (r *OptionalRelationship) IsZero() bool
IsZero returns if this is a zero value.
func (*OptionalRelationship) Scan ¶
func (r *OptionalRelationship) Scan(src interface{}) error
Scan implements sql.Scanner
func (*OptionalRelationship) String ¶
func (r *OptionalRelationship) String() string
type OptionalTime ¶
OptionalTime is a nullable time, but can scan strings
func (*OptionalTime) IsZero ¶
func (r *OptionalTime) IsZero() bool
IsZero returns if this is a zero value.
func (*OptionalTime) Scan ¶
func (r *OptionalTime) Scan(src interface{}) error
Scan implements sql.Scanner
func (*OptionalTime) String ¶
func (r *OptionalTime) String() string
type Pathway ¶
type Pathway struct { PathwayID string `csv:"pathway_id" required:"true"` FromStopID string `csv:"from_stop_id" required:"true"` ToStopID string `csv:"to_stop_id" required:"true"` PathwayMode int `csv:"pathway_mode" required:"true" min:"1" max:"7"` IsBidirectional int `csv:"is_bidirectional" required:"true" min:"0" max:"1"` Length float64 `csv:"length" min:"0"` TraversalTime int `csv:"traversal_time" min:"0"` StairCount int `csv:"stair_count"` MaxSlope float64 `csv:"max_slope"` MinWidth float64 `csv:"min_width"` SignpostedAs string `csv:"signposted_as"` ReverseSignpostedAs string `csv:"reversed_signposted_as"` BaseEntity }
Pathway pathways.txt
func (*Pathway) UpdateKeys ¶
UpdateKeys updates Entity references.
type Point ¶
Point is an EWKB/SL encoded point
func (Point) MarshalGQL ¶ added in v0.7.2
MarshalGQL implements the graphql.Marshaler interface
func (*Point) UnmarshalGQL ¶ added in v0.7.2
UnmarshalGQL implements the graphql.Unmarshaler interface
type Polygon ¶ added in v0.7.2
Polygon is an EWKB/SL encoded Polygon
func (Polygon) MarshalGQL ¶ added in v0.7.2
MarshalGQL implements the graphql.Marshaler interface
func (*Polygon) UnmarshalGQL ¶ added in v0.7.2
UnmarshalGQL implements the graphql.Unmarshaler interface
type Reader ¶
type Reader interface { Open() error Close() error ValidateStructure() []error StopTimesByTripID(...string) chan []StopTime // Entities ReadEntities(c interface{}) error Stops() chan Stop StopTimes() chan StopTime Agencies() chan Agency Calendars() chan Calendar CalendarDates() chan CalendarDate FareAttributes() chan FareAttribute FareRules() chan FareRule FeedInfos() chan FeedInfo Frequencies() chan Frequency Routes() chan Route Shapes() chan Shape Transfers() chan Transfer Pathways() chan Pathway Levels() chan Level Trips() chan Trip }
Reader defines an interface for reading entities from a GTFS feed.
type Route ¶
type Route struct { RouteID string `csv:"route_id" required:"true"` AgencyID string `csv:"agency_id"` RouteShortName string `csv:"route_short_name"` RouteLongName string `csv:"route_long_name"` RouteDesc string `csv:"route_desc"` RouteType int `csv:"route_type" required:"true"` RouteURL string `csv:"route_url"` RouteColor string `csv:"route_color"` RouteTextColor string `csv:"route_text_color"` RouteSortOrder int `csv:"route_sort_order"` BaseEntity }
Route routes.txt
func (*Route) UpdateKeys ¶
UpdateKeys updates Entity references.
type Service ¶
type Service struct { Calendar // contains filtered or unexported fields }
Service is a Calendar / CalendarDate union.
func NewService ¶
func NewService(c Calendar, cds ...CalendarDate) *Service
NewService returns a new Service.
func NewServicesFromReader ¶
NewServicesFromReader returns
func (*Service) AddCalendarDate ¶
func (s *Service) AddCalendarDate(cd CalendarDate)
AddCalendarDate adds a service exception.
type Shape ¶
type Shape struct { ShapeID string `csv:"shape_id" required:"true"` ShapePtLat float64 `csv:"shape_pt_lat" db:"-" required:"true"` ShapePtLon float64 `csv:"shape_pt_lon" db:"-" required:"true"` ShapePtSequence int `csv:"shape_pt_sequence" db:"-" required:"true"` ShapeDistTraveled float64 `csv:"shape_dist_traveled" db:"-"` Geometry LineString `db:"geometry"` Generated bool `db:"generated"` BaseEntity }
Shape shapes.txt
func NewShapeFromShapes ¶
NewShapeFromShapes takes Shapes with single points and returns a Shape with linestring geometry. Any errors from the input errors, or errors such as duplicate sequences, are added as entity errors.
type Stop ¶
type Stop struct { StopID string `csv:"stop_id" required:"true"` StopName string `csv:"stop_name"` // conditionally required StopCode string `csv:"stop_code"` StopDesc string `csv:"stop_desc"` StopLat float64 `csv:"stop_lat" db:"-"` // required handled below StopLon float64 `csv:"stop_lon" db:"-"` ZoneID string `csv:"zone_id"` StopURL string `csv:"stop_url"` LocationType int `csv:"location_type"` ParentStation OptionalRelationship `csv:"parent_station"` StopTimezone string `csv:"stop_timezone"` WheelchairBoarding int `csv:"wheelchair_boarding"` LevelID OptionalRelationship `csv:"level_id"` Geometry Point `db:"geometry"` BaseEntity }
Stop stops.txt
func (*Stop) Coordinates ¶
Coordinates returns the stop lon,lat as a [2]float64
func (*Stop) SetCoordinates ¶
SetCoordinates takes a [2]float64 and sets the Stop's lon,lat
func (*Stop) UpdateKeys ¶
UpdateKeys updates Entity references.
type StopTime ¶
type StopTime struct { TripID string `csv:"trip_id"` ArrivalTime int `csv:"arrival_time" ` DepartureTime int `csv:"departure_time" ` StopID string `csv:"stop_id" required:"true"` StopSequence int `csv:"stop_sequence" required:"true" min:"0"` StopHeadsign sql.NullString `csv:"stop_headsign"` PickupType sql.NullInt32 `csv:"pickup_type" min:"0" max:"3"` DropOffType sql.NullInt32 `csv:"drop_off_type" min:"0" max:"3"` ShapeDistTraveled sql.NullFloat64 `csv:"shape_dist_traveled" min:"0"` Timepoint sql.NullInt32 `csv:"timepoint" min:"0" max:"1"` Interpolated sql.NullInt32 // interpolated times: 0 for provided, 1 interpolated // TODO: 1 for shape, 2 for straight-line FeedVersionID int // contains filtered or unexported fields }
StopTime stop_times.txt
func (*StopTime) AddError ¶ added in v0.7.1
AddError adds a loading error to the entity, e.g. from a CSV parse failure
func (*StopTime) AddWarning ¶ added in v0.7.1
AddWarning .
func (*StopTime) SetExtra ¶ added in v0.7.1
SetExtra adds a string key, value pair to the entity's extra fields.
func (*StopTime) SetFeedVersionID ¶ added in v0.7.1
SetFeedVersionID sets the Entity's FeedVersionID.
func (*StopTime) UpdateKeys ¶
UpdateKeys updates Entity references.
type Timestamps ¶
Timestamps .
func (*Timestamps) UpdateTimestamps ¶
func (ent *Timestamps) UpdateTimestamps()
UpdateTimestamps initializes or updates CreatedAt / UpdatedAt
type Transfer ¶
type Transfer struct { FromStopID string `csv:"from_stop_id" required:"true"` ToStopID string `csv:"to_stop_id" required:"true"` TransferType int `csv:"transfer_type" required:"true"` MinTransferTime sql.NullInt64 `csv:"min_transfer_time"` BaseEntity }
Transfer transfers.txt
func (*Transfer) UpdateKeys ¶
UpdateKeys updates entity references.
type Trip ¶
type Trip struct { RouteID string `csv:"route_id" required:"true"` ServiceID string `csv:"service_id" required:"true"` TripID string `csv:"trip_id" required:"true"` TripHeadsign string `csv:"trip_headsign"` TripShortName string `csv:"trip_short_name"` DirectionID int `csv:"direction_id"` BlockID string `csv:"block_id"` ShapeID OptionalRelationship `csv:"shape_id"` WheelchairAccessible int `csv:"wheelchair_accessible"` BikesAllowed int `csv:"bikes_allowed"` StopPatternID int JourneyPatternID string JourneyPatternOffset int BaseEntity }
Trip trips.txt
func (*Trip) UpdateKeys ¶
UpdateKeys updates Entity references.
type WideTime ¶
WideTime handles seconds since midnight, allows >24 hours.
func NewWideTime ¶
NewWideTime converts the csv string to a WideTime.
func (WideTime) MarshalGQL ¶ added in v0.7.2
MarshalGQL implements the graphql.Marshaler interface
func (*WideTime) UnmarshalGQL ¶ added in v0.7.2
UnmarshalGQL implements the graphql.Unmarshaler interface
Source Files
¶
- entitymap.go
- feed.go
- feed_version.go
- geom.go
- gtfs_agency.go
- gtfs_calendar.go
- gtfs_calendar_date.go
- gtfs_entity.go
- gtfs_fare_attribute.go
- gtfs_fare_rule.go
- gtfs_feed_info.go
- gtfs_frequency.go
- gtfs_level.go
- gtfs_pathway.go
- gtfs_route.go
- gtfs_shape.go
- gtfs_stop.go
- gtfs_stop_time.go
- gtfs_transfer.go
- gtfs_trip.go
- optional.go
- reader.go
- service.go
- tl.go
- widetime.go
- writer.go