Skip to content

Commit

Permalink
Merge branch 'results-with-feedids' of https://github.com/conveyal/r5
Browse files Browse the repository at this point in the history
…into results-with-feedids
  • Loading branch information
ansoncfit committed Feb 29, 2024
2 parents 5aa45f5 + c9be778 commit a55fa2d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class PathResult {
"routes",
"boardStops",
"alightStops",
"feedIds",
"rideTimes",
"accessTime",
"egressTime",
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/conveyal/r5/transit/TransitLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -873,4 +873,8 @@ public String stopString(int stopIndex, EntityRepresentation nameOrId) {
default -> stopId;
};
}

public String feedFromStop(int stopIndex) {
return stopIdForIndex.get(stopIndex) == null ? "[new]" : stopIdForIndex.get(stopIndex).split(":")[0];
}
}
22 changes: 13 additions & 9 deletions src/main/java/com/conveyal/r5/transit/path/RouteSequence.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,26 @@ public RouteSequence(PatternSequence patternSequence, TransitLayer transitLayer)

/** Returns details summarizing this route sequence, using GTFS ids stored in the supplied transitLayer. */
public String[] detailsWithGtfsIds (TransitLayer transitLayer, CsvResultOptions csvOptions){
StringJoiner routeIds = new StringJoiner("|");
StringJoiner boardStopIds = new StringJoiner("|");
StringJoiner alightStopIds = new StringJoiner("|");
StringJoiner routeString = new StringJoiner("|");
StringJoiner boardStops = new StringJoiner("|");
StringJoiner alightStops = new StringJoiner("|");
StringJoiner feedString = new StringJoiner("|");
StringJoiner rideTimes = new StringJoiner("|");
for (int i = 0; i < routes.size(); i++) {
routeIds.add(transitLayer.routeString(routes.get(i), csvOptions.routeRepresentation));
boardStopIds.add(transitLayer.stopString(stopSequence.boardStops.get(i), csvOptions.stopRepresentation));
alightStopIds.add(transitLayer.stopString(stopSequence.alightStops.get(i), csvOptions.stopRepresentation));
routeString.add(transitLayer.routeString(routes.get(i), csvOptions.routeRepresentation));
boardStops.add(transitLayer.stopString(stopSequence.boardStops.get(i), csvOptions.stopRepresentation));
alightStops.add(transitLayer.stopString(stopSequence.alightStops.get(i), csvOptions.stopRepresentation));
if (csvOptions.feedRepresentation != null) {
feedString.add(transitLayer.feedFromStop(stopSequence.boardStops.get(i)));
}
rideTimes.add(String.format("%.1f", stopSequence.rideTimesSeconds.get(i) / 60f));
}
String accessTime = stopSequence.access == null ? null : String.format("%.1f", stopSequence.access.time / 60f);
String egressTime = stopSequence.egress == null ? null : String.format("%.1f", stopSequence.egress.time / 60f);
return new String[]{
routeIds.toString(),
boardStopIds.toString(),
alightStopIds.toString(),
routeString.toString(),
boardStops.toString(),
alightStops.toString(),
rideTimes.toString(),
accessTime,
egressTime
Expand Down

0 comments on commit a55fa2d

Please sign in to comment.