Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix route count attribute in case of using stoptimes instead of frequencies #254

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading