transxchange

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: 22 Imported by: 0

Documentation

Index

Constants

View Source
const DateTimeFormat = "2006-01-02T15:04:05"
View Source
const DateTimeFormatWithTimezone = "2006-01-02T15:04:05-07:00"
View Source
const DateTimeFormatWithTimezoneRegex = ".+[+-]\\d{2}:\\d{2}"

Variables

This section is empty.

Functions

This section is empty.

Types

type DatePattern

type DatePattern struct {
	DateRange   []DateRange
	Description string

	DateExclusion string
}

type DateRange

type DateRange struct {
	StartDate string
	EndDate   string
	Note      string
}

type Garage

type Garage struct {
	GarageCode string
	GarageName string
	Location   Location
}

type JourneyPattern

type JourneyPattern struct {
	ID                   string `xml:"id,attr"`
	CreationDateTime     string `xml:",attr"`
	ModificationDateTime string `xml:",attr"`

	OperatingProfile OperatingProfile // `xml:",innerxml" json:"-" bson:"-"`

	DestinationDisplay        string
	OperatorRef               string
	Direction                 string
	RouteRef                  string
	JourneyPatternSectionRefs string
}

type JourneyPatternSection

type JourneyPatternSection struct {
	ID string `xml:"id,attr"`

	JourneyPatternTimingLinks []JourneyPatternTimingLink `xml:"JourneyPatternTimingLink"`
}
func (jp *JourneyPatternSection) GetTimingLink(ID string) (*JourneyPatternTimingLink, error)
type JourneyPatternTimingLink struct {
	ID string `xml:"id,attr"`

	RouteLinkRef string
	RunTime      string

	From JourneyPatternTimingLinkPoint
	To   JourneyPatternTimingLinkPoint
}

type JourneyPatternTimingLinkPoint

type JourneyPatternTimingLinkPoint struct {
	ID             string `xml:"id,attr"`
	SequenceNumber string `xml:",attr"`

	WaitTime                  string
	Activity                  string
	DynamicDestinationDisplay string
	StopPointRef              string
	TimingStatus              string
	FareStageNumber           string
}

type Line

type Line struct {
	ID       string `xml:"id,attr"`
	LineName string

	OutboundOrigin      string `xml:"OutboundDescription>Origin"`
	OutboundDestination string `xml:"OutboundDescription>Destination"`
	OutboundDescription string `xml:"OutboundDescription>Description"`

	InboundOrigin      string `xml:"InboundDescription>Origin"`
	InboundDestination string `xml:"InboundDescription>Destination"`
	InboundDescription string `xml:"InboundDescription>Description"`
}

type Location

type Location struct {
	LocationInner

	Translation LocationInner
}

type LocationInner

type LocationInner struct {
	Longitude float64
	Latitude  float64

	GridType string
	Easting  string
	Northing string
}

type OperatingProfile

type OperatingProfile struct {
	XMLValue string `xml:",innerxml" json:"-" bson:"-"`

	RegularDayType              []string
	PeriodicDayType             []string
	BankHolidayOperation        []string
	BankHolidayNonOperation     []string
	ServicedOrganisationDayType []string
	SpecialDaysOperation        []string
}

func (*OperatingProfile) ToCTDF

func (operatingProfile *OperatingProfile) ToCTDF(servicedOrganisations []*ServicedOrganisation) (*ctdf.Availability, error)

This is a bit hacky and doesn't seem like the best way of doing it but it works

type Operator

type Operator struct {
	ID string `xml:"id,attr"`

	CreationDateTime     string `xml:",attr"`
	ModificationDateTime string `xml:",attr"`

	NationalOperatorCode  string
	OperatorCode          string
	OperatorShortName     string
	OperatorNameOnLicence string
	TradingName           string
	LicenceNumber         string

	Garages []Garage `xml:"Garages>Garage"`
}

type Route

type Route struct {
	ID                   string `xml:"id,attr"`
	CreationDateTime     string `xml:",attr"`
	ModificationDateTime string `xml:",attr"`

	PrivateCode     string
	Description     string
	RouteSectionRef []string
}
type RouteLink struct {
	ID                   string `xml:"id,attr"`
	CreationDateTime     string `xml:",attr"`
	ModificationDateTime string `xml:",attr"`

	FromStop string `xml:"From>StopPointRef"`
	ToStop   string `xml:"To>StopPointRef"`
	Distance int

	Track []Location `xml:"Track>Mapping>Location"`
}

type RouteSection

type RouteSection struct {
	ID string `xml:"id,attr"`

	RouteLinks []RouteLink `xml:"RouteLink"`
}
func (r *RouteSection) GetRouteLink(ID string) (*RouteLink, error)

type Service

type Service struct {
	CreationDateTime     string `xml:",attr"`
	ModificationDateTime string `xml:",attr"`

	ServiceCode              string
	TicketMachineServiceCode string
	RegisteredOperatorRef    string
	PublicUse                bool
	OperatingPeriod          DateRange

	Mode string

	OperatingProfile OperatingProfile // `xml:",innerxml" json:"-" bson:"-"`

	Lines []Line `xml:"Lines>Line"`

	//TODO: Handle Flexible service
	Origin           string `xml:"StandardService>Origin"`
	Destination      string `xml:"StandardService>Destination"`
	UseAllStopPoints string `xml:"StandardService>UseAllStopPoints"`

	JourneyPatterns []*JourneyPattern `xml:"StandardService>JourneyPattern"`
}

type ServicedOrganisation

type ServicedOrganisation struct {
	ServicedOrganisationClassification string
	NatureOfOrganisation               string
	PhaseOfEducation                   string

	OrganisationCode string
	Name             string
	Note             string

	WorkingDays DatePattern
	Holidays    DatePattern

	DateExclusion []string

	ParentServicedOrganisationRef string
}

type StopPoint

type StopPoint struct {
	AtcoCode string

	CommonName string `xml:"Descriptor>CommonName"`
}

type TransXChange

type TransXChange struct {
	CreationDateTime     string `xml:",attr"`
	ModificationDateTime string `xml:",attr"`

	StopPoints []*StopPoint

	Operators              []*Operator
	Routes                 []*Route
	Services               []*Service
	JourneyPatternSections []*JourneyPatternSection
	RouteSections          []*RouteSection
	VehicleJourneys        []*VehicleJourney
	ServicedOrganisations  []*ServicedOrganisation

	SchemaVersion string `xml:",attr"`
}

func ParseXMLFile

func ParseXMLFile(reader io.Reader) (*TransXChange, error)

func (*TransXChange) Import

func (doc *TransXChange) Import(datasource *ctdf.DataSource, transportType ctdf.TransportType, overrides map[string]string)

func (*TransXChange) Validate

func (doc *TransXChange) Validate() error

type VehicleJourney

type VehicleJourney struct {
	CreationDateTime     string `xml:",attr"`
	ModificationDateTime string `xml:",attr"`
	SequenceNumber       string `xml:",attr"`

	PrivateCode        string
	OperatorRef        string
	Direction          string
	GarageRef          string
	VehicleJourneyCode string
	ServiceRef         string
	LineRef            string
	JourneyPatternRef  string
	DepartureTime      string
	DestinationDisplay string

	Frequency *struct {
		EndTime  string
		Interval *struct {
			ScheduledFrequency string
		}
	}

	Operational struct {
		TicketMachine struct {
			JourneyCode string
		}
		Block struct {
			BlockNumber string
		}
	}

	VehicleJourneyTimingLinks []VehicleJourneyTimingLink `xml:"VehicleJourneyTimingLink"`

	OperatingProfile OperatingProfile // `xml:",innerxml" json:"-" bson:"-"`
}

func (*VehicleJourney) GetVehicleJourneyTimingLinkByJourneyPatternTimingLinkRef

func (v *VehicleJourney) GetVehicleJourneyTimingLinkByJourneyPatternTimingLinkRef(ID string) *VehicleJourneyTimingLink
type VehicleJourneyTimingLink struct {
	ID string `xml:"id,attr"`

	JourneyPatternTimingLinkRef string
	RunTime                     string

	From JourneyPatternTimingLinkPoint
	To   JourneyPatternTimingLinkPoint
}

Jump to

Keyboard shortcuts

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