Skip to content

Commit

Permalink
Fix for Trailer Record Missing in NR CIF
Browse files Browse the repository at this point in the history
Plus a devtools::document()
  • Loading branch information
mem48 committed Sep 11, 2024
1 parent eb64abe commit 4c746de
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 13 deletions.
7 changes: 5 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ Imports:
doSNOW,
dplyr,
digest,
foreach,
foreach,
future,
future.apply,
geodist,
httr,
iotools,
Expand All @@ -39,6 +41,7 @@ Imports:
pbapply,
readr (>= 2.0),
RcppSimdJson,
tidyr,
xml2,
zip,
Suggests:
Expand All @@ -48,4 +51,4 @@ Suggests:
rmarkdown,
testthat
VignetteBuilder: knitr
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ export(gtfs_read)
export(gtfs_routes_sf)
export(gtfs_split)
export(gtfs_split_ids)
export(gtfs_stop_frequency)
export(gtfs_stops_sf)
export(gtfs_trim_dates)
export(gtfs_trips_per_zone)
export(gtfs_trips_sf)
export(gtfs_validate_internal)
export(gtfs_write)
Expand Down
29 changes: 19 additions & 10 deletions R/atoc_import.R
Original file line number Diff line number Diff line change
Expand Up @@ -641,17 +641,26 @@ importMCA <- function(file,
message(paste0(Sys.time(), " importing Trailer Record"))
}
ZZ <- raw[types == "ZZ"]
ZZ <- iotools::dstrfw(
x = ZZ,
col_types = rep("character", 2),
widths = c(2, 78)
)
names(ZZ) <- c("Record Identity", "Spare")
ZZ$Spare <- NULL
ZZ <- strip_whitespace(ZZ)
if(length(ZZ) > 0){
ZZ <- iotools::dstrfw(
x = ZZ,
col_types = rep("character", 2),
widths = c(2, 78)
)
names(ZZ) <- c("Record Identity", "Spare")
ZZ$Spare <- NULL
ZZ <- strip_whitespace(ZZ)

# Add the rowid
ZZ$rowID <- seq(from = 1, to = length(types))[types == "ZZ"]
} else {
# Trailer Record Missing
ZZ <- data.frame(`Record Identity` = "ZZ", `Spare` = "")
names(ZZ) <- c("Record Identity", "Spare")
ZZ$rowID = length(types) + 1
}


# Add the rowid
ZZ$rowID <- seq(from = 1, to = length(types))[types == "ZZ"]

# Prep the main files
if (!silent) {
Expand Down
6 changes: 5 additions & 1 deletion R/transxchange_import6.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ transxchange_import <- function(file, run_debug = TRUE, full_import = FALSE) {
JourneyPatternSections <- NULL
}

## VehicleJourneysTimingLinks #############################

VehicleJourneysTimingLinks <- NULL

## Services ##########################################
Services <- xml2::xml_child(xml, "d1:Services")
Expand Down Expand Up @@ -143,7 +145,9 @@ transxchange_import <- function(file, run_debug = TRUE, full_import = FALSE) {
DaysOfNonOperation <- VehicleJourneys$DaysOfNonOperation
VehicleJourneys_notes <- VehicleJourneys$VJ_Notes
VehicleJourneys <- VehicleJourneys$VehicleJourneys
VehicleJourneysTimingLinks <- NULL





## Final Steps #########################################
Expand Down
22 changes: 22 additions & 0 deletions man/gtfs_stop_frequency.Rd

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

22 changes: 22 additions & 0 deletions man/gtfs_trim_dates.Rd

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

31 changes: 31 additions & 0 deletions man/gtfs_trips_per_zone.Rd

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

0 comments on commit 4c746de

Please sign in to comment.