Documentation
¶
Index ¶
- Constants
- func Populate(db *bolt.DB, agencies AgencyMap, routes RouteMap, services ServiceMap, ...) error
- type Agency
- type AgencyMap
- type Coordinate
- func (c Coordinate) BearingTo(other Coordinate) float64
- func (c *Coordinate) Decode(data []byte) error
- func (c Coordinate) DistanceTo(other Coordinate) float64
- func (c Coordinate) Encode() []byte
- func (c Coordinate) IsValid() bool
- func (c Coordinate) IsZero() bool
- func (c Coordinate) String() string
- type CoordinateArray
- type ExceptionType
- type GTFS
- func (g *GTFS) Close() error
- func (g *GTFS) FromDB(dbFile string) error
- func (g *GTFS) FromURL(gtfsURL, dbFile string) error
- func (g *GTFS) GetAgenciesByIDs(agencyIDs []Key) (AgencyMap, error)
- func (g *GTFS) GetAgencyByID(agencyID Key) (*Agency, error)
- func (g *GTFS) GetAllAgencies() (AgencyMap, error)
- func (g *GTFS) GetAllCurrentTrips() (TripMap, error)
- func (g *GTFS) GetAllRoutes() (RouteMap, error)
- func (g *GTFS) GetAllServiceExceptions() (ServiceExceptionMap, error)
- func (g *GTFS) GetAllServices() (ServiceMap, error)
- func (g *GTFS) GetAllShapes() (ShapeMap, error)
- func (g *GTFS) GetAllStops() (StopMap, error)
- func (g *GTFS) GetAllTrips() (TripMap, error)
- func (g *GTFS) GetCurrentTrips(trips TripMap) (TripMap, error)
- func (g *GTFS) GetCurrentTripsAt(trips TripMap, t time.Time) (TripMap, error)
- func (g *GTFS) GetCurrentTripsBetween(trips TripMap, start, end time.Time) (TripMap, error)
- func (g *GTFS) GetCurrentTripsWithBuffer(trips TripMap, t time.Time, buffer time.Duration) (TripMap, error)
- func (g *GTFS) GetRouteByID(routeID Key) (*Route, error)
- func (g *GTFS) GetRouteByName(routeName string) (*Route, error)
- func (g *GTFS) GetRoutesByIDs(routeIDs []Key) (RouteMap, error)
- func (g *GTFS) GetServiceByID(serviceID Key) (*Service, error)
- func (g *GTFS) GetServiceException(serviceID Key, date time.Time) (*ServiceException, error)
- func (g *GTFS) GetServicesByIDs(serviceIDs []Key) (ServiceMap, error)
- func (g *GTFS) GetShapeByID(shapeID Key) (*Shape, error)
- func (g *GTFS) GetShapesByIDs(shapeIDs []Key) (ShapeMap, error)
- func (g *GTFS) GetStopByID(stopID Key) (*Stop, error)
- func (g *GTFS) GetStopByName(stopName string) (*Stop, error)
- func (g *GTFS) GetStopsByIDs(stopIDs []Key) (StopMap, error)
- func (g *GTFS) GetTripByID(tripID Key) (*Trip, error)
- func (g *GTFS) GetTripsByIDs(tripIDs []Key) (TripMap, error)
- func (g *GTFS) GetTripsByRouteID(routeID Key) (TripMap, error)
- type Key
- type KeyArray
- type LocationType
- type ModeFlag
- type Route
- type RouteMap
- type RouteType
- type Service
- type ServiceException
- type ServiceExceptionKey
- type ServiceExceptionMap
- type ServiceMap
- type Shape
- type ShapeMap
- type Stop
- type StopMap
- type Trip
- type TripDirection
- type TripMap
- type TripStop
- type TripStopArray
- type TripTimepoint
- type WeekdayFlag
Constants ¶
const CurrentVersion = 3
Current version of the GTFS database
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Agency ¶ added in v0.0.5
Represents an agency that provides transit services
type Coordinate ¶ added in v0.0.5
Represents a geographical coordinate with latitude and longitude.
func NewCoordinate ¶ added in v0.0.5
func NewCoordinate(lat, lon float64) Coordinate
Create a new Coordinate instance with the given latitude and longitude.
func NewCoordinateFromString ¶ added in v0.0.5
func NewCoordinateFromString(coord string) (Coordinate, error)
Create a new Coordinate instance from a string in the format "lat,lon".
func (Coordinate) BearingTo ¶ added in v0.1.6
func (c Coordinate) BearingTo(other Coordinate) float64
Calculate the bearing to another coordinate in degrees
func (*Coordinate) Decode ¶ added in v0.1.0
func (c *Coordinate) Decode(data []byte) error
Decode the byte slice into a Coordinate
func (Coordinate) DistanceTo ¶ added in v0.0.5
func (c Coordinate) DistanceTo(other Coordinate) float64
Calculate the distance to another coordinate in metres using the Haversine formula
func (Coordinate) Encode ¶ added in v0.1.0
func (c Coordinate) Encode() []byte
Encode the Coordinate into a byte slice Format: - Latitude: 8 bytes (float64) - Longitude: 8 bytes (float64)
func (Coordinate) IsValid ¶ added in v0.0.5
func (c Coordinate) IsValid() bool
Check if the coordinate is valid (latitude between -90 and 90, longitude between -180 and 180).
func (Coordinate) IsZero ¶ added in v0.0.5
func (c Coordinate) IsZero() bool
Check if the coordinate is zero (0, 0).
func (Coordinate) String ¶ added in v0.0.5
func (c Coordinate) String() string
Return a string representation of the coordinate in the format "lat,lon".
type CoordinateArray ¶ added in v0.0.5
type CoordinateArray []Coordinate
func (*CoordinateArray) Decode ¶ added in v0.1.0
func (ca *CoordinateArray) Decode(data []byte) error
Decode the byte slice into the CoordinateArray
func (CoordinateArray) Encode ¶ added in v0.1.0
func (ca CoordinateArray) Encode() []byte
Encode the CoordinateArray into a byte slice Format: - Count: 4 bytes (number of coordinates) - Each coordinate: 8 bytes (float64 for latitude) + 8 bytes (float64 for longitude)
type ExceptionType ¶ added in v0.0.5
type ExceptionType bool
Enum for the types of service exception
const ( AddedExceptionType ExceptionType = false RemovedExceptionType ExceptionType = true )
type GTFS ¶
Represents a GTFS database connection
func (*GTFS) GetAgenciesByIDs ¶ added in v0.1.1
Returns the agencies with the given IDs
func (*GTFS) GetAgencyByID ¶
Returns the agency with the given ID
func (*GTFS) GetAllAgencies ¶
Returns all agencies in the GTFS database
func (*GTFS) GetAllCurrentTrips ¶
Returns all trips that are currently running
func (*GTFS) GetAllRoutes ¶ added in v0.0.3
Returns all routes in the GTFS database
func (*GTFS) GetAllServiceExceptions ¶ added in v0.0.6
func (g *GTFS) GetAllServiceExceptions() (ServiceExceptionMap, error)
Returns all service exceptions in the GTFS database
func (*GTFS) GetAllServices ¶ added in v0.0.6
func (g *GTFS) GetAllServices() (ServiceMap, error)
Returns all services in the GTFS database
func (*GTFS) GetAllShapes ¶ added in v0.1.1
Returns all shapes in the GTFS database
func (*GTFS) GetAllStops ¶ added in v0.0.6
Returns all stops in the GTFS database
func (*GTFS) GetAllTrips ¶ added in v0.0.6
Returns all trips in the GTFS database
func (*GTFS) GetCurrentTrips ¶ added in v0.0.8
Returns the trips that are currently running from the given array
func (*GTFS) GetCurrentTripsAt ¶ added in v0.0.3
Returns the trips that are running at the given time from the given array
func (*GTFS) GetCurrentTripsBetween ¶ added in v0.0.11
Returns the trips that are running between the given start and end times from the given array
func (*GTFS) GetCurrentTripsWithBuffer ¶ added in v0.0.7
func (g *GTFS) GetCurrentTripsWithBuffer(trips TripMap, t time.Time, buffer time.Duration) (TripMap, error)
Returns the trips that are running at the given time with a buffer, from the given array
func (*GTFS) GetRouteByID ¶
Returns the route with the given ID
func (*GTFS) GetRouteByName ¶ added in v0.0.6
Returns the route with the given name
func (*GTFS) GetRoutesByIDs ¶ added in v0.1.1
Returns the routes with the given IDs
func (*GTFS) GetServiceByID ¶
Returns the service with the given ID
func (*GTFS) GetServiceException ¶ added in v0.0.3
Returns all services exceptions for a given service ID and date
func (*GTFS) GetServicesByIDs ¶ added in v0.1.1
func (g *GTFS) GetServicesByIDs(serviceIDs []Key) (ServiceMap, error)
Returns the services with the given IDs
func (*GTFS) GetShapeByID ¶ added in v0.0.12
Returns the shape with the given ID
func (*GTFS) GetShapesByIDs ¶ added in v0.1.1
Returns the shapes with the given IDs
func (*GTFS) GetStopByID ¶
Returns the stop with the given ID
func (*GTFS) GetStopByName ¶ added in v0.0.6
Returns the stop with the given name
func (*GTFS) GetStopsByIDs ¶ added in v0.1.1
Returns the stops with the given IDs
func (*GTFS) GetTripByID ¶
Returns the trip with the given ID
func (*GTFS) GetTripsByIDs ¶ added in v0.1.1
Returns the trips with the given IDs
type KeyArray ¶ added in v0.0.5
type KeyArray []Key
type LocationType ¶ added in v0.0.5
type LocationType uint8
const ( StopLocationType LocationType = iota StationLocationType EntranceExitLocationType GenericNodeLocationType BoardingAreaLocationType UnknownLocationType )
type Route ¶ added in v0.0.5
type Route struct {
ID Key
AgencyID Key
Name string
Type RouteType
Colour string
InboundShapeID *Key
OutboundShapeID *Key
Stops KeyArray
}
Represents a route in a transit system
func (Route) Encode ¶ added in v0.1.0
Encode the Route struct into a byte slice Format: - AgencyID: 4-byte length + UTF-8 string - Name: 4-byte length + UTF-8 string - Type: 1-byte enum (RouteType) - Colour: 4-byte length + UTF-8 string - InboundShapeID: 4-byte length + UTF-8 string - OutboundShapeID: 4-byte length + UTF-8 string - Stops: KeyArray (encoded as a byte slice)
type Service ¶ added in v0.0.5
Represents the days of the week a service is active
type ServiceException ¶ added in v0.0.5
type ServiceException struct {
ServiceID Key
Date time.Time
Type ExceptionType
}
Represents an exception for a service on a specific date
func (*ServiceException) Decode ¶ added in v0.1.0
func (se *ServiceException) Decode(data []byte) error
Decode deserializes the byte slice into the ServiceException struct.
func (ServiceException) Encode ¶ added in v0.1.0
func (se ServiceException) Encode() []byte
Encode serializes the ServiceException struct into a byte slice. Format: - ServiceID: 4-byte length + UTF-8 string - Date: 8 bytes (Unix timestamp) - Type: 1 byte (bool as uint8)
type ServiceExceptionKey ¶ added in v0.1.5
type ServiceExceptionMap ¶ added in v0.0.5
type ServiceExceptionMap map[ServiceExceptionKey]*ServiceException
func ParseServiceExceptions ¶ added in v0.0.5
func ParseServiceExceptions(file io.Reader) (ServiceExceptionMap, error)
Load and parse service exceptions from the GTFS calendar_dates.txt file
type ServiceMap ¶ added in v0.0.5
func ParseServices ¶ added in v0.0.5
func ParseServices(file io.Reader) (ServiceMap, error)
Load and parse services from the GTFS calendar.txt file
type Shape ¶ added in v0.0.5
type Shape struct {
ID Key
Coordinates CoordinateArray
}
Represents the shape of a transit route
type Stop ¶ added in v0.0.5
type Stop struct {
ID Key
Code string
Name string
ParentID Key
Location Coordinate
LocationType LocationType
SupportedModes ModeFlag
}
Represents a stop, platform, or station in a transit system
func (Stop) Encode ¶ added in v0.1.0
Encode serializes the Stop struct (excluding ID) into a byte slice. Format: - Code: 4-byte length + UTF-8 string - Name: 4-byte length + UTF-8 string - ParentID: 4-byte length + UTF-8 string - Location: 2 * float64 (fixed size) - LocationType: 1 byte (LocationType enum) - SupportedModes: 1 byte (bitmask for each mode)
type Trip ¶ added in v0.0.5
type Trip struct {
ID Key
RouteID Key
ServiceID Key
ShapeID Key
Direction TripDirection
Headsign string
Stops TripStopArray
}
Represents a trip on a particular route in a transit system
func (Trip) Encode ¶ added in v0.1.0
Encode the Trip struct into a byte slice Format: - RouteID: 4-byte length + UTF-8 string - ServiceID: 4-byte length + UTF-8 string - ShapeID: 4-byte length + UTF-8 string - Direction: 1 byte (bool as uint8) - Headsign: 4-byte length + UTF-8 string - Stops: TripStopArray (see TripStopArray.Encode)
type TripDirection ¶ added in v0.0.5
type TripDirection bool
const ( OutboundTripDirection TripDirection = false InboundTripDirection TripDirection = true )
type TripStop ¶ added in v0.0.5
type TripStop struct {
StopID Key `json:"stop_id"`
ArrivalTime uint `json:"arrival_time"`
DepartureTime uint `json:"departure_time"`
Timepoint TripTimepoint `json:"timepoint"`
}
Represents a stop in a trip
type TripStopArray ¶ added in v0.0.5
type TripStopArray []*TripStop
func (*TripStopArray) Decode ¶ added in v0.1.0
func (tsa *TripStopArray) Decode(data []byte) error
Decode the byte slice into the TripStopArray
func (TripStopArray) Encode ¶ added in v0.1.0
func (tsa TripStopArray) Encode() []byte
Encode the TripStopArray into a byte slice Format: - Count: 4 bytes (uint32) - Each TripStop (see TripStop.Encode)
type TripTimepoint ¶ added in v0.0.5
type TripTimepoint bool
const ( ApproximateTripTimepoint TripTimepoint = false ExactTripTimepoint TripTimepoint = true )
type WeekdayFlag ¶ added in v0.0.5
type WeekdayFlag uint8
Flag for each day of the week
const ( MondayWeekdayFlag WeekdayFlag = 1 << iota TuesdayWeekdayFlag WednesdayWeekdayFlag ThursdayWeekdayFlag FridayWeekdayFlag SaturdayWeekdayFlag SundayWeekdayFlag )