Segments are numbered as in get_trip_segment_duration(), so both outputs
can be joined by trip_id and segment. Trips with a single stop have a
length of 0.
With method = "shapes", each stop is projected onto the closest point of
its trip's shape, with stops advancing along the shape in stop_sequence
order, so loops and shapes that pass by the same place more than once are
handled. Some limitations remain:
a stop slightly behind the previous one along the shape (e.g. due to
imprecise coordinates) is placed at the previous stop's position, so their
segment has a length of 0. On shapes that pass the same place twice in the
same direction, such a stop may be matched to the later pass instead;
on shapes whose outbound and return legs overlap exactly, the stops just
before and after the turnaround may be placed at the same position. The
trip length is unaffected, but the segment between them gets a length of
0 and the next one is longer.
shape_dist_traveled is ignored. Trips not linked to a shape with at least
two distinct points have NA lengths, with a warning. Use
get_shape_length() for the length of entire shapes.
Lengths are great-circle (haversine) distances on the sphere used by
{s2}. Stops with missing coordinates, or not listed in stops, result in
NA lengths for their segments and trips.
from and to are compared with the departure_time of the first stop of
each trip (in stop_sequence order) or segment, as written in
stop_times, so use times past "24:00:00" for departures after midnight.
With by = "segment", times after midnight written as early morning times
(e.g. "00:30:00" instead of "24:30:00") are first fixed with
fix_overnight_times(); a trip's first departure is never changed by it.
For trips listed in frequencies, these are template times, not the times
of each departure. Trips and segments whose departure is blank are never
included when from or to is given.