Skip to content

Commit

Permalink
Update code style for #486
Browse files Browse the repository at this point in the history
  • Loading branch information
Robinlovelace committed May 6, 2022
1 parent b9861e6 commit b54697d
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 21 deletions.
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ export(rnet_get_nodes)
export(rnet_group)
export(route)
export(route_average_gradient)
export(route_bikecitizens)
export(route_cyclestreets)
export(route_dodgr)
export(route_google)
Expand Down
6 changes: 3 additions & 3 deletions R/google-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ dist_google <- function(from, to, google_api = Sys.getenv("GOOGLEDIST"),
mode <- match.arg(mode)
base_url <- "https://maps.googleapis.com/maps/api/distancematrix/json?units="
# Convert sp object to lat/lon vector
if (class(from) == "SpatialPoints" | class(from) == "SpatialPointsDataFrame") {
if (is(from, "SpatialPoints") | is(from, "SpatialPointsDataFrame")) {
from <- coordinates(from)
}
if (class(to) == "SpatialPoints" | class(to) == "SpatialPointsDataFrame") {
if (is(to, "SpatialPoints") | is(to, "SpatialPointsDataFrame")) {
to <- coordinates(to)
}
if (google_api == "") {
Expand All @@ -120,7 +120,7 @@ dist_google <- function(from, to, google_api = Sys.getenv("GOOGLEDIST"),
base_url, g_units, "&origins=", from,
"&destinations=", to, "&mode=", mode
)
if (class(arrival_time)[1] == "POSIXlt") {
if (is(arrival_time[1], "POSIXlt")) {
arrival_time <- as.numeric(arrival_time)
url_travel <- paste0(url_travel, "&arrival_time=", arrival_time)
}
Expand Down
8 changes: 4 additions & 4 deletions R/oneway.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ od_id_szudzik <- function(x, y, ordermatters = FALSE) {
stop("x and y are not of equal length")
}

if (class(x) == "factor") {
if (is(x, "factor")) {
x <- as.character(x)
}
if (class(y) == "factor") {
if (is(y, "factor")) {
y <- as.character(y)
}
lvls <- unique(c(x, y))
Expand Down Expand Up @@ -88,8 +88,8 @@ od_id_character <- function(x, y) {

convert_to_numeric <- function(x, y) {
if (length(x) != length(y)) stop("x and y are not of equal length")
if (class(x) == "factor") x <- as.character(x)
if (class(y) == "factor") y <- as.character(y)
if (is(x, "factor")) x <- as.character(x)
if (is(y, "factor")) y <- as.character(y)
lvls <- unique(c(x, y))
x <- as.integer(factor(x, levels = lvls))
y <- as.integer(factor(y, levels = lvls))
Expand Down
4 changes: 2 additions & 2 deletions R/route-transport-api.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ route_transportapi_public <- function(from, to, silent = FALSE,
region = "southeast", modes = NA, not_modes = NA) {

# Convert sp object to lat/lon vector
if (class(from) == "SpatialPoints" | class(from) == "SpatialPointsDataFrame") {
if (is(from, "SpatialPoints") | is(from, "SpatialPointsDataFrame")) {
from <- coordinates(from)
}
if (class(to) == "SpatialPoints" | class(to) == "SpatialPointsDataFrame") {
if (is(to, "SpatialPoints") | is(to, "SpatialPointsDataFrame")) {
to <- coordinates(to)
}

Expand Down
5 changes: 3 additions & 2 deletions R/route_cyclestreets.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,14 @@ route_cyclestreets <- function(from, to, plan = "fastest", silent = TRUE, pat =
save_raw = "FALSE") {

# Convert sp object to lat/lon vector
if (class(from) == "SpatialPoints" | class(from) == "SpatialPointsDataFrame") {
if (is(from, "SpatialPoints") | is(from, "SpatialPointsDataFrame")) {
from <- coordinates(from)
}
if (class(to) == "SpatialPoints" | class(to) == "SpatialPointsDataFrame") {
if (is(to, "SpatialPoints") | is(to, "SpatialPointsDataFrame")) {
to <- coordinates(to)
}


# Convert character strings to lon/lat if needs be
if (is.character(from)) {
from <- geo_code(from)
Expand Down
12 changes: 3 additions & 9 deletions man/route_bikecitizens.Rd

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

0 comments on commit b54697d

Please sign in to comment.