Skip to content
Merged
Show file tree
Hide file tree
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
25 changes: 22 additions & 3 deletions src/main/java/org/mtransit/parser/DefaultAgencyTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,30 @@ public boolean excludeAgencyNullable(@Nullable GAgency gAgency) {

@Override
public boolean excludeAgency(@NotNull GAgency gAgency) {
final org.mtransit.parser.config.gtfs.data.AgencyConfig agencyConfig = Configs.getAgencyConfig();
if (agencyConfig == null) {
return KEEP;
}
final String agencyId = agencyConfig.getAgencyId();
final List<String> otherAgencyIds = agencyConfig.getOtherAgencyIds();
final boolean hasAgencyId = agencyId != null;
final boolean hasOtherAgencyIds = !otherAgencyIds.isEmpty();
if (!hasAgencyId && !hasOtherAgencyIds) {
return KEEP; // no filters
}
//noinspection DiscouragedApi
if (getAgencyId() != null && gAgency.isDifferentAgency(getAgencyId())) {
return EXCLUDE;
if (hasAgencyId && !gAgency.isDifferentAgency(agencyId)) {
return KEEP;
}
return KEEP;
if (hasOtherAgencyIds) {
for (final String otherAgencyId : otherAgencyIds) {
//noinspection DiscouragedApi
if (!gAgency.isDifferentAgency(otherAgencyId)) {
return KEEP;
}
}
}
return EXCLUDE;
}

private final Map<String, String> serviceIdToCleanupServiceId = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ data class AgencyConfig(
*/
@SerialName("agency_id")
val agencyId: String? = null, // OPT-IN filter
/**
* (Optional) Agency IDs filter (useful when multiple agencies in same GTFS)
*/
@SerialName("other_agency_ids")
val otherAgencyIds: List<String> = emptyList(), // OPT-IN filter
/**
* Route type filter (integer from GTFS Static `routes.txt` > `route_type` field)
* (useful when multiple route type in same GTFS)
Expand Down