Skip to content

Commit

Permalink
Merge pull request #191 from DavisVaughan/fix/multiple-matches
Browse files Browse the repository at this point in the history
Suppress multiple match warning
  • Loading branch information
polettif authored Dec 16, 2022
2 parents 11c8117 + 9516986 commit 3203e95
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 3 additions & 1 deletion R/spatial.R
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ get_trip_geometry <- function(gtfs_sf_obj, trip_ids) {
}

trips = gtfs_sf_obj$trips %>% filter(trip_id %in% trip_ids)
trips_shapes = dplyr::inner_join(gtfs_sf_obj$shapes, trips, by = "shape_id")
trips_shapes = suppress_matches_multiple_warning(
dplyr::inner_join(gtfs_sf_obj$shapes, trips, by = "shape_id")
)
return(trips_shapes)
}

Expand Down
4 changes: 3 additions & 1 deletion R/time.R
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ set_dates_services <- function(gtfs_obj) {

# set services to dates according to weekdays and start/end date
date_service_df <-
dplyr::full_join(dates, service_ids_weekdays, by="weekday") %>%
suppress_matches_multiple_warning(
dplyr::full_join(dates, service_ids_weekdays, by="weekday")
) %>%
dplyr::filter(date >= start_date & date <= end_date) %>%
dplyr::select(-weekday, -start_date, -end_date)

Expand Down
13 changes: 13 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,16 @@ na_to_empty_strings = function(gtfs_obj) {
df
})
}

# TODO: Remove after dplyr 1.1.0 is released and use `multiple = "all"` instead
suppress_matches_multiple_warning <- function(expr) {
handler_matches_multiple <- function(cnd) {
if (inherits(cnd, "dplyr_warning_join_matches_multiple")) {
restart <- findRestart("muffleWarning")
if (!is.null(restart)) {
invokeRestart(restart)
}
}
}
withCallingHandlers(expr, warning = handler_matches_multiple)
}

0 comments on commit 3203e95

Please sign in to comment.