gtfstools (version 0.1.0)

validate_gtfs: Validate GTFS file

Description

Validates the GTFS object against GTFS specifications and raises warnings if required files/fields are not found.

Usage

validate_gtfs(gtfs, files = NULL, quiet = TRUE, warnings = TRUE)

Arguments

gtfs

A GTFS object as created by read_gtfs.

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.

quiet

Whether to hide log messages (defaults to TRUE).

warnings

Whether to display warning messages (defaults to TRUE).

Value

A GTFS object with a validation_result attribute. This attribute is a data.table 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 Google's Static GTFS Reference:

  • GTFS feeds are considered valid if they include all required files and fields. If a required file/field is missing the function (optionally) raises a warning.

  • Optional files/fields are listed in the reference above but are not required, thus no warning is raised if they are missing.

  • Extra files/fields are those who are not listed in the reference above (either because they refer to a specific GTFS extension or due to any other reason).

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

  • calendar.txt is initially set as a required file. If it's not present, however, it becomes optional and calendar_dates.txt (originally set as optional) becomes required.

  • feed_info.txt is initially set as an optional file. If translations.txt is present, however, it becomes required.

Examples

Run this code
# NOT RUN {
data_path <- system.file("extdata/spo_gtfs.zip", package = "gtfstools")

gtfs <- read_gtfs(data_path)
attr(gtfs, "validation_result")

# should not raise a warning, because 'shapes' is not a required file
gtfs$shapes <- NULL
validation_result <- validate_gtfs(gtfs)

# should raise a warning, because 'stop_times' is a required file
gtfs$stop_times <- NULL
validation_result <- validate_gtfs(gtfs)

# }

Run the code above in your browser using DataLab