models

package
v1.4.7 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: GPL-3.0 Imports: 4 Imported by: 10

Documentation

Index

Constants

View Source
const ModificationArrivalPlatformAllocated = 23

ModificationArrivalPlatformAllocated when a arrival platform is allocated (only DVM stations, i.e. Schiphol Airport)

View Source
const ModificationBusReplacement = 51

ModificationBusReplacement service is a bus replacement service

View Source
const ModificationCancelledArrival = 39

ModificationCancelledArrival train was scheduled to arrive, but didn't

View Source
const ModificationCancelledDeparture = 32

ModificationCancelledDeparture cancelled departure (train was scheduled to stop here)

View Source
const ModificationCancelledThroughTrain = 44

ModificationCancelledThroughTrain passing-through train has been cancelled (train would not stop at this station)

View Source
const ModificationCancelledTrain = 25

ModificationCancelledTrain Train is cancelled

View Source
const ModificationChangedArrivalPlatform = 21

ModificationChangedArrivalPlatform is for changed arrival platforms (compared to the schedule)

View Source
const ModificationChangedArrivalTime = 13

ModificationChangedArrivalTime when the arrival time has been changed

View Source
const ModificationChangedDeparturePlatform = 20

ModificationChangedDeparturePlatform is for changed departure platforms (compared to the schedule)

View Source
const ModificationChangedDepartureTime = 12

ModificationChangedDepartureTime when the departure time has been changed

View Source
const ModificationChangedDestination = 41

ModificationChangedDestination destination has been changed (not extended nor shortened, it's a new route)

View Source
const ModificationChangedOrigin = 42

ModificationChangedOrigin origin has been changed (not an extension or shortening of the normal route)

View Source
const ModificationChangedStopPattern = 30

ModificationChangedStopPattern when an extra stop is added or a stop is changed

View Source
const ModificationDelayedArrival = 11

ModificationDelayedArrival is the status for delays on arriving trains

View Source
const ModificationDelayedDeparture = 10

ModificationDelayedDeparture is the status for delays on departing trains

View Source
const ModificationDeparturePlatformAllocated = 22

ModificationDeparturePlatformAllocated when a departure platform is allocated (only DVM stations, i.e. Schiphol Airport)

View Source
const ModificationDiverted = 33

ModificationDiverted train is diverted, takes another route

View Source
const ModificationExtraArrival = 38

ModificationExtraArrival extra arrival, i.e. train doesn't normally arrive at this station

View Source
const ModificationExtraDeparture = 31

ModificationExtraDeparture extra departure for this station (train usually doesn't depart here)

View Source
const ModificationExtraThroughTrain = 43

ModificationExtraThroughTrain extra train which just passes by (doesn't stop at this station)

View Source
const ModificationExtraTrain = 24

ModificationExtraTrain for extra trains (not in the normal schedule)

View Source
const ModificationIntercityRunsAsSprinter = 81

ModificationSprinterRunsAsIntercity when an Sprinter train is running with intercity stock

View Source
const ModificationMaterialAdded = 83

ModificationMaterialAdded when material is added on a station

View Source
const ModificationMaterialAlreadyRemoved = 85

ModificationMaterialAlreadyRemoved when the material that was left behind has already been removed (driven away)

View Source
const ModificationMaterialClosed = 82

ModificationMaterialClosed when material is closed for passengers

View Source
const ModificationMaterialLeftBehind = 84

ModificationMaterialLeftBehind when material is left behind on a station

View Source
const ModificationNotActual = 50

ModificationNotActual indicator for non-realtime information, e.g. replacement buses or some foreign trains

View Source
const ModificationOriginRouteExtended = 37

ModificationOriginRouteExtended train departs from an earlier stop than the normal origin station

View Source
const ModificationOriginRouteShortened = 36

ModificationOriginRouteShortened departs from a later stop than usual

View Source
const ModificationRouteExtended = 35

ModificationRouteExtended train continues beyond normal destination

View Source
const ModificationRouteShortened = 34

ModificationRouteShortened train terminates early

View Source
const ModificationSprinterRunsAsIntercity = 80

ModificationSprinterRunsAsIntercity when an intercity train is running with Sprinter stock

View Source
const ModificationStatusChange = 40

ModificationStatusChange train status changed (i.e. from 'at platform' to 'departed')

Variables

This section is empty.

Functions

func GetFilteredRemarks

func GetFilteredRemarks(modifications []Modification, language string) []string

GetFilteredRemarks filters out modification types for arrival/departure platforms (useful for wings)

func GetRemarks

func GetRemarks(modifications []Modification, language string) []string

GetRemarks translates a slice of Modification structs to remarks in the requested language

func Translate

func Translate(remarkNL, remarkEN, language string) string

Translate returns the appropriate translation based on language

func TranslateCause

func TranslateCause(causeLong string) string

TranslateCause translates a Dutch cause (long version) to an English cause

func TranslateStations

func TranslateStations(remarkNL, remarkEN string, stations []Station, language string) string

TranslateStations returns the appropriate translation based on language

Types

type Arrival

type Arrival struct {
	StoreItem

	ServiceID   string
	ServiceDate string
	ServiceName string
	Station     Station
	LineNumber  string

	Status          int
	ServiceNumber   string
	ServiceType     string
	ServiceTypeCode string
	Company         string

	ArrivalTime time.Time
	Delay       int

	ReservationRequired bool
	WithSupplement      bool
	SpecialTicket       bool
	RearPartRemains     bool
	DoNotBoard          bool
	Cancelled           bool
	NotRealTime         bool

	OriginActual  []Station
	OriginPlanned []Station
	ViaActual     []Station
	ViaPlanned    []Station

	PlatformActual  string
	PlatformPlanned string

	Modifications []Modification

	Hidden bool
}

Arrival is an arriving train on a single station

func (Arrival) ActualOriginCodes

func (arrival Arrival) ActualOriginCodes() []string

ActualOriginCodes returns a slice of all actual origin station codes

func (Arrival) ActualOriginString

func (arrival Arrival) ActualOriginString() string

ActualOriginString returns a string of all actual origins (long name)

func (*Arrival) GenerateID

func (arrival *Arrival) GenerateID()

GenerateID generates an ID for this arrival

func (Arrival) PlannedOriginString

func (arrival Arrival) PlannedOriginString() string

PlannedOriginString returns a string of all planned origins (long name)

func (Arrival) PlatformChanged

func (arrival Arrival) PlatformChanged() bool

PlatformChanged returns true when the platform has been changed

func (Arrival) RealArrivalTime

func (arrival Arrival) RealArrivalTime() time.Time

RealArrivalTime returns the actual arrival time, including delay

func (Arrival) ViaStationsString

func (arrival Arrival) ViaStationsString() string

ViaStationsString returns a string of all actual via stations (medium name)

type BoardingTip

type BoardingTip struct {
	ExitStation       Station
	Destination       Station
	TrainType         string
	TrainTypeCode     string
	DeparturePlatform string
	DepartureTime     time.Time
}

BoardingTip is a tip for passengers to board another train for certain destinations

func (BoardingTip) Translation

func (tip BoardingTip) Translation(language string) string

Translation provides a translation for this tip

type ChangeTip

type ChangeTip struct {
	Destination   Station
	ChangeStation Station
}

ChangeTip is a tip to change trains at ChangeStation for the given destination

func (ChangeTip) Translation

func (tip ChangeTip) Translation(language string) string

Translation provides a translation for this tip

type Departure

type Departure struct {
	StoreItem

	ServiceID   string
	ServiceDate string
	ServiceName string
	Station     Station
	LineNumber  string

	Status          int
	ServiceNumber   string
	ServiceType     string
	ServiceTypeCode string
	Company         string

	DepartureTime time.Time
	Delay         int

	ReservationRequired bool
	WithSupplement      bool
	SpecialTicket       bool
	RearPartRemains     bool
	DoNotBoard          bool
	Cancelled           bool
	NotRealTime         bool

	DestinationActual  []Station
	DestinationPlanned []Station
	ViaActual          []Station
	ViaPlanned         []Station

	PlatformActual  string
	PlatformPlanned string

	TrainWings []TrainWing

	BoardingTips []BoardingTip
	TravelTips   []TravelTip
	ChangeTips   []ChangeTip

	Modifications []Modification

	Hidden bool
}

Departure is a train service which departs from a single station

func (Departure) ActualDestinationCodes

func (departure Departure) ActualDestinationCodes() []string

ActualDestinationCodes returns a slice of all actual destination station codes

func (Departure) ActualDestinationString

func (departure Departure) ActualDestinationString() string

ActualDestinationString returns a string of all actual destinations (long name)

func (Departure) ActualViaStationsString

func (departure Departure) ActualViaStationsString() string

ActualViaStationsString returns a string of all actual via stations (medium name)

func (*Departure) GenerateID

func (departure *Departure) GenerateID()

GenerateID generates an ID for this departure

func (Departure) GetRemarksTips

func (departure Departure) GetRemarksTips(language string) (remarks, tips []string)

GetRemarksTips returns all (translated) remarks and tips, both travel tips and tips based on departure flags

func (Departure) PlannedDestinationString

func (departure Departure) PlannedDestinationString() string

PlannedDestinationString returns a string of all planned destinations (long name)

func (Departure) PlannedViaStationsString

func (departure Departure) PlannedViaStationsString() string

PlannedViaStationsString returns a string of all planned via stations (medium name)

func (Departure) PlatformChanged

func (departure Departure) PlatformChanged() bool

PlatformChanged returns true when the platform has been changed

func (Departure) RealDepartureTime

func (departure Departure) RealDepartureTime() time.Time

RealDepartureTime returns the actual departure time, including delay

type Material

type Material struct {
	NaterialType       string  `json:"type"`
	Number             string  `json:"number"`
	Position           int     `json:"position"`
	DestinationActual  Station `json:"destination_actual"`
	DestinationPlanned Station `json:"destination_planned"`
	Accessible         bool    `json:"accessible"`

	Closed         bool `json:"closed"`
	RemainsBehind  bool `json:"remains_behind"`
	Added          bool `json:"added"`
	AlreadyRemoved bool `json:"already_removed"`

	Modifications []Modification
}

Material is the physical train unit

func (Material) NormalizedNumber

func (material Material) NormalizedNumber() *string

NormalizedNumber returns a normal material number (i.e. it removes the 000000-0...-0 prefixes and suffixes). Example: 000000-09547-0 will be translated to 9547

type Modification

type Modification struct {
	ModificationType int     `json:"type"`
	CauseShort       string  `json:"cause_short"`
	CauseLong        string  `json:"cause_long"`
	Station          Station `json:"station"`
}

Modification is a change (to the schedule) which is communicated to travellers

func (Modification) Remark

func (modification Modification) Remark(language string) (string, bool)

Remark translates a Modification object to a translated text message

type Service

type Service struct {
	StoreItem

	ValidUntil      time.Time
	ServiceNumber   string
	ServiceDate     string
	ServiceType     string
	ServiceTypeCode string
	LineNumber      string
	Company         string

	ServiceParts []ServicePart

	ReservationRequired bool
	WithSupplement      bool
	SpecialTicket       bool
	JourneyPlanner      bool

	Modifications []Modification

	Hidden bool
}

Service is the train service containing all parts, stops etc.

func (*Service) GenerateID

func (service *Service) GenerateID()

GenerateID generates an ID for this service

func (*Service) GetStops

func (service *Service) GetStops() map[string]ServiceStop

GetStops returns all stops (from all service parts) as a map, with the station code as key

type ServicePart

type ServicePart struct {
	ServiceNumber string
	Stops         []ServiceStop
	Modifications []Modification
}

ServicePart is a single part of a train service (a service usually contains just one part, but may contain more)

func (ServicePart) GetStoppingStations

func (servicePart ServicePart) GetStoppingStations() (stops []ServiceStop)

GetStoppingStations filters out ServiceStops which are not called by the service.

type ServiceStop

type ServiceStop struct {
	Station Station

	StationAccessible   bool
	AssistanceAvailable bool

	DestinationActual        string
	DestinationPlanned       string
	ArrivalPlatformActual    string
	ArrivalPlatformPlanned   string
	DeparturePlatformActual  string
	DeparturePlatformPlanned string

	StoppingActual  bool
	StoppingPlanned bool
	StopType        string
	DoNotBoard      bool

	ArrivalTime    time.Time
	ArrivalDelay   int
	DepartureTime  time.Time
	DepartureDelay int

	ArrivalCancelled   bool
	DepartureCancelled bool

	Modifications []Modification
	Material      []Material
}

ServiceStop is a stops which is called by a train service.

func (*ServiceStop) ArrivalPlatformChanged

func (stop *ServiceStop) ArrivalPlatformChanged() bool

ArrivalPlatformChanged returns true when the planned platform is not the actual one

func (*ServiceStop) DeparturePlatformChanged

func (stop *ServiceStop) DeparturePlatformChanged() bool

DeparturePlatformChanged returns true when the planned platform is not the actual one

func (*ServiceStop) IsStopping

func (stop *ServiceStop) IsStopping() bool

IsStopping checks whether the service is stopping at this stop or whether is was planned to do so

type Station

type Station struct {
	Code       string `json:"code"`
	NameShort  string `json:"short"`
	NameMedium string `json:"medium"`
	NameLong   string `json:"long"`
}

Station is a station in the railway network. It has a code and 3 names (short, medium, long)

type StoreItem

type StoreItem struct {
	ID        string    `json:"-"`
	Timestamp time.Time `json:"-"`
	ProductID string    `json:"-"`
}

StoreItem is for shared fields like ID, timestamp etc.

type TrainWing

type TrainWing struct {
	DestinationActual  []Station
	DestinationPlanned []Station
	Stations           []Station
	StationsPlanned    []Station
	Material           []Material
	Modifications      []Modification
}

TrainWing is a part of a train departure with a single destination

func (TrainWing) DestinationActualString added in v1.0.5

func (wing TrainWing) DestinationActualString() string

DestinationActualString returns a string of all actual destination stations (medium name)

func (TrainWing) DestinationPlannedString added in v1.0.5

func (wing TrainWing) DestinationPlannedString() string

DestinationPlannedString returns a string of all planned destination stations (medium name)

type TravelTip

type TravelTip struct {
	TipCode  string
	Stations []Station
}

TravelTip is a tip that a service calls (or doesn't call) at a specific station

func (TravelTip) Translation

func (tip TravelTip) Translation(language string) string

Translation provides a translation for this tip

Jump to

Keyboard shortcuts

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