Skip to content

trips, schedules and legs in fptf 2 #61

@juliuste

Description

@juliuste

This issue is an attempt to bundle and advance the discussion about major changes to FPTF types in version 2, previously debated in #5, #33 and #42.


General consensus

There are a few points about which there seemed to be general consensus (?):

  • Introduce a trip type (mentioned in this comment)
  • Adapt the schedule type to fit together with the newly introduced trip type (mentioned in this comment)
  • Change how we handle time information in journey and stopover to distinguish between realtime and scheduled dates (mentioned in this comment)

However, we didn't agree on any specific specification changes yet, so here's my proposal, please express your opinions!


schedule, trip and leg

In my original proposal to introduce a trip type, I initially intended to remove the schedule type entirely. However @derhuerst made the point that in some cases it might actually be useful to have another “aggregator“ type like schedule so that a large amount of trips could also be condensed to a smaller amount of schedules (like in GTFS, for example).

What I take from this is that we should design both types in a way that one could always generate a consistent dataset using only trips from one using schedules. This doesn't need to work vice versa however, since trips can contain additional data, e.g. realtime information, that doesn't belong to a schedule. With this in mind, I came up with the following specification(s):

trip

{
	type: 'trip', // required
	id: '12345', // unique, required
	line: '1234', // line id or object, optional
	route: '1234', // route id or object, optional
	mode: 'bus', // required if route is an id or if the trip mode differs from the route mode
	subMode: , // reserved for future use
	stopovers: [] // required, list of stopover objects
}

One could discuss adding an optional schedule key similar to trip.route or trip.line.

schedule

schedule.starts is an object tripId -> startTime now instead of an array. This allows both to translate a schedule into a set of single trips as well as to provide updated realtime information for trips that are part of a schedule (as discussed in #43).

Also, schedule.line was added to be consistent with the other objects.

{
	type: 'schedule', // required
	id: '12345', // unique, required
	route: '1234', // route id or object, required
	line: '1234', // line id or object, optional
	mode: 'bus', // see section on modes, overrides `route`/`line` mode, e.g. for replacements services
	subMode: , // reserved for future use
	sequence: [
		// seconds relative to departure at first station/stop
		// in 1-to-1 relation to `route` stops
		{
			arrival: -30 // optional, when the vehicle enters the route
			// The departure at the first stop must be 0.
			departure: 0 // required
		},
		{
			arrival: 50, // optional
			departure: 70 // required
		}
		{
			arrival: 120, // The arrival at the last stop is required.
			departure: 150 // optional, when the vehicle leaves the route
		}
	],
	starts: { // object trip.id -> Unix timestamp, required
		'trip1234': 1488379661, // start time of the trip
   		'trip2345': 1488379761,
		'trip3456': 1488379861,
		'trip4567': 1488379961
	}
}

We could further discuss whether to use timestamps or dates as values in the starts object, I kept the timestamps for now.

leg

I suggest that we treat leg as a separate new type, enabling applications to differentiate between trips, which are associated to the movement of an actual vehicle, meaning that the trip starts where the vehicle/line starts and ends where the line/vehicle movement ends, and legs, which depend on the movement of the passenger.

{
	type: 'leg', // required
	id: '12345', // unique, required
	trip: '1234', // trip id or object, optional
	line: '1234', // line id or object, optional
	schedule: undefined, // removed, schedules - if used - should be referenced using the trip or trip id
	// other keys of the existing journey.leg specification
	// see proposed spec changes regarding date information below
}

scheduled / realtime data in leg and stopover

I applied the proposal from #33 to leg and stopover, giving us the following spec changes:

leg

{
	type: 'leg', // required
	id: '12345', // unique, required
	
	// other keys mentioned above
	
	schedule: undefined // removed, see explanation above
	departure: undefined, // removed
	departureDelay: undefined, // removed
	arrival: undefined, // removed
	arrivalDelay: undefined, // removed

	scheduledDeparture: '2017-03-17T15:00:00+02:00', // ISO 8601 string (with origin timezone), required if `realtimeDeparture` is null
	realtimeDeparture: '2017-03-17T15:01:00+02:00', // ISO 8601 string (with origin timezone), required if `scheduledDeparture` is null
	scheduledArrival: '2017-03-17T15:00:00+02:00', // ISO 8601 string (with destination timezone), required if `realtimeArrival` is null
	realtimeArrival: '2017-03-17T15:01:00+02:00' // ISO 8601 string (with destination timezone), required if `scheduledArrival` is null
}

stopover

{
	type: 'stopover', // required
	// other keys defined in the stopover spec
	
	line: '1234', // line id or object, optional
	trip: '1234', // trip id or object, optional
	schedule: undefined // removed, schedules - if used - should be referenced using the trip or trip id
	
	departure: undefined, // removed
	departureDelay: undefined, // removed
	arrival: undefined, // removed
	arrivalDelay: undefined, // removed

	scheduledDeparture: '2017-03-17T15:00:00+02:00', // ISO 8601 string (with origin timezone), required if `realtimeDeparture` is null
	realtimeDeparture: '2017-03-17T15:01:00+02:00', // ISO 8601 string (with origin timezone), required if `scheduledDeparture` is null
	scheduledArrival: '2017-03-17T15:00:00+02:00', // ISO 8601 string (with destination timezone), required if `realtimeArrival` is null
	realtimeArrival: '2017-03-17T15:01:00+02:00' // ISO 8601 string (with destination timezone), required if `scheduledArrival` is null
}

Again, this is just a proposal based on previous discussions, so please express your opinions!

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions