Skip to content

Commit

Permalink
process trips with no trip_headsign col; closes #15
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed May 16, 2019
1 parent 6a09b2c commit 9a50146
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions R/router.R
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,12 @@ gtfs_route1 <- function (gtfs, start_stns, end_stns, start_time,
rownames (res) <- seq (nrow (res))

# Then insert routes and trip headsigns
index <- match (res$trip_id, gtfs$trips [, trip_id])
res$trip_name <- gtfs$trips [index, trip_headsign]
res$trip_name <- NA_character_
if ("trip_headsign" %in% names (gtfs$trips))
{
index <- match (res$trip_id, gtfs$trips [, trip_id])
res$trip_name <- gtfs$trips [index, trip_headsign]
}

index <- match (res$trip_id, gtfs$trips [, trip_id])
res$route_id <- gtfs$trips [index, route_id]
Expand All @@ -149,6 +153,9 @@ gtfs_route1 <- function (gtfs, start_stns, end_stns, start_time,
col_order <- col_order [c (2, 4, 6:8)]
res <- res [, col_order]

if (all (is.na (res$trip_name)))
res$trip_name <- NULL

return (res)
}

Expand Down

0 comments on commit 9a50146

Please sign in to comment.