Documentation
¶
Index ¶
- Constants
- func Bool(b bool) *bool
- func Delay(delay int) *int
- func Int(i int) *int
- func MustBool(b *bool) bool
- func MustInt(i *int) int
- func MustTime(t *time.Time) time.Time
- func Time(t time.Time) *time.Time
- type Journey
- func (j *Journey) GetArrival() time.Time
- func (j *Journey) GetArrivalDelay() *int
- func (j *Journey) GetArrivalPlatform() string
- func (j *Journey) GetDeparture() time.Time
- func (j *Journey) GetDepartureDelay() *int
- func (j *Journey) GetDeparturePlatform() string
- func (j *Journey) GetDestination() *StopStation
- func (j *Journey) GetFirstTrip() *Trip
- func (j *Journey) GetLastTrip() *Trip
- func (j *Journey) GetOrigin() *StopStation
- func (j Journey) MarshalBSON() ([]byte, error)
- func (j Journey) MarshalBSONValue() (bsontype.Type, []byte, error)
- func (j *Journey) MarshalJSON() ([]byte, error)
- func (j *Journey) UnmarshalBSON(data []byte) error
- func (j *Journey) UnmarshalBSONValue(typ bsontype.Type, data []byte) error
- func (j *Journey) UnmarshalJSON(data []byte) error
- type Line
- type Location
- type Mode
- type Operator
- type Price
- type Region
- type Route
- type Schedule
- type SequenceElement
- type Station
- type Stop
- type StopStation
- func (s *StopStation) GetId() string
- func (s *StopStation) GetLocation() *Location
- func (s *StopStation) GetName() string
- func (s StopStation) MarshalBSONValue() (bsontype.Type, []byte, error)
- func (s *StopStation) MarshalJSON() ([]byte, error)
- func (s *StopStation) SetId(id string)
- func (s *StopStation) SetLocation(loc *Location)
- func (s *StopStation) SetName(name string)
- func (s *StopStation) UnmarshalBSONValue(typ bsontype.Type, data []byte) error
- func (s *StopStation) UnmarshalJSON(data []byte) error
- type Stopover
- type TimeNullable
- type TimeUnix
- type Trip
- type Typed
Constants ¶
const ( ModeTrain = Mode("train") ModeBus = Mode("bus") ModeWatercraft = Mode("watercraft") ModeTaxi = Mode("taxi") ModeGondola = Mode("gondola") ModeAircraft = Mode("aircraft") ModeCar = Mode("car") ModeBicycle = Mode("bicycle") ModeWalking = Mode("walking") )
As discussed in #4, we decided to have two fields mode and subMode. The following list shows all possible values for a mode property. For consumers to be able to use mode meaningfully, we will keep this list very short.
In order to convey more details, we will add the subMode field in the future. It will differentiate means of transport in a more fine-grained way, in order to enable consumers to provide more context and a better service.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Journey ¶
type Journey struct {
Id string
Trips []*Trip
Price *Price
Meta interface{} // any additional data
}
Journey is a computed set of directions to get from A to B at a specific time. It would typically be the result of a route planning algorithm.
func (*Journey) GetArrival ¶
func (*Journey) GetArrivalDelay ¶
func (*Journey) GetArrivalPlatform ¶
func (*Journey) GetDeparture ¶
func (*Journey) GetDepartureDelay ¶
func (*Journey) GetDeparturePlatform ¶
func (*Journey) GetDestination ¶
func (j *Journey) GetDestination() *StopStation
func (*Journey) GetFirstTrip ¶
func (*Journey) GetLastTrip ¶
func (*Journey) GetOrigin ¶
func (j *Journey) GetOrigin() *StopStation
func (Journey) MarshalBSON ¶ added in v1.0.1
func (Journey) MarshalBSONValue ¶ added in v1.0.1
func (*Journey) MarshalJSON ¶
func (*Journey) UnmarshalBSON ¶ added in v1.0.1
func (*Journey) UnmarshalBSONValue ¶ added in v1.0.1
func (*Journey) UnmarshalJSON ¶
type Line ¶
type Line struct {
Id string
Name string
Mode Mode
SubMode string
Routes []*Route
Operator *Operator
Meta interface{} // any additional data
Partial bool // only show the id in the json response?
}
func (Line) MarshalBSONValue ¶ added in v1.0.1
func (*Line) MarshalJSON ¶
func (*Line) UnmarshalBSONValue ¶ added in v1.0.1
func (*Line) UnmarshalJSON ¶
as it is optional to give either line id or Line object, we have to unmarshal|marshal it ourselves.
type Location ¶
type Location struct {
Name string
Address string
Longitude float64
Latitude float64
Altitude float64
Meta interface{}
}
func (Location) MarshalBSONValue ¶ added in v1.0.1
func (*Location) MarshalJSON ¶
func (*Location) UnmarshalBSONValue ¶ added in v1.0.1
func (*Location) UnmarshalJSON ¶
type Operator ¶
type Operator struct {
Id string
Name string
Meta interface{} // any additional data
Partial bool // only show the id in the json response?
}
func (Operator) MarshalBSONValue ¶ added in v1.0.1
func (*Operator) MarshalJSON ¶
func (*Operator) UnmarshalBSONValue ¶ added in v1.0.1
func (*Operator) UnmarshalJSON ¶
as it is optional to give either operator id or Operator object, we have to unmarshal|marshal it ourselves.
type Region ¶
type Region struct {
Id string
Name string
Stations []*Station
Meta interface{} // any additional data
Partial bool // only show the id in the json response?
}
A Region is a group of Stations, for example a metropolitan area or a geographical or cultural region.
In many urban areas, there are several long-distance train & bus stations, all distinct but well-connected through local public transport. It makes sense to keep them as Stations, because they may still have individual Stop s, but clustering them enables more advanced routing information.
A Station can be part of multiple Region's.
func (Region) MarshalBSONValue ¶ added in v1.0.1
func (*Region) MarshalJSON ¶
func (*Region) UnmarshalBSONValue ¶ added in v1.0.1
func (*Region) UnmarshalJSON ¶
as it is optional to give either region id or Region object, we have to unmarshal|marshal it ourselves.
type Route ¶
type Route struct {
Id string
Line *Line
Mode Mode
SubMode string
Stops []*Stop
Meta interface{} // any additional data
}
A Route represents a single set of stations, of a single Line.
For a very consistent subway service, there may be one route for each direction. Planned detours, trains stopping early and additional directions would have their own route.
func (Route) MarshalBSONValue ¶ added in v1.0.1
func (*Route) MarshalJSON ¶
func (*Route) UnmarshalBSONValue ¶ added in v1.0.1
func (*Route) UnmarshalJSON ¶
type Schedule ¶
type Schedule struct {
Id string
Route *Route
Mode Mode
SubMode string
Sequence []*SequenceElement
Starts []TimeUnix
Meta interface{} // any additional data
Partial bool // only show the id in the json response?
}
Schedule There are many ways to format schedules of public transport routes. This one tries to balance the amount of data and consumability. It is specifically geared towards urban public transport, with frequent trains and homogenous travels.
func (Schedule) MarshalBSONValue ¶ added in v1.0.1
func (*Schedule) MarshalJSON ¶
func (*Schedule) UnmarshalBSONValue ¶ added in v1.0.1
func (*Schedule) UnmarshalJSON ¶
type SequenceElement ¶
type Station ¶
type Station struct {
Id string
Name string
Location *Location
Regions []*Region
Meta interface{} // any additional data
Partial bool // only show the id in the json response?
}
Station is a larger building or area that can be identified by a name. It is usually represented by a single node on a public transport map. Whereas a Stop usually specifies a location, a Station often is a broader area that may span across multiple levels or buildings.
func (Station) MarshalBSONValue ¶ added in v1.0.1
func (*Station) MarshalJSON ¶
func (*Station) ToStopStation ¶
func (s *Station) ToStopStation() *StopStation
func (*Station) UnmarshalBSONValue ¶ added in v1.0.1
func (*Station) UnmarshalJSON ¶
type Stop ¶
type Stop struct {
Id string
Name string
Station *Station
Location *Location
Meta interface{}
Partial bool // only show the id in the json response?
}
Stop is a single small point or structure at which vehicles stop. A Stop always belongs to a Station. It may for example be a sign, a basic shelter or a railway platform.
If the underlying data source does not allow such a fine-grained distinction, use stations instead.
func (*Stop) MarshalBSONValue ¶ added in v1.0.1
func (*Stop) MarshalJSON ¶
func (*Stop) ToStopStation ¶
func (s *Stop) ToStopStation() *StopStation
func (*Stop) UnmarshalBSONValue ¶ added in v1.0.1
func (*Stop) UnmarshalJSON ¶
type StopStation ¶
type StopStation struct {
Stop *Stop // if it is a stop, this will be not Stop{}
Station *Station // if it is a station, this will be not Station{}
Id *string // if it is just an id, this will be not ""
}
func (*StopStation) GetId ¶
func (s *StopStation) GetId() string
func (*StopStation) GetLocation ¶
func (s *StopStation) GetLocation() *Location
func (*StopStation) GetName ¶
func (s *StopStation) GetName() string
func (StopStation) MarshalBSONValue ¶ added in v1.0.1
func (s StopStation) MarshalBSONValue() (bsontype.Type, []byte, error)
func (*StopStation) MarshalJSON ¶
func (s *StopStation) MarshalJSON() ([]byte, error)
func (*StopStation) SetId ¶
func (s *StopStation) SetId(id string)
func (*StopStation) SetLocation ¶
func (s *StopStation) SetLocation(loc *Location)
func (*StopStation) SetName ¶
func (s *StopStation) SetName(name string)
func (*StopStation) UnmarshalBSONValue ¶ added in v1.0.1
func (s *StopStation) UnmarshalBSONValue(typ bsontype.Type, data []byte) error
func (*StopStation) UnmarshalJSON ¶
func (s *StopStation) UnmarshalJSON(data []byte) error
as it is optional to give either stop|station id or Stop or Station object, we have to unmarshal|marshal it ourselves.
type Stopover ¶
type Stopover struct {
StopStation *StopStation
Arrival TimeNullable
ArrivalDelay *int
ArrivalPlatform string
Departure TimeNullable
DepartureDelay *int
DeparturePlatform string
Meta interface{}
}
A Stopover represents a vehicle stopping at a stop/station at a specific time.
func (Stopover) MarshalBSONValue ¶ added in v1.0.1
func (*Stopover) MarshalJSON ¶
func (*Stopover) UnmarshalBSONValue ¶ added in v1.0.1
func (*Stopover) UnmarshalJSON ¶
type TimeNullable ¶
Is essentially just a time.Time object, but zero values are marshalled as null
func (TimeNullable) MarshalBSONValue ¶ added in v1.0.1
func (t TimeNullable) MarshalBSONValue() (bsontype.Type, []byte, error)
func (TimeNullable) MarshalJSON ¶
func (t TimeNullable) MarshalJSON() ([]byte, error)
MarshalJSON is used to convert the timestamp to JSON
func (*TimeNullable) UnmarshalBSONValue ¶ added in v1.0.1
func (t *TimeNullable) UnmarshalBSONValue(typ bsontype.Type, data []byte) error
type TimeUnix ¶
TimeUnix a time.Time object, that is (un)marshalled as unix integers
func (TimeUnix) MarshalBSONValue ¶ added in v1.0.1
func (TimeUnix) MarshalJSON ¶
MarshalJSON is used to convert the timestamp to JSON
func (*TimeUnix) UnmarshalBSONValue ¶ added in v1.0.1
func (*TimeUnix) UnmarshalJSON ¶
UnmarshalJSON is used to convert the timestamp from JSON
type Trip ¶
type Trip struct {
Origin *StopStation `json:"origin,omitempty" bson:"origin,omitempty"`
Destination *StopStation `json:"destination,omitempty" bson:"destination,omitempty"`
Departure TimeNullable `json:"departure,omitempty" bson:"departure,omitempty"`
DepartureDelay *int `json:"departureDelay,omitempty" bson:"departureDelay,omitempty"`
DeparturePlatform string `json:"departurePlatform,omitempty" bson:"departurePlatform,omitempty"`
Arrival TimeNullable `json:"arrival,omitempty" bson:"arrival,omitempty"`
ArrivalDelay *int `json:"arrivalDelay,omitempty" bson:"arrivalDelay,omitempty"`
ArrivalPlatform string `json:"arrivalPlatform,omitempty" bson:"arrivalPlatform,omitempty"`
Schedule *Schedule `json:"schedule,omitempty" bson:"schedule,omitempty"`
Stopovers []*Stopover `json:"stopovers,omitempty" bson:"stopovers,omitempty"`
Mode Mode `json:"mode,omitempty" bson:"mode,omitempty"`
SubMode string `json:"subMode,omitempty" bson:"subMode,omitempty"`
Public *bool `json:"public,omitempty" bson:"public,omitempty"`
Operator *Operator `json:"operator,omitempty" bson:"operator,omitempty"`
Price *Price `json:"price,omitempty" bson:"price,omitempty"`
// Some additional arguments, inspired by https://github.com/public-transport/hafas-client
Line *Line `json:"line,omitempty" bson:"line,omitempty"` // The line on which this trip is going
Direction string `json:"direction,omitempty" bson:"direction,omitempty"` // The direction string on the train
Polyline string `json:"polyline,omitempty" bson:"polyline,omitempty"` // The polyline of the trip
Meta interface{} `json:"meta,omitempty" bson:"meta,omitempty"` // any additional data
}
Trip is a formalized, inferred version of a journey leg
func (*Trip) GetLine ¶
GetLine The line of a trip can be defined in multiple places This method finds it