diff --git a/src/main/java/org/matsim/pt2matsim/gtfs/GtfsConverter.java b/src/main/java/org/matsim/pt2matsim/gtfs/GtfsConverter.java index 815153d..3f16fc3 100644 --- a/src/main/java/org/matsim/pt2matsim/gtfs/GtfsConverter.java +++ b/src/main/java/org/matsim/pt2matsim/gtfs/GtfsConverter.java @@ -123,6 +123,9 @@ public void convert(String serviceIdsParam, String transformation, TransitSchedu // clean the schedule cleanSchedule(schedule); + + // add departure info to attributes (needs to be done after cleaning to account for merging of lines/routes) + addDepartureInfoToAttributes(schedule); // create default vehicles createVehicles(schedule, vehicles); @@ -190,7 +193,6 @@ protected void createTransitLines(TransitSchedule schedule, LocalDate extractDat for(Route gtfsRoute : this.feed.getRoutes().values()) { // create a MATSim TransitLine for each Route TransitLine newTransitLine = createTransitLine(gtfsRoute); - AdditionalTransitLineInfo info = additionalLineInfo.get(newTransitLine.getId()); if(newTransitLine != null) { schedule.addTransitLine(newTransitLine); @@ -201,7 +203,6 @@ protected void createTransitLines(TransitSchedule schedule, LocalDate extractDat TransitRoute transitRoute = createTransitRoute(trip, schedule.getFacilities()); if(transitRoute != null) { newTransitLine.addRoute(transitRoute); - info.countRoute(transitRoute.getDepartures().size()); } } } @@ -311,6 +312,15 @@ protected void cleanSchedule(TransitSchedule schedule) { ScheduleCleaner.removeNotUsedStopFacilities(schedule); ScheduleCleaner.removeNotUsedMinimalTransferTimes(schedule); } + + protected void addDepartureInfoToAttributes(TransitSchedule schedule) { + for (TransitLine transitLine : schedule.getTransitLines().values()) { + AdditionalTransitLineInfo info = additionalLineInfo.get(transitLine.getId()); + for (TransitRoute transitRoute : transitLine.getRoutes().values()) { + info.countRoute(transitRoute.getDepartures().size()); + } + } + } protected Id createTransitLineId(Route gtfsRoute) { String id = gtfsRoute.getId();