Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bczernecki committed Aug 5, 2022
1 parent 2b6545e commit b99cc58
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 29 deletions.
4 changes: 2 additions & 2 deletions R/nearest_stations_ogimet.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#' point = c(-2, 50),
#' add_map = TRUE,
#' no_of_stations = 60,
#' main = "Meteo stations in UK") -> a
#' main = "Meteo stations in UK")
#' }
#'

Expand Down Expand Up @@ -136,7 +136,7 @@ nearest_stations_ogimet = function(country = "United+Kingdom",

point = as.data.frame(t(point))
names(point) = c("lon", "lat")
distmatrix = rbind(point,result[, 3:4])
distmatrix = rbind(point, result[, 3:4])
distance_points = stats::dist(distmatrix, method = "euclidean")[1:dim(result)[1]]
result["distance"] = distance_points * 112.196672
orderd_distance = result[order(result$distance), ]
Expand Down
7 changes: 2 additions & 5 deletions R/ogimet_daily.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@
#' @keywords internal
#'
#' @examples \donttest{
#' # downloading data for Poznan-Lawica
#' poznan = ogimet_daily(station = 12330,
#' date = c("2019-01-01", "2019-03-31"),
#' coords = TRUE)
#' head(poznan)
#' ## downloading data for Poznan-Lawica
#' # poznan = ogimet_daily(station = 12330, coords = TRUE)
#' }
#'

Expand Down
4 changes: 2 additions & 2 deletions R/ogimet_hourly.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#' @examples
#' \donttest{
#' # downloading data for Poznan-Lawica
#' poznan = ogimet_hourly(station = 12330, coords = TRUE, precip_split = TRUE)
#' head(poznan)
#' # poznan = ogimet_hourly(station = 12330, coords = TRUE, precip_split = TRUE)
#' # head(poznan)
#' }
#'

Expand Down
15 changes: 6 additions & 9 deletions R/stations_ogimet.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
#'
#' @examples
#' \donttest{
#' stations_ogimet(country = "Australia", add_map = TRUE)
#' # stations_ogimet(country = "Australia", add_map = TRUE)
#' }
#'
stations_ogimet = function(country = "United+Kingdom", date = Sys.Date(), add_map = FALSE) {

#options(RCurlOptions = list(ssl.verifypeer = FALSE)) # required on windows for RCurl

if (length(country)!=1) {
if (length(country) != 1) {
stop("To many country selected. Please choose one country")
}

if (length(date)!=1) {
if (length(date) != 1) {
stop("You can check available nearest stations for one day. Please chenge selection")

} # initalizing empty data frame for storing results:
Expand All @@ -44,7 +44,7 @@ stations_ogimet = function(country = "United+Kingdom", date = Sys.Date(), add_ma
if (!is.na(file.size(temp)) & (file.size(temp) > 0)) {

a = readLines(temp)
a = paste(a, sep="", collapse="")
a = paste(a, sep = "", collapse = "")

b = strsplit(a, "Decoded synops since")

Expand Down Expand Up @@ -114,15 +114,12 @@ if (!is.null(res)) {
addfactor = ifelse(addfactor > 0.2, 0.2, addfactor)
addfactor = ifelse(addfactor < 0.05, 0.05, addfactor)

graphics::plot(res$lon, res$lat, col='red', pch=19, xlab = 'longitude', ylab = 'latitude')
graphics::plot(res$lon, res$lat, col = 'red', pch = 19, xlab = 'longitude', ylab = 'latitude')
graphics::text(res$lon, res$lat + addfactor, labels = res$station_names,
col = 'grey70', cex = 0.6)
maps::map(add = TRUE)
}

} # end of checking if res is NULL

return(res)

}

2 changes: 1 addition & 1 deletion man/nearest_stations_ogimet.Rd

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

7 changes: 2 additions & 5 deletions man/ogimet_daily.Rd

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

4 changes: 2 additions & 2 deletions man/ogimet_hourly.Rd

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

2 changes: 1 addition & 1 deletion man/stations_ogimet.Rd

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

2 changes: 1 addition & 1 deletion tests/testthat/test-meteo_ogimet.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ y <- 2018

test_that("meteo_ogimet works!", {

df = meteo_ogimet(interval = "daily", date = c("2019-06-01", "2019-07-08"),
df = meteo_ogimet(interval = "daily", date = c("2019-06-01", "2019-06-08"),
station = c(12330, 12375), coords = TRUE)
expect_true(any(colnames(df) %in% c("Lon", "Lat")))

Expand Down
2 changes: 1 addition & 1 deletion vignettes/getstarted.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
options(scipen=999)
options(scipen = 999)
```

The goal of the **climate** R package is to automatize downloading of meteorological
Expand Down

0 comments on commit b99cc58

Please sign in to comment.