Skip to content

Commit

Permalink
2.3 fixes 2
Browse files Browse the repository at this point in the history
  • Loading branch information
dkahle committed Apr 5, 2013
1 parent da1ccac commit 5b13197
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 12 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ CHANGES
* now imports mapproj.
* theme_nothing now accepts argument legend to prevent legend wiping.
* ggmap and qmplot can now properly display legends in the map again, but transparency in the legend has been removed. (this will likely return if/when ggplot2 allows an alpha argument to element_rect).
* dataset crime now has variable offense as a factor, month and day as ordered factors.
* several functions now message the user with the URL queried as well as the Google Maps Terms of Service URL to better agree with Google's License Restrictions.


DOCUMENTATION CHANGES
Expand Down
8 changes: 6 additions & 2 deletions R/geocode.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Geocode
#'
#' geocodes a location using Google Maps.
#' geocodes a location using Google Maps. Note that in most cases by using this function you are agreeing to the Google Maps API Terms of Service at https://developers.google.com/maps/terms.
#'
#' @param location a character string specifying a location of interest (e.g. "Baylor University")
#' @param output amount of output
Expand Down Expand Up @@ -75,7 +75,11 @@ geocode <- function (location, output = c('latlon','latlona','more','all'),
gc <- fromJSON(paste(readLines(connect), collapse = ''))
if(messaging) message(' done.')
close(connect)
if(output == 'all') return(gc)
if(output == 'all') return(gc)

# message user
message(paste0('Information from URL : ', url_string))
message('Google Maps API Terms of Service : http://developers.google.com/maps/terms')

# did geocode fail?
#print(gc$status)
Expand Down
4 changes: 3 additions & 1 deletion R/get_googlemap.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Get a Google Map
#'
#' get_googlemap accesses the Google Static Maps API version 2 to download a static map.
#' get_googlemap accesses the Google Static Maps API version 2 to download a static map. Note that in most cases by using this function you are agreeing to the Google Maps API Terms of Service at https://developers.google.com/maps/terms.
#'
#' @param center the center of the map. this can either be 1. a longitude/latitude numeric vector or 2. a character string address (note that the latter uses a geocode)
#' @param zoom map zoom, an integer from 3 (continent) to 21 (building), default value 10 (city)
Expand Down Expand Up @@ -274,6 +274,8 @@ get_googlemap <- function(
paste(filename,'gif',sep = '.')
}
download.file(url, destfile = destfile, quiet = !messaging, mode = 'wb')
message(paste0('Map from URL : ', url))
message('Google Maps API Terms of Service : http://developers.google.com/maps/terms')
map <- readPNG(destfile)

# format file
Expand Down
6 changes: 5 additions & 1 deletion R/mapdist.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Compute map distances using Google
#'
#' Compute map distances using Google Maps
#' Compute map distances using Google Maps. Note that in most cases by using this function you are agreeing to the Google Maps API Terms of Service at https://developers.google.com/maps/terms.
#'
#' @param from name of origin addresses in a data frame (vector accepted)
#' @param to name of destination addresses in a data frame (vector accepted)
Expand Down Expand Up @@ -103,6 +103,10 @@ mapdist <- function(from, to, mode = c('driving','walking','bicycling'),
tree <- fromJSON(paste(readLines(connect), collapse = ''))
close(connect)

# message user
message(paste0('Information from URL : ', url_string))
message('Google Maps API Terms of Service : http://developers.google.com/maps/terms')

# label destinations
names( tree$rows[[1]][[1]] ) <- df$to

Expand Down
6 changes: 5 additions & 1 deletion R/revgeocode.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Reverse geocode
#'
#' reverse geocodes a longitude/latitude location using Google Maps.
#' reverse geocodes a longitude/latitude location using Google Maps. Note that in most cases by using this function you are agreeing to the Google Maps API Terms of Service at https://developers.google.com/maps/terms.
#'
#' @param location a location in longitude/latitude format
#' @param output amount of output
Expand Down Expand Up @@ -59,6 +59,10 @@ revgeocode <- function(location, output = c('address','more','all'),
location, '"', sep = ''))
return(data.frame(address = NA))
}

# message user
message(paste0('Information from URL : ', url_string))
message('Google Maps API Terms of Service : http://developers.google.com/maps/terms')

# more than one location found?
if(length(rgc$results) > 1 && messaging){
Expand Down
6 changes: 4 additions & 2 deletions R/route.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Grab a route from Google
#'
#' Grab a route from Google
#' Grab a route from Google. Note that in most cases by using this function you are agreeing to the Google Maps API Terms of Service at https://developers.google.com/maps/terms.
#'
#' @param from name of origin addresses in a data frame (vector accepted)
#' @param to name of destination addresses in a data frame (vector accepted)
Expand Down Expand Up @@ -133,7 +133,9 @@ route <- function(from, to, mode = c('driving','walking','bicycling'),
if(output == 'all') return(tree)



# message user
message(paste0('Information from URL : ', url_string))
message('Google Maps API Terms of Service : http://developers.google.com/maps/terms')


# extract output from tree and format
Expand Down
Binary file modified data/crime.rda
Binary file not shown.
5 changes: 4 additions & 1 deletion man/geocode.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
lat)
}
\description{
geocodes a location using Google Maps.
geocodes a location using Google Maps. Note that in most
cases by using this function you are agreeing to the
Google Maps API Terms of Service at
https://developers.google.com/maps/terms.
}
\details{
note that the google maps api limits to 2500 queries a
Expand Down
5 changes: 4 additions & 1 deletion man/get_googlemap.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@
}
\description{
get_googlemap accesses the Google Static Maps API version
2 to download a static map.
2 to download a static map. Note that in most cases by
using this function you are agreeing to the Google Maps
API Terms of Service at
https://developers.google.com/maps/terms.
}
\examples{
\dontrun{
Expand Down
5 changes: 4 additions & 1 deletion man/mapdist.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
information (output='all')
}
\description{
Compute map distances using Google Maps
Compute map distances using Google Maps. Note that in
most cases by using this function you are agreeing to the
Google Maps API Terms of Service at
https://developers.google.com/maps/terms.
}
\details{
if parameters from and to are specified as geographic
Expand Down
4 changes: 3 additions & 1 deletion man/revgeocode.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
}
\description{
reverse geocodes a longitude/latitude location using
Google Maps.
Google Maps. Note that in most cases by using this
function you are agreeing to the Google Maps API Terms of
Service at https://developers.google.com/maps/terms.
}
\details{
note that the google maps api limits to 2500 queries a
Expand Down
5 changes: 4 additions & 1 deletion man/route.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
information (output='all')
}
\description{
Grab a route from Google
Grab a route from Google. Note that in most cases by
using this function you are agreeing to the Google Maps
API Terms of Service at
https://developers.google.com/maps/terms.
}
\examples{
\dontrun{
Expand Down

0 comments on commit 5b13197

Please sign in to comment.