Documentation ¶
Index ¶
- Constants
- type Filter
- func And(f1, f2 Filter, rest ...Filter) Filter
- func ElementMatch(f1, f2 Filter, rest ...Filter) Filter
- func Equal(name, value string) Filter
- func Exists(name string, exists bool) Filter
- func GreaterThan(name, value string) Filter
- func GreaterThanOrEqual(name, value string) Filter
- func In(name, value string) Filter
- func Intersects(name, value string) Filter
- func LessThan(name, value string) Filter
- func LessThanOrEqual(name, value string) Filter
- func Like(name, value string) Filter
- func Near(name, value string, minDistance, maxDistance int) Filter
- func Not(f1, f2 Filter, rest ...Filter) Filter
- func NotEqual(name, value string) Filter
- func NotIn(name, value string) Filter
- func NotLike(name, value string) Filter
- func Or(f1, f2 Filter, rest ...Filter) Filter
- func Within(name, value, shape string, radius float64) Filter
- type ObjectType
- type Query
- func (q *Query) ChangeID(opt int) *Query
- func (q *Query) Distinct(field string) *Query
- func (q *Query) Exclude(fields ...string) *Query
- func (q *Query) Filter(filters ...Filter) *Query
- func (q *Query) ID(opt string) *Query
- func (q *Query) Include(fields ...string) *Query
- func (q *Query) IncludeDeletedObjects(opt bool) *Query
- func (q *Query) LastModified(opt bool) *Query
- func (q *Query) Limit(opt int) *Query
- func (q *Query) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (q *Query) OrderBy(opt string) *Query
- func (q *Query) Skip(opt int) *Query
- type Request
Constants ¶
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 Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter represents a filter element in the query.
func ElementMatch ¶
ElementMatch builds an ELEMENTMATCH filter
func GreaterThan ¶
GreaterThan filters by whether the field specified by name is greater than the specified value
func GreaterThanOrEqual ¶
GreaterThanOrEqual filters by whether the field specified by name is greater than or equal to the specified value
func Intersects ¶
Intersects filters by if te field specified in name intersects with the coordinates provided in value
func LessThan ¶
LessThan filters by whether the field specified by name is less than the specified value
func LessThanOrEqual ¶
LessThanOrEqual filters by whether the field specified by name is less than or equal to the specified value
func Near ¶
Near filters by if the field specified in name is within the specified min/max dinstance from the point coordinates sepcified in value
func Within ¶
Within filters by if the field specified in name falls within the specified shape, radius and the coordinates in value
func (*Filter) MarshalXML ¶
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 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
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.
Note that setting a ChangeID of 0 does not cause the Change ID to be ommitted from the request. This is harmless, the only difference being that without having a Change ID set at all there won't be a Change ID returned in the response.
func (*Query) ID ¶ added in v0.1.1
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) IncludeDeletedObjects ¶ added in v0.1.1
IncludeDeletedObjects requests that deleted objects also be returned. This defaults to false.
func (*Query) LastModified ¶ added in v0.1.1
LastModified results in a lastmodified timestamp being included in the response.
func (*Query) Limit ¶ added in v0.1.1
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 ¶
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) Build ¶
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.