@@ -31,25 +31,39 @@ public RouteSequence(PatternSequence patternSequence, TransitLayer transitLayer)
31
31
}
32
32
}
33
33
34
- /** Returns details summarizing this route sequence, using GTFS ids stored in the supplied transitLayer. */
34
+ /**
35
+ * Returns details summarizing this route sequence, using GTFS ids stored in the supplied transitLayer.
36
+ * @param csvOptions indicates whether names or IDs should be returned for certain fields.
37
+ * @return array of pipe-concatenated strings, with the route, board stop, alight stop, ride time, and feed for
38
+ * each transit leg, as well as the access and egress time.
39
+ *
40
+ * If csvOptions.feedRepresentation is not null, the feed values will be R5-generated UUID for boarding stop of
41
+ * each leg. We are grabbing the feed ID from the stop rather than the route (which might seem like a better
42
+ * representative of the leg) because stops happen to have a readily available feed ID.
43
+ */
35
44
public String [] detailsWithGtfsIds (TransitLayer transitLayer , CsvResultOptions csvOptions ){
36
- StringJoiner routeIds = new StringJoiner ("|" );
37
- StringJoiner boardStopIds = new StringJoiner ("|" );
38
- StringJoiner alightStopIds = new StringJoiner ("|" );
39
- StringJoiner rideTimes = new StringJoiner ("|" );
45
+ StringJoiner routeJoiner = new StringJoiner ("|" );
46
+ StringJoiner boardStopJoiner = new StringJoiner ("|" );
47
+ StringJoiner alightStopJoiner = new StringJoiner ("|" );
48
+ StringJoiner feedJoiner = new StringJoiner ("|" );
49
+ StringJoiner rideTimeJoiner = new StringJoiner ("|" );
40
50
for (int i = 0 ; i < routes .size (); i ++) {
41
- routeIds .add (transitLayer .routeString (routes .get (i ), csvOptions .routeRepresentation ));
42
- boardStopIds .add (transitLayer .stopString (stopSequence .boardStops .get (i ), csvOptions .stopRepresentation ));
43
- alightStopIds .add (transitLayer .stopString (stopSequence .alightStops .get (i ), csvOptions .stopRepresentation ));
44
- rideTimes .add (String .format ("%.1f" , stopSequence .rideTimesSeconds .get (i ) / 60f ));
51
+ routeJoiner .add (transitLayer .routeString (routes .get (i ), csvOptions .routeRepresentation ));
52
+ boardStopJoiner .add (transitLayer .stopString (stopSequence .boardStops .get (i ), csvOptions .stopRepresentation ));
53
+ alightStopJoiner .add (transitLayer .stopString (stopSequence .alightStops .get (i ), csvOptions .stopRepresentation ));
54
+ if (csvOptions .feedRepresentation != null ) {
55
+ feedJoiner .add (transitLayer .feedFromStop (stopSequence .boardStops .get (i )));
56
+ }
57
+ rideTimeJoiner .add (String .format ("%.1f" , stopSequence .rideTimesSeconds .get (i ) / 60f ));
45
58
}
46
59
String accessTime = stopSequence .access == null ? null : String .format ("%.1f" , stopSequence .access .time / 60f );
47
60
String egressTime = stopSequence .egress == null ? null : String .format ("%.1f" , stopSequence .egress .time / 60f );
48
61
return new String []{
49
- routeIds .toString (),
50
- boardStopIds .toString (),
51
- alightStopIds .toString (),
52
- rideTimes .toString (),
62
+ routeJoiner .toString (),
63
+ boardStopJoiner .toString (),
64
+ alightStopJoiner .toString (),
65
+ rideTimeJoiner .toString (),
66
+ feedJoiner .toString (),
53
67
accessTime ,
54
68
egressTime
55
69
};
0 commit comments