Skip to content

Commit

Permalink
turn off last https call for london stations; closes #95
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Jan 10, 2020
1 parent 2f39837 commit 6281cd0
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 11 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: bikedata
Title: Download and Aggregate Data from Public Hire Bicycle Systems
Version: 0.2.4.001
Version: 0.2.4.002
Authors@R: c(
person("Mark", "Padgham", email = "mark.padgham@email.com",
role = c("aut", "cre"),
Expand Down Expand Up @@ -53,7 +53,7 @@ URL: https://docs.ropensci.org/bikedata, https://github.com/ropensci/bikedata
BugReports: https://github.com/ropensci/bikedata/issues
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.0.1
RoxygenNote: 7.0.2
X-schema.org-applicationCategory: Data Access
X-schema.org-keywords: bicycle-hire-systems, bike-hire-systems, bike-hire, bicycle-hire, database, bike-data
X-schema.org-isPartOf: https://ropensci.org
11 changes: 11 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
0.2.4.XXX
==================
Minor changes:
- `store_bikedata()` now has additional parameter `latest_lo_stns` that should
generally just be left at default value, but which can be set to `FALSE` for
truly offline use.

0.2.4
==================
Back on CRAN after being removed due to dependency (dodgr) having been removed

0.2.3
===================
Minor changes:
Expand Down
13 changes: 13 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,16 @@
#' using \code{bike_write_test_data()}. These \code{.zip} files can be
#' subsequently read into an SQLite3 database using \code{store_bikedata}.
"bike_test_data"

#' Docking stations for London, U.K.
#'
#' A \code{data.frame} of station id values, names, and geographic coordinates
#' for 786 stations for London, U.K. These stations are generally (and by
#' default) downloaded automatically to ensure they are always up to date, but
#' such downloading can be disabled in the \code{store_bikedata()} function by
#' setting \code{latest_lo_stns = FALSE}.
#'
#' @docType data
#'
#' @format A \code{data.frame} of the four columns described above.
"lo_stns"
4 changes: 3 additions & 1 deletion R/database-stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ bike_stored_files <- function (bikedb, city)
#' data_dir <- tempdir ()
#' bike_write_test_data (data_dir = data_dir)
#' bikedb <- file.path (data_dir, 'testdb')
#' store_bikedata (data_dir = data_dir, bikedb = bikedb)
#' # latest_lo_stns is set to FALSE just to avoid download on CRAN; this should
#' # normally remain at default value of TRUE:
#' store_bikedata (data_dir = data_dir, bikedb = bikedb, latest_lo_stns = FALSE)
#' # create database indexes for quicker access:
#' index_bikedata_db (bikedb = bikedb)
#'
Expand Down
19 changes: 18 additions & 1 deletion R/stations.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,31 @@ bike_stations <- function (bikedb, city)

#' Get London station data from Transport for London (TfL)
#'
#' @param external If \code{TRUE}, download latest list of stations from
#' external TfL site, otherwise use potentially obsolete internal version.
#' @param quiet If \code{FALSE}, just declare getting stations (coz it can take
#' a while).
#' @return \code{data.frame} of (id, name, lon, lat) of all stations in London's
#' Santander Cycles system
#'
#' @noRd
bike_get_london_stations <- function (quiet = TRUE)
bike_get_london_stations <- function (external = TRUE, quiet = TRUE)
{
if (external)
res <- get_london_stns_external (quiet = quiet)
else
res <- get_london_stns_internal ()

return (res)
}

get_london_stns_internal <- function () {
env <- new.env ()
utils::data ('lo_stns', envir = env)
return (env$lo_stns)
}

get_london_stns_external <- function (quiet = TRUE) {
if (!quiet)
message ("getting london stations ...", appendLF = FALSE)
tfl_url <- "https://api.tfl.gov.uk/BikePoint"
Expand Down
10 changes: 8 additions & 2 deletions R/store-bikedata.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#' @param dates If specified and no \code{data_dir} is given, data are
#' downloaded and stored only for these dates specified as vector of YYYYMM
#' values.
#' @param latest_lo_stns If \code{TRUE} (default), download latest version of
#' London stations; otherwise use potentially obsolete internal version. (This
#' parameter should not need to be changed, but can be set to \code{FALSE} to
#' avoid external calls; for example when not online.)
#' @param quiet If FALSE, progress is displayed on screen
#'
#' @return Number of trips added to database
Expand Down Expand Up @@ -62,7 +66,8 @@
#' # don't forget to remove real data!
#' # file.remove (list.files (data_dir, pattern = '.zip'))
#' }
store_bikedata <- function (bikedb, city, data_dir, dates = NULL, quiet = FALSE)
store_bikedata <- function (bikedb, city, data_dir, dates = NULL,
latest_lo_stns = TRUE, quiet = FALSE)
{
if (missing (city) & missing (data_dir))
{
Expand Down Expand Up @@ -164,7 +169,8 @@ store_bikedata <- function (bikedb, city, data_dir, dates = NULL, quiet = FALSE)
} else if (ci %in% c('bo', 'dc', 'gu', 'lo', 'mn', 'mo'))
{
if (ci == "lo")
stns <- bike_get_london_stations (quiet)
stns <- bike_get_london_stations (external = latest_lo_stns,
quiet = quiet)
else if (ci == 'dc')
stns <- bike_get_dc_stations ()
else if (ci == 'bo')
Expand Down
9 changes: 6 additions & 3 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"codeRepository": "https://github.com/ropensci/bikedata",
"issueTracker": "https://github.com/ropensci/bikedata/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.2.4.1",
"version": "0.2.4.2",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down Expand Up @@ -282,7 +282,7 @@
"developmentStatus": "active",
"releaseNotes": "https://github.com/ropensci/bikedata/blob/master/NEWS.md",
"readme": "https://github.com/ropensci/bikedata/blob/master/README.md",
"fileSize": "2925.934KB",
"fileSize": "2945.521KB",
"copyrightHolder": {},
"funder": {},
"review": {
Expand Down Expand Up @@ -323,5 +323,8 @@
}
}
],
"relatedLink": ["https://docs.ropensci.org/bikedata", "https://CRAN.R-project.org/package=bikedata"]
"relatedLink": [
"https://docs.ropensci.org/bikedata",
"https://CRAN.R-project.org/package=bikedata"
]
}
4 changes: 3 additions & 1 deletion man/bike_db_totals.Rd

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

14 changes: 13 additions & 1 deletion man/store_bikedata.Rd

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

0 comments on commit 6281cd0

Please sign in to comment.