models

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agency

type Agency struct {
	ID   Key
	Name string
	URL  string
}

Represents an agency that provides transit services

func (*Agency) Load

func (a *Agency) Load(r column.Row) error

Loads an agency from the database

func (Agency) Save

func (a Agency) Save(r column.Row) error

Saves an agency to the database

type AgencyArray added in v0.0.3

type AgencyArray []*Agency

func (*AgencyArray) Load added in v0.0.3

func (aa *AgencyArray) Load(txn *column.Txn) error

Loads all agencies from the database transaction

type AgencyMap

type AgencyMap map[Key]*Agency

func ParseAgencies added in v0.0.3

func ParseAgencies(file io.Reader) (AgencyMap, error)

Load and parse agencies from the GTFS agency.txt file

type Coordinate

type Coordinate struct {
	Latitude  float64
	Longitude float64
}

Represents a geographical coordinate with latitude and longitude.

func NewCoordinate

func NewCoordinate(lat, lon float64) Coordinate

Create a new Coordinate instance with the given latitude and longitude.

func NewCoordinateFromString

func NewCoordinateFromString(coord string) (Coordinate, error)

Create a new Coordinate instance from a string in the format "lat,lon".

func (Coordinate) DistanceTo

func (c Coordinate) DistanceTo(other Coordinate) float64

Calculate the distance to another coordinate using the Haversine formula.

func (Coordinate) IsValid

func (c Coordinate) IsValid() bool

Check if the coordinate is valid (latitude between -90 and 90, longitude between -180 and 180).

func (Coordinate) IsZero

func (c Coordinate) IsZero() bool

Check if the coordinate is zero (0, 0).

func (Coordinate) String

func (c Coordinate) String() string

Return a string representation of the coordinate in the format "lat,lon".

type CoordinateArray

type CoordinateArray []Coordinate

func (CoordinateArray) MarshalBinary

func (ca CoordinateArray) MarshalBinary() ([]byte, error)

func (*CoordinateArray) UnmarshalBinary

func (ca *CoordinateArray) UnmarshalBinary(data []byte) error

type ExceptionType

type ExceptionType uint8

Enum for the types of service exception

const (
	AddedExceptionType ExceptionType = iota + 1
	RemovedExceptionType
)

type Key

type Key string

type KeyArray

type KeyArray []Key

func (KeyArray) MarshalBinary

func (ka KeyArray) MarshalBinary() ([]byte, error)

func (*KeyArray) UnmarshalBinary

func (ka *KeyArray) UnmarshalBinary(data []byte) error

type LocationType

type LocationType uint8
const (
	StopLocationType LocationType = iota
	StationLocationType
	EntranceExitLocationType
	GenericNodeLocationType
	BoardingAreaLocationType
	UnknownLocationType
)

type ModeFlag

type ModeFlag uint8
const (
	BusModeFlag ModeFlag = 1 << iota
	SchoolBusModeFlag
	RailModeFlag
	FerryModeFlag
	UnknownModeFlag = 0
)

type Route

type Route struct {
	ID       Key
	AgencyID Key
	Name     string
	Type     RouteType
	Colour   string
	ShapeID  Key
	Stops    KeyArray
}

Represents a route in a transit system

func (*Route) Load

func (r *Route) Load(row column.Row) error

Loads a route from the database

func (Route) Save

func (r Route) Save(row column.Row) error

Saves a route to the database

type RouteArray added in v0.0.3

type RouteArray []*Route

func (*RouteArray) Load added in v0.0.3

func (ra *RouteArray) Load(txn *column.Txn) error

Loads all routes from the database transaction

type RouteMap

type RouteMap map[Key]*Route

func ParseRoutes added in v0.0.3

func ParseRoutes(file io.Reader) (RouteMap, error)

Load and parse routes from the GTFS routes.txt file

type RouteType

type RouteType uint8
const (
	TramRouteType RouteType = iota
	SubwayRouteType
	RailRouteType
	BusRouteType
	FerryRouteType
	CableCarRouteType
	GondolaRouteType
	FunicularRouteType
	TrolleybusRouteType = iota + 3
	MonorailRouteType
)

type Service

type Service struct {
	ID        Key
	Weekdays  WeekdayFlag
	StartDate time.Time
	EndDate   time.Time
}

Represents the days of the week a service is active

func (*Service) Load

func (s *Service) Load(row column.Row) error

Loads a service from the database

func (Service) Save

func (s Service) Save(row column.Row) error

Saves a service to the database

type ServiceArray added in v0.0.3

type ServiceArray []*Service

func (*ServiceArray) Load added in v0.0.3

func (sa *ServiceArray) Load(txn *column.Txn) error

Loads all services from the database transaction

type ServiceException

type ServiceException struct {
	ServiceID Key
	Date      time.Time
	Type      ExceptionType
}

Represents an exception for a service on a specific date

func (*ServiceException) Load

func (se *ServiceException) Load(row column.Row) error

Loads a service exception from the database

func (ServiceException) Save

func (se ServiceException) Save(row column.Row) error

Saves a service exception to the database

type ServiceExceptionArray added in v0.0.3

type ServiceExceptionArray []*ServiceException

func (*ServiceExceptionArray) Load added in v0.0.3

func (sea *ServiceExceptionArray) Load(txn *column.Txn) error

Loads all service exceptions from the database transaction

type ServiceExceptionMap

type ServiceExceptionMap map[Key]*ServiceException

func ParseServiceExceptions added in v0.0.3

func ParseServiceExceptions(file io.Reader) (ServiceExceptionMap, error)

Load and parse service exceptions from the GTFS calendar_dates.txt file

type ServiceMap

type ServiceMap map[Key]*Service

func ParseServices added in v0.0.3

func ParseServices(file io.Reader) (ServiceMap, error)

Load and parse services from the GTFS calendar.txt file

type Shape

type Shape struct {
	ID          Key
	Coordinates CoordinateArray
}

Represents the shape of a transit route

func (*Shape) Load

func (s *Shape) Load(row column.Row, numRows int) error

Loads a shape from the database

func (Shape) Save

func (s Shape) Save(row column.Row, coordsPerRow int) error

Saves a shape to the database

type ShapeArray added in v0.0.3

type ShapeArray []*Shape

func (*ShapeArray) Load added in v0.0.3

func (sa *ShapeArray) Load(txn *column.Txn, numRows int) error

Loads all shapes from the database transaction

type ShapeMap

type ShapeMap map[Key]*Shape

func ParseShapes added in v0.0.3

func ParseShapes(file io.Reader) (ShapeMap, int, error)

Load and parse shapes from the GTFS shapes.txt file

type Stop

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

func (s *Stop) Load(r column.Row) error

Loads a stop from the database

func (Stop) Save

func (s Stop) Save(r column.Row) error

Saves a stop to the database

type StopArray added in v0.0.3

type StopArray []*Stop

func (*StopArray) Load added in v0.0.3

func (sa *StopArray) Load(txn *column.Txn) error

Loads all stops from the database transaction

type StopMap

type StopMap map[Key]*Stop

func ParseStops added in v0.0.3

func ParseStops(file io.Reader) (StopMap, error)

Load and parse stops from the GTFS stops.txt file

type Trip

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

func (t *Trip) EndTime() uint

Get the time that a trip ends at the last stop

func (*Trip) Load

func (t *Trip) Load(row column.Row) error

Loads the trip from the database

func (Trip) Save

func (t Trip) Save(row column.Row) error

Saves the trip to the database

func (*Trip) StartTime

func (t *Trip) StartTime() uint

Get the time that a trip starts at the first stop

type TripArray added in v0.0.3

type TripArray []*Trip

func (*TripArray) Load added in v0.0.3

func (ta *TripArray) Load(txn *column.Txn) error

Loads all trips from the database transaction

type TripDirection

type TripDirection uint8
const (
	OutboundTripDirection TripDirection = iota
	InboundTripDirection
)

type TripMap

type TripMap map[Key]*Trip

func ParseTrips added in v0.0.3

func ParseTrips(tripsFile io.Reader, stopTimesFile io.Reader) (TripMap, error)

Load and parse trips from the GTFS trips.txt and stop_times.txt files

type TripStop

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

func (*TripStop) FromString

func (ts *TripStop) FromString(s string) error

Converts a string representation back to a TripStop

func (*TripStop) String

func (ts *TripStop) String() string

Converts the TripStop to a string representation

type TripStopArray

type TripStopArray []*TripStop

func (TripStopArray) MarshalBinary

func (tsa TripStopArray) MarshalBinary() ([]byte, error)

func (*TripStopArray) UnmarshalBinary

func (tsa *TripStopArray) UnmarshalBinary(data []byte) error

type TripTimepoint

type TripTimepoint uint8
const (
	ApproximateTripTimepoint TripTimepoint = iota
	ExactTripTimepoint
)

type WeekdayFlag

type WeekdayFlag uint8

Flag for each day of the week

const (
	MondayWeekdayFlag WeekdayFlag = 1 << iota
	TuesdayWeekdayFlag
	WednesdayWeekdayFlag
	ThursdayWeekdayFlag
	FridayWeekdayFlag
	SaturdayWeekdayFlag
	SundayWeekdayFlag
)

Jump to

Keyboard shortcuts

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