ctdf

package
v0.0.0-...-73876c2 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AvailabilityDayOfWeek  AvailabilityRecordType = "DayOfWeek"
	AvailabilityDate                              = "Date"
	AvailabilityDateRange                         = "DateRange"
	AvailabilitySpecialDay                        = "SpecialDay"
	AvailabilityMatchAll                          = "MatchAll"
)
View Source
const (
	BoolUnknownTrue    BoolUnknown = "true"
	BoolUnknownFalse               = "false"
	BoolUnknownUnknown             = "unknown"
)
View Source
const (
	DepartureBoardRecordTypeScheduled       DepartureBoardRecordType = "Scheduled"
	DepartureBoardRecordTypeRealtimeTracked                          = "RealtimeTracked"
	DepartureBoardRecordTypeEstimated                                = "Estimated"
	DepartureBoardRecordTypeCancelled                                = "Cancelled"
)
View Source
const (
	EventTypeServiceAlertCreated EventType = "ServiceAlertCreated"

	EventTypeRealtimeJourneyCreated             = "RealtimeJourneyCreated"
	EventTypeRealtimeJourneyActivelyTracked     = "RealtimeJourneyActivelyTracked"
	EventTypeRealtimeJourneyPlatformSet         = "RealtimeJourneyPlatformSet"
	EventTypeRealtimeJourneyPlatformChanged     = "RealtimeJourneyPlatformChanged"
	EventTypeRealtimeJourneyCancelled           = "RealtimeJourneyCancelled"
	EventTypeRealtimeJourneyLocationTextChanged = "RealtimeJourneyLocationTextChanged"
	EventTypeRealtimeJourneyNextStopChanged     = "RealtimeJourneyNextStopChanged"
)
View Source
const (
	JourneyPathItemActivityPickup  = "Pickup"
	JourneyPathItemActivitySetdown = "Setdown"
	JourneyPathItemActivityPass    = "Pass"
)
View Source
const (
	JourneyDetailedRailSeatingFirstStandard JourneyDetailedRailSeating = "FirstStandard"
	JourneyDetailedRailSeatingFirst                                    = "First"
	JourneyDetailedRailSeatingStandard                                 = "Standard"
	JourneyDetailedRailSeatingUnknown                                  = "Unknown"
)
View Source
const (
	RealtimeJourneyReliabilityExternalProvided     RealtimeJourneyReliabilityType = "ExternalProvided"
	RealtimeJourneyReliabilityLocationWithTrack                                   = "LocationWithTrack"
	RealtimeJourneyReliabilityLocationWithoutTrack                                = "LocationWithoutTrack"
)
View Source
const (
	ServiceAlertTypeInformation               ServiceAlertType = "Information"
	ServiceAlertTypeWarning                                    = "Warning"
	ServiceAlertTypeStopClosed                                 = "StopClosed"
	ServiceAlertTypeServiceSuspended                           = "ServiceSuspended"
	ServiceAlertTypeServicePartSuspended                       = "ServicePartSuspended"
	ServiceAlertTypeSevereDelays                               = "SevereDelays"
	ServiceAlertTypeDelays                                     = "Delays"
	ServiceAlertTypeMinorDelays                                = "MinorDelays"
	ServiceAlertTypePlanned                                    = "Planned"
	ServiceAlertTypeJourneyDelayed                             = "JourneyDelayed"
	ServiceAlertTypeJourneyPartiallyCancelled                  = "JourneyPartiallyCancelled"
	ServiceAlertTypeJourneyCancelled                           = "JourneyCancelled"
)
View Source
const (
	TransportTypeBus      TransportType = "Bus"
	TransportTypeCoach                  = "Coach"
	TransportTypeTram                   = "Tram"
	TransportTypeTaxi                   = "Taxi"
	TransportTypeRail                   = "Rail"
	TransportTypeMetro                  = "Metro"
	TransportTypeFerry                  = "Ferry"
	TransportTypeAirport                = "Airport"
	TransportTypeCableCar               = "CableCar"
	TransportTypeUnknown                = "UNKNOWN"
)
View Source
const GBStopIDFormat = "GB:ATCO:%s"
View Source
const OperatorGroupIDFormat = "GB:NOCGRPID:%s"
View Source
const OperatorNOCFormat = "GB:NOC:%s"
View Source
const OperatorNOCIDFormat = "GB:NOCID:%s"
View Source
const OperatorTOCFormat = "GB:TOC:%s"
View Source
const StopGroupIDFormat = "GB:STOPGRP:%s"
View Source
const XSDDateTimeFormat = "2006-01-02T15:04:05-07:00"
View Source
const XSDDateTimeWithFractionalFormat = "2006-01-02T15:04:05.999999-07:00"
View Source
const YearMonthDayFormat = "2006-01-02"

Variables

View Source
var RealtimeJourneyIDFormat = "REALTIME:%s:%s"
View Source
var SpecialDays = make(map[int]map[string]time.Time) // year specialday time

Functions

func GetActiveRealtimeJourneyCutOffDate

func GetActiveRealtimeJourneyCutOffDate() time.Time

func LoadSpecialDayCache

func LoadSpecialDayCache()

Types

type Availability

type Availability struct {
	Match          []AvailabilityRule `groups:"basic"` // Must match at least one
	MatchSecondary []AvailabilityRule `groups:"basic"` // Must match at least one if exists
	Condition      []AvailabilityRule `groups:"basic"` // Must match all
	Exclude        []AvailabilityRule `groups:"basic"` // Must not match one
}

func (*Availability) MatchDate

func (availability *Availability) MatchDate(dateTime time.Time) bool

type AvailabilityRecordType

type AvailabilityRecordType string

type AvailabilityRule

type AvailabilityRule struct {
	Type        AvailabilityRecordType `groups:"basic"`
	Value       string                 `groups:"basic"`
	Description string                 `groups:"basic"`
}

type BoolUnknown

type BoolUnknown string

type DataSource

type DataSource struct {
	OriginalFormat string `groups:"internal"` // or enum (eg. NaPTAN, TransXChange)
	Provider       string `groups:"internal"`
	DatasetID      string `groups:"internal"`
	Timestamp      string `groups:"internal"`
}

type DatasetVersion

type DatasetVersion struct {
	Dataset      string
	Hash         string
	LastModified time.Time
}

type DepartureBoard

type DepartureBoard struct {
	Journey            *Journey                 `groups:"basic"`
	DestinationDisplay string                   `groups:"basic"`
	Type               DepartureBoardRecordType `groups:"basic"`

	Platform     string `groups:"basic"`
	PlatformType string `groups:"basic"`

	Time time.Time `groups:"basic"`
}

func GenerateDepartureBoardFromJourneys

func GenerateDepartureBoardFromJourneys(journeys []*Journey, stopRefs []string, dateTime time.Time, doEstimates bool) []*DepartureBoard

type DepartureBoardRecordType

type DepartureBoardRecordType string

type Event

type Event struct {
	Type      EventType
	Timestamp time.Time
	Body      interface{}
}

type EventNotificationData

type EventNotificationData struct {
	Title   string
	Message string
}

type EventType

type EventType string

type Journey

type Journey struct {
	PrimaryIdentifier string            `groups:"basic" bson:",omitempty"`
	OtherIdentifiers  map[string]string `groups:"basic" json:",omitempty" bson:",omitempty"`

	CreationDateTime     time.Time `groups:"detailed" bson:",omitempty"`
	ModificationDateTime time.Time `groups:"detailed" bson:",omitempty"`

	DataSource *DataSource `groups:"detailed" bson:",omitempty"`

	ServiceRef string   `groups:"internal" bson:",omitempty"`
	Service    *Service `groups:"basic" json:",omitempty" bson:"-"`

	OperatorRef string    `groups:"internal" bson:",omitempty"`
	Operator    *Operator `groups:"basic" json:",omitempty" bson:"-"`

	Direction         string    `groups:"detailed" json:",omitempty" bson:",omitempty"`
	DepartureTime     time.Time `groups:"basic" bson:",omitempty"`
	DepartureTimezone string    `groups:"basic" bson:",omitempty"`

	Track []Location `groups:"detailed" bson:",omitempty"`

	DestinationDisplay string `groups:"basic" bson:",omitempty"`

	Availability *Availability `groups:"internal" bson:",omitempty"`

	Path []*JourneyPathItem `groups:"detailed" bson:",omitempty"`

	RealtimeJourney *RealtimeJourney `groups:"basic" bson:"-" bson:",omitempty"`

	// Detailed journey information
	DetailedRailInformation *JourneyDetailedRail `groups:"detailed" bson:",omitempty"`
}

func FilterIdenticalJourneys

func FilterIdenticalJourneys(journeys []*Journey, includeAvailabilityCondition bool) []*Journey

func (Journey) FlattenStops

func (j Journey) FlattenStops() ([]string, map[string]time.Time, map[string]time.Time)

func (*Journey) GenerateFunctionalHash

func (j *Journey) GenerateFunctionalHash(includeAvailabilityCondition bool) string

func (*Journey) GetDeepReferences

func (j *Journey) GetDeepReferences()

func (*Journey) GetOperator

func (j *Journey) GetOperator()

func (*Journey) GetRealtimeJourney

func (j *Journey) GetRealtimeJourney()

func (*Journey) GetReferences

func (j *Journey) GetReferences()

func (*Journey) GetService

func (j *Journey) GetService()

func (Journey) MarshalBinary

func (j Journey) MarshalBinary() ([]byte, error)

type JourneyDetailedRail

type JourneyDetailedRail struct {
	VehicleType     string `groups:"detailed"`
	VehicleTypeName string `groups:"detailed"`
	PowerType       string `groups:"detailed"`

	Carriages []RailCarriage `groups:"detailed"`

	Seating JourneyDetailedRailSeating `groups:"detailed"`

	SleeperAvailable bool                       `groups:"detailed"`
	Sleepers         JourneyDetailedRailSeating `groups:"detailed"`

	SpeedKMH int `groups:"detailed"`

	AirConditioning bool `groups:"detailed"`

	WiFi           bool `groups:"detailed"`
	Toilets        bool `groups:"detailed"`
	PowerPlugs     bool `groups:"detailed"`
	USBPlugs       bool `groups:"detailed"`
	DisabledAccess bool `groups:"detailed"`
	BicycleSpaces  bool `groups:"detailed"`

	DriverOnly    bool `groups:"detailed"`
	GuardRequired bool `groups:"detailed"`

	ReservationRequired     bool `groups:"detailed"`
	ReservationBikeRequired bool `groups:"detailed"`
	ReservationRecommended  bool `groups:"detailed"`

	CateringAvailable   bool   `groups:"detailed"`
	CateringDescription string `groups:"detailed"`

	ReplacementBus bool `groups:"detailed"`
}

type JourneyDetailedRailSeating

type JourneyDetailedRailSeating string

type JourneyPathItem

type JourneyPathItem struct {
	OriginStopRef      string `groups:"basic"`
	DestinationStopRef string `groups:"basic"`

	OriginStop      *Stop `groups:"basic"`
	DestinationStop *Stop `groups:"basic"`

	OriginPlatform      string `groups:"basic"`
	DestinationPlatform string `groups:"basic"`

	Distance int `groups:"basic"`

	OriginArrivalTime      time.Time `groups:"basic"`
	DestinationArrivalTime time.Time `groups:"basic"`

	OriginDepartureTime time.Time `groups:"basic"`

	DestinationDisplay string `groups:"basic"`

	OriginActivity      []JourneyPathItemActivity `groups:"basic"`
	DestinationActivity []JourneyPathItemActivity `groups:"basic"`

	Track []Location `groups:"basic"`
}

func (*JourneyPathItem) GetDestinationStop

func (jpi *JourneyPathItem) GetDestinationStop()

func (*JourneyPathItem) GetOriginStop

func (jpi *JourneyPathItem) GetOriginStop()

func (*JourneyPathItem) GetReferences

func (jpi *JourneyPathItem) GetReferences()

type JourneyPathItemActivity

type JourneyPathItemActivity string

type JourneyPlan

type JourneyPlan struct {
	RouteItems []JourneyPlanRouteItem

	StartTime   time.Time
	ArrivalTime time.Time
	Duration    time.Duration
}

type JourneyPlanResults

type JourneyPlanResults struct {
	JourneyPlans []JourneyPlan

	OriginStop      Stop
	DestinationStop Stop
}

type JourneyPlanRouteItem

type JourneyPlanRouteItem struct {
	Journey Journey

	OriginStopRef      string
	DestinationStopRef string

	StartTime   time.Time
	ArrivalTime time.Time
}

type Location

type Location struct {
	Type        string    `json:"point" groups:"basic"`
	Coordinates []float64 `json:"coordinates" groups:"basic"`
}

func (*Location) Distance

func (l1 *Location) Distance(l2 *Location) float64

func (*Location) DistanceFromLine

func (l *Location) DistanceFromLine(a Location, b Location) float64

Shameless taken 'inspiration' from https://stackoverflow.com/a/6853926

type Notification

type Notification struct {
	TargetUser string
	Type       NotificationType

	Title   string
	Message string
}

type NotificationType

type NotificationType string
const (
	NotificationTypePush  NotificationType = "Push"
	NotificationTypeEmail                  = "Email"
)

type Operator

type Operator struct {
	PrimaryIdentifier string   `groups:"basic" bson:",omitempty"`
	OtherIdentifiers  []string `groups:"detailed" bson:",omitempty"`

	CreationDateTime     time.Time `groups:"detailed" bson:",omitempty"`
	ModificationDateTime time.Time `groups:"detailed" bson:",omitempty"`

	DataSource *DataSource `groups:"internal" bson:",omitempty"`

	PrimaryName string   `groups:"basic" bson:",omitempty"`
	OtherNames  []string `groups:"detailed" bson:",omitempty"`

	OperatorGroupRef string         `groups:"internal" bson:",omitempty"`
	OperatorGroup    *OperatorGroup `groups:"detailed" bson:"-"`

	TransportType string `groups:"detailed" bson:",omitempty"`

	Licence string `groups:"internal" bson:",omitempty"`

	Website     string            `groups:"detailed" bson:",omitempty"`
	Email       string            `groups:"detailed" bson:",omitempty"`
	Address     string            `groups:"detailed" bson:",omitempty"`
	PhoneNumber string            `groups:"detailed" bson:",omitempty"`
	SocialMedia map[string]string `groups:"detailed" bson:",omitempty"`

	Regions []string `groups:"detailed" bson:",omitempty"`
}

func (*Operator) GetOperatorGroup

func (operator *Operator) GetOperatorGroup()

func (*Operator) GetReferences

func (operator *Operator) GetReferences()

func (*Operator) UniqueHash

func (operator *Operator) UniqueHash() string

type OperatorGroup

type OperatorGroup struct {
	Identifier string `groups:"basic"`
	Name       string `groups:"basic"`

	DataSource *DataSource `groups:"internal"`

	Operators []*Operator `bson:"-" groups:"detailed"`

	CreationDateTime     time.Time `groups:"detailed"`
	ModificationDateTime time.Time `groups:"detailed"`
}

func (*OperatorGroup) GetOperators

func (group *OperatorGroup) GetOperators()

func (*OperatorGroup) GetReferences

func (group *OperatorGroup) GetReferences()

func (*OperatorGroup) UniqueHash

func (group *OperatorGroup) UniqueHash() string

type RailCarriage

type RailCarriage struct {
	ID      string               `groups:"basic"`
	Class   string               `groups:"basic"`
	Toilets []RailCarriageToilet `groups:"basic"`

	Occupancy int `groups:"basic"`
}

type RailCarriageToilet

type RailCarriageToilet struct {
	Type   string `groups:"basic"`
	Status string `groups:"basic"`
}

type RealtimeJourney

type RealtimeJourney struct {
	PrimaryIdentifier string            `groups:"basic"`
	OtherIdentifiers  map[string]string `groups:"detailed"`

	ActivelyTracked bool `groups:"basic"`

	//JourneyRef string   `groups:"internal"`
	Journey *Journey `groups:"basic"`

	JourneyRunDate time.Time `groups:"basic"`

	CreationDateTime     time.Time `groups:"detailed"`
	ModificationDateTime time.Time `groups:"basic"`

	TimeoutDurationMinutes int `groups:"internal"`

	DataSource *DataSource `groups:"internal"`

	VehicleLocation            Location `groups:"basic"`
	VehicleLocationDescription string   `groups:"basic"`
	VehicleBearing             float64  `groups:"basic"`

	DepartedStopRef string `groups:"basic"`
	DepartedStop    *Stop  `groups:"basic" bson:"-"`

	NextStopRef string `groups:"basic"`
	NextStop    *Stop  `groups:"basic" bson:"-"`

	Stops  map[string]*RealtimeJourneyStops `groups:"basic"` // Historic & future estimates
	Offset time.Duration                    `groups:"internal"`

	Reliability RealtimeJourneyReliabilityType `groups:"basic"`

	VehicleRef string `groups:"internal"`

	Cancelled bool `groups:"basic"`

	Occupancy RealtimeJourneyOccupancy `groups:"detailed"`

	// Detailed realtime journey information
	DetailedRailInformation RealtimeJourneyDetailedRail `groups:"detailed"`
}

func (*RealtimeJourney) IsActive

func (r *RealtimeJourney) IsActive() bool

type RealtimeJourneyDetailedRail

type RealtimeJourneyDetailedRail struct {
	Carriages []RailCarriage `groups:"basic"`
}

type RealtimeJourneyOccupancy

type RealtimeJourneyOccupancy struct {
	OccupancyAvailable bool `groups:"basic"`

	ActualValues          bool `groups:"basic"`
	WheelchairInformation bool `groups:"basic"`
	SeatedInformation     bool `groups:"basic"`

	TotalPercentageOccupancy int `groups:"basic"`

	Capacity           int `groups:"basic"`
	SeatedCapacity     int `groups:"basic"`
	WheelchairCapacity int `groups:"basic"`

	Occupancy           int `groups:"basic"`
	SeatedOccupancy     int `groups:"basic"`
	WheelchairOccupancy int `groups:"basic"`
}

type RealtimeJourneyReliabilityType

type RealtimeJourneyReliabilityType string

type RealtimeJourneyStopTimeType

type RealtimeJourneyStopTimeType string
const (
	// Unknown         RealtimeJourneyStopTimeType = "Unknown"
	RealtimeJourneyStopTimeHistorical      RealtimeJourneyStopTimeType = "Historical"
	RealtimeJourneyStopTimeEstimatedFuture                             = "EstimatedFuture"
)

type RealtimeJourneyStops

type RealtimeJourneyStops struct {
	StopRef string `groups:"basic"`
	Stop    *Stop  `groups:"basic" bson:"-"`

	Platform string `groups:"basic"`

	ArrivalTime   time.Time `groups:"basic"`
	DepartureTime time.Time `groups:"basic"`

	TimeType RealtimeJourneyStopTimeType `groups:"basic"`

	Cancelled bool `groups:"basic"`
}

type Route

type Route struct {
	Origin      string `groups:"basic"`
	Destination string `groups:"basic"`
	Description string `groups:"basic"`
}

type Service

type Service struct {
	PrimaryIdentifier string            `groups:"basic"`
	OtherIdentifiers  map[string]string `groups:"basic"`

	CreationDateTime     time.Time `groups:"detailed"`
	ModificationDateTime time.Time `groups:"detailed"`

	DataSource *DataSource `groups:"internal"`

	ServiceName string `groups:"basic"`

	OperatorRef string `groups:"basic"`

	Routes []Route `groups:"detailed"`

	BrandColour          string `groups:"basic"`
	SecondaryBrandColour string `groups:"basic"`
	BrandIcon            string `groups:"basic"`
	BrandDisplayMode     string `groups:"basic"`

	StopNameOverrides map[string]string `groups:"internal"`

	TransportType TransportType `groups:"basic"`
}

type ServiceAlert

type ServiceAlert struct {
	PrimaryIdentifier string            `groups:"basic"`
	OtherIdentifiers  map[string]string `groups:"basic"`

	CreationDateTime     time.Time `groups:"detailed"`
	ModificationDateTime time.Time `groups:"detailed"`

	DataSource *DataSource `groups:"internal"`

	AlertType ServiceAlertType `groups:"basic"`

	Title string `groups:"basic"`
	Text  string `groups:"basic"`

	MatchedIdentifiers []string `groups:"internal"`

	ValidFrom  time.Time `groups:"internal"`
	ValidUntil time.Time `groups:"internal"`
}

func (*ServiceAlert) IsValid

func (a *ServiceAlert) IsValid(checkTime time.Time) bool

type ServiceAlertType

type ServiceAlertType string

type Stop

type Stop struct {
	PrimaryIdentifier string            `groups:"basic" bson:",omitempty"`
	OtherIdentifiers  map[string]string `groups:"basic" bson:",omitempty"`

	CreationDateTime     time.Time `groups:"detailed" bson:",omitempty"`
	ModificationDateTime time.Time `groups:"detailed" bson:",omitempty"`

	DataSource *DataSource `groups:"internal" bson:",omitempty"`

	PrimaryName    string            `groups:"basic" bson:",omitempty"`
	OtherNames     map[string]string `groups:"basic" bson:",omitempty"`
	TransportTypes []TransportType   `groups:"detailed" bson:",omitempty"`

	Timezone string `groups:"basic" bson:",omitempty"`

	Location *Location `groups:"basic" bson:",omitempty"`

	Services []*Service `bson:"-" groups:"basic" bson:",omitempty"`

	Active bool `groups:"basic" bson:",omitempty"`

	Associations []*StopAssociation `groups:"detailed" bson:",omitempty"`

	Platforms []*StopPlatform `groups:"detailed" bson:",omitempty"`
	Entrances []*StopEntrance `groups:"detailed" bson:",omitempty"`
}

func (*Stop) GetAllStopIDs

func (stop *Stop) GetAllStopIDs() []string

func (*Stop) UpdateNameFromServiceOverrides

func (stop *Stop) UpdateNameFromServiceOverrides(service *Service)

type StopAssociation

type StopAssociation struct {
	Type                 string
	AssociatedIdentifier string
}

type StopEntrance

type StopEntrance struct {
	PrimaryIdentifier string            `groups:"basic"`
	OtherIdentifiers  map[string]string `groups:"basic"`

	PrimaryName string            `groups:"basic"`
	OtherNames  map[string]string `groups:"basic"`

	Location *Location `groups:"detailed"`
}

type StopGroup

type StopGroup struct {
	PrimaryIdentifier string            `groups:"basic"`
	OtherIdentifiers  map[string]string `groups:"basic"`

	CreationDateTime     time.Time `groups:"detailed"`
	ModificationDateTime time.Time `groups:"detailed"`

	DataSource *DataSource `groups:"internal"`

	Name   string `groups:"basic"`
	Type   string `groups:"basic"`
	Status string `groups:"basic"`

	Stops []Stop `bson:"-" groups:"detailed"`
}

func (*StopGroup) GetStops

func (stopGroup *StopGroup) GetStops()

type StopPlatform

type StopPlatform struct {
	PrimaryIdentifier string            `groups:"basic"`
	OtherIdentifiers  map[string]string `groups:"basic"`

	PrimaryName string            `groups:"basic"`
	OtherNames  map[string]string `groups:"basic"`

	Location *Location `groups:"detailed"`
}

type TransportType

type TransportType string

type UserEventSubscription

type UserEventSubscription struct {
	UserID string

	EventType        EventType
	NotificationType NotificationType

	Expression string
}

type UserPushNotificationTarget

type UserPushNotificationTarget struct {
	UserID                string
	ModificationDateTime  time.Time
	PushNotificationToken string
}

Jump to

Keyboard shortcuts

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