trafikinfo

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2022 License: MIT Imports: 4 Imported by: 0

README

🚦 Trafikinfo 🦺

A Go library for the Trafikinfo API from Trafikverket

Build Status Release Coverage Status Go report card GoDoc

This library provides the necessary primitives to interact with the Trafikinfo API. It contains a query builder that can be used to build up a Request object. You can then xml.Marshal it and pass it on to your favourite HTTP client to retrieve it.

The API endpoint is available through the Endpoint constant. The only supported endpoint is v2, v1.x is being deprecated by Trafikverket.

This library is under construction and currently lacks the struct types to decode the response into.

Usage

req, err := trafikinfo.NewRequest().
	APIKey("YOUR_API_KEY").
	Query(
		trafikinfo.NewQuery(
			trafikinfo.WeatherStation,
			1.0,
		).Filter(
			trafikinfo.Equal("Id", "YOUR_STATION_ID"),
		),
	).Build()

if err != nil {
	panic(err)
}

// Rest of the code here to do the request, handle non-200 error
// responses etc.

type respMsg struct {
	Resonpse struct {
		Result []struct {
			WeatherStation []trafikinfo.WeatherStation1Dot0 `json:"WeatherStation"`
			Info           trafikinfo.Info                  `json:"INFO"`
		}
	} `json:"RESPONSE"`
}

var c respMsg
d := json.NewDecoder(resp.Body)
err = d.Decode(&c)

if err != nil {
	panic(err)
}

// Enjoy your struct!

More complete code can be found in the examples/ directory.

Multiple queries can be passed by either passing multiple NewQuery() into a single Query() call, or chaining .Query() multiple times on the result of NewRequest().

Calling .Filter() multiple times on a Query will replace the whole filter, as a query can only have one filter block.

Supported object types

This library provides structs for response decoding for the following object types and versions.

Object Versions
Camera 1.0: ❌
FerryAnnouncement 1.2: ❌
FerryRoute 1.2: ❌
Icon 1.0: ❌
MeasurementData100 1.0: ❌
MeasurementData20 1.0: ❌
Parking 1.0: ❌ 1.4: ❌
PavementData 1.0: ❌
RailCrossing 1.4: ✅ 1.5: ✅
ReasonCode 1.0: ✅
RoadCondition 1.0: ❌ 1.1: ❌ 1.2: ❌
RoadConditionOverview 1.0: ❌
RoadData 1.0: ❌
RoadGeometry 1.0: ❌
TrafficFlow 1.0: ❌ 1.4: ❌
TrafficSafetyCamera 1.0: ❌
TrainAnnouncement 1.0: ✅ 1.3: ✅ 1.4: ✅ 1.5: ✅ 1.6: ✅
TrainMessage 1.0: ✅ 1.3: ✅ 1.4: ✅ 1.5: ✅ 1.6: ✅ 1.7: ✅
TrainStation 1.0: ✅ 1.4: ✅
TrainStationMessage 1.0: ✅
TravelTimeRoute 1.0: ❌ 1.3: ❌ 1.4: ❌ 1.5
WeatherMeasurepoint 1.0: ❌ 2.0: ❌
WeatherObservation 1.0: ❌ 2.0: ❌
WeatherStation 1.0: ✅

Documentation

Index

Constants

View Source
const Endpoint = "https://api.trafikinfo.trafikverket.se/v2/data.json"

Endpoint is the current recommended endpoint for the Trafikinfo API

Variables

This section is empty.

Functions

This section is empty.

Types

type ActivityType added in v0.2.0

type ActivityType string
const (
	ActivityTypeArrival   ActivityType = "Ankomst"
	ActivityTypeDeparture ActivityType = "Avgang"
)

type CountryCode added in v0.2.0

type CountryCode string
const (
	CountryCodeGermany CountryCode = "DE"
	CountryCodeDenmark CountryCode = "DK"
	CountryCodeNorway  CountryCode = "NO"
	CountryCodeSweden  CountryCode = "SE"
)

type CountyNumber added in v0.2.0

type CountyNumber uint

CountyNumber is a numerical ID assigned to a county in Sweden

const (
	CountyStockholm CountyNumber = iota + 1
	CountyStockholmDeprecated
	CountyUppsala
	CountySodermanland
	CountyOstergotland
	CountyJonkoping
	CountyKronobergs
	CountyKalmar
	CountyGotland
	CountyBlekinge

	CountySkane
	CountyHallands
	CountyVastraGotaland

	CountyVarmland
	CountyOrebro
	CountyVastmanland
	CountyDalarna
	CountyGavleborg
	CountyVasternorrland
	CountyJamtland
	CountyVasterbotten
	CountyNorrbotten
)

func (CountyNumber) String added in v0.2.0

func (c CountyNumber) String() string

type Filter

type Filter struct {
	// contains filtered or unexported fields
}

Filter represents a filter element in the query.

func And

func And(f1, f2 Filter, rest ...Filter) Filter

And builds an AND filter

func ElementMatch

func ElementMatch(f1, f2 Filter, rest ...Filter) Filter

ElementMatch builds an ELEMENTMATCH filter

func Equal

func Equal(name, value string) Filter

Equal filters by if the field provided by name matches the specified value

func Exists

func Exists(name string, exists bool) Filter

Exists filters by whether the field provided by name exists or not

func GreaterThan

func GreaterThan(name, value string) Filter

GreaterThan filters by whether the field specified by name is greater than the specified value

func GreaterThanOrEqual

func GreaterThanOrEqual(name, value string) Filter

GreaterThanOrEqual filters by whether the field specified by name is greater than or equal to the specified value

func In

func In(name, value string) Filter

In filters by if the field specified by name matches any of the provided values

func Intersects

func Intersects(name, value string) Filter

Intersects filters by if te field specified in name intersects with the coordinates provided in value

func LessThan

func LessThan(name, value string) Filter

LessThan filters by whether the field specified by name is less than the specified value

func LessThanOrEqual

func LessThanOrEqual(name, value string) Filter

LessThanOrEqual filters by whether the field specified by name is less than or equal to the specified value

func Like

func Like(name, value string) Filter

Like filters by if the field provided by name matches the regex provided by value

func Near

func Near(name, value string, minDistance, maxDistance int) Filter

Near filters by if the field specified in name is within the specified min/max dinstance from the point coordinates sepcified in value

func Not

func Not(f1, f2 Filter, rest ...Filter) Filter

Not builds an NOT filter

func NotEqual

func NotEqual(name, value string) Filter

NotEqual is the inverse of Equal

func NotIn

func NotIn(name, value string) Filter

NotIn is the inverse of In

func NotLike

func NotLike(name, value string) Filter

NotLIke is the inverse of Like

func Or

func Or(f1, f2 Filter, rest ...Filter) Filter

Or builds an OR filter

func Within

func Within(name, value, shape string, radius float64) Filter

Within filters by if the field specified in name falls within the specified shape, radius and the coordinates in value

func (*Filter) MarshalXML

func (f *Filter) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type Geometry added in v0.2.0

type Geometry struct {
	SWEREF99TM *string `json:"SWEREF99TM,omitempty"`
	WGS84      *string `json:"WGS84,omitempty"`
}

type Info added in v0.2.0

type Info struct {
	LastModified *LastModified `json:"LASTMODIFIED,omitempty"`
	LastChangeID *string       `json:"LASTCHANGEID,omitempty"`
	EvalResult   []any         `json:"EVALRESULT,omitempty"`
	SSEURL       *string       `json:"SSEURL,omitempty"`
}

type LastModified added in v0.2.0

type LastModified struct {
	DateTime *time.Time `json:"_attr_datetime,omitempty"`
}

type MediaType added in v0.2.0

type MediaType string
const (
	MediaTypeMonitor      MediaType = "Monitor"
	MediaTypePlatformSign MediaType = "Plattformsskylt"
	MediaTypeAnnouncement MediaType = "Utrop"
)

type MessageStatus added in v0.2.0

type MessageStatus string
const (
	MessageStatusLow        MessageStatus = "Lag"
	MessageStatusNormal     MessageStatus = "Normal"
	MessageStatusHigh       MessageStatus = "Hog"
	MessageStatusDisruption MessageStatus = "StortLage"
)

type ObjectType

type ObjectType string

ObjectType is a type of object you can retrieve from the API

const (
	RailCrossing        ObjectType = "RailCrossing"
	ReasonCode          ObjectType = "ReasonCode"
	TrainAnnouncement   ObjectType = "TrainAnnouncement"
	TrainMessage        ObjectType = "TrainMessage"
	TrainStation        ObjectType = "TrainStation"
	TrainStationMessage ObjectType = "TrainStationMessage"
	TrainPosition       ObjectType = "TrainPosition"

	Camera                ObjectType = "Camera"
	FerryAnnouncement     ObjectType = "FerryAnnouncement"
	FerryRoute            ObjectType = "FerryRoute"
	Icon                  ObjectType = "Icon"
	Parking               ObjectType = "Parking"
	RoadCondition         ObjectType = "RoadCondition"
	RoadConditionOverview ObjectType = "RoadConditionOverview"
	Situation             ObjectType = "Situation"
	TrafficFlow           ObjectType = "TrafficFlow"
	TrafficSafetyCamera   ObjectType = "TrafficSafetyCamera"
	TravelTimeRoute       ObjectType = "TravelTimeRoute"
	WeatherMeasurePoint   ObjectType = "WeatherMeasurePoint"
	WeatherObservation    ObjectType = "WeatherObservation"
	WeatherStation        ObjectType = "WeatherStation"

	MeasurementData100 ObjectType = "MeasurementData100"
	MeasurementData20  ObjectType = "MeasurementData20"
	PavementData       ObjectType = "PavementData"
	RoadData           ObjectType = "RoadData"
	RoadGeometry       ObjectType = "RoadGeometry"
)

type PrecipitationAmountName added in v0.2.0

type PrecipitationAmountName string
const (
	PrecipitationDataMissing PrecipitationAmountName = "Givare saknas/Fel på givare"
	PrecipitationLightRain   PrecipitationAmountName = "Lätt regn"
	PrecipitationMildRain    PrecipitationAmountName = "Måttligt regn"
	PrecipitationHeavyRain   PrecipitationAmountName = "Kraftigt regn"

	PrecipitationLightSleet PrecipitationAmountName = "Lätt snöblandat regn"
	PrecipitationMildSleet  PrecipitationAmountName = "Måttligt snöblandat regn"
	PrecipitationHeavySleet PrecipitationAmountName = "Kraftigt snöblandat regn"

	PrecipitationLightSnow PrecipitationAmountName = "Lätt snöfall"
	PrecipitationMindSnow  PrecipitationAmountName = "Måttligt snöfall"
	PrecipitationHeavySnow PrecipitationAmountName = "Kraftigt snöfall"

	PrecipitationOther   PrecipitationAmountName = "Annan nederbördstyp"
	PrecipitationUnknown PrecipitationAmountName = "Okänd nederbördstyp"
	PrecipitationNone    PrecipitationAmountName = "Ingen nederbörd"
)

type PrecipitationType added in v0.2.0

type PrecipitationType string
const (
	PrecipitationTypeDrizzle      PrecipitationType = "Duggregn"
	PrecipitationTypeHail         PrecipitationType = "Hagel"
	PrecipitationTypeRain         PrecipitationType = "Regn"
	PrecipitationTypeSnow         PrecipitationType = "Snö"
	PrecipitationTypeSleet        PrecipitationType = "Snöblandat regn"
	PrecipitationTypeFreezingRain PrecipitationType = "Underkylt regn"
	PrecipitationTypeNone         PrecipitationType = "Ingen nederbörd"
)

type Query

type Query struct {
	// contains filtered or unexported fields
}

Query is used to request information from the Trafikinfo API

func NewQuery

func NewQuery(objectType ObjectType, schemaVersion float64) *Query

NewQuery returns a query that other methods can be chained on to further customise the request.

func (*Query) ChangeID added in v0.1.1

func (q *Query) ChangeID(opt string) *Query

ChangeID sets the change ID for the request. This should initially be 0 to request all data, and then be set to the value of the change ID in the response to only get updated/deleted objects since the previous change ID.

func (*Query) Distinct

func (q *Query) Distinct(field string) *Query

Distinct returns an array of unique values of this field

func (*Query) Exclude

func (q *Query) Exclude(fields ...string) *Query

Exclude ensures element matching the specifields fields are ommitted

func (*Query) Filter

func (q *Query) Filter(filters ...Filter) *Query

func (*Query) ID added in v0.1.1

func (q *Query) ID(opt string) *Query

ID is an arbitrary value which will be echoed in the response. It can be used to associate queries with responses, especially when a request includes multiple queries.

func (*Query) Include

func (q *Query) Include(fields ...string) *Query

Include ensures only elements matching the specified fields are returned

func (*Query) IncludeDeletedObjects added in v0.1.1

func (q *Query) IncludeDeletedObjects(opt bool) *Query

IncludeDeletedObjects requests that deleted objects also be returned. This defaults to false.

func (*Query) LastModified added in v0.1.1

func (q *Query) LastModified(opt bool) *Query

LastModified results in a lastmodified timestamp being included in the response.

func (*Query) Limit added in v0.1.1

func (q *Query) Limit(opt int) *Query

Limit sets the limit for the amount of items to be returned. This can be used together with Skip to implement pagination. A Limit of 0 means no limit at all, i.e return everything.

func (*Query) MarshalXML

func (q *Query) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*Query) OrderBy added in v0.1.1

func (q *Query) OrderBy(opt string) *Query

OrderBy takes a sorting expression the items in the response will be sorted by.

For example:

OrderBy("SomeData.Name desc, SomeData.Description asc")

func (*Query) Skip added in v0.1.1

func (q *Query) Skip(opt int) *Query

Skip sets how many items to skip/exclude from the response. This can be used together with Limit to implement pagination.

type RailCrossing1Dot4 added in v0.2.0

type RailCrossing1Dot4 struct {
	ObjectID *int `json:"ObjectId,omitempty"`
	RailCrossing1Dot5
}

type RailCrossing1Dot5 added in v0.2.0

type RailCrossing1Dot5 struct {
	DataLastUpdated        *time.Time       `json:"DataLastUpdated,omitempty"`
	Deleted                *bool            `json:"Deleted,omitempty"`
	Geometry               *Geometry        `json:"Geometry,omitempty"`
	Kilometer              *int             `json:"Kilometer,omitempty"`
	LevelCrossingID        *int             `json:"LevelCrossingId,omitempty"`
	Meter                  *int             `json:"Meter,omitempty"`
	ModifiedTime           *time.Time       `json:"ModifiedTime,omitempty"`
	NumberOfTracks         *int             `json:"NumberOfTracks,omitempty"`
	OperatingMode          *string          `json:"OperatingMode,omitempty"`
	PortalHeightLeft       *float64         `json:"PortalHeightLeft,omitempty"`
	PortalHeightRight      *float64         `json:"PortalHeightRight,omitempty"`
	RailwayRouteID         *string          `json:"RailwayRouteId,omitempty"`
	RoadNameAlternative    *string          `json:"RoadNameAlternative,omitempty"`
	RoadNameOfficial       *string          `json:"RoadNameOfficial,omitempty"`
	RoadProfileCrest       *int             `json:"RoadProfileCrest,omitempty"`
	RoadProfileCrossCurve  *int             `json:"RoadProfileCrossCurve,omitempty"`
	RoadProfileSteepSlope  *int             `json:"RoadProfileSteepSlope,omitempty"`
	RoadProtectionAddition []TrainCodeDescr `json:"RoadProtectionAddition,omitempty"`
	RoadProtectionBase     []TrainCodeDescr `json:"RoadProtectionBase,omitempty"`
	RoadRouteID            *string          `json:"RoadRouteId,omitempty"`
	TrackPortion           *int             `json:"TrackPortion,omitempty"`
	TrainFlow              *int             `json:"TrainFlow,omitempty"`
}

type ReasonCode1Dot0 added in v0.2.0

type ReasonCode1Dot0 struct {
	Code              *string    `json:"Code,omitempty"`
	Deleted           *bool      `json:"Deleted,omitempty"`
	GroupDescription  *string    `json:"GroupDescription,omitempty"`
	Level1Description *string    `json:"Level1Description,omitempty"`
	Level2Description *string    `json:"Level2Description,omitempty"`
	Level3Description *string    `json:"Level3Description,omitempty"`
	ModifiedTime      *time.Time `json:"ModifiedTime,omitempty"`
}

ReasonCode1Dot0 represents a reason for a train related issue.

The "Code" and "Level3Description" fields correspond to the "Code" and "Description" fields for the TrainAnnouncement and TrainMessage object types.

type Request

type Request struct {
	XMLName string   `xml:"REQUEST"`
	Login   *login   `xml:"LOGIN"`
	Queries []*Query `xml:"QUERY"`
}

Request tells the API what we're interested in

It must include the Login information and at least one Query.

func NewRequest

func NewRequest() *Request

NewRequest returns a Request using the specified API authentication key and the data to be retrieved and filtered by the specified queries. At least 1 query needs to be provided.

func (*Request) APIKey

func (r *Request) APIKey(key string) *Request

APIKey sets the API key to use for this request

func (*Request) Build

func (r *Request) Build() ([]byte, error)

Build returns the XML encoded request as an array of bytes. It can be passed as http.NewRequest's body by wrapping it in a call to bytes.NewBuffer().

The Build() method is final when used in a fluent API style, you can't chain additional methods on it that continue to modify the request.

func (*Request) Query

func (r *Request) Query(query *Query, rest ...*Query) *Request

Query adds one or more queries to the request

type Road added in v0.2.0

type Road struct {
	Temperature       *float64 `json:"Temp,omitempty"`
	TemperatureIconID *string  `json:"TempIconId,omitempty"`
}

type TrainAnnouncement1Dot0 added in v0.2.0

type TrainAnnouncement1Dot0 struct {
	ActivityID                 *string       `json:"ActivityId,omitempty"`
	ActivityType               *ActivityType `json:"ActivityType,omitempty"`
	Advertised                 *bool         `json:"Advertised,omitempty"`
	AdvertisedTimeAtLocation   *time.Time    `json:"AdvertisedTimeAtLocation,omitempty"`
	AdvertisedTrainIdent       *string       `json:"AdvertisedTrainIdent,omitempty"`
	Booking                    []string      `json:"Booking,omitempty"`
	Canceled                   *bool         `json:"Canceled,omitempty"`
	Deleted                    *bool         `json:"Deleted,omitempty"`
	Deviation                  []string      `json:"Deviation,omitempty"`
	EstimatedTimeAtLocation    *time.Time    `json:"EstimatedTimeAtLocation,omitempty"`
	EstimatedTimeIsPreliminary *bool         `json:"EstimatedTimeIsPreliminary,omitempty"`
	FromLocation               []string      `json:"FromLocation,omitempty"`
	InformationOwner           *string       `json:"InformationOwner,omitempty"`
	LocationSignature          *string       `json:"LocationSignature,omitempty"`
	MobileWebLink              *string       `json:"MobileWebLink,omitempty"`
	ModifiedTime               *time.Time    `json:"ModifiedTime,omitempty"`
	OtherInformation           []string      `json:"OtherInformation,omitempty"`
	ProductInformation         []string      `json:"ProductInformation,omitempty"`
	ScheduledDepartureDateTime *time.Time    `json:"ScheduledDepartureDateTime,omitempty"`
	Service                    []string      `json:"Service,omitempty"`
	TimeAtLocation             *time.Time    `json:"TimeAtLocation,omitempty"`
	ToLocation                 []string      `json:"ToLocation,omitempty"`
	TrackAtLocation            *string       `json:"TrackAtLocation,omitempty"`
	TrainComposition           []string      `json:"TrainComposition,omitempty"`
	TypeOfTraffic              *string       `json:"TypeOfTraffic,omitempty"`
	WebLink                    *string       `json:"WebLink,omitempty"`
}

type TrainAnnouncement1Dot3 added in v0.2.0

type TrainAnnouncement1Dot3 struct {
	ActivityID                            *string                     `json:"ActivityId,omitempty"`
	ActivityType                          *ActivityType               `json:"ActivityType,omitempty"`
	Advertised                            *bool                       `json:"Advertised,omitempty"`
	AdvertisedTimeAtLocation              *time.Time                  `json:"AdvertisedTimeAtLocation,omitempty"`
	AdvertisedTrainIdent                  *string                     `json:"AdvertisedTrainIdent,omitempty"`
	Booking                               []string                    `json:"Booking,omitempty"`
	Canceled                              *bool                       `json:"Canceled,omitempty"`
	Deleted                               *bool                       `json:"Deleted,omitempty"`
	Deviation                             []string                    `json:"Deviation,omitempty"`
	EstimatedTimeAtLocation               *time.Time                  `json:"EstimatedTimeAtLocation,omitempty"`
	EstimatedTimeIsPreliminary            *bool                       `json:"EstimatedTimeIsPreliminary,omitempty"`
	FromLocation                          []TrainAnnouncementLocation `json:"FromLocation,omitempty"`
	InformationOwner                      *string                     `json:"InformationOwner,omitempty"`
	LocationSignature                     *string                     `json:"LocationSignature,omitempty"`
	MobileWebLink                         *string                     `json:"MobileWebLink,omitempty"`
	ModifiedTime                          *time.Time                  `json:"ModifiedTime,omitempty"`
	NewEquipment                          *int                        `json:"NewEquipment,omitempty"`
	OtherInformation                      []string                    `json:"OtherInformation,omitempty"`
	PlannedEstimatedTimeAtLocation        *time.Time                  `json:"PlannedEstimatedTimeAtLocation,omitempty"`
	PlannedEstimatedTimeAtLocationIsValid *bool                       `json:"PlannedEstimatedTimeAtLocationIsValid,omitempty"`
	ProductInformation                    []string                    `json:"ProductInformation,omitempty"`
	ScheduledDepartureDateTime            *time.Time                  `json:"ScheduledDepartureDateTime,omitempty"`
	Service                               []string                    `json:"Service,omitempty"`
	TechnicalTrainIdent                   *string                     `json:"TechnicalTrainIdent,omitempty"`
	TimeAtLocation                        *time.Time                  `json:"TimeAtLocation,omitempty"`
	ToLocation                            []TrainAnnouncementLocation `json:"ToLocation,omitempty"`
	TrackAtLocation                       *string                     `json:"TrackAtLocation,omitempty"`
	TrainComposition                      []string                    `json:"TrainComposition,omitempty"`
	TypeOfTraffic                         *string                     `json:"TypeOfTraffic,omitempty"`
	ViaFromLocation                       []TrainAnnouncementLocation `json:"ViaFromLocation,omitempty"`
	ViaToLocation                         []TrainAnnouncementLocation `json:"ViaToLocation,omitempty"`
	WebLink                               *string                     `json:"WebLink,omitempty"`
	WebLinkName                           *string                     `json:"WebLinkName,omitempty"`
}

type TrainAnnouncement1Dot4 added in v0.2.0

type TrainAnnouncement1Dot4 struct {
	TrainAnnouncement1Dot3
	Operator                  *string    `json:"Operator,omitempty"`
	TechnicalDateTime         *time.Time `json:"TechnicalDateTime,omitempty"`
	TimeAtLocationWithSeconds *time.Time `json:"TimeAtLocationWithSeconds,omitempty"`
	TrainOwner                *string    `json:"TrainOwner,omitempty"`
}

type TrainAnnouncement1Dot5 added in v0.2.0

type TrainAnnouncement1Dot5 struct {
	ActivityID                            *string                     `json:"ActivityId,omitempty"`
	ActivityType                          *ActivityType               `json:"ActivityType,omitempty"`
	Advertised                            *bool                       `json:"Advertised,omitempty"`
	AdvertisedTimeAtLocation              *time.Time                  `json:"AdvertisedTimeAtLocation,omitempty"`
	AdvertisedTrainIdent                  *string                     `json:"AdvertisedTrainIdent,omitempty"`
	Booking                               []TrainCodeDescr            `json:"Booking,omitempty"`
	Canceled                              *bool                       `json:"Canceled,omitempty"`
	Deleted                               *bool                       `json:"Deleted,omitempty"`
	Deviation                             []TrainCodeDescr            `json:"Deviation,omitempty"`
	EstimatedTimeAtLocation               *time.Time                  `json:"EstimatedTimeAtLocation,omitempty"`
	EstimatedTimeIsPreliminary            *bool                       `json:"EstimatedTimeIsPreliminary,omitempty"`
	FromLocation                          []TrainAnnouncementLocation `json:"FromLocation,omitempty"`
	InformationOwner                      *string                     `json:"InformationOwner,omitempty"`
	LocationSignature                     *string                     `json:"LocationSignature,omitempty"`
	MobileWebLink                         *string                     `json:"MobileWebLink,omitempty"`
	ModifiedTime                          *time.Time                  `json:"ModifiedTime,omitempty"`
	NewEquipment                          *int                        `json:"NewEquipment,omitempty"`
	Operator                              *string                     `json:"Operator,omitempty"`
	OtherInformation                      []TrainCodeDescr            `json:"OtherInformation,omitempty"`
	PlannedEstimatedTimeAtLocation        *time.Time                  `json:"PlannedEstimatedTimeAtLocation,omitempty"`
	PlannedEstimatedTimeAtLocationIsValid *bool                       `json:"PlannedEstimatedTimeAtLocationIsValid,omitempty"`
	ProductInformation                    []TrainCodeDescr            `json:"ProductInformation,omitempty"`
	ScheduledDepartureDateTime            *time.Time                  `json:"ScheduledDepartureDateTime,omitempty"`
	Service                               []TrainCodeDescr            `json:"Service,omitempty"`
	TechnicalDateTime                     *time.Time                  `json:"TechnicalDateTime,omitempty"`
	TechnicalTrainIdent                   *string                     `json:"TechnicalTrainIdent,omitempty"`
	TimeAtLocation                        *time.Time                  `json:"TimeAtLocation,omitempty"`
	TimeAtLocationWithSeconds             *time.Time                  `json:"TimeAtLocationWithSeconds,omitempty"`
	ToLocation                            []TrainAnnouncementLocation `json:"ToLocation,omitempty"`
	TrackAtLocation                       *string                     `json:"TrackAtLocation,omitempty"`
	TrainComposition                      []TrainCodeDescr            `json:"TrainComposition,omitempty"`
	TrainOwner                            *string                     `json:"TrainOwner,omitempty"`
	TypeOfTraffic                         *string                     `json:"TypeOfTraffic,omitempty"`
	ViaFromLocation                       []TrainAnnouncementLocation `json:"ViaFromLocation,omitempty"`
	ViaToLocation                         []TrainAnnouncementLocation `json:"ViaToLocation,omitempty"`
	WebLink                               *string                     `json:"WebLink,omitempty"`
	WebLinkName                           *string                     `json:"WebLinkName,omitempty"`
}

type TrainAnnouncement1Dot6 added in v0.2.0

type TrainAnnouncement1Dot6 struct {
	ActivityID                            *string                     `json:"ActivityId,omitempty"`
	ActivityType                          *ActivityType               `json:"ActivityType,omitempty"`
	Advertised                            *bool                       `json:"Advertised,omitempty"`
	AdvertisedTimeAtLocation              *time.Time                  `json:"AdvertisedTimeAtLocation,omitempty"`
	AdvertisedTrainIdent                  *string                     `json:"AdvertisedTrainIdent,omitempty"`
	Booking                               []TrainCodeDescr            `json:"Booking,omitempty"`
	Canceled                              *bool                       `json:"Canceled,omitempty"`
	Deleted                               *bool                       `json:"Deleted,omitempty"`
	Deviation                             []TrainCodeDescr            `json:"Deviation,omitempty"`
	EstimatedTimeAtLocation               *time.Time                  `json:"EstimatedTimeAtLocation,omitempty"`
	EstimatedTimeIsPreliminary            *bool                       `json:"EstimatedTimeIsPreliminary,omitempty"`
	FromLocation                          []TrainAnnouncementLocation `json:"FromLocation,omitempty"`
	InformationOwner                      *string                     `json:"InformationOwner,omitempty"`
	LocationSignature                     *string                     `json:"LocationSignature,omitempty"`
	MobileWebLink                         *string                     `json:"MobileWebLink,omitempty"`
	ModifiedTime                          *time.Time                  `json:"ModifiedTime,omitempty"`
	NewEquipment                          *int                        `json:"NewEquipment,omitempty"`
	Operator                              *string                     `json:"Operator,omitempty"`
	OtherInformation                      []TrainCodeDescr            `json:"OtherInformation,omitempty"`
	PlannedEstimatedTimeAtLocation        *time.Time                  `json:"PlannedEstimatedTimeAtLocation,omitempty"`
	PlannedEstimatedTimeAtLocationIsValid *bool                       `json:"PlannedEstimatedTimeAtLocationIsValid,omitempty"`
	ProductInformation                    []TrainCodeDescr            `json:"ProductInformation,omitempty"`
	ScheduledDepartureDateTime            *time.Time                  `json:"ScheduledDepartureDateTime,omitempty"`
	Service                               []TrainCodeDescr            `json:"Service,omitempty"`
	TechnicalDateTime                     *time.Time                  `json:"TechnicalDateTime,omitempty"`
	TechnicalTrainIdent                   *string                     `json:"TechnicalTrainIdent,omitempty"`
	TimeAtLocation                        *time.Time                  `json:"TimeAtLocation,omitempty"`
	TimeAtLocationWithSeconds             *time.Time                  `json:"TimeAtLocationWithSeconds,omitempty"`
	ToLocation                            []TrainAnnouncementLocation `json:"ToLocation,omitempty"`
	TrackAtLocation                       *string                     `json:"TrackAtLocation,omitempty"`
	TrainComposition                      []TrainCodeDescr            `json:"TrainComposition,omitempty"`
	TrainOwner                            *string                     `json:"TrainOwner,omitempty"`
	TypeOfTraffic                         []TrainCodeDescr            `json:"TypeOfTraffic,omitempty"`
	ViaFromLocation                       []TrainAnnouncementLocation `json:"ViaFromLocation,omitempty"`
	ViaToLocation                         []TrainAnnouncementLocation `json:"ViaToLocation,omitempty"`
	WebLink                               *string                     `json:"WebLink,omitempty"`
	WebLinkName                           *string                     `json:"WebLinkName,omitempty"`
}

type TrainAnnouncementLocation added in v0.2.0

type TrainAnnouncementLocation struct {
	LocationName *string `json:"LocationName,omitempty"`
	Priority     *int    `json:"Priority,omitempty"`
	Order        *int    `json:"Order,omitempty"`
}

type TrainCodeDescr added in v0.2.0

type TrainCodeDescr struct {
	Code        *string `json:"Code,omitempty"`
	Description *string `json:"Description,omitempty"`
}

type TrainMessage1Dot0 added in v0.2.0

type TrainMessage1Dot0 struct {
	TrainMessageCommon
	AffectedLocation []string `json:"AffectedLocation,omitempty"`
	ReasonCodeText   *string  `json:"ReasonCodeText,omitempty"`
}

type TrainMessage1Dot3 added in v0.2.0

type TrainMessage1Dot3 struct {
	TrainMessage1Dot0
	Header        *string `json:"Header,omitempty"`
	TrafficImpact *struct {
		AffectedLocation []string `json:"AffectedLocation,omitempty"`
		FromLocation     []string `json:"FromLocation,omitempty"`
		ToLocation       []string `json:"ToLocation,omitempty"`
	} `json:"TrafficImpact,omitempty"`
	EndDateTime *time.Time `json:"EndDateTime,omitempty"`
}

type TrainMessage1Dot4 added in v0.2.0

type TrainMessage1Dot4 struct {
	TrainMessage1Dot3
	PrognosticatedEndDateTimeTrafficImpact *time.Time `json:"PrognosticatedEndDateTimeTrafficImpact,omitempty"`
	ExpectTrafficImpact                    *bool      `jsno:"ExpectTrafficImpact,omitempty"`
}

type TrainMessage1Dot5 added in v0.2.0

type TrainMessage1Dot5 struct {
	TrainMessageCommon
	AffectedLocation                       []string        `json:"AffectedLocation,omitempty"`
	EndDateTime                            *time.Time      `json:"EndDateTime,omitempty"`
	ExpectTrafficImpact                    *bool           `jsno:"ExpectTrafficImpact,omitempty"`
	Header                                 *string         `json:"Header,omitempty"`
	PrognosticatedEndDateTimeTrafficImpact *time.Time      `json:"PrognosticatedEndDateTimeTrafficImpact,omitempty"`
	ReasonCode                             *TrainCodeDescr `json:"ReasonCodeText,omitempty"`
	TrafficImpact                          *struct {
		AffectedLocation []string `json:"AffectedLocation,omitempty"`
		FromLocation     []string `json:"FromLocation,omitempty"`
		ToLocation       []string `json:"ToLocation,omitempty"`
	} `json:"TrafficImpact,omitempty"`
}

type TrainMessage1Dot6 added in v0.2.0

type TrainMessage1Dot6 struct {
	TrainMessageCommon
	EndDateTime                            *time.Time      `json:"EndDateTime,omitempty"`
	Header                                 *string         `json:"Header,omitempty"`
	PrognosticatedEndDateTimeTrafficImpact *time.Time      `json:"PrognosticatedEndDateTimeTrafficImpact,omitempty"`
	ReasonCode                             *TrainCodeDescr `json:"ReasonCodeText,omitempty"`
	TrafficImpact                          *struct {
		AffectedLocation []string `json:"AffectedLocation,omitempty"`
		FromLocation     []string `json:"FromLocation,omitempty"`
		IsConfirmed      *bool    `json:"IsConfirmed,omitempty"`
		ToLocation       []string `json:"ToLocation,omitempty"`
	} `json:"TrafficImpact,omitempty"`
}

type TrainMessage1Dot7 added in v0.2.0

type TrainMessage1Dot7 struct {
	TrainMessageCommon
	EndDateTime                            *time.Time      `json:"EndDateTime,omitempty"`
	Header                                 *string         `json:"Header,omitempty"`
	PrognosticatedEndDateTimeTrafficImpact *time.Time      `json:"PrognosticatedEndDateTimeTrafficImpact,omitempty"`
	ReasonCode                             *TrainCodeDescr `json:"ReasonCodeText,omitempty"`
	TrafficImpact                          *struct {
		AffectedLocation []struct {
			LocationSignature       *string `json:"LocationSignature,omitempty"`
			ShouldBeTrafficInformed *bool   `json:"ShouldBeTrafficInformed,omitempty"`
		} `json:"AffectedLocation,omitempty"`
		FromLocation []string `json:"FromLocation,omitempty"`
		IsConfirmed  *bool    `json:"IsConfirmed,omitempty"`
		ToLocation   []string `json:"ToLocation,omitempty"`
	} `json:"TrafficImpact,omitempty"`
}

type TrainMessageCommon added in v0.2.0

type TrainMessageCommon struct {
	CountyNo            []CountyNumber `json:"CountyNo,omitempty"`
	Deleted             *bool          `json:"Deleted,omitempty"`
	EventID             *string        `json:"EventId,omitempty"`
	ExternalDescription *string        `json:"ExternalDescription,omitempty"`
	Geometry            *Geometry      `json:"Geometry,omitempty"`
	LastUpdateDateTime  *time.Time     `json:"LastUpdateDateTime,omitempty"`
	ModifiedTime        *time.Time     `json:"ModifiedTime,omitempty"`
	StartDateTime       *time.Time     `json:"StartDateTime,omitempty"`
}

type TrainStation1Dot0 added in v0.2.0

type TrainStation1Dot0 struct {
	Advertised                  *bool          `json:"Advertised,omitempty"`
	AdvertisedLocationName      *string        `json:"AdvertisedLocationName,omitempty"`
	AdvertisedShortLocationName *string        `json:"AdvertisedShortLocationName,omitempty"`
	CountryCode                 *CountryCode   `json:"CountryCode,omitempty"`
	CountyNo                    []CountyNumber `json:"CountyNo,omitempty"`
	Deleted                     *bool          `json:"Deleted,omitempty"`
	Geometry                    *Geometry      `json:"Geometry,omitempty"`
	LocationInformationText     *string        `json:"LocationInformationText,omitempty"`
	LocationSignature           *string        `json:"LocationSignature,omitempty"`
	ModifiedTime                *time.Time     `json:"ModifiedTime,omitempty"`
	PlatformLine                []string       `json:"PlatformLine,omitempty"`
	Prognosticated              *bool          `json:"Prognosticated,omitempty"`
}

type TrainStation1Dot4 added in v0.2.0

type TrainStation1Dot4 struct {
	TrainStation1Dot0
	OfficialLocationName *string `json:"OfficialLocationName,omitempty"`
}

type TrainStationMessage1Dot0 added in v0.2.0

type TrainStationMessage1Dot0 struct {
	ActiveDays        *string    `json:"ActiveDays,omitempty"`
	Deleted           *bool      `json:"Deleted,omitempty"`
	EndDateTime       *time.Time `json:"EndDateTime,omitempty"`
	EventID           *string    `json:"EventId,omitempty" yaml:"EventId,omitempty"`
	FreeText          *string    `json:"FreeText,omitempty"`
	ID                *string    `json:"Id,omitempty"`
	LocationCode      *string    `json:"LocationCode,omitempty"`
	MediaType         *MediaType `json:"MediaType,omitempty"`
	ModifiedTime      *time.Time `json:"ModifiedTime,omitempty"`
	MonitorAttributes *struct {
		BigScreenMonitorActivated *bool `json:"BigScreenMonitorActivated,omitempty"`
		CommuterMonitor           *bool `json:"CommuterMonitor,omitempty"`
	} `json:"MonitorAttributes,omitempty"`
	PlatformSignAttributes *struct {
		CommuterPlatformSign *bool `json:"CommuterPlatformSign,omitempty"`
		TrackList            *struct {
			Track []string `json:"Track,omitempty"`
		} `json:"TrackList,omitempty"`
	} `json:"PlatformSignAttributes,omitempty"`
	PublicAnnouncementAttributes *struct {
		EnglishPublicAnnouncementActivated *bool   `json:"EnglishPublicAnnouncementActivated,omitempty"`
		EnglishText                        *string `json:"EnglishText,omitempty"`
		PublicAnnouncementPlanList         *struct {
			PublicAnnouncementPlan []struct {
				ActiveDays                     *string `json:"ActiveDays,omitempty"`
				PublicAnnouncementOccasionList *struct {
					PublicAnnouncementOccasion []int `json:"PublicAnnouncementOccasion,omitempty"`
				} `json:"PublicAnnouncementOccasionList,omitempty"`
				ValidFrom *time.Time `json:"ValidFrom,omitempty"`
				ValidTo   *time.Time `json:"ValidTo,omitempty"`
			} `json:"PublicAnnouncementPlan,omitempty"`
		} `json:"PublicAnnouncementPlanList,omitempty"`
		PublicAnnouncementZoneList *struct {
			PublicAnnouncementZone []string `json:"PublicAnnouncementZone,omitempty"`
		} `json:"PublicAnnouncementZoneList,omitempty"`
	} `json:"PublicAnnouncementAttributes,omitempty"`
	SplitActivationTime *bool          `json:"SplitActivationTime,omitempty"`
	StartDateTime       *time.Time     `json:"StartDateTime,omitempty"`
	Status              *MessageStatus `json:"Status,omitempty"`
	VersionNumber       *int           `json:"VersionNumber,omitempty"`
}

type WeatherMeasurement added in v0.2.0

type WeatherMeasurement struct {
	Air *struct {
		RelativeHumidity  *float64 `json:"RelativeHumidity,omitempty"`
		Temperature       *float64 `json:"Temp,omitempty"`
		TemperatureIconID *string  `json:"TempIconId,omitempty"`
	} `json:"Air,omitempty"`
	MeasureTime   *time.Time `json:"MeasureTime,omitempty"`
	Precipitation *struct {
		Amount     *float64                 `json:"Amount,omitempty"`
		AmountName *PrecipitationAmountName `json:"AmountName,omitempty"`
		Type       *PrecipitationType       `json:"Type,omitempty"`
		TypeIconID *string                  `json:"TypeIconId,omitempty"`
	} `json:"Precipitation,omitempty"`
	Road *Road `json:"Road,omitempty"`
	Wind *struct {
		Direction       *float64       `json:"Direction,omitempty"`
		DirectionIconID *string        `json:"DirectionIconId,omitempty"`
		DirectionText   *WindDirection `json:"DirectionText,omitempty"`
		Force           *float64       `json:"Force,omitempty"`
		ForceMax        *float64       `json:"ForceMax,omitempty"`
	} `json:"Wind,omitempty"`
}

type WeatherStation1Dot0 added in v0.2.0

type WeatherStation1Dot0 struct {
	Active             *bool                `json:"Active,omitempty"`
	CountyNumber       []CountyNumber       `json:"CountyNo,omitempty"`
	Deleted            *bool                `json:"Deleted,omitempty"`
	Geometry           *Geometry            `json:"Geometry,omitempty"`
	IconID             *string              `json:"IconId,omitempty"`
	ID                 *string              `json:"Id,omitempty"`
	Measurement        *WeatherMeasurement  `json:"Measurement,omitempty"`
	MeasurementHistory []WeatherMeasurement `json:"MeasurementHistory,omitempty"`
	ModifiedTime       *time.Time           `json:"ModifiedTime,omitempty"`
	Name               *string              `json:"Name,omitempty"`
	RoadNumber         *int                 `json:"RoadNumberNumeric,omitempty"`
}

type WindDirection added in v0.2.0

type WindDirection string
const (
	WindDirectionN   WindDirection = "Norr"
	WindDirectionNE  WindDirection = "Nordöst"
	WindDirectionNNE WindDirection = "Nordnordöst"
	WindDirectionNNW WindDirection = "Nordnordväst"
	WindDirectionNW  WindDirection = "Nordväst"

	WindDirectionE   WindDirection = "Öst"
	WindDirectionESE WindDirection = "Östsydöst"

	WindDirectionS   WindDirection = "Söder"
	WindDirectionSE  WindDirection = "Sydöst"
	WindDirectionSSW WindDirection = "Sydsydväst"
	WindDirectionSW  WindDirection = "Sydväst"

	WindDirectionW WindDirection = "Väst"
)

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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