Skip to content

Commit

Permalink
add 'frequencies' to cleaning - otherwise resulting GTFS file can't b…
Browse files Browse the repository at this point in the history
…e loaded into OTP
  • Loading branch information
oweno-tfwm committed Sep 11, 2023
1 parent e7dcbbe commit 07995f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions R/gtfs_cleaning.R
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ PUBLIC_SERVICE_CATEGORY = c("OL", "OU", "OO", "OW", "XC", "XD", "XI",
#' (these have a null route_type, so loading into OpenTripPlanner fails if these are present)
#' 6. If public_only=TRUE then remove services with 'train_category' not for public use. e.g. EE (ECS-Empty Coaching Stock)
#' 7. Remove shapes that no longer have any trips
#' 8 Remove frequencies that no longer have any trips
#'
#' @export
gtfs_clean <- function(gtfs, public_only = FALSE) {
Expand Down Expand Up @@ -309,6 +310,11 @@ gtfs_clean <- function(gtfs, public_only = FALSE) {
gtfs$shapes <- gtfs$shapes[gtfs$shapes$shape_id %in% gtfs$trips$shape_id, ]
}

# 8 remove frequencies that no longer have any trips
if ("frequencies" %in% names(gtfs))
{
gtfs$frequencies <- gtfs$frequencies[gtfs$frequencies$trip_id %in% gtfs$trips$trip_id, ]
}

return(gtfs)
}
1 change: 1 addition & 0 deletions man/gtfs_clean.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 07995f8

Please sign in to comment.