tl

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2021 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GTFSVERSION = "fec428e9023a8dabb1a23cbd56ba607fe5e3e96c"

GTFSVERSION is the commit for the spec reference.md file.

View Source
var VERSION = "v0.7.1"

VERSION is the current software version.

Functions

func SecondsToString

func SecondsToString(secs int) string

SecondsToString takes seconds-since-midnight and returns a GTFS-style time.

func StringToSeconds

func StringToSeconds(value string) (int, error)

StringToSeconds parses a GTFS-style time and returns seconds since midnight.

func ValidateShapes

func ValidateShapes(shapes []Shape) []error

ValidateShapes returns errors for an array of shapes.

func ValidateStopTimes

func ValidateStopTimes(stoptimes []StopTime) []error

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

func (*Agency) EntityID

func (ent *Agency) EntityID() string

EntityID returns the ID or AgencyID.

func (*Agency) EntityKey added in v0.7.1

func (ent *Agency) EntityKey() string

EntityKey returns the GTFS identifier.

func (*Agency) Errors

func (ent *Agency) Errors() (errs []error)

Errors for this Entity.

func (*Agency) Filename

func (ent *Agency) Filename() string

Filename agency.txt

func (*Agency) TableName

func (ent *Agency) TableName() string

TableName gtfs_agencies

func (*Agency) Warnings

func (ent *Agency) Warnings() (errs []error)

Warnings for this Entity.

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) AddWarning

func (ent *BaseEntity) AddWarning(err error)

AddWarning .

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) SetID

func (ent *BaseEntity) SetID(id int)

SetID sets the integer ID.

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

func (*Calendar) EntityID

func (ent *Calendar) EntityID() string

EntityID returns the ID or ServiceID.

func (*Calendar) EntityKey added in v0.7.1

func (ent *Calendar) EntityKey() string

EntityKey returns the GTFS identifier.

func (*Calendar) Errors

func (ent *Calendar) Errors() (errs []error)

Errors for this Entity.

func (*Calendar) Filename

func (ent *Calendar) Filename() string

Filename calendar.txt

func (*Calendar) TableName

func (ent *Calendar) TableName() string

TableName gtfs_calendars

func (*Calendar) Warnings

func (ent *Calendar) Warnings() (errs []error)

Warnings for this Entity.

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

type EntityFilter interface {
	Filter(Entity, *EntityMap) error
}

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.

func NewEntityMap

func NewEntityMap() *EntityMap

NewEntityMap returns a new EntityMap.

func (*EntityMap) Get

func (emap *EntityMap) Get(efn string, eid string) (string, bool)

Get gets directly by filename, eid

func (*EntityMap) GetEntity

func (emap *EntityMap) GetEntity(ent Entity) (string, bool)

GetEntity returns the new ID for an Entity.

func (*EntityMap) KeysFor

func (emap *EntityMap) KeysFor(efn string) []string

KeysFor returns the keys for a filename.

func (*EntityMap) Set

func (emap *EntityMap) Set(efn string, oldid string, newid string) error

Set directly adds an entry to the set.

func (*EntityMap) SetEntity

func (emap *EntityMap) SetEntity(ent Entity, oldid string, newid string) error

SetEntity sets the old and new ID for an Entity.

func (*EntityMap) Update

func (emap *EntityMap) Update(other EntityMap)

Update copies values from another EntityMap.

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) Errors

func (ent *FareRule) Errors() (errs []error)

Errors for this Entity.

func (*FareRule) Filename

func (ent *FareRule) Filename() string

Filename fare_rules.txt

func (*FareRule) TableName

func (ent *FareRule) TableName() string

TableName gtfs_fare_Rules

func (*FareRule) UpdateKeys

func (ent *FareRule) UpdateKeys(emap *EntityMap) error

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

func (*Feed) EntityID

func (ent *Feed) EntityID() string

EntityID .

func (*Feed) GetID added in v0.7.1

func (ent *Feed) GetID() int

GetID .

func (*Feed) SetID added in v0.7.1

func (ent *Feed) SetID(id int)

SetID .

func (Feed) TableName

func (Feed) TableName() string

TableName .

type FeedAssociatedFeeds

type FeedAssociatedFeeds map[string]string

FeedAssociatedFeeds .

func (*FeedAssociatedFeeds) Scan

func (a *FeedAssociatedFeeds) Scan(value interface{}) error

Scan .

func (FeedAssociatedFeeds) Value

func (a FeedAssociatedFeeds) Value() (driver.Value, error)

Value .

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.

func (*FeedAuthorization) Scan

func (a *FeedAuthorization) Scan(value interface{}) error

Scan .

func (FeedAuthorization) Value

func (a FeedAuthorization) Value() (driver.Value, error)

Value .

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

func (*FeedInfo) Errors

func (ent *FeedInfo) Errors() (errs []error)

Errors for this Entity.

func (*FeedInfo) Filename

func (ent *FeedInfo) Filename() string

Filename feed_info.txt

func (*FeedInfo) TableName

func (ent *FeedInfo) TableName() string

TableName gtfs_feed_infos

type FeedLanguages

type FeedLanguages []string

FeedLanguages .

func (*FeedLanguages) Scan

func (a *FeedLanguages) Scan(value interface{}) error

Scan .

func (FeedLanguages) Value

func (a FeedLanguages) Value() (driver.Value, error)

Value .

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"`
	ShareAlikeOptional      string `json:"share_alike_optional,omitempty"`
	AttributionText         string `json:"attribution_text,omitempty"`
	AttributionInstructions string `json:"attribution_instructions,omitempty"`
}

FeedLicense describes the license and usage information for a Feed.

func (*FeedLicense) Scan

func (a *FeedLicense) Scan(value interface{}) error

Scan .

func (FeedLicense) Value

func (a FeedLicense) Value() (driver.Value, error)

Value .

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.

func (*FeedUrls) Scan

func (a *FeedUrls) Scan(value interface{}) error

Scan .

func (FeedUrls) Value

func (a FeedUrls) Value() (driver.Value, error)

Value .

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) EntityID

func (ent *FeedVersion) EntityID() string

EntityID .

func (*FeedVersion) GetID added in v0.7.1

func (ent *FeedVersion) GetID() int

GetID .

func (*FeedVersion) SetID added in v0.7.1

func (ent *FeedVersion) SetID(id int)

SetID .

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) Errors

func (ent *Frequency) Errors() (errs []error)

Errors for this Entity.

func (*Frequency) Filename

func (ent *Frequency) Filename() string

Filename frequencies.txt

func (*Frequency) RepeatCount added in v0.7.1

func (ent *Frequency) RepeatCount() int

RepeatCount returns the number of times this trip will be repeated.

func (*Frequency) TableName

func (ent *Frequency) TableName() string

TableName gtfs_frequencies

func (*Frequency) UpdateKeys

func (ent *Frequency) UpdateKeys(emap *EntityMap) error

UpdateKeys updates Entity references.

func (*Frequency) Warnings

func (ent *Frequency) Warnings() (errs []error)

Warnings for this Entity.

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

func (*Level) EntityID

func (ent *Level) EntityID() string

EntityID returns the ID or StopID.

func (*Level) EntityKey added in v0.7.1

func (ent *Level) EntityKey() string

EntityKey returns the GTFS identifier.

func (*Level) Filename

func (ent *Level) Filename() string

Filename levels.txt

func (*Level) TableName

func (ent *Level) TableName() string

TableName ext_pathways_levels

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) Scan

func (g *LineString) Scan(src interface{}) error

Scan implements Scanner

func (*LineString) UnmarshalGQL added in v0.7.2

func (g *LineString) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements the graphql.Unmarshaler interface

func (LineString) Value

func (g LineString) Value() (driver.Value, error)

Value implements driver.Value

type OptionalKey

type OptionalKey struct {
	sql.NullInt64
}

OptionalKey is the same as sql.NullInt

type OptionalRelationship

type OptionalRelationship struct {
	Key   string
	Valid bool
}

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

func (OptionalRelationship) Value

func (r OptionalRelationship) Value() (driver.Value, error)

Value returns nil if empty

type OptionalTime

type OptionalTime struct {
	Time  time.Time
	Valid bool
}

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

func (OptionalTime) Value

func (r OptionalTime) Value() (driver.Value, error)

Value returns nil if empty

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) EntityID

func (ent *Pathway) EntityID() string

EntityID returns the ID or StopID.

func (*Pathway) EntityKey added in v0.7.1

func (ent *Pathway) EntityKey() string

EntityKey returns the GTFS identifier.

func (*Pathway) Filename

func (ent *Pathway) Filename() string

Filename pathways.txt

func (*Pathway) GetString

func (ent *Pathway) GetString(key string) (string, error)

GetString returns the string representation of an field.

func (*Pathway) TableName

func (ent *Pathway) TableName() string

TableName ext_pathway_pathways

func (*Pathway) UpdateKeys

func (ent *Pathway) UpdateKeys(emap *EntityMap) error

UpdateKeys updates Entity references.

type Point

type Point struct {
	Valid bool
	geom.Point
}

Point is an EWKB/SL encoded point

func NewPoint

func NewPoint(lon, lat float64) Point

NewPoint returns a Point from lon, lat

func (Point) MarshalGQL added in v0.7.2

func (g Point) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface

func (*Point) Scan

func (g *Point) Scan(src interface{}) error

Scan implements Scanner

func (*Point) UnmarshalGQL added in v0.7.2

func (g *Point) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements the graphql.Unmarshaler interface

func (Point) Value

func (g Point) Value() (driver.Value, error)

Value implements driver.Value

type Polygon added in v0.7.2

type Polygon struct {
	Valid bool
	geom.Polygon
}

Polygon is an EWKB/SL encoded Polygon

func (Polygon) MarshalGQL added in v0.7.2

func (g Polygon) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface

func (*Polygon) Scan added in v0.7.2

func (g *Polygon) Scan(src interface{}) error

Scan implements Scanner

func (*Polygon) UnmarshalGQL added in v0.7.2

func (g *Polygon) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements the graphql.Unmarshaler interface

func (Polygon) Value added in v0.7.2

func (g Polygon) Value() (driver.Value, error)

Value implements driver.Value

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) EntityID

func (ent *Route) EntityID() string

EntityID returns ID or RouteID.

func (*Route) EntityKey added in v0.7.1

func (ent *Route) EntityKey() string

EntityKey returns the GTFS identifier.

func (*Route) Errors

func (ent *Route) Errors() (errs []error)

Errors for this Entity.

func (*Route) Filename

func (ent *Route) Filename() string

Filename routes.txt

func (*Route) TableName

func (ent *Route) TableName() string

TableName gtfs_routes

func (*Route) UpdateKeys

func (ent *Route) UpdateKeys(emap *EntityMap) error

UpdateKeys updates Entity references.

func (*Route) Warnings

func (ent *Route) Warnings() (errs []error)

Warnings for this Entity.

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

func NewServicesFromReader(reader Reader) []*Service

NewServicesFromReader returns

func (*Service) AddCalendarDate

func (s *Service) AddCalendarDate(cd CalendarDate)

AddCalendarDate adds a service exception.

func (*Service) IsActive

func (s *Service) IsActive(t time.Time) bool

IsActive returns if this Service period is active on a specified date.

func (*Service) ServicePeriod

func (s *Service) ServicePeriod() (time.Time, time.Time)

ServicePeriod returns the widest possible range of days with transit service, including service exceptions.

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

func NewShapeFromShapes(shapes []Shape) Shape

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.

func (*Shape) EntityID

func (ent *Shape) EntityID() string

EntityID returns the ID or ShapeID.

func (*Shape) EntityKey added in v0.7.1

func (ent *Shape) EntityKey() string

EntityKey returns the GTFS identifier.

func (*Shape) Errors

func (ent *Shape) Errors() (errs []error)

Errors for this Entity.

func (*Shape) Filename

func (ent *Shape) Filename() string

Filename shapes.txt

func (*Shape) SetString

func (ent *Shape) SetString(key string, value string) error

SetString provides a fast, non-reflect loading path.

func (*Shape) TableName

func (ent *Shape) TableName() string

TableName gtfs_shapes

func (*Shape) Warnings

func (ent *Shape) Warnings() (errs []error)

Warnings for this Entity.

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

func (ent *Stop) Coordinates() [2]float64

Coordinates returns the stop lon,lat as a [2]float64

func (*Stop) EntityID

func (ent *Stop) EntityID() string

EntityID returns the ID or StopID.

func (*Stop) EntityKey added in v0.7.1

func (ent *Stop) EntityKey() string

EntityKey returns the GTFS identifier.

func (*Stop) Errors

func (ent *Stop) Errors() (errs []error)

Errors for this Entity.

func (*Stop) Filename

func (ent *Stop) Filename() string

Filename stops.txt

func (*Stop) SetCoordinates

func (ent *Stop) SetCoordinates(p [2]float64)

SetCoordinates takes a [2]float64 and sets the Stop's lon,lat

func (*Stop) TableName

func (ent *Stop) TableName() string

TableName gtfs_stops

func (*Stop) UpdateKeys

func (ent *Stop) UpdateKeys(emap *EntityMap) error

UpdateKeys updates Entity references.

func (*Stop) Warnings

func (ent *Stop) Warnings() (errs []error)

Warnings for this Entity.

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

func (ent *StopTime) AddError(err error)

AddError adds a loading error to the entity, e.g. from a CSV parse failure

func (*StopTime) AddWarning added in v0.7.1

func (ent *StopTime) AddWarning(err error)

AddWarning .

func (*StopTime) EntityID

func (ent *StopTime) EntityID() string

EntityID returns nothing.

func (*StopTime) Errors

func (ent *StopTime) Errors() []error

Errors for this Entity.

func (*StopTime) Extra added in v0.7.1

func (ent *StopTime) Extra() map[string]string

Extra provides any additional fields that were present.

func (*StopTime) Filename

func (ent *StopTime) Filename() string

Filename stop_times.txt

func (*StopTime) GetString

func (ent *StopTime) GetString(key string) (string, error)

GetString returns the string representation of an field.

func (*StopTime) SetExtra added in v0.7.1

func (ent *StopTime) SetExtra(key string, value string)

SetExtra adds a string key, value pair to the entity's extra fields.

func (*StopTime) SetFeedVersionID added in v0.7.1

func (ent *StopTime) SetFeedVersionID(fvid int)

SetFeedVersionID sets the Entity's FeedVersionID.

func (*StopTime) SetString

func (ent *StopTime) SetString(key, value string) error

SetString provides a fast, non-reflect loading path.

func (*StopTime) TableName

func (ent *StopTime) TableName() string

TableName gtfs_stop_times

func (*StopTime) UpdateKeys

func (ent *StopTime) UpdateKeys(emap *EntityMap) error

UpdateKeys updates Entity references.

func (*StopTime) Warnings added in v0.7.1

func (ent *StopTime) Warnings() []error

Warnings returns validation warnings.

type Timestamps

type Timestamps struct {
	CreatedAt time.Time
	UpdatedAt time.Time
}

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) Errors

func (ent *Transfer) Errors() (errs []error)

Errors for this Entity.

func (*Transfer) Filename

func (ent *Transfer) Filename() string

Filename transfers.txt

func (*Transfer) TableName

func (ent *Transfer) TableName() string

TableName gtfs_transfers

func (*Transfer) UpdateKeys

func (ent *Transfer) UpdateKeys(emap *EntityMap) error

UpdateKeys updates entity references.

func (*Transfer) Warnings

func (ent *Transfer) Warnings() (errs []error)

Warnings for this Entity.

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) EntityID

func (ent *Trip) EntityID() string

EntityID returns the ID or TripID.

func (*Trip) EntityKey added in v0.7.1

func (ent *Trip) EntityKey() string

EntityKey returns the GTFS identifier.

func (*Trip) Errors

func (ent *Trip) Errors() (errs []error)

Errors for this Entity.

func (*Trip) Filename

func (ent *Trip) Filename() string

Filename trips.txt

func (*Trip) TableName

func (ent *Trip) TableName() string

TableName gtfs_trips

func (*Trip) UpdateKeys

func (ent *Trip) UpdateKeys(emap *EntityMap) error

UpdateKeys updates Entity references.

type WideTime

type WideTime struct {
	Seconds int
	Valid   bool
}

WideTime handles seconds since midnight, allows >24 hours.

func NewWideTime

func NewWideTime(value string) (wt WideTime, err error)

NewWideTime converts the csv string to a WideTime.

func (WideTime) MarshalGQL added in v0.7.2

func (wt WideTime) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface

func (*WideTime) Scan

func (wt *WideTime) Scan(src interface{}) error

Scan implements sql.Scanner

func (*WideTime) String

func (wt *WideTime) String() string

func (*WideTime) UnmarshalGQL added in v0.7.2

func (wt *WideTime) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements the graphql.Unmarshaler interface

func (WideTime) Value

func (wt WideTime) Value() (driver.Value, error)

Value implements driver.Value

type Writer

type Writer interface {
	Open() error
	Close() error
	Create() error
	Delete() error
	NewReader() (Reader, error)
	AddEntity(Entity) (string, error)
	AddEntities([]Entity) ([]string, error)
}

Writer writes a GTFS feed.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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