Skip to content

Commit

Permalink
ready for CRAN
Browse files Browse the repository at this point in the history
  • Loading branch information
SymbolixAU committed Jun 25, 2017
1 parent 637c188 commit 730922f
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 24 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: googleway
Type: Package
Title: Accesses Google Maps APIs to Retrieve Data and Plot Maps
Version: 2.2.0
Date: 2017-04-26
Date: 2017-06-25
Authors@R: c(
person("David", "Cooley", ,"[email protected]", role = c("aut", "cre")),
person("Paulo", "Barcelos", role = "ctb", comment = "Author of c++ decode_pl"),
Expand Down
28 changes: 18 additions & 10 deletions R/google_map_layers.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@
#'
#'
#' ## using marker icons
#' tram_stops$icon <- "https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png"
#' iconUrl <- paste0("https://developers.google.com/maps/documentation/",
#' "javascript/examples/full/images/beachflag.png")
#'
#' tram_stops$icon <- iconUrl
#'
#' google_map(key = map_key, data = tram_stops) %>%
#' add_markers(lat = "stop_lat", lon = "stop_lon", marker_icon = "icon")
#'
Expand Down Expand Up @@ -1694,10 +1698,10 @@ update_rectangles <- function(map, data, id,
#' Adds a ground overlay to a map. The overlay can only be added from a URL
#'
#' @param map a googleway map object created from \code{google_map()}
#' @param north northern most latitude coordinate
#' @param east eastern most longitude
#' @param south southern most latitude coordinate
#' @param west western most longitude
#' @param north northern-most latitude coordinate
#' @param east eastern-most longitude
#' @param south southern-most latitude coordinate
#' @param west western-most longitude
#' @param overlay_url URL string specifying the location of the overlay layer
#' @param layer_id single value specifying an id for the layer.
#' @param digits integer. Use this parameter to specify how many digits (decimal places)
Expand Down Expand Up @@ -1725,6 +1729,10 @@ add_overlay <- function(map,
digits = 4){

URLCheck(overlay_url)
LatitudeCheck(north, "north")
LatitudeCheck(south, "south")
LongitudeCheck(east, "east")
LongitudeCheck(west, "west")

layer_id <- LayerId(layer_id)

Expand All @@ -1741,7 +1749,7 @@ add_overlay <- function(map,

#' Add KML
#'
#' Adds a KML layer to a map. The KML layer can only be added from a URL
#' Adds a KML layer to a map.
#'
#' @param map a googleway map object created from \code{google_map()}
#' @param kml_url URL string specifying the location of the kml layer
Expand All @@ -1752,8 +1760,11 @@ add_overlay <- function(map,
#'
#' map_key <- 'your_api_key'
#'
#' kmlUrl <- paste0('https://developers.google.com/maps/',
#' 'documentation/javascript/examples/kml/westcampus.kml')
#'
#' google_map(key = map_key) %>%
#' add_kml(kml_url = 'https://developers.google.com/maps/documentation/javascript/examples/kml/westcampus.kml')
#' add_kml(kml_url = kmlUrl)
#'
#' }
#' @export
Expand All @@ -1773,9 +1784,6 @@ add_kml <- function(map, kml_url, layer_id = NULL){
#'
#' Adds a fusion table layer to a map.
#'
#' @details
#'
#'
#' @param map a googleway map object created from \code{google_map()}
#' @param query a \code{data.frame} of 2 or 3 columns, and only 1 row. Two columns
#' must be 'select' and 'from', and the third 'where'. The 'select' value is the column
Expand Down
17 changes: 17 additions & 0 deletions R/parameter_checks.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# Latitude Check
#
# Checks that a value is between -90:90
LatitudeCheck <- function(lat, arg){
if(!is.numeric(lat) | lat < -90 | lat > 90)
stop(paste0(arg, " must be a value between -90 and 90 (inclusive)"))
}

# Longitude Check
#
# Checks that a value is between -90:90
LongitudeCheck <- function(lat, arg){
if(!is.numeric(lat) | lat < -180 | lat > 180)
stop(paste0(arg, " must be a value between -180 and 180 (inclusive)"))
}


# URL Check
#
# Checks for a valid URL
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Version 2.0.0 has **significant changes** compared to the previous release. See

See [**vignettes**](https://github.com/SymbolixAU/googleway/blob/master/vignettes/googleway-vignette.Rmd) for instructions and examples.

## v2.2.0 - pre-release version
## v2.2.0

see [News](https://github.com/SymbolixAU/googleway/blob/master/NEWS.md) for a list of changes

Expand Down
5 changes: 3 additions & 2 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@

## Release summary

* Updates v1.0.0 to v2.0.0
* Added a Google Map html widget
* Updates v2.0.0 to v2.2.0
* Added three map layers
* various bug fixes


## Test Environments
Expand Down
3 changes: 0 additions & 3 deletions man/add_fusion.Rd

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

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

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

6 changes: 5 additions & 1 deletion man/add_markers.Rd

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

8 changes: 4 additions & 4 deletions man/add_overlay.Rd

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

Binary file modified revdep/checks.rds
Binary file not shown.
22 changes: 22 additions & 0 deletions tests/testthat/test-google_map_layers.R
Original file line number Diff line number Diff line change
Expand Up @@ -301,5 +301,27 @@ test_that("polygons added and removed", {

})

test_that("map overlays coordinates are accurate", {

expect_error(google_map(key = 'abc') %>%
add_overlay(north = 40.773941, south = 1000, east = -74.12544, west = -74.22655,
overlay_url = "https://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg")
)

expect_error(google_map(key = 'abc') %>%
add_overlay(north = 40.773941, south = 40.712216, east = -274.12544, west = -74.22655,
overlay_url = "https://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg")
)

expect_error(google_map(key = 'abc') %>%
add_overlay(north = 40.773941, south = 40.712216, east = -74.12544, west = -274.22655,
overlay_url = "https://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg")
)

expect_error(google_map(key = 'abc') %>%
add_overlay(north = 240.773941, south = 40.712216, east = -74.12544, west = -74.22655,
overlay_url = "https://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg")
)

})

0 comments on commit 730922f

Please sign in to comment.