Skip to content

Commit

Permalink
fix route count attribute in case of using stoptimes instead of frequ…
Browse files Browse the repository at this point in the history
…encies (#254)

authored-by: Tobias Kohl <[email protected]>
  • Loading branch information
Royal2Flush authored Jan 14, 2025
1 parent 2da717f commit aba540e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/main/java/org/matsim/pt2matsim/gtfs/GtfsConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand All @@ -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());
}
}
}
Expand Down Expand Up @@ -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<TransitLine> createTransitLineId(Route gtfsRoute) {
String id = gtfsRoute.getId();
Expand Down

0 comments on commit aba540e

Please sign in to comment.