Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cartoDB basetiles #327

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Add cartoDB basetiles #327

wants to merge 5 commits into from

Conversation

gregleleu
Copy link

Adding basemap tiles from Carto DB (cleanup from now deleted pull request)

Before you open your PR

  • Did you run R CMD CHECK?
  • Did you run roxygen2::roxygenise(".")?

Thanks for contributing!

@gregleleu
Copy link
Author

Hi @dkahle, would you have time to take a look at this PR? happy to make any required changes. Thanks!

Copy link
Collaborator

@scottmmjackson scottmmjackson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind writing some unit tests in addition to making some of the changes?

It also look like your https parameter doesn't do anything. It should be inverted to an opt-out because we should be secure by default (I know the rest of the code doesn't do that yet, but it's a good aspiration).

#'
#' @param bbox a bounding box in the format c(lowerleftlon, lowerleftlat,
#' upperrightlon, upperrightlat).
#' @param zoom a zoom level
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could probably use some information on format here.

#' upperrightlon, upperrightlat).
#' @param zoom a zoom level
#' @param maptype light_all, dark_all, light_nolabels, light_only_labels, dark_nolabels, dark_only_labels,
#' rastertiles/voyager, rastertiles/voyager_nolabels, rastertiles/voyager_only_labels, or rastertiles/voyager_labels_under.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small nit: indentation

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also looks like the line length is different from the rest of the docstring

#' rastertiles/voyager, rastertiles/voyager_nolabels, rastertiles/voyager_only_labels, or rastertiles/voyager_labels_under.
#' @param crop crop raw map tiles to specified bounding box. if FALSE, the
#' resulting map will more than cover the bounding box specified.
#' @param messaging turn messaging on/off
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#' @param messaging turn messaging on/off
#' @param messaging if FALSE, turn messaging off

Consider also using a more standard parameter name like verbose or silent

#' @param crop crop raw map tiles to specified bounding box. if FALSE, the
#' resulting map will more than cover the bounding box specified.
#' @param messaging turn messaging on/off
#' @param urlonly return url only
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

specify type, explain that it's the url to the map

#' resulting map will more than cover the bounding box specified.
#' @param messaging turn messaging on/off
#' @param urlonly return url only
#' @param color color or black-and-white (use force = TRUE if you've already
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

specify type

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function signature says this is an enum between color and bw so that should appear in the docstring.

Comment on lines +20 to +21
#' @param https if TRUE, queries an https endpoint so that web traffic between
#' you and the tile server is ecrypted using SSL.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be an opt-out. There's no good reason not to use HTTPS when it's available.

"rastertiles/voyager_only_labels",
"rastertiles/voyager_labels_under"),
crop = TRUE, messaging = FALSE, urlonly = FALSE, color = c("color","bw"), force = FALSE,
where = tempdir(), https = FALSE, ...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HTTPS needs to be enabled by default.

Comment on lines +296 to +317






















Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove whitespace




get_carto_tile <- function(maptype, zoom, x, y, color, force = FALSE, messaging = TRUE, where = tempdir(), https = FALSE, url){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HTTPS should be enabled by default

# the map is only a covering of the bounding box extent the idea is to get
# the lower left tile and the upper right tile and compute their bounding boxes
# tiles are referenced by top left of tile, starting at 0,0
# see http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https :)

@gregleleu
Copy link
Author

Hi @scottmmjackson
Thanks for taking a look. Happy to have a go at the changes, but just to be sure: get_carto currently mimics all other get_* functions (google, stamen etc.). The changes you suggest make sense for all of these. Are we sure we want this one to diverge from the others?
Regarding the unit tests: there are no tests for the other get_* functions. So not sure what to test for: I could save some tiles and compare results, but what if tiles change on the carto server?

@scottmmjackson
Copy link
Collaborator

As far as tests, a simple smoke test that proves no blatant runtime errors would suffice.

For the changes, the only one I really care about is inverting https and we can diverge for that. For the rest, use your judgment, but I would like types documented a little clearer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants