tests/testthat/helper.R

create_square <- function(width = 2, lng = 0, lat = 0, hole = FALSE, type = Polygon) {
  lngs <- c(lng - width / 2, lng + width / 2, lng + width / 2, lng - width / 2)
  lats <- c(lat + width / 2, lat + width / 2, lat - width / 2, lat - width / 2)

  if (hole) {
    lngs <- rev(lngs)
    lats <- rev(lats)
  }

  if ("hole" %in% names(formals(type))) {
    type(cbind(lng = lngs, lat = lats), hole = hole)
  } else {
    type(cbind(lng = lngs, lat = lats))
  }
}

Try the leaflet package in your browser

Any scripts or data that you put into this service are public.

leaflet documentation built on May 29, 2024, 1:19 a.m.