Skip to content

Commit

Permalink
version 0.9.3
Browse files Browse the repository at this point in the history
  • Loading branch information
k5cents authored and cran-robot committed Mar 12, 2024
1 parent 73a0932 commit 2c274d1
Show file tree
Hide file tree
Showing 27 changed files with 292 additions and 111 deletions.
28 changes: 13 additions & 15 deletions DESCRIPTION
@@ -1,20 +1,17 @@
Package: metro
Title: Washington Metropolitan Area Transit Authority API
Version: 0.9.2
Version: 0.9.3
Authors@R:
person(given = "Kiernan",
family = "Nicholls",
role = c("aut", "cre"),
email = "kiernann@protonmail.com")
Description: The Washington Metropolitan Area Transit Authority
is a government agency operating light rail and passenger buses in the
person("Kiernan", "Nicholls", email = "k5cents@gmail.com", role = c("aut", "cre", "cph"),
comment = c(ORCID = "0000-0002-9229-7897"))
Description: The Washington Metropolitan Area Transit Authority is a
government agency operating light rail and passenger buses in the
Washington D.C. area. With a free developer account, access their
'Metro Transparent Data Sets API' <https://developer.wmata.com/> to
return data frames of transit data for easy analysis.
License: MIT + file LICENSE
URL: https://github.com/kiernann/metro,
https://kiernann.github.io/metro/
BugReports: https://github.com/kiernann/metro/issues
License: GPL (>= 3)
URL: https://k5cents.github.io/metro/, https://github.com/k5cents/metro
BugReports: https://github.com/k5cents/metro/issues
Depends: R (>= 2.10)
Imports: geodist (>= 0.0.6), hms (>= 1.0.0), httr (>= 1.4.2), jsonlite
(>= 1.7.1), tibble (>= 3.0.4)
Expand All @@ -25,8 +22,9 @@ Language: en-US
LazyData: true
RoxygenNote: 7.2.3
NeedsCompilation: no
Packaged: 2023-10-28 15:43:16 UTC; kiernan
Author: Kiernan Nicholls [aut, cre]
Maintainer: Kiernan Nicholls <kiernann@protonmail.com>
Packaged: 2024-03-11 14:26:00 UTC; kiernan
Author: Kiernan Nicholls [aut, cre, cph]
(<https://orcid.org/0000-0002-9229-7897>)
Maintainer: Kiernan Nicholls <k5cents@gmail.com>
Repository: CRAN
Date/Publication: 2023-10-28 21:50:08 UTC
Date/Publication: 2024-03-11 15:40:08 UTC
2 changes: 0 additions & 2 deletions LICENSE

This file was deleted.

49 changes: 25 additions & 24 deletions MD5
@@ -1,9 +1,8 @@
3ee8ff10e376317dd99b8001b54cef7f *DESCRIPTION
837175cb0f91fb7784032b5309ed2137 *LICENSE
37f37c710f6924611acf2e68fe11420f *DESCRIPTION
38e04ec9f4d9b511ca4b97f2308d8bc6 *NAMESPACE
4dbe5078c063bf9cc9cf863366386dc7 *NEWS.md
ba398d158d38f4b1f666bf5b6899a5a0 *R/api.R
5ac5bc2836cf56752daef77b399525c0 *R/bus-departs.R
defc427015ff2a1475477a6fe645ab6f *NEWS.md
9c5aefca27d52b845eed89c87841f93f *R/api.R
877b2933a422ed9caedb4c97735902bc *R/bus-departs.R
f1ae87c1b4d509e04ba3cd5ab4db83fb *R/bus-path.R
e2ceac330ea91c88637c4fb26b1bdffb *R/bus-position.R
2c547a32c714e42707d5a094d543c7a5 *R/bus-routes.R
Expand All @@ -12,29 +11,31 @@ baece55bca2c7a2a6cd87a68bb840e36 *R/bus-stops.R
fec772a3d2eebf046c624cf0c4664788 *R/data.R
2203907fb509263f6b8640338d49200f *R/incidents-bus.R
b82464a76982d0aeaf898156c1e44e6c *R/incidents-elevator.R
95fc9ed517fbf434e4839bce7dbd93ee *R/incidents-rail.R
6cfa30d646d9ed221aadb0cbd3767b80 *R/incidents-rail.R
d4450e6ea1007935c6a9dfef493413b2 *R/key.R
9af7b7cd6936fe9539917ac0e3567d19 *R/metro-package.R
9d101bf58c45a4ab46bdb9e88a353a4c *R/next-bus.R
8e58fa8e660261e887dfe53a9dcee8b7 *R/next-train.R
bed700111d315bd7957ce13424c7b83e *R/rail-destination.R
f0cd6eeddc240d8c63a819031434ae2e *R/rail-destination.R
006542b6fd6799c01210fa30dc9e590c *R/rail-entrance.R
890a26035db152e02d9bd336c2c0e843 *R/rail-info.R
806852e4b6e3562b6405f92442564f92 *R/rail-lines.R
8b6e2e1bc530a0863b5953bb339ae03f *R/rail-path.R
6e7c1cb93209d5fbf10634d979d5f630 *R/rail-position.R
7a4ecb57d3b6d8800d8127bf347a8d51 *R/rail-position.R
0cd12e7cb6d9b7152804ffb501a10361 *R/rail-stations.R
516fb27f6da093444db57ff42bae6aab *R/rail-times.R
a3a3d3547e3f19aaf751e0c2abcb8888 *R/rail-times.R
3bcf787631277edf03a1cf62fbd813d8 *R/standard-routes.R
7f96f93cbfef233dc3a4ae3f802f5b76 *R/track-circuits.R
f34c6e2397c2c38b67287bbe86531b69 *R/utils.R
89fc300f93aab6b874efb437889a885d *README.md
b27ff1670a76907d0236416ee6967d0a *README.md
9a9262bb243e77fe3fbc372e946cc0d3 *data/metro_lines.rda
00e16a8865c8ffdb2065ef360ab44aec *data/metro_routes.rda
f7065223551863ab4b643c61791b1eed *data/metro_stations.rda
ca19d7efb76aa729c4998bde941d1173 *data/metro_stops.rda
e55374caa496cf5a9dd121829f834b02 *inst/WORDLIST
421a8ce8fdcb52851ffaf161416f8aea *man/bus_departs.Rd
cc884ffcb159036fd556b0386db441fb *inst/TrainPositions.json
1b739d49890febd71f28496f3a058a2a *inst/WORDLIST
132c5200a3d82130cf96212108e3dd63 *inst/jStationTimes.json
a936e76737f49fe03d5f7bea9de9fb94 *man/bus_departs.Rd
981795aeaab90c6a96ca40610ffbe268 *man/bus_incidents.Rd
73833cb61641c7d98bff570ce48f7b7f *man/bus_path.Rd
d693b8596274ec5b85ed397404609aab *man/bus_position.Rd
Expand All @@ -43,20 +44,20 @@ e5f208dc63d8c5c6dedf5f97847f65e8 *man/bus_schedule.Rd
e9a111a5d1ba84be3e37eb2794206973 *man/bus_stops.Rd
07cd1a6aa1f2207a9ab017ec3f37e57d *man/elevator_incidents.Rd
2853946eeb5721454dc99c0bca0538f1 *man/figures/logo.png
cfa1f1d9f10eae3eff3748d30e30405b *man/metro-package.Rd
44c06e6ea45ba1d28d2f8577d918e234 *man/metro-package.Rd
69a2f4814b2fba32386640ec6d9a7ed3 *man/metro_lines.Rd
d9b4925fb9888b74ae3824adc32cd8cd *man/metro_routes.Rd
9adc772bc200fd4e16fa71fee30e7c46 *man/metro_stations.Rd
8797c79b23a3f84191114d62d66c5ac9 *man/metro_stops.Rd
6abf91283922f320f64491102e891218 *man/next_bus.Rd
0e02bad4b1b699a84d9cf205d23a3c39 *man/next_train.Rd
a5d9c8ddcd9340487f6d55d44261c522 *man/no_data_now.Rd
f9001fa1e69c21cacf731d3f780908a8 *man/rail_destination.Rd
7b59afbbe9000f146259fcd7b59e1ab9 *man/rail_destination.Rd
1b90e93f71ea63771eb90233a44a2798 *man/rail_entrance.Rd
abed5abb77347820ae0cb364175754fa *man/rail_incidents.Rd
7b4ce45edba7ef35c6598a618048b8a8 *man/rail_lines.Rd
327874922c5e3a172d83724b68a3c2d1 *man/rail_path.Rd
4b6aceb9cfc100f50bf2dc48621b468a *man/rail_positions.Rd
286d21a6990bce8eaaa66dfe3253151e *man/rail_positions.Rd
dab8423c92e7ac2ef6f65674738eb59a *man/rail_stations.Rd
0975fedad72d6b469e4f5a2e2ca81f80 *man/rail_times.Rd
8cdd4a79ddb9efe4fbbf815f206aef05 *man/standard_routes.Rd
Expand All @@ -67,25 +68,25 @@ a86fc417889fc36b3ee540810ebc3fff *man/wmata_key.Rd
0622a97a2aaa3c342f09636052c2d7f5 *tests/spelling.R
dfa4e8c38d40fde94c6db8b57955c2f2 *tests/testthat.R
519f8c277d6886c6322a9823eda36f83 *tests/testthat/test-api.R
adc80ecd42d86d2e058323d5a0fdc2e7 *tests/testthat/test-bus-departs.R
ec8cc879ffdbe37b00fdb220cec7b4cb *tests/testthat/test-bus-departs.R
cc7989b14d2a091f6269fac7f9a206eb *tests/testthat/test-bus-path.R
67d1661a28760732dc98517d2de81258 *tests/testthat/test-bus-positions.R
a4e6f9b75e641e86f4d6f99a91f28e33 *tests/testthat/test-bus-routes.R
2a261efed78945854f596cea75080c93 *tests/testthat/test-bus-schedules.R
eec19ba9b3fbea1cda5530302c791c4a *tests/testthat/test-bus-stops.R
1e6a092e7ff379ef661e267e2591e22b *tests/testthat/test-incidents-bus.R
ecfeb61b5afd00d635548116f41afaa1 *tests/testthat/test-incidents-elevator.R
9713d81de69f098aad637d570760c806 *tests/testthat/test-incidents-rail.R
ca1e9affc07b3f63a03bc115e230b7ac *tests/testthat/test-bus-stops.R
1c7249fb3e2c9a1afa83ed78dbc8a19c *tests/testthat/test-incidents-bus.R
29de3e333504477c02346d4c23f37872 *tests/testthat/test-incidents-elevator.R
ed255bf3c1951136cf882a696fdb9dec *tests/testthat/test-incidents-rail.R
12d247a3eff49ccd5f73b723415e9eed *tests/testthat/test-key.R
edc8d6ef1e4c2572ba091c69ce902a3e *tests/testthat/test-next-bus.R
682f6e0967077a7ba43d1ea5efa42326 *tests/testthat/test-next-train.R
c8eb6b4f60c7088f7f1e5849cf4b9caf *tests/testthat/test-next-bus.R
bda5885b66fd3262948188679b1be024 *tests/testthat/test-next-train.R
d8bd52c0b9b81be0e13f2e93a2a1b4bc *tests/testthat/test-rail-dest.R
b45b0655c3f2307c92d0d2b890a33c69 *tests/testthat/test-rail-entrance.R
2eac5057df1c651ace8767925a1e4783 *tests/testthat/test-rail-info.R
c7c15f4c08ed17f5ec93f62e3c7b5897 *tests/testthat/test-rail-lines.R
826a2ee43c46cebdd30e54aa7106f9a7 *tests/testthat/test-rail-path.R
c4947f98139f6cb75bf38fb4788f593a *tests/testthat/test-rail-position.R
ec329eadc95569473a6301546b02750e *tests/testthat/test-rail-stations.R
297968c10b15bd2f82f1807ecfba3b28 *tests/testthat/test-rail-times.R
62a3bff47d3870745257b55ec7aeb0ef *tests/testthat/test-rail-stations.R
d8ff275df387929357d8590349f64021 *tests/testthat/test-rail-times.R
7fad2de39f256bf5f72e931b096c5447 *tests/testthat/test-standard-routes.R
6513c0bb9a7db91a4e3b1ca574779034 *tests/testthat/test-track-circuits.R
10 changes: 10 additions & 0 deletions NEWS.md
@@ -1,3 +1,13 @@
# metro 0.9.3

* Switch from MIT license to GPL-3
* Update maintainer email, website URL, and GitHub URL.
* Due to an error in the rail timing endpoint, the `rail_times()` function can
only return example data for the time being. (#15)
* Due to an error in the train position endpoint, the `train_position()`
function can only return example data for the time being. (#16)
* Add `StopId` column to `bus_departs()` and use current date in the example.

# metro 0.9.2

* Update to new package doc help page.
Expand Down
5 changes: 3 additions & 2 deletions R/api.R
Expand Up @@ -30,15 +30,16 @@ wmata_api <- function(path, query = NULL, ..., level, api_key = wmata_key()) {
query = query,
httr::accept_json(),
httr::add_headers(api_key = api_key),
httr::user_agent("https://github.com/kiernann/metro/"),
httr::user_agent("https://github.com/k5cents/metro/"),
terminate_on = c(400:417)
)
if (httr::http_type(resp) != "application/json") {
stop("API did not return JSON", call. = FALSE)
}
raw <- httr::content(resp, as = "text", encoding = "UTF-8")
parsed <- jsonlite::fromJSON(raw, ...)
if (httr::http_error(resp) && "message" %in% names(parsed)) {
if (httr::http_error(resp) && "message" %in% tolower(names(parsed))) {
names(parsed) <- tolower(names(parsed))
stop(
sprintf(
"WMATA API request failed [%s]\n%s",
Expand Down
5 changes: 4 additions & 1 deletion R/bus-departs.R
Expand Up @@ -4,6 +4,7 @@
#'
#' @format A tibble with 1 row per bus departure and 8 variables:
#' \describe{
#' \item{StopID}{7-digit regional ID which can be used in various bus-related}
#' \item{ScheduleTime}{Date and time (UTC) when the bus is scheduled to stop
#' at this location.}
#' \item{DirectionNum}{Denotes a binary direction (0 or 1) of the bus. There
Expand All @@ -28,7 +29,7 @@
#' @inheritParams wmata_key
#' @examples
#' \dontrun{
#' bus_departs(1001195, "2021-01-01")
#' bus_departs(1001195, Sys.Date())
#' }
#' @return Data frame containing scheduled arrival information.
#' @seealso <https://developer.wmata.com/docs/services/54763629281d83086473f231/operations/5476362a281d830c946a3d6c/console>
Expand All @@ -44,5 +45,7 @@ bus_departs <- function(StopID, Date = NULL, api_key = wmata_key()) {
api_key = api_key
)
dat[, c(1, 3:4)] <- lapply(dat[, c(1, 3:4)], api_time)
dat$StopID <- as.character(StopID)
dat <- dat[, c(length(dat), 1, seq(2, length(dat) - 1))]
tibble::as_tibble(dat)
}
10 changes: 5 additions & 5 deletions R/incidents-rail.R
Expand Up @@ -44,9 +44,9 @@ rail_incidents <- function(api_key = wmata_key()) {
}

empty_rail_incidents <- tibble::tibble(
incident = character(),
type = character(),
lines = character(),
updated = as.POSIXct(character()),
description = character()
IncidentID = character(),
IncidentType = character(),
LinesAffected = list(),
DateUpdated = as.POSIXct(character()),
Description = character()
)
2 changes: 1 addition & 1 deletion R/rail-destination.R
Expand Up @@ -25,7 +25,7 @@
#' }
#'
#' [1]: https://www.wmata.com/about/records/public_docs/upload/Tariff-on-Fares-Annotated-2-12-18.pdf#page=6
#' [2]: https://www.wmata.com/fares/reduced.cfm
#' [2]: https://www.wmata.com/service/accessibility/reduced-fare.cfm
#'
#' @param FromStationCode Station code for the origin station. Use the
#' [rail_stations()] function to return a list of all station codes.
Expand Down
8 changes: 7 additions & 1 deletion R/rail-position.R
Expand Up @@ -55,12 +55,18 @@
#' @family Train Positions
#' @importFrom tibble as_tibble
#' @export
rail_positions <- function(api_key = api_key) {
rail_positions <- function(api_key = wmata_key()) {
dat <- wmata_api(
path = "TrainPositions/TrainPositions",
query = list(contentType = "json"),
flatten = TRUE,
level = 1
)
if (length(dat) == 0) {
warning("Using example data until issue is resolved: ",
"https://github.com/k5cents/metro/issues/16")
example_file <- system.file("TrainPositions.json", package = "metro")
dat <- jsonlite::fromJSON(example_file, flatten = TRUE)[[1]]
}
tibble::as_tibble(dat)
}
6 changes: 6 additions & 0 deletions R/rail-times.R
Expand Up @@ -49,6 +49,12 @@ rail_times <- function(StationCode = NULL, api_key = wmata_key()) {
level = 1,
api_key = api_key
)
if (length(dat$Monday$FirstTrains[[1]]) == 0) {
warning("Using example data until issue is resolved: ",
"https://github.com/k5cents/metro/issues/15")
example_file <- system.file("jStationTimes.json", package = "metro")
dat <- jsonlite::fromJSON(example_file)[[1]]
}
stn_codes <- dat$Code
stn_names <- dat$StationName
dat <- dat[, 3:9]
Expand Down

0 comments on commit 2c274d1

Please sign in to comment.