Skip to content

Commit

Permalink
Properly set the stop area in a stop time
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Jul 22, 2023
1 parent 96a1851 commit ea748e2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public Converter create(CsvEntityContext context) {

private class ConverterImpl implements Converter {

private GtfsReaderContext _context;
private final GtfsReaderContext _context;

public ConverterImpl(GtfsReaderContext context) {
_context = context;
Expand All @@ -55,8 +55,10 @@ public Object convert(@SuppressWarnings("rawtypes") Class type, Object value) {
if (stop != null) return stop;
Object location = _context.getEntity(Location.class, id);
if (location != null) return location;
Object locationGroup = _context.getEntity(LocationGroup.class, id);
Object locationGroup = _context.getEntity(LocationGroup.class, id);
if (locationGroup != null) return locationGroup;
Object stopArea = _context.getEntity(StopArea.class, id);
if (stopArea != null) return stopArea;
return null;
}
// we fell through -- unexpected situation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ public void pierceTransitStopAreas() throws CsvEntityIOException, IOException {
var names = area2.getStops().stream().map(s -> s.getId().toString()).collect(Collectors.toSet());

assertEquals(Set.of("1_area_1075", "1_area_1074", "1_area_1076"), names);

var trips = dao.getAllTrips();
assertEquals(7, trips.size());

var trip = trips.stream().filter(t -> t.getId().getId().equals("t_5586096_b_80376_tn_0")).findFirst().get();
var stopTimes = dao.getStopTimesForTrip(trip);

var classes = stopTimes.stream().map(st -> st.getStop().getClass()).collect(Collectors.toList());
assertEquals(List.of(StopArea.class, StopArea.class), classes);

}

private static StopArea getArea(List<StopArea> stopAreas, String id) {
Expand Down

0 comments on commit ea748e2

Please sign in to comment.