validate_gtfs {tidytransit}R Documentation

Validate GTFS file

Description

Validates the GTFS object against GTFS specifications and raises warnings if required files/fields are not found. This function is called in read_gtfs.

Usage

validate_gtfs(gtfs_obj, files = NULL, warnings = TRUE)

Arguments

gtfs_obj

gtfs object (i.e. a list of tables, not necessary a tidygtfs object)

files

A character vector containing the text files to be validated against the GTFS specification (without the .txt extension). If NULL (the default) the provided GTFS is validated against all possible GTFS text files.

warnings

Whether to display warning messages (defaults to TRUE).

Details

Note that this function just checks if required files or fields are missing. There's no validation for internal consistency (e.g. no departure times before arrival times or calendar covering a reasonable period).

Value

A validation_result tibble containing the validation summary of all possible fields from the specified files.

Details

GTFS object's files and fields are validated against the GTFS specifications as documented in GTFS Schedule Reference:

Note that some files (calendar.txt, calendar_dates.txt and feed_info.txt) are conditionally required. This means that:

Examples

validate_gtfs(gtfs_duke)
#> # A tibble: 233 × 8
#>    file   file_spec file_provided_status field  field_spec field_provided_status
#>    <chr>  <chr>     <lgl>                <chr>  <chr>      <lgl>                
#>  1 agency req       TRUE                 agenc… opt        TRUE                 
#>  2 agency req       TRUE                 agenc… req        TRUE                 
#>  3 agency req       TRUE                 agenc… req        TRUE                 
#>  4 agency req       TRUE                 agenc… req        TRUE                 
#>  5 agency req       TRUE                 agenc… opt        TRUE                 
#>  6 agency req       TRUE                 agenc… opt        TRUE                 
#>  7 agency req       TRUE                 agenc… opt        TRUE                 
#>  8 agency req       TRUE                 agenc… opt        FALSE                
#>  9 stops  req       TRUE                 stop_… req        TRUE                 
#> 10 stops  req       TRUE                 stop_… opt        TRUE                 
#> # 223 more rows
#> # 2 more variables: validation_status <chr>, validation_details <chr>

## Not run: 
local_gtfs_path <- system.file("extdata", "google_transit_nyc_subway.zip", package = "tidytransit")
gtfs <- read_gtfs(local_gtfs_path)
attr(gtfs, "validation_result")

gtfs$shapes <- NULL
validation_result <- validate_gtfs(gtfs)

# should raise a warning
gtfs$stop_times <- NULL
validation_result <- validate_gtfs(gtfs)

## End(Not run)

[Package tidytransit version 1.6.1 Index]