diff --git a/.Rbuildignore b/.Rbuildignore index e633dded8..8712b4935 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -5,3 +5,4 @@ ^basic_small.png ^docs$ ^vignettes$ +^tic.R diff --git a/.travis.yml b/.travis.yml index b9f05be9c..6457a10c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,27 +1,52 @@ language: r +sudo: required +dist: trusty +cache: + - packages + - ccache +latex: false + +addons: + postgresql: "9.6" + apt: + sources: + - sourceline: 'ppa:ubuntugis/ubuntugis-unstable' + packages: + - libproj-dev + - libgeos-dev + - libgdal-dev + - libudunits2-dev + - postgresql-server-dev-9.6 # required for postgis installation r: - release - devel -cache: packages - -sudo: required - -dist: trusty - before_install: - - sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable --yes - - sudo apt-get --yes --force-yes update -qq - - sudo apt-get install --yes libudunits2-dev libproj-dev libgeos-dev libgdal-dev - -warnings_are_errors: false - -r_packages: - - rgdal - - roxygen2 - - rmarkdown - - sf - -after_success: - - Rscript -e 'covr::codecov()' + # install postgis from source (required for lwgeom installation): + - wget http://download.osgeo.org/postgis/source/postgis-2.3.2.tar.gz + - (mv postgis* /tmp; cd /tmp; tar xzf postgis-2.3.2.tar.gz) + - (cd /tmp/postgis-2.3.2 ; ./configure; make; sudo make install) + # create postgis databases: + - sudo service postgresql restart + - createdb postgis + - psql -d postgis -c "CREATE EXTENSION postgis;" + - psql -d postgis -c "GRANT CREATE ON DATABASE postgis TO travis" + - createdb empty + - psql -d empty -c "CREATE EXTENSION postgis;" + - R -q -e 'install.packages("remotes"); remotes::install_github("ropenscilabs/tic"); tic::prepare_all_stages(); tic::before_install()' +install: R -q -e 'tic::install()' +script: R -q -e 'tic::script()' + +before_deploy: R -q -e 'tic::before_deploy()' +deploy: + provider: script + script: R -q -e 'tic::deploy()' + on: + branch: develop + condition: + - $TRAVIS_PULL_REQUEST = false + - $TRAVIS_EVENT_TYPE != cron + - $TRAVIS_R_VERSION_STRING = release + +after_success: R -q -e 'tic::after_success()' diff --git a/DESCRIPTION b/DESCRIPTION index 8a0149672..4840e4270 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: mapview Type: Package Title: Interactive Viewing of Spatial Data in R -Version: 2.3.0 -Date: 2018-01-30 +Version: 2.4.0 +Date: 2018-04-28 Authors@R: c( person("Tim", "Appelhans", email = "tim.appelhans@gmail.com", role = c("cre", "aut")), person("Florian", "Detsch", email = "florian.detsch@staff.uni-marburg.de", role = c("aut")), @@ -13,6 +13,8 @@ Authors@R: c( person("Edzer", "Pebesma", role = c("ctb")), person("Kenton", "Russell", role = c("ctb")), person("Michael", "Sumner", role = c("ctb")), + person("Jochen", "Darley", email = "Debugger@jedimasters.de", role = c("ctb")), + person("Pierre", "Roudier", role = c("ctb")), person("Environmental Informatics Marburg", role = c("ctb")) ) Maintainer: Tim Appelhans @@ -52,4 +54,5 @@ Suggests: rmarkdown, dplyr, testthat, - covr + covr, + lwgeom diff --git a/NAMESPACE b/NAMESPACE index 583de8f59..e233dd5d3 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -4,10 +4,10 @@ export(addExtent) export(addFeatures) export(addHomeButton) export(addImageQuery) -export(addLargeFeatures) export(addLogo) +export(addMapPane) export(addMouseCoordinates) -export(addStarsImage) +export(addStaticLabels) export(coords2JSON) export(coords2Lines) export(coords2Polygons) diff --git a/NEWS b/NEWS index f765bbc70..6119822c1 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,24 @@ +mapview 2.4.0 + +new features: + + * addImageQuery has gained argument prefix to modify the layerId prefix. + * mapview methods for raster data have gained arguments label, query.type, query.digits, query.position and query.prefix to modify raster value query settings. https://twitter.com/pierreroudier/status/958476875344392193 + * popupTable now right aligns values. + * Thanks to Pierre Roudier quantile strectching in viewRGB can now be turned off by simply setting to NULL. #127 + * mapshot has gained argument remove_controls to remove map junk when saving to image file format. + * mapview method for data.frame has gained argument crs to enable rendering on a basemap #138 + * updated to work with leaflet 2.0.0 #129 (incl. deprecation of previously used large methods) + * new function addMapPane to enable control over layer order. + * mapview has gained argument pane as it now uses addMapPane to ensure points overlay lines overlay polygons. + * mapview has gained argument canvas to enable canvas rendering. + +bugfixes: + + * viewRGB failed because of missing method argument. #125 + * combineExtent didn't check properly for crs and failed for raster images. + + mapview 2.3.0 new features: diff --git a/NEWS.md b/NEWS.md index 6144a564f..6a8e2a409 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,24 @@ +## mapview 2.4.0 + +new features: + + * addImageQuery has gained argument prefix to modify the layerId prefix. + * mapview methods for raster data have gained arguments label, query.type, query.digits, query.position and query.prefix to modify raster value query settings. https://twitter.com/pierreroudier/status/958476875344392193 + * popupTable now right aligns values. + * Thanks to Pierre Roudier quantile strectching in viewRGB can now be turned off by simply setting to NULL. #127 + * mapshot has gained argument remove_controls to remove map junk when saving to image file format. + * mapview method for data.frame has gained argument crs to enable rendering on a basemap #138 + * updated to work with leaflet 2.0.0 #129 (incl. deprecation of previously used large methods) + * new function addMapPane to enable control over layer order. + * mapview has gained argument pane as it now uses addMapPane to ensure points overlay lines overlay polygons. + * mapview has gained argument canvas to enable canvas rendering. + +bugfixes: + + * viewRGB failed because of missing method argument. #125 + * combineExtent didn't check properly for crs and failed for raster images. + + ## mapview 2.3.0 new features: diff --git a/R/addLargeFeatures.R b/R/addLargeFeatures.R deleted file mode 100644 index ac6a14715..000000000 --- a/R/addLargeFeatures.R +++ /dev/null @@ -1,220 +0,0 @@ -#' Add moderately large datasets with up to ~100k features to a map. -#' -#' @description -#' This function allows users to add moderately sized datasets to a leaflet -#' or mapview map. Things are drawn on a html canvas for performance. Feature -#' querying is supported but only at higher zoom levels to preserve performance. -#' -#' @param map a mapview or leaflet object. -#' @param data the data to be added to the map. -#' @param color color of the features. This can be a single character value, -#' a vector of character values or a function that takes argument \code{n} to -#' create a vector of \code{n} colors. -#' @param weight the weight of the lines. -#' @param radius the radius of the circleMarkers (ignored for lines/polygons). -#' @param opacity the opacity of the stroke paths. -#' @param fillOpacity opacity of the fill (for circleMarkers and polygons). -#' @param canvasOpacity the opacity of features when rendered on canvas. -#' @param group the name of the group the data layer should belong to. -#' THIS NEEDS TO BE A VALID CHARACTER STRING, I.E. CANNOT BE 'NA' OR 'NULL'! -#' @param maxpoints see \code{\link{mapview}} for details. -#' @param attributes an optional attribute table (data.frame) to be used for -#' popups. If NULL (the default) popups will show only the feature ID. -#' @param ... currently not used. -#' -#' @examples -#' \dontrun{ -#' library(sf) -#' library(ggmap) -#' -#' data(crime) -#' crime <- crime[complete.cases(crime), ] -#' crime_sf <- st_as_sf(crime, coords = c("lon", "lat"), crs = "+init=epsg:4326") -#' -#' mapview(crime_sf, zcol = "offense", cex = 3) -#' -#' } -#' -#' -#' @export addLargeFeatures -#' @name addLargeFeatures -#' @rdname addLargeFeatures -#' @aliases addLargeFeatures -#' -addLargeFeatures <- function(map, - data, - color = "#03F", - weight = 1, - radius = 8, - opacity = 1, - fillOpacity = 0.6, - canvasOpacity = 0.5, - group = deparse(substitute(data)), - maxpoints = getMaxFeatures(data), - attributes = NULL, - ...) { - - jsgroup <- gsub(".", "", make.names(group), fixed = TRUE) - ## temp dir - tmp <- makepathLarge(as.character(jsgroup)) - pathJsonFn <- tmp[[2]][1] - sfpathJsonFn <- tmp[[3]][1] - jsonFn <- tmp[[4]][1] - - cntr <- 1 - - if (inherits(data, "Spatial")) data <- sf::st_as_sf(data) - - # calculate the maximum number of features to be rendered using RTree - # based on the mean number of vertices per feature - maxFeatures <- maxpoints / (npts(data) / length(sf::st_geometry(data))) - - # check and correct if sp object is of type dataframe - #data <- toSPDF(data) - - # check if a correct WGSS84 proj4 string exist - #data@proj4string@projargs<-compareProjCode(strsplit(data@proj4string@projargs,split = " ")) - - # check and transform projection - #data <- spCheckAdjustProjection(data) - - # get the variable names - #geompos <- which(names(data) == "geometry") - if (inherits(data, "sfc")) { - if (!is.null(attributes)) { - d <- cbind(sf2DataFrame(data, drop_sf_column = TRUE), attributes) - } else { - d <- sf2DataFrame(data, drop_sf_column = TRUE) - } - d$geom <- data - data <- sf::st_as_sf(d) - } - - keep <- colnames(data)#[-geompos] - - # apply zcol - # if (!is.null(zcol)) { - # keep <- c(keep, "color") - # data@data$color <- color - # col <- color[1] - # } else { - col <- color[1] - data$color <- color - data$"Feature ID" <- getFeatureIds(data) - # if (inherits(data, "sf")) { - keep <- unique(c("Feature ID", keep, "color")) - # } else { - # keep <- c(keep, "color") - # } - # # } - - data <- data[, keep] - - # write to a file to be able to use ogr2ogr - # fl <- pathJsonFn #paste(tmpPath, "data.geojson", sep = .Platform$file.sep) - # rgdal::writeOGR(obj = data, dsn = fl, layer = "OGRGeoJSON", driver = "GeoJSON", - # check_exists = FALSE) - # - # # for fastet json read in a html document we wrap it with var data = {}; - # #lns<-paste('var data = ', paste(readLines(pathJsonFn), collapse="\n"),';') - # lns <- data.table::fread(pathJsonFn, header = FALSE, sep = "\n", - # data.table = FALSE, fill = TRUE) - # lns[1,] <- 'var data = {' - # lns[length(lns[,1]),]<- '};' - # - # write.table(lns, pathJsonFn, sep="\n", row.names=FALSE, col.names=FALSE, quote = FALSE) - - ### geojsonio currently does not support sf, therefore a workaround with st_write ### - pre <- paste0('var ', jsgroup, ' = ') - writeLines(pre, pathJsonFn) - # gj <- paste(pre, geojsonio::geojson_json(data), ';', sep = "\n") - sf::st_write(data, dsn = sfpathJsonFn, quiet = TRUE) - file.append(pathJsonFn, sfpathJsonFn) - file.remove(sfpathJsonFn) - # gj <- paste(pre, paste(readLines(pathJsonFn), collapse = ""), sep = "") - # writeLines(gj, con = pathJsonFn) - # gdalUtils::ogr2ogr(src_datasource_name = sfpathJsonFn, - # dst_datasource_name = pathJsonFn, - # f = "GeoJSON", - # append = TRUE, - # overwrite = TRUE) - - # estimate the minimum zoomlevel for the rtree part - # using an empirically (from OSM data) derived function with noFeatures as f(data) - # scaled by the coarse assumption that a polygons lines and points - # have an formal relationship of at least 1 to 2 to 3 points each - # that leads to something like the divisor 1 2 5 - - # to be done - - # getting the extent and map center - ext <- createExtent(data) - # xArea <- (ext@ymax-ext@ymin)*(ext@xmax-ext@xmin) - yc <- (ext@ymax-ext@ymin) * 0.5 + ext@ymin - xc <- (ext@xmax-ext@xmin) * 0.5 + ext@xmin - - # create list of user data that is passed to the widget - lst_x <- list(color = col, - #layer = map.types, - data = 'undefined', - group = jsgroup, - html = getPopupStyle(), - centerLat = yc, - centerLon = xc, - opacity = opacity, - alpharegions = fillOpacity, - canvasOpacity = canvasOpacity, - cex = radius, - weight = weight, - layername = as.character(group), - xmax = ext@xmax, - ymax = ext@ymax, - xmin = ext@xmin, - ymin = ext@ymin, - maxFeatures = as.integer(maxFeatures)) - - # creating the widget - # bViewInternal(jFn = pathJsonFn, x = lst_x) - map$dependencies <- c(map$dependencies, - largeFeaturesDependencies(), - largeDataDependency(jFn = pathJsonFn, - counter = cntr, - group = jsgroup)) - leaflet::invokeMethod(map, leaflet::getMapData(map), - 'addLargeFeatures', lst_x) - -} - -largeFeaturesDependencies <- function() { - list( - htmltools::htmlDependency( - "LargeFeatures", - '0.0.1', - system.file("htmlwidgets/lib/large", package = "mapview"), - script = c("addLargeFeatures.js", - "leaflet.label.js", - "leaflet.ajax.min.js", - "leaflet-providers.min.js", - "geojson-vt-dev.min.js", - "L.CanvasTiles.js", - "rtree.min.js", - "jquery.min.js"), - stylesheet = c("leaflet.css", - "leafletfix.css", - "leaflet.label.css", - "gh-fork-ribbon.css", - "gh-fork-ribbon.ie.css") - )) -} - - -largeDataDependency <- function(jFn, counter, group) { - data_dir <- dirname(jFn) - data_file <- basename(jFn) - list( - htmltools::htmlDependency( - name = group, - version = counter, - src = c(file = data_dir), - script = list(data_file))) -} diff --git a/R/addVeryLargeFeatures.R b/R/addVeryLargeFeatures.R deleted file mode 100644 index 0306e01d2..000000000 --- a/R/addVeryLargeFeatures.R +++ /dev/null @@ -1,163 +0,0 @@ -addVeryLargeFeatures <- function(map, - data, - color = "#0033ff", - na.color = "transparent", - opacity = 0.8, - weight = 2, - group = deparse(substitute(data)), - popup = NULL, - ...) { - - if (inherits(data, "Spatial")) data <- sf::st_as_sf(data) - stopifnot(inherits(sf::st_geometry(data), c("sfc_POINT", "sfc_MULTIPOINT"))) - - jsgroup <- gsub(".", "", make.names(group), fixed = TRUE) - ## temp dir - tmp <- makepathLarge(as.character(jsgroup)) - pathJsonFn <- tmp[[2]][1] - sfpathJsonFn <- tmp[[3]][1] - jsonFn <- tmp[[4]][1] - - # check if x is a dataframe - # if (inherits(data, c("sfc_POINT", "sfc_MULTIPOINT"))) data$dummy <- "0" - data <- sf2DataFrame(data) - - # check projection - data <- checkAdjustProjection(data) - - ind1 <- seq(1, 2*nrow(data), 2) - ind2 <- seq(2, 2*nrow(data), 2) - # create dataframe - cnames <- colnames(sf2DataFrame(data, drop_sf_column = TRUE)) - data$r <- grDevices::col2rgb(color)[1, ] - data$g <- grDevices::col2rgb(color)[2, ] - data$b <- grDevices::col2rgb(color)[3, ] - # data$x <- t(sapply(sf::st_geometry(data), function(i) as.matrix(i)))[, 1] - # data$y <- t(sapply(sf::st_geometry(data), function(i) as.matrix(i)))[, 2] - data$x <- unlist(sf::st_geometry(data))[ind1] - data$y <- unlist(sf::st_geometry(data))[ind2] - data <- data[, c("x", "y", "r", "g", "b", cnames)] - - # generate reduced geojson string - # gj <- paste('var data = ', geojsonio::geojson_json(x), ';', sep = "\n") - # writeLines(gj, con = pathJsonFn) - #data.json <- paste('var data = {[', coords2JSON(as.matrix(x@data)), ']};', sep = "\n") - data.json <- coords2JSON(as.matrix(sf2DataFrame(data, drop_sf_column = TRUE))) - # write geojson file to temp dir - file.create(pathJsonFn) - fileConn <- file(pathJsonFn) - write(data.json, fileConn) - close(fileConn) - - # get extent and center of area - ext <- createExtent(data) - yc <- (ext@ymax-ext@ymin) * 0.5 + ext@ymin - xc <- (ext@xmax-ext@xmin) * 0.5 + ext@xmin - - - - # create the popups - cHelp <- list() - cHelp[1] <- "Longitude" - cHelp[2] <- "Latitude" - for (i in 1:length(cnames)) { - if (i %% 2 == 1) { - cHelp[i + 2] <- paste0("", "", cnames[i], "", "") - } else { - cHelp[i + 2] <- paste0("", "", cnames[i], "", "") - } - } - - #color <- mapviewColors(x, colors = color, at = at, na.color = na.color) - - # create list of user data that is passed to the widget - lst_x = list( - color = "undefined", # color, #col2Hex(color), - data = "undefined", - #cnames = cnames, - centerLat = yc, - centerLon = xc, - popTemplate = getPopupStyle(), - cHelp = cHelp, - layer.opacity = opacity, - layername = as.character(group), - xmax = ext@xmax, - ymax = ext@ymax, - xmin = ext@xmin, - ymin = ext@ymin - ) - - - # now creating the widget - # fpViewInternal(jFn = pathJsonFn, x = lst_x) - map$dependencies <- c(map$dependencies, - veryLargePointsDependencies(), - vertexShaderDependency(), - fragmentShaderDependency(), - veryLargeDataDependency(jFn = pathJsonFn, - group = group)) - leaflet::invokeMethod(map, leaflet::getMapData(map), - 'addVeryLargePoints', lst_x) - -} - -veryLargePointsDependencies <- function() { - list( - htmltools::htmlDependency( - "VeryLargePoints", - '0.0.1', - system.file("htmlwidgets/lib/large", package = "mapview"), - script = c("addVeryLargePoints.js", - "gl.js", - "jquery.min.js", - "leaflet.label.js", - "leaflet.ajax.min.js", - "leaflet.canvasoverlay.js", - "leaflet.glify.min.js") - )) -} - -veryLargeDataDependency <- function(jFn, group) { - - data_dir <- dirname(jFn) - data_file <- basename(jFn) - list( - htmltools::htmlDependency( - name = group, - version = "1", - src = c(file = data_dir), - attachment = data_file)) -} - -# dataDependency <- function(jFn) { -# data_dir <- dirname(jFn) -# data_file <- basename(jFn) -# list( -# htmltools::htmlDependency( -# name = "data", -# version = "1", -# # src = system.file("htmlwidgets/lib/veryLarge", package = "mapview"), -# # attachment = c(data_file))) -# src = c(file = data_dir), -# script = list(data_file))) -# } - - - -vertexShaderDependency <- function() { - list( - htmltools::htmlDependency( - name = "vertex-shader", - version = "1", - system.file("htmlwidgets/lib/large", package = "mapview"), - attachment = "vertex-shader.glsl")) -} - -fragmentShaderDependency <- function() { - list( - htmltools::htmlDependency( - name = "fragment-shader", - version = "1", - system.file("htmlwidgets/lib/large", package = "mapview"), - attachment = "fragment-shader.glsl")) -} diff --git a/R/coords2Lines.R b/R/coords2Lines.R index 8b04fbefe..d2b6591b7 100644 --- a/R/coords2Lines.R +++ b/R/coords2Lines.R @@ -25,7 +25,6 @@ if ( !isGeneric("coords2Lines") ) { #' \code{\link{SpatialLines-class}}, \code{\link{SpatialLinesDataFrame}}. #' #' @examples -#' \dontrun{ #' library(sp) #' #' coords1 <- cbind(c(2, 4, 4, 1, 2), c(2, 3, 5, 4, 2)) @@ -38,7 +37,6 @@ if ( !isGeneric("coords2Lines") ) { #' #' plot(sln1, col = "grey75") #' plot(sln2, col = "grey25", add = TRUE) -#' } #' #' @export coords2Lines #' @name coords2Lines diff --git a/R/coords2Polygons.R b/R/coords2Polygons.R index 1104a60d5..a11b23995 100644 --- a/R/coords2Polygons.R +++ b/R/coords2Polygons.R @@ -26,7 +26,6 @@ if ( !isGeneric("coords2Polygons") ) { #' \code{\link{SpatialPolygons-class}}, \code{\link{SpatialPolygonsDataFrame}}. #' #' @examples -#' \dontrun{ #' library(sp) #' #' coords1 <- cbind(c(2, 4, 4, 1, 2), c(2, 3, 5, 4, 2)) @@ -37,7 +36,6 @@ if ( !isGeneric("coords2Polygons") ) { #' #' plot(spy1, col = "grey75") #' plot(spy2, col = "grey25", add = TRUE) -#' } #' #' @export coords2Polygons #' @name coords2Polygons diff --git a/R/cubeView.R b/R/cubeView.R index d2e29159c..617bce47d 100644 --- a/R/cubeView.R +++ b/R/cubeView.R @@ -42,8 +42,7 @@ #' #' cubeView(kiliNDVI) #' -#' library(RColorBrewer) -#' clr <- colorRampPalette(brewer.pal(9, "BrBG")) +#' clr <- viridisLite::viridis #' cubeView(kiliNDVI, at = seq(-0.15, 0.95, 0.1), col.regions = clr) #' } #' diff --git a/R/extensions.R b/R/extensions.R index 7a254abc2..8f6e4fd34 100644 --- a/R/extensions.R +++ b/R/extensions.R @@ -31,11 +31,15 @@ #' If style is set to "basic", only 'lat', 'lon' and 'zoom' are shown. #' #' @examples -#' \dontrun{ -#' leaflet() %>% addTiles() # without mouse position info -#' leaflet() %>% addTiles() %>% addMouseCoordinates(style = "basic") # with basic mouse position info -#' mapview(easter.egg = TRUE) # detailed mouse position info by default ;-) -#' } +#' library(leaflet) +#' +#' leaflet() %>% addProviderTiles("OpenStreetMap") # without mouse position info +#' leaflet() %>% +#' addProviderTiles("OpenStreetMap") %>% +#' addMouseCoordinates(style = "basic") # with basic mouse position info +#' leaflet() %>% +#' addProviderTiles("OpenStreetMap") %>% +#' addMouseCoordinates() # with detailed mouse position info #' #' #' @export addMouseCoordinates @@ -85,49 +89,50 @@ addMouseCoordinates <- function(map, style = c("detailed", "basic"), " function(el, x, data) { - // get the leaflet map - var map = this; //HTMLWidgets.find('#' + el.id); - - // we need a new div element because we have to handle - // the mouseover output separately - // debugger; - function addElement () { - // generate new div Element - var newDiv = $(document.createElement('div')); - // append at end of leaflet htmlwidget container - $(el).append(newDiv); - //provide ID and style - newDiv.addClass('lnlt'); - newDiv.css({ - 'position': 'relative', - 'bottomleft': '0px', - 'background-color': 'rgba(255, 255, 255, 0.7)', - 'box-shadow': '0 0 2px #bbb', - 'background-clip': 'padding-box', - 'margin': '0', - 'padding-left': '5px', - 'color': '#333', - 'font': '9px/1.5 \"Helvetica Neue\", Arial, Helvetica, sans-serif', - }); - return newDiv; - } - - // check for already existing lnlt class to not duplicate - var lnlt = $(el).find('.lnlt'); - - if(!lnlt.length) { - lnlt = addElement(); - //$(el).keypress(function (e) { - // if (e.which == 32 || event.keyCode == 32) { - // alert('space key is pressed'); - // } - //}); - // grab the special div we generated in the beginning - // and put the mousmove output there - map.on('mousemove', function (e) { - lnlt.text(", txt, "); - }); - }; + // get the leaflet map + var map = this; //HTMLWidgets.find('#' + el.id); + + // we need a new div element because we have to handle + // the mouseover output separately + // debugger; + function addElement () { + // generate new div Element + var newDiv = $(document.createElement('div')); + // append at end of leaflet htmlwidget container + $(el).append(newDiv); + //provide ID and style + newDiv.addClass('lnlt'); + newDiv.css({ + 'position': 'relative', + 'bottomleft': '0px', + 'background-color': 'rgba(255, 255, 255, 0.7)', + 'box-shadow': '0 0 2px #bbb', + 'background-clip': 'padding-box', + 'margin': '0', + 'padding-left': '5px', + 'color': '#333', + 'font': '9px/1.5 \"Helvetica Neue\", Arial, Helvetica, sans-serif', + 'z-index': '700', + }); + return newDiv; + } + + // check for already existing lnlt class to not duplicate + var lnlt = $(el).find('.lnlt'); + + if(!lnlt.length) { + lnlt = addElement(); + //$(el).keypress(function (e) { + // if (e.which == 32 || event.keyCode == 32) { + // alert('space key is pressed'); + // } + //}); + // grab the special div we generated in the beginning + // and put the mousmove output there + map.on('mousemove', function (e) { + lnlt.text(", txt, "); + }); + }; } " ) @@ -135,6 +140,19 @@ addMouseCoordinates <- function(map, style = c("detailed", "basic"), map } + +removeMouseCoordinates = function(map) { + if (inherits(map, "mapview")) map = mapview2leaflet(map) + + rc = map$jsHooks$render + rc_lnlt = lapply(rc, grep, pattern = "lnlt") + for (i in seq_along(map$jsHooks$render)) { + map$jsHooks$render[[i]][rc_lnlt[[i]]] = NULL + } + + return(map) +} + ############################################################################## @@ -155,16 +173,17 @@ addMouseCoordinates <- function(map, style = c("detailed", "basic"), #' @param add logical. Whether to add the button to the map (mainly for internal use). #' #' @examples -#' \dontrun{ +#' library(leaflet) #' library(raster) #' -#' m <- leaflet() %>% addTiles() %>% addCircleMarkers(data = breweries91) %>% -#' addHomeButton(extent(breweries91), "breweries91") +#' m <- leaflet() %>% +#' addProviderTiles("OpenStreetMap") %>% +#' addCircleMarkers(data = breweries) %>% +#' addHomeButton(extent(breweries), "breweries") #' m #' #' ## remove the button #' removeHomeButton(m) -#' } #' #' #' @export addHomeButton @@ -176,6 +195,12 @@ addHomeButton <- function(map, ext, layer.name = "layer", if (inherits(map, "mapview")) map <- mapview2leaflet(map) stopifnot(inherits(map, "leaflet")) + # drop names in case extent of sf object + ext@xmin = unname(ext@xmin) + ext@xmax = unname(ext@xmax) + ext@ymin = unname(ext@ymin) + ext@ymax = unname(ext@ymax) + hb <- try(getCallEntryFromMap(map, "addHomeButton"), silent = TRUE) if (!inherits(hb, "try-error") & length(hb) == 1) { ext_coords <- unlist(map$x$calls[[hb]][["args"]][1:4]) @@ -264,7 +289,7 @@ leafletHomeButtonDependencies <- function() { #' @param height height of the rendered image in pixels. #' #' @examples -#' \dontrun{ +#' library(leaflet) #' ## default position is topleft next to zoom control #' #' img <- "https://www.r-project.org/logo/Rlogo.svg" @@ -277,7 +302,6 @@ leafletHomeButtonDependencies <- function() { #' leaflet() %>% addTiles() %>% addLogo(img, src = "local", alpha = 0.3) #' #' ## dancing banana gif :-) -#' library(magick) #' m <- mapview(breweries91) #' #' addLogo(m, "https://jeroenooms.github.io/images/banana.gif", @@ -287,8 +311,6 @@ leafletHomeButtonDependencies <- function() { #' width = 100, #' height = 100) #' -#' } -#' #' #' @export addLogo #' @name addLogo @@ -483,10 +505,11 @@ remoteImage <- function(img, alpha, url, width, height) { #' Type agnositc version of \code{leaflet::add*} functions. #' #' @description -#' Add simple features geomertries from \code{\link[sf]{sf}} +#' Add simple features geometries from \code{\link[sf]{sf}} #' #' @param map A \code{leaflet} or \code{mapview} map. #' @param data A \code{sf} object to be added to the \code{map}. +#' @param pane The name of the map pane for the features to be rendered in. #' @param ... Further arguments passed to the respective \code{leaflet::add*} #' functions. See \code{\link{addCircleMarkers}}, \code{\link{addPolylines}} #' and \code{\link{addPolygons}}. @@ -495,41 +518,42 @@ remoteImage <- function(img, alpha, url, width, height) { #' A leaflet \code{map} object. #' #' @examples -#' \dontrun{ -#' leaflet() %>% addTiles() %>% addCircleMarkers(data = breweries) -#' leaflet() %>% addTiles() %>% addFeatures(data = breweries) +#' library(leaflet) #' -#' leaflet() %>% addTiles() %>% addPolylines(data = atlStorms2005) -#' leaflet() %>% addTiles() %>% addFeatures(atlStorms2005) +#' leaflet() %>% addProviderTiles("OpenStreetMap") %>% addCircleMarkers(data = breweries) +#' leaflet() %>% addProviderTiles("OpenStreetMap") %>% addFeatures(data = breweries) #' -#' leaflet() %>% addTiles() %>% addPolygons(data = franconia) -#' leaflet() %>% addTiles() %>% addFeatures(franconia) -#' } +#' leaflet() %>% addProviderTiles("OpenStreetMap") %>% addPolylines(data = atlStorms2005) +#' leaflet() %>% addProviderTiles("OpenStreetMap") %>% addFeatures(atlStorms2005) +#' +#' leaflet() %>% addProviderTiles("OpenStreetMap") %>% addPolygons(data = franconia) +#' leaflet() %>% addProviderTiles("OpenStreetMap") %>% addFeatures(franconia) #' #' @export addFeatures #' @name addFeatures #' @rdname addFeatures addFeatures <- function(map, data, + pane = "overlayPane", ...) { if (inherits(data, "Spatial")) data = sf::st_as_sf(data) switch(getSFClass(sf::st_geometry(data)), - sfc_POINT = addPointFeatures(map, data, ...), - sfc_MULTIPOINT = addPointFeatures(map, data, ...), - sfc_LINESTRING = addLineFeatures(map, data, ...), - sfc_MULTILINESTRING = addLineFeatures(map, data, ...), - sfc_POLYGON = addPolygonFeatures(map, data, ...), - sfc_MULTIPOLYGON = addPolygonFeatures(map, data, ...), - sfc_GEOMETRY = addGeometry(map, data, ...), - POINT = addPointFeatures(map, data, ...), - MULTIPOINT = addPointFeatures(map, data, ...), - LINESTRING = addLineFeatures(map, data, ...), - MULTILINESTRING = addLineFeatures(map, data, ...), - POLYGON = addPolygonFeatures(map, data, ...), - MULTIPOLYGON = addPolygonFeatures(map, data, ...), - GEOMETRY = addGeometry(map, data, ...)) + sfc_POINT = addPointFeatures(map, data, pane, ...), + sfc_MULTIPOINT = addPointFeatures(map, data, pane, ...), + sfc_LINESTRING = addLineFeatures(map, data, pane, ...), + sfc_MULTILINESTRING = addLineFeatures(map, data, pane, ...), + sfc_POLYGON = addPolygonFeatures(map, data, pane, ...), + sfc_MULTIPOLYGON = addPolygonFeatures(map, data, pane, ...), + sfc_GEOMETRY = addGeometry(map, data, pane, ...), + POINT = addPointFeatures(map, data, pane, ...), + MULTIPOINT = addPointFeatures(map, data, pane, ...), + LINESTRING = addLineFeatures(map, data, pane, ...), + MULTILINESTRING = addLineFeatures(map, data, pane, ...), + POLYGON = addPolygonFeatures(map, data, pane, ...), + MULTIPOLYGON = addPolygonFeatures(map, data, pane, ...), + GEOMETRY = addGeometry(map, data, pane, ...)) } @@ -541,44 +565,51 @@ addFeatures <- function(map, mw = 800 -### Point Features ======================================================== +### Point Features addPointFeatures <- function(map, data, + pane, ...) { garnishMap(map, leaflet::addCircleMarkers, data = sf::st_zm(sf::st_cast(data, "POINT")), popupOptions = popupOptions(maxWidth = mw, closeOnClick = TRUE), + options = leafletOptions(pane = pane), ...) } -### Line Features ========================================================= +### Line Features addLineFeatures <- function(map, data, + pane, ...) { garnishMap(map, leaflet::addPolylines, data = sf::st_zm(data), popupOptions = popupOptions(maxWidth = mw, closeOnClick = TRUE), + options = leafletOptions(pane = pane), ...) } -### PolygonFeatures ======================================================= +### PolygonFeatures addPolygonFeatures <- function(map, data, + pane, ...) { garnishMap(map, leaflet::addPolygons, data = sf::st_zm(data), popupOptions = popupOptions(maxWidth = mw, closeOnClick = TRUE), + options = leafletOptions(pane = pane), ...) } -### GeometryCollections =================================================== +### GeometryCollections addGeometry = function(map, data, + pane, ...) { - ls = list(...) + ls = append(list(pane), list(...)) if (!is.null(ls$label)) label = split(ls$label, f = as.character(sf::st_dimension(data))) if (!is.null(ls$popup)) @@ -631,6 +662,7 @@ addGeometry = function(map, #' to 'mousemove'. #' @param digits the number of digits to be shown in the display field. #' @param position where to place the display field. Default is 'topright'. +#' @param prefix a character string to be shown as prefix for the layerId. #' @param ... currently not used. #' #' @return @@ -660,6 +692,7 @@ addImageQuery = function(map, type = c("mousemove", "click"), digits, position = 'topright', + prefix = 'Layer', ...) { if (inherits(map, "mapview")) map = mapview2leaflet(map) @@ -700,7 +733,8 @@ addImageQuery = function(map, ctrlid = ctrlid[imctrl] if (length(ctrlid) == 0) { - map = addControl(map, NULL, layerId = 'imageValues', position = position) + # must add empty character instead of NULL for html with addControl + map = addControl(map, html = "", layerId = 'imageValues', position = position) } map$dependencies <- c(map$dependencies, @@ -723,7 +757,7 @@ addImageQuery = function(map, 'function(el, x, data) { var map = this; map.on("', type, '", function (e) { - rasterPicker.pick(e, x, ', digits, '); + rasterPicker.pick(e, x, ', digits, ', "', prefix, ' "); }); }' ) @@ -734,3 +768,221 @@ addImageQuery = function(map, } ############################################################################## + + + +### addStaticLabels ########################################################## +############################################################################## +#' Add static labels to \code{leaflet} or \code{mapview} objects +#' +#' @description +#' Being a wrapper around \code{\link[leaflet]{addLabelOnlyMarkers}}, this +#' function provides a smart-and-easy solution to add custom text labels to an +#' existing \code{leaflet} or \code{mapview} map object. +#' +#' @param map A \code{leaflet} or \code{mapview} object. +#' @param data A \code{sf} or \code{Spatial*} object used for label placement, +#' defaults to the locations of the first dataset in 'map'. +#' @param label The labels to be placed at the positions indicated by 'data' as +#' \code{character}, or any vector that can be coerced to this type. +#' @param group the group of the static labels layer. +#' @param layerId the layerId of the static labels layer. +#' @param ... Additional arguments passed to +#' \code{\link[leaflet]{addLabelOnlyMarkers}}. +#' +#' @return +#' A labelled \strong{mapview} object. +#' +#' @author +#' Florian Detsch +#' +#' @seealso +#' \code{\link[leaflet]{addLabelOnlyMarkers}}. +#' +#' @examples +#' \dontrun{ +#' ## leaflet label display options +#' library(leaflet) +#' +#' lopt = labelOptions(noHide = TRUE, +#' direction = 'top', +#' textOnly = TRUE) +#' +#' ## point labels +#' m1 = mapview(breweries) +#' l1 = addStaticLabels(m1, +#' label = breweries$number.of.types, +#' labelOptions = lopt) +#' l1 +#' +#' ## polygon centroid labels +#' m2 = mapview(franconia) +#' l2 = addStaticLabels(m2, +#' label = franconia$NAME_ASCI, +#' labelOptions = lopt) +#' l2 +#' +#' ## custom labels +#' m3 = m2 + m1 +#' l3 = addStaticLabels(m3, +#' data = franconia, +#' label = franconia$NAME_ASCI, +#' labelOptions = lopt) +#' l3 +#' } +#' +#' @export addStaticLabels +#' @name addStaticLabels +addStaticLabels = function(map, + data, + label, + group = NULL, + layerId = NULL, + ...) { + + if (inherits(map, "mapview") & missing(data)) { + data = map@object[[1]] + if (is.null(group)) { + group = getLayerNamesFromMap(map@map)[1] + } else { + group = NULL + } + } + + dots = list(...) + min_opts = list(noHide = TRUE, + direction = "top", + textOnly = TRUE) + + dots = append(dots, min_opts) + + if (inherits(map, "mapview")) map = mapview2leaflet(map) + + ## 'Raster*' locations not supported so far -> error + if (inherits(data, "Raster")) { + stop(paste("'Raster*' input is not supported, yet." + , "Please refer to ?addLabels for compatible input formats.\n"), + call. = FALSE) + } + + ## if input is 'Spatial*', convert to 'sf' + if (inherits(data, "Spatial")) { + data = sf::st_as_sf(data) + } + + if (missing(label)) label = makeLabels(data, NULL) + # { + # sf_col = attr(data, "sf_column") + # if (inherits(data, "sf")) { + # if (ncol(data) == 2) { + # colnm = setdiff(colnames(data), sf_col) + # label = data[[colnm]] + # } else { + # label = seq(nrow(data)) + # } + # } else { + # label = seq(length(data)) + # } + # } + + if (getGeometryType(data) == "ln") { + crds = as.data.frame(sf::st_coordinates(data)) + crds_lst = split(crds, crds[[ncol(crds)]]) + mat = do.call(rbind, lapply(seq(crds_lst), function(i) { + crds_lst[[i]][sapply(crds_lst, nrow)[i], c("X", "Y")] + })) + } else { + mat = sf::st_coordinates(suppressWarnings(sf::st_centroid(data))) + } + + ## add labels to map + map = garnishMap(leaflet::addLabelOnlyMarkers, + map = map, + lng = mat[, 1], + lat = mat[, 2], + label = as.character(label), + group = group, + layerId = layerId, + labelOptions = dots) + # map = leaflet::addLabelOnlyMarkers(map, + # lng = mat[, 1], + # lat = mat[, 2], + # label = as.character(label), + # ...) + + return(map) +} + + +############################################################################## + +### addStaticLabels ########################################################## +############################################################################## +#' Add additional panes to leaflet map to control layer order +#' +#' @description +#' map panes can be created by supplying a name and a zIndex to control layer +#' ordering. We recommend a \code{zIndex} value between 400 (the default +#' overlay pane) and 500 (the default shadow pane). You can then use this pane +#' to render overlays (points, lines, polygons) by setting the \code{pane} +#' argument in \code{leafletOptions}. This will give you control +#' over the order of the layers, e.g. points always on top of polygons. +#' If two layers are provided to the same pane, overlay will be determined by +#' order of adding. See examples below. +#' See \url{http://www.leafletjs.com/reference-1.3.0.html#map-pane} for details. +#' +#' @param map A \code{leaflet} or \code{mapview} object. +#' @param name The name of the new pane (refer to this in \code{leafletOptions}. +#' @param zIndex The zIndex of the pane. Panes with higher index are rendered +#' above panes with lower indices. +#' +#' @examples +#' library(leaflet) +#' library(mapview) +#' +#' ## points above polygons +#' leaflet() %>% +#' addTiles() %>% +#' addMapPane("polygons", zIndex = 410) %>% +#' addMapPane("points", zIndex = 420) %>% +#' addPolygons(data = franconia, +#' group = "pol1", +#' fillOpacity = 0.7, +#' fillColor = "green", +#' color = "black", +#' options = leafletOptions(pane = "polygons")) %>% +#' addPolygons(data = franconia, +#' group = "pol2", +#' color = "black", +#' fillColor = "purple", +#' fillOpacity = 0.7, +#' options = leafletOptions(pane = "polygons")) %>% +#' addCircleMarkers(data = breweries, +#' group = "pts", +#' color = "darkblue", +#' options = leafletOptions(pane = "points")) %>% +#' addLayersControl(overlayGroups = c("pol1", "pol2", "pts")) +#' +#' +#' @export addMapPane +#' @name addMapPane +#' +addMapPane = function(map, name, zIndex) { + + if (inherits(map, "mapview")) map = mapview2leaflet(map) + + map$dependencies <- c(map$dependencies, leafletMapPaneDependencies()) + leaflet::invokeMethod(map, leaflet::getMapData(map), 'createMapPane', + name, zIndex) + +} + +leafletMapPaneDependencies <- function() { + list( + htmltools::htmlDependency( + "mapPane", + '0.0.1', + system.file("htmlwidgets/lib/pane", package = "mapview"), + script = c('map-pane.js') + )) +} diff --git a/R/extent.R b/R/extent.R index 9e115f35e..d66804fe7 100644 --- a/R/extent.R +++ b/R/extent.R @@ -21,13 +21,13 @@ #' Tim Appelhans #' #' @examples -#' \dontrun{ +#' library(leaflet) +#' #' viewExtent(poppendorf) #' viewExtent(breweries) #' viewExtent(franconia) + breweries #' viewExtent(trails) + trails + breweries #' leaflet() %>% addProviderTiles("OpenStreetMap") %>% addExtent(breweries) -#' } #' #' @export viewExtent #' @name viewExtent @@ -91,7 +91,8 @@ combineExtent = function(lst, sf = FALSE, crs = 4326) { # lst = list(breweries, st_as_sf(atlStorms2005), st_as_sf(gadmCHE)) # bb = do.call(rbind, lapply(lst, sf::st_bbox)) bb = do.call(rbind, lapply(seq(lst), function(i) { - if (!is.na(st_crs(lst[[i]]))) { + + if (!is.na(getProjection(lst[[i]]))) { sf::st_bbox(sf::st_transform(sf::st_as_sfc(sf::st_bbox(lst[[i]])), crs = crs)) } else { diff --git a/R/garnishMap.R b/R/garnishMap.R index d28061399..f9ece1cc0 100644 --- a/R/garnishMap.R +++ b/R/garnishMap.R @@ -11,14 +11,16 @@ #' @param ... functions and their arguments to add things to a map. #' #' @examples -#' \dontrun{ -#' m <- leaflet() %>% addTiles() -#' garnishMap(m, addMouseCoordinates) +#' library(leaflet) +#' +#' m <- leaflet() %>% addProviderTiles("OpenStreetMap") +#' garnishMap(m, addMouseCoordinates, style = "basic") #' #' ## add more than one with named argument #' library(raster) +#' #' m1 <- garnishMap(m, addMouseCoordinates, addHomeButton, -#' ext = extent(breweries91)) +#' ext = extent(breweries)) #' m1 #' #' ## even more flexible @@ -26,8 +28,6 @@ #' fillOpacity = 0.8, color = "black", fillColor = "#BEBEBE") #' garnishMap(m2, addCircleMarkers, data = breweries) #' -#' } -#' #' @export garnishMap #' @name garnishMap #' @rdname garnishMap diff --git a/R/largeControls.R b/R/largeControls.R deleted file mode 100644 index a7af11a22..000000000 --- a/R/largeControls.R +++ /dev/null @@ -1,90 +0,0 @@ -### getPopupStyle creates popup style ================================================= -getPopupStyle <- function() { - # htmlTemplate <- paste( - # "", - # "", - # "", - # "", - # "", - # "
", - # "", - # "") - # return(htmlTemplate) - fl <- system.file("templates/popup.brew", package = "mapview") - pop <- readLines(fl) - end <- grep("<%=pop%>", pop) - return(paste(pop[1:(end-2)], collapse = "")) -} - - -### make path -makepathLarge <- function(group) { - dirs <- list.dirs(tempdir()) - # tmpPath <- grep(utils::glob2rx("*data_large*"), dirs, value = TRUE) - # if (length(tmpPath) == 0) { - tmpPath <- paste(tempfile(pattern = "data_large"), - createFileId(), - sep = "_") - dir.create(tmpPath) - # } - baseFn <- paste("data_large", group, sep = "_") - extFn <- "geojson" - jsonFn <- paste0(baseFn, createFileId(), ".", extFn) - pathJsonFn <- paste0(tmpPath, "/", jsonFn) - sfpathJsonFn <- paste0(tmpPath, "/", "sf_", jsonFn) - return(list(tmpPath, pathJsonFn, sfpathJsonFn, jsonFn)) -} - - -### calculate zoom -calcZoom <- function(data) { - - if (inherits(data, 'SpatialPolygons')) { - noFeature <- length(data@polygons) - noF <- noFeature / 1 - } else if (inherits(data, 'SpatialLines')) { - noFeature <- length(data@lines) - noF <- noFeature / 1 - } else { - noFeature <- length(data@coords) - noF <- noFeature / 5 - } - - zoom <- floor(-0.000000000429 * (noF^2) + 0.000148 * noF + 1) - if (zoom > 14) {zoom <- 16} - if (zoom < 9) {zoom <- 9} - - return(zoom) -} - - -## convert sp objects to dummy dataframes -toSPDF <- function(x) { - cls <- class(x)[1] - newcls <- paste0(cls, "DataFrame") - if (cls %in% "SpatialPolygons") { - x <- as(x, newcls) - } - - if (cls %in% c("SpatialPoints", "SpatialLines")) { - x <- as(x, newcls) - x@data <- data.frame(dummy = rep(0, length(x))) - } - - return(x) - -} - - -## get sf point coordinates -sfPointCoordinates <- function(x) { - stopifnot(is.matrix(x) || inherits(x, "XY")) - structure(as.data.frame(unclass(x)), names = c("x", "y")) -} diff --git a/R/leafletControls.R b/R/leafletControls.R index 671b18752..d23f24db8 100644 --- a/R/leafletControls.R +++ b/R/leafletControls.R @@ -89,6 +89,13 @@ appendMapCallEntries <- function(map1, map2) { m1_calls = map1$x$calls m2_calls = map2$x$calls + ## dependencies + m1_deps = map1$dependencies + m2_deps = map2$dependencies + + mp_deps = append(m1_deps, m2_deps) + mp_deps = mp_deps[!duplicated(mp_deps)] + ## base map controls ctrls1 <- getLayerControlEntriesFromMap(map1) ctrls2 <- getLayerControlEntriesFromMap(map2) @@ -131,6 +138,7 @@ appendMapCallEntries <- function(map1, map2) { }, silent = TRUE) map1$x$calls <- mpcalls + map1$dependencies = mp_deps return(map1) } @@ -171,7 +179,7 @@ rasterCheckSize <- function(x, maxpixels) { # Initialise mapView base maps -------------------------------------------- -initBaseMaps <- function(map.types) { +initBaseMaps <- function(map.types, canvas = FALSE) { ## create base map using specified map types if (missing(map.types)) map.types <- mapviewGetOption("basemaps") leafletHeight <- mapviewGetOption("leafletHeight") @@ -183,7 +191,8 @@ initBaseMaps <- function(map.types) { maxZoom = 100, bounceAtZoomLimits = FALSE, maxBounds = list(list(c(-90, -370)), - list(c(90, 370))))) + list(c(90, 370))), + preferCanvas = canvas)) m <- leaflet::addProviderTiles(m, provider = map.types[1], layerId = lid[1], group = map.types[1]) if (length(map.types) > 1) { @@ -201,7 +210,8 @@ initBaseMaps <- function(map.types) { initMap <- function(map = NULL, map.types = NULL, proj4str, - native.crs = FALSE) { + native.crs = FALSE, + canvas = FALSE) { # if (missing(map.types)) map.types <- mapviewGetOption("basemaps") @@ -219,9 +229,10 @@ initMap <- function(map = NULL, m <- leaflet::leaflet(height = leafletHeight, width = leafletWidth, options = leaflet::leafletOptions( minZoom = -1000, - crs = leafletCRS(crsClass = "L.CRS.Simple"))) + crs = leafletCRS(crsClass = "L.CRS.Simple"), + preferCanvas = canvas)) } else { - m <- initBaseMaps(map.types) + m <- initBaseMaps(map.types, canvas = canvas) } } else { m <- map diff --git a/R/mapView.R b/R/mapView.R index 532c44d3c..9342e5a9b 100644 --- a/R/mapView.R +++ b/R/mapView.R @@ -17,22 +17,24 @@ if ( !isGeneric('mapView') ) { #' a length one character vector (again referring to a column of #' the attribute table). \cr #' \cr -#' The usage of big data sets is performed by loading local copies -#' of json files from temporary storage. This works fine for most of -#' the current browsers. If you are using Google's chrome browser you have to -#' start the browser with the flag \code{-allow-file-access-from-files} (i.e -#' for windows: "path_to_your_chrome_installation\\chrome.exe --allow-file-access-from-files", -#' for linux: "/usr/bin/google-chrome --allow-access-from-files"). -#' See \url{http://www.chrome-allow-file-access-from-file.com/} for further details. -#' \cr #' NOTE: if XYZ or XYM or XYZM data from package sf is passed to mapview, #' domensions Z and M will be stripped to ensure smooth rendering even though #' the popup will potentially still say something like "POLYGON Z". #' #' @param x a \code{Raster*} or \code{Spatial*} or \code{Satellite} or #' \code{sf} object or a list of any combination of those. Furthermore, -#' this can also be a \code{data.frame} or a \code{numeric vector}. +#' this can also be a \code{data.frame} or a \code{numeric vector}. If missing, +#' a blank map will be drawn. #' @param map an optional existing map to be updated/added to +#' @param pane name of the map pane in which to render features. See +#' \code{\link{addMapPane}} for details. Currently only supported for vector layers. +#' Ignored if \code{canvas = TRUE}. The default \code{"auto"} will create different panes +#' for points, lines and polygons such that points overlay lines overlay polygons. +#' Set to \code{NULL} to get default leaflet behaviour where allfeatures +#' are rendered in the same pane and layer order is determined by automatically/sequencially. +#' @param canvas whether to use canvas rendering rather than svg. May help +#' performance with larger data. See \url{http://leafletjs.com/reference-1.3.0.html#canvas} +#' for more information. #' @param maxpixels integer > 0. Maximum number of cells to use for the plot. #' If maxpixels < \code{ncell(x)}, sampleRegular is used before plotting. #' @param color color (palette) for points/polygons/lines @@ -60,8 +62,9 @@ if ( !isGeneric('mapView') ) { #' @param popup a \code{list} of HTML strings with the popup contents, usually #' created from \code{\link{popupTable}}. See \code{\link{addControl}} for #' details. -#' @param label a character vector of labels to be shown on mouseover. See -#' \code{\link{addControl}} for details. +#' @param label For vector data (sf/sp) a character vector of labels to be +#' shown on mouseover. See \code{\link{addControl}} for details. For raster +#' data (Raster*/stars) a logical indicating whether to add image query. #' @param native.crs logical whether to reproject to web map coordinate #' reference system (web mercator - epsg:3857) or render using native CRS of #' the supplied data (can also be NA). Default is FALSE which will render in @@ -81,6 +84,15 @@ if ( !isGeneric('mapView') ) { #' @param maxpoints the maximum number of points making up the geometry. #' In case of lines and polygons this refers to the number of vertices. See #' Details for more information. +#' @param query.type for raster methods only. Whether to show raster value query +#' on \code{'mousemove'} or \code{'click'}. Ignored if \code{label = FALSE}. +#' @param query.digits for raster methods only. The amount of digits to be shown +#' by raster value query. Ignored if \code{label = FALSE}. +#' @param query.position for raster methods only. The position of the raster +#' value query info box. See \code{position} argument of \code{\link{addLegend}} +#' for possible values. Ignored if \code{label = FALSE}. +#' @param query.prefix for raster methods only. a character string to be shown +#' as prefix for the layerId. Ignored if \code{label = FALSE}. #' @param ... additional arguments passed on to repective functions. #' See \code{\link{addRasterImage}}, \code{\link{addCircles}}, #' \code{\link{addPolygons}}, \code{\link{addPolylines}} for details @@ -109,6 +121,8 @@ if ( !isGeneric('mapView') ) { #' mapview() #' #' ## simple features ==================================================== +#' library(sf) +#' #' # sf #' mapview(breweries) #' mapview(franconia) @@ -129,25 +143,24 @@ if ( !isGeneric('mapView') ) { #' #' ## spatial objects ===================================================== #' mapview(leaflet::gadmCHE) -#' mapview(atlStorms2005) +#' mapview(leaflet::atlStorms2005) #' #' #' ## styling options & legends =========================================== -#' mapview(cantons, color = "white", col.regions = "red") -#' mapview(cantons, color = "magenta", col.regions = "white") +#' mapview(franconia, color = "white", col.regions = "red") +#' mapview(franconia, color = "magenta", col.regions = "white") #' #' mapview(breweries, zcol = "founded") #' mapview(breweries, zcol = "founded", at = seq(1400, 2200, 200), legend = TRUE) -#' mapview(cantons, zcol = "NAME_1", legend = TRUE) +#' mapview(franconia, zcol = "district", legend = TRUE) #' -#' library(RColorBrewer) -#' clrs <- colorRampPalette(brewer.pal(9, "Blues")) -#' mapview(breweries, zcol = "founded", col.regions = clrs, legend = TRUE) +#' clrs <- sf.colors +#' mapview(franconia, zcol = "district", col.regions = clrs, legend = TRUE) #' #' ### multiple layers ==================================================== #' mapview(franconia) + breweries #' mapview(list(breweries, franconia)) -#' mapview(breweries) + mapview(franconia) + stormtracks +#' mapview(franconia) + mapview(breweries) + trails #' #' mapview(franconia, zcol = "district") + mapview(breweries, zcol = "village") #' mapview(list(franconia, breweries), @@ -196,7 +209,6 @@ if ( !isGeneric('mapView') ) { #' mutate(count = lengths(st_contains(., breweries)), #' density = count / st_area(.)) %>% #' mapview(zcol = "density") -#' #' } #' #' @export @@ -228,6 +240,11 @@ setMethod('mapView', signature(x = 'RasterLayer'), homebutton = TRUE, native.crs = FALSE, method = c("bilinear", "ngb"), + label = TRUE, + query.type = c("mousemove", "click"), + query.digits, + query.position = "topright", + query.prefix = "Layer", ...) { method = match.arg(method) @@ -251,7 +268,7 @@ setMethod('mapView', signature(x = 'RasterLayer'), maxpixels = maxpixels, col.regions = col.regions, at = at, - na.color, na.color, + na.color = na.color, use.layer.names = use.layer.names, values = values, map.types = map.types, @@ -264,6 +281,11 @@ setMethod('mapView', signature(x = 'RasterLayer'), homebutton = homebutton, native.crs = native.crs, method = method, + label = label, + query.type = query.type, + query.digits = query.digits, + query.position = query.position, + query.prefix = query.prefix, ...) } else { NULL @@ -275,8 +297,7 @@ setMethod('mapView', signature(x = 'RasterLayer'), # ## Stars layer ================================================================== -# #' @describeIn mapview \code{stars} -# +# #' @describeIn mapView \code{\link{stars}} # setMethod('mapView', signature(x = 'stars'), # function(x, # map = NULL, @@ -296,13 +317,18 @@ setMethod('mapView', signature(x = 'RasterLayer'), # homebutton = TRUE, # native.crs = FALSE, # method = c("bilinear", "ngb"), +# label = TRUE, +# query.type = c("mousemove", "click"), +# query.digits, +# query.position = "topright", +# query.prefix = "Layer", # ...) { # # method = match.arg(method) -# +# if(length(dim(x)) == 2) layer = x[[1]] else layer = x[[1]][, , 1] # if (is.null(at)) at <- lattice::do.breaks( -# extendLimits(range(as.numeric(x[[1]][, , 1]), -# na.rm = TRUE)), 256 +# extendLimits(range(layer, na.rm = TRUE)), +# 256 # ) # # if (mapviewGetOption("platform") == "leaflet") { @@ -324,6 +350,11 @@ setMethod('mapView', signature(x = 'RasterLayer'), # homebutton = homebutton, # native.crs = native.crs, # method = method, +# label = label, +# query.type = query.type, +# query.digits = query.digits, +# query.position = query.position, +# query.prefix = query.prefix, # ...) # } else { # NULL @@ -353,6 +384,11 @@ setMethod('mapView', signature(x = 'RasterStackBrick'), verbose = mapviewGetOption("verbose"), homebutton = TRUE, method = c("bilinear", "ngb"), + label = TRUE, + query.type = c("mousemove", "click"), + query.digits, + query.position = "topright", + query.prefix = "Layer", ...) { if (mapviewGetOption("platform") == "leaflet") { @@ -371,6 +407,11 @@ setMethod('mapView', signature(x = 'RasterStackBrick'), verbose = verbose, homebutton = homebutton, method = method, + label = label, + query.type = query.type, + query.digits = query.digits, + query.position = query.position, + query.prefix = query.prefix, ...) } else { NULL @@ -399,6 +440,7 @@ setMethod('mapView', signature(x = 'Satellite'), verbose = mapviewGetOption("verbose"), homebutton = TRUE, method = c("bilinear", "ngb"), + label = TRUE, ...) { if (mapviewGetOption("platform") == "leaflet") { @@ -416,6 +458,7 @@ setMethod('mapView', signature(x = 'Satellite'), verbose = verbose, homebutton = homebutton, method = method, + label = label, ...) } else { NULL @@ -435,6 +478,8 @@ setMethod('mapView', signature(x = 'Satellite'), setMethod('mapView', signature(x = 'sf'), function(x, map = NULL, + pane = "auto", + canvas = FALSE, zcol = NULL, burst = FALSE, color = mapviewGetOption("vector.palette"), @@ -465,6 +510,11 @@ setMethod('mapView', signature(x = 'sf'), burst = TRUE } + if (length(zcol) > 1) { + x = x[, zcol] + burst = TRUE + } + # if (inherits(sf::st_geometry(x), "sfc_GEOMETRY")) { # x = split(x, f = sf::st_dimension(sf::st_geometry(x))) # } @@ -499,6 +549,7 @@ setMethod('mapView', signature(x = 'sf'), leaflet_sf(sf::st_cast(x), map = map, + pane = pane, zcol = zcol, color = color, col.regions = col.regions, @@ -520,6 +571,7 @@ setMethod('mapView', signature(x = 'sf'), native.crs = native.crs, highlight = highlight, maxpoints = maxpoints, + canvas = canvas, ...) } else { @@ -538,6 +590,8 @@ setMethod('mapView', signature(x = 'sf'), alpha = alpha, alpha.regions = alpha.regions, na.alpha = na.alpha, + canvas = canvas, + pane = pane, ...) } @@ -555,6 +609,8 @@ setMethod('mapView', signature(x = 'sf'), setMethod('mapView', signature(x = 'sfc'), function(x, map = NULL, + pane = "auto", + canvas = FALSE, color = standardColor(x), #mapviewGetOption("vector.palette"), col.regions = standardColRegions(x), #mapviewGetOption("vector.palette"), at = NULL, @@ -581,6 +637,8 @@ setMethod('mapView', signature(x = 'sfc'), leaflet_sfc(sf::st_cast(x), map = map, + pane = pane, + canvas = canvas, color = color, col.regions = col.regions, na.color = na.color, @@ -651,6 +709,9 @@ setMethod('mapView', signature(x = 'numeric'), #' of the visualisation. Only relevant for the data.frame method. #' @param aspect the ratio of x/y axis corrdinates to adjust the plotting #' space to fit the screen. Only relevant for the data.frame method. +#' @param crs an optional crs specification for the provided data to enable +#' rendering on a basemap. See argument description in \code{\link{st_sf}} +#' for details. setMethod('mapView', signature(x = 'data.frame'), function(x, xcol, @@ -659,7 +720,17 @@ setMethod('mapView', signature(x = 'data.frame'), aspect = 1, popup = popupTable(x), label, + crs = NA, ...) { + if (missing(xcol) | missing(ycol)) { + obj = deparse(substitute(x, env = parent.frame())) + msg = paste0("\noops! Arguments xcol and/or ycol are missing!\n", + "You probably expected ", obj, + " to be a spatial object. \nHowever it is of class ", + class(x), ". \nEither convert ", obj, " to a spatial object ", + "or provide xcol and ycol.") + stop(msg, call. = FALSE) + } if (missing(label)) { labs = lapply(seq(nrow(x)), function(i) { paste0(xcol, " (x) : ", x[[xcol]][i], '
', @@ -674,6 +745,7 @@ setMethod('mapView', signature(x = 'data.frame'), aspect = aspect, popup = popup, label = label, + crs = crs, ...) } ) @@ -686,6 +758,8 @@ setMethod('mapView', signature(x = 'data.frame'), setMethod('mapView', signature(x = 'XY'), function(x, map = NULL, + pane = "auto", + canvas = FALSE, color = standardColor(x), #mapviewGetOption("vector.palette"), col.regions = standardColRegions(x), #mapviewGetOption("vector.palette"), at = NULL, @@ -713,6 +787,8 @@ setMethod('mapView', signature(x = 'XY'), x = sf::st_cast(sf::st_sfc(x)) leaflet_sfc(x, map = map, + pane = pane, + canvas = canvas, color = color, col.regions = col.regions, na.color = na.color, @@ -1035,6 +1111,11 @@ setMethod('mapView', signature(x = 'SpatialPixelsDataFrame'), homebutton = TRUE, native.crs = FALSE, method = c("bilinear", "ngb"), + label = TRUE, + query.type = c("mousemove", "click"), + query.digits, + query.position = "topright", + query.prefix = "Layer", ...) { if (mapviewGetOption("platform") == "leaflet") { @@ -1057,6 +1138,11 @@ setMethod('mapView', signature(x = 'SpatialPixelsDataFrame'), homebutton = homebutton, native.crs = native.crs, method = method, + label = label, + query.type = query.type, + query.digits = query.digits, + query.position = query.position, + query.prefix = query.prefix, ...) } else { NULL @@ -1089,6 +1175,11 @@ setMethod('mapView', signature(x = 'SpatialGridDataFrame'), homebutton = TRUE, native.crs = FALSE, method = c("bilinear", "ngb"), + label = TRUE, + query.type = c("mousemove", "click"), + query.digits, + query.position = "topright", + query.prefix = "Layer", ...) { if (mapviewGetOption("platform") == "leaflet") { @@ -1111,6 +1202,11 @@ setMethod('mapView', signature(x = 'SpatialGridDataFrame'), homebutton = homebutton, native.crs = native.crs, method = method, + label = label, + query.type = query.type, + query.digits = query.digits, + query.position = query.position, + query.prefix = query.prefix, ...) } else { NULL diff --git a/R/mapshot.R b/R/mapshot.R index 96bf9ac18..2406acfab 100644 --- a/R/mapshot.R +++ b/R/mapshot.R @@ -27,6 +27,10 @@ #' @param remove_url \code{logical}. If \code{TRUE} (default), the \code{.html} #' file is removed once processing is completed. Only applies if 'url' is not #' specified. +#' @param remove_controls \code{character} vector of control buttons to be removed +#' from the map when saving to file. Any combination of +#' "zoomControl", "layersControl", "homeButton", "scaleBar". If set to \code{NULL} +#' nothing will be removed. #' @param ... Further arguments passed on to \code{\link{webshot}}. #' #' @seealso @@ -42,6 +46,8 @@ #' ## create standalone .png; temporary .html is removed automatically unless #' ## 'remove_url = FALSE' is specified #' mapshot(m, file = paste0(getwd(), "/map.png")) +#' mapshot(m, file = paste0(getwd(), "/map.png"), +#' remove_controls = c("homeButton", "layersControl")) #' #' ## create .html and .png #' mapshot(m, url = paste0(getwd(), "/map.html"), @@ -50,7 +56,15 @@ #' #' @export mapshot #' @name mapshot -mapshot <- function(x, url = NULL, file = NULL, remove_url = TRUE, ...) { +mapshot <- function(x, + url = NULL, + file = NULL, + remove_url = TRUE, + remove_controls = c("zoomControl", + "layersControl", + "homeButton", + "scaleBar"), + ...) { ## if both 'url' and 'file' are missing, throw an error avl_url <- !is.null(url) @@ -64,8 +78,11 @@ mapshot <- function(x, url = NULL, file = NULL, remove_url = TRUE, ...) { x <- mapview2leaflet(x) } - ## remove layers control - # x <- leaflet::removeLayersControl(x) + if (avl_file & !avl_url) { + for (i in remove_controls) { + x = removeMapJunk(x, i) + } + } ## if url is missing, create temporary .html file if (!avl_url) @@ -91,11 +108,23 @@ mapshot <- function(x, url = NULL, file = NULL, remove_url = TRUE, ...) { do.call(htmlwidgets::saveWidget, append(list(x), sw_ls[sw_args])) ## save to file + if (avl_file) { + url_tmp = gsub(".html", "_tmp.html", url) + sw_ls[which(names(sw_ls) == "file")] = url_tmp + args$url = url_tmp + # names(sw_ls)[which(names(sw_ls) == "url")] <- "file" + x_tmp = x + for (i in remove_controls) { + x_tmp = removeMapJunk(x_tmp, i) + } + do.call(htmlwidgets::saveWidget, append(list(x_tmp), sw_ls[sw_args])) ws_args <- match.arg(names(args), names(as.list(args(webshot::webshot))), several.ok = TRUE) do.call(webshot::webshot, args[ws_args]) + url_tmp_files = paste0(tools::file_path_sans_ext(url_tmp), "_files") + unlink(c(url_tmp, url_tmp_files), recursive = TRUE) } ## if url was missing, remove temporary .html file @@ -106,3 +135,29 @@ mapshot <- function(x, url = NULL, file = NULL, remove_url = TRUE, ...) { return(invisible()) } + + +removeMapJunk = function(map, junk) { + if (inherits(map, "mapview")) map = mapview2leaflet(map) + switch( + junk, + "zoomControl" = removeZoomControl(map), + "layersControl" = leaflet::removeLayersControl(map), + "homeButton" = removeHomeButtons(map), + "scaleBar" = leaflet::removeScaleBar(map), + NULL = map + ) +} + +removeZoomControl = function(map) { + map$x$options = append(map$x$options, list("zoomControl" = FALSE)) + return(map) +} + +removeHomeButtons = function(map) { + hb_ind = getCallEntryFromMap(map, "addHomeButton") + map$x$calls[hb_ind] = NULL + return(map) +} + + diff --git a/R/mapviewControls.R b/R/mapviewControls.R index bbd3bda42..e8e3f8d60 100644 --- a/R/mapviewControls.R +++ b/R/mapviewControls.R @@ -267,3 +267,20 @@ makeListLayerNames = function(x, layer.name) { return(as.list(lnms)) } + + +paneName = function(x) { + switch(getGeometryType(x), + "pt" = "point", + "ln" = "line", + "pl" = "polygon", + "gc" = "gcollection") +} + +zIndex = function(x) { + switch(getGeometryType(x), + "pt" = 440, + "ln" = 430, + "pl" = 420, + "gc" = 410) +} diff --git a/R/mapviewOptions.R b/R/mapviewOptions.R index 8abafb81b..d04e65b97 100644 --- a/R/mapviewOptions.R +++ b/R/mapviewOptions.R @@ -65,26 +65,20 @@ #' \code{\link{rasterOptions}}, \code{\link{options}} #' #' @examples -#' \dontrun{ #' mapviewOptions() #' mapviewOptions(na.color = "pink") #' mapviewOptions() #' #' mapviewGetOption("platform") -#' } +#' +#' mapviewOptions(default = TRUE) +#' mapviewOptions() #' #' #' @export mapviewOptions #' @name mapviewOptions #' @rdname mapviewOptions #' @aliases mapviewOptions - -# pkgs <- c("viridis", "viridisLite") -# viridis_avl <- try(sapply(pkgs, "requireNamespace", -# quietly = TRUE, USE.NAMES = FALSE)) -# viridis_avl <- any(viridis_avl) - - mapviewOptions <- function(platform, basemaps, raster.size, diff --git a/R/plainView.R b/R/plainView.R index 6b6a872ad..1cc36784d 100644 --- a/R/plainView.R +++ b/R/plainView.R @@ -52,7 +52,6 @@ if ( !isGeneric('plainView') ) { #' Tim Appelhans #' #' @examples -#' \dontrun{ #' ### raster data ### #' library(sp) #' library(raster) @@ -71,11 +70,9 @@ if ( !isGeneric('plainView') ) { #' m1 <- plainView(poppendorf[[5]]) #' m1 #' -#' # raster stack +#' # raster stack - true color #' plainview(poppendorf, 4, 3, 2) #' -#' } -#' #' @export plainView #' @name plainView #' @rdname plainView diff --git a/R/plus.R b/R/plus.R index 40c084211..340ea726f 100644 --- a/R/plus.R +++ b/R/plus.R @@ -10,20 +10,15 @@ if ( !isGeneric('+') ) { #' the objects should be added to e1. #' #' @examples -#' \dontrun{ -#' ### raster data ### -#' library(sp) -#' library(raster) -#' -#' m1 <- mapView(poppendorf[[5]]) -#' -#' ### point vector data ### -#' m2 <- mapView(breweries91) +#' m1 <- mapView(franconia, col.regions = "red") +#' m2 <- mapView(breweries) #' #' ### add two mapview objects #' m1 + m2 #' '+'(m2, m1) -#' } +#' +#' ### add layers to a mapview object +#' m1 + breweries + poppendorf[[4]] #' #' @name + #' @docType methods @@ -66,19 +61,25 @@ setMethod("+", signature(e1 = "mapview", e2 = "ANY"), function (e1, e2) { - nm <- deparse(substitute(e2)) - # e1 + mapview(e2, layer.name = nm) - m = mapview(e2, map = e1, layer.name = nm) - out_obj = append(e1@object, m@object) - hbcalls = getCallEntryFromMap(m@map, "addHomeButton") - zf = grep("Zoom full", m@map$x$calls[hbcalls]) - ind = hbcalls[zf] - if (length(zf) > 0) m@map$x$calls[ind] = NULL + nm <- deparse(substitute(e2)) + e1 + mapview(e2, layer.name = nm) - m = addZoomFullButton(m@map, out_obj) - out = methods::new('mapview', object = out_obj, map = m) - return(out) + # nm <- deparse(substitute(e2)) + # e1@map = removeMouseCoordinates(e1@map) + # # e1 + mapview(e2, layer.name = nm) + # m = mapview(e2, map = e1, layer.name = nm) + # print(str(m, 5)) + # out_obj = append(e1@object, m@object) + # + # hbcalls = getCallEntryFromMap(m@map, "addHomeButton") + # zf = grep("Zoom full", m@map$x$calls[hbcalls]) + # ind = hbcalls[zf] + # if (length(zf) > 0) m@map$x$calls[ind] = NULL + # + # m = addZoomFullButton(m@map, out_obj) + # out = methods::new('mapview', object = out_obj, map = m) + # return(out) } ) diff --git a/R/popup.R b/R/popup.R index 5406c1b16..00f838ab6 100644 --- a/R/popup.R +++ b/R/popup.R @@ -14,7 +14,7 @@ #' A \code{list} of HTML strings required to create feature popup tables. #' #' @examples -#' \dontrun{ +#' library(leaflet) #' #' ## include columns 1 and 2 only #' mapview(franconia, popup = popupTable(franconia, zcol = 1:2)) @@ -23,7 +23,6 @@ #' leaflet() %>% addCircleMarkers(data = breweries) #' leaflet() %>% addCircleMarkers(data = breweries, #' popup = popupTable(breweries)) -#' } #' #' @export popupTable #' @name popupTable @@ -236,18 +235,6 @@ popupRemoteImage = function(img, width = 300, height = "100%") { #' mapview(pt, popup = popupGraph(p2, width = 300, height = 400)) #' #' ### example: html ----- -#' library(scatterD3) -#' p = lapply(1:length(meuse), function(i) { -#' clr =rep(0, length(meuse)) -#' clr[[i]] = 1 -#' scatterD3(x = meuse$cadmium, -#' y = meuse$copper, -#' col_var = clr, -#' legend_width = 0) -#' }) -#' -#' mapview(meuse, popup = popupGraph(p, type = "html", width = 400, height = 300)) -#' #' mapview(breweries[1, ], map.types = "Esri.WorldImagery", #' popup = popupGraph(mapview(breweries[1, ])@map, #' type = "html", @@ -422,9 +409,10 @@ brewPopupTable = function(x, width = 300, height = 300, row.numbers = TRUE) { } else { # data.frame with 1 column - if (ncol(x) == 1) { + if (ncol(x) == 1 && names(x) == attr(x, "sf_column")) { + mat = as.matrix(class(x[, 1])[1]) + } else if (ncol(x) == 1) { mat = matrix(as.character(x[, 1])) - # data.frame with multiple columns } else { diff --git a/R/projection.R b/R/projection.R index 582320664..1aca99e00 100644 --- a/R/projection.R +++ b/R/projection.R @@ -10,12 +10,12 @@ wrong_proj_warning <- " projecting to '", llcrs, "'") # Check and potentially adjust projection of objects to be rendered ======= -checkAdjustProjection <- function(x) { +checkAdjustProjection <- function(x, method = "bilinear") { x <- switch(class(x)[1], - "RasterLayer" = rasterCheckAdjustProjection(x), - "RasterStack" = rasterCheckAdjustProjection(x), - "RasterBrick" = rasterCheckAdjustProjection(x), + "RasterLayer" = rasterCheckAdjustProjection(x, method), + "RasterStack" = rasterCheckAdjustProjection(x, method), + "RasterBrick" = rasterCheckAdjustProjection(x, method), "SpatialPointsDataFrame" = spCheckAdjustProjection(x), "SpatialPolygonsDataFrame" = spCheckAdjustProjection(x), "SpatialLinesDataFrame" = spCheckAdjustProjection(x), diff --git a/R/raster.R b/R/raster.R index a74f465ba..4d0b0eadf 100644 --- a/R/raster.R +++ b/R/raster.R @@ -23,6 +23,11 @@ leafletRL = function(x, homebutton, native.crs, method, + label, + query.type, + query.digits, + query.position, + query.prefix, ...) { if (inherits(map, "mapview")) map = mapview2leaflet(map) @@ -110,7 +115,10 @@ leafletRL = function(x, group = grp, layerId = grp, ...) - m = addImageQuery(m, x, group = grp, layerId = grp, position = "topright") + if (label) + m = addImageQuery(m, x, group = grp, layerId = grp, + type = query.type, digits = query.digits, + position = query.position, prefix = query.prefix) if (legend) { ## add legend # m = leaflet::addLegend(map = m, @@ -167,6 +175,11 @@ leafletRSB = function(x, layer.name, homebutton, method, + label, + query.type, + query.digits, + query.position, + query.prefix, ...) { pkgs = c("leaflet", "raster", "magrittr") @@ -190,6 +203,11 @@ leafletRSB = function(x, layer.name = layer.name, homebutton = homebutton, method = method, + label = label, + query.type = query.type, + query.digits = query.digits, + query.position = query.position, + query.prefix = query.prefix, ...) out = new('mapview', object = list(x), map = m@map) } else { @@ -204,6 +222,11 @@ leafletRSB = function(x, legend = legend, homebutton = homebutton, method = method, + label = label, + query.type = query.type, + query.digits = query.digits, + query.position = query.position, + query.prefix = query.prefix, ...) for (i in 2:nlayers(x)) { m = mapView(x[[i]], @@ -217,6 +240,11 @@ leafletRSB = function(x, legend = legend, homebutton = FALSE, method = method, + label = label, + query.type = query.type, + query.digits = query.digits, + query.position = query.position, + query.prefix = query.prefix, ...) } @@ -254,6 +282,11 @@ leafletPixelsDF = function(x, homebutton, native.crs, method, + label, + query.type, + query.digits, + query.position, + query.prefix, ...) { pkgs = c("leaflet", "sp", "magrittr") @@ -288,6 +321,11 @@ leafletPixelsDF = function(x, homebutton = homebutton, native.crs = native.crs, method = method, + label = label, + query.type = query.type, + query.digits = query.digits, + query.position = query.position, + query.prefix = query.prefix, ...) out = new('mapview', object = list(x), map = m@map) @@ -319,6 +357,73 @@ leafletSatellite = function(x, ...) { +# Convert RasterLayers to png or RasterStacks/Bricks to RGB png + +## raster layer ----------------------------------------------------------- +raster2PNG <- function(x, + col.regions, + at, + na.color, + maxpixels) { + + x <- rasterCheckSize(x, maxpixels = maxpixels) + + mat <- t(raster::as.matrix(x)) + + if (missing(at)) at <- lattice::do.breaks(range(mat, na.rm = TRUE), 256) + + cols <- lattice::level.colors(mat, + at = at, + col.regions = col.regions) + cols[is.na(cols)] = na.color + cols = col2Hex(cols, alpha = TRUE) + #cols <- clrs(t(mat)) + png_dat <- as.raw(grDevices::col2rgb(cols, alpha = TRUE)) + dim(png_dat) <- c(4, ncol(x), nrow(x)) + + return(png_dat) +} + + +## raster stack/brick ----------------------------------------------------- + +rgbStack2PNG <- function(x, r, g, b, + na.color, + quantiles = c(0.02, 0.98), + maxpixels, + ...) { + + x <- rasterCheckSize(x, maxpixels = maxpixels) + + x3 <- raster::subset(x, c(r, g, b)) + + mat <- cbind(x[[r]][], + x[[g]][], + x[[b]][]) + + for(i in seq(ncol(mat))){ + z <- mat[, i] + lwr <- stats::quantile(z, quantiles[1], na.rm = TRUE) + upr <- stats::quantile(z, quantiles[2], na.rm = TRUE) + z <- (z - lwr) / (upr - lwr) + z[z < 0] <- 0 + z[z > 1] <- 1 + mat[, i] <- z + } + + na_indx <- rowNA(mat) #apply(mat, 1, base::anyNA) # + cols <- rep(na.color, nrow(mat)) #mat[, 1] # + #cols[na_indx] <- na.color + cols[!na_indx] <- grDevices::rgb(mat[!na_indx, ], alpha = 1) + png_dat <- as.raw(grDevices::col2rgb(cols, alpha = TRUE)) + dim(png_dat) <- c(4, ncol(x), nrow(x)) + + return(png_dat) +} + + + + ########################################################################### ########################################################################### diff --git a/R/raster2PNG.R b/R/raster2PNG.R deleted file mode 100644 index 7688cb9fc..000000000 --- a/R/raster2PNG.R +++ /dev/null @@ -1,63 +0,0 @@ -# Convert RasterLayers to png or RasterStacks/Bricks to RGB png - -## raster layer ----------------------------------------------------------- -raster2PNG <- function(x, - col.regions, - at, - na.color, - maxpixels) { - - x <- rasterCheckSize(x, maxpixels = maxpixels) - - mat <- t(raster::as.matrix(x)) - - if (missing(at)) at <- lattice::do.breaks(range(mat, na.rm = TRUE), 256) - - cols <- lattice::level.colors(mat, - at = at, - col.regions = col.regions) - cols[is.na(cols)] = na.color - cols = col2Hex(cols, alpha = TRUE) - #cols <- clrs(t(mat)) - png_dat <- as.raw(grDevices::col2rgb(cols, alpha = TRUE)) - dim(png_dat) <- c(4, ncol(x), nrow(x)) - - return(png_dat) -} - - -## raster stack/brick ----------------------------------------------------- - -rgbStack2PNG <- function(x, r, g, b, - na.color, - quantiles = c(0.02, 0.98), - maxpixels, - ...) { - - x <- rasterCheckSize(x, maxpixels = maxpixels) - - x3 <- raster::subset(x, c(r, g, b)) - - mat <- cbind(x[[r]][], - x[[g]][], - x[[b]][]) - - for(i in seq(ncol(mat))){ - z <- mat[, i] - lwr <- stats::quantile(z, quantiles[1], na.rm = TRUE) - upr <- stats::quantile(z, quantiles[2], na.rm = TRUE) - z <- (z - lwr) / (upr - lwr) - z[z < 0] <- 0 - z[z > 1] <- 1 - mat[, i] <- z - } - - na_indx <- rowNA(mat) #apply(mat, 1, base::anyNA) # - cols <- rep(na.color, nrow(mat)) #mat[, 1] # - #cols[na_indx] <- na.color - cols[!na_indx] <- grDevices::rgb(mat[!na_indx, ], alpha = 1) - png_dat <- as.raw(grDevices::col2rgb(cols, alpha = TRUE)) - dim(png_dat) <- c(4, ncol(x), nrow(x)) - - return(png_dat) -} diff --git a/R/sf.R b/R/sf.R index 5401f5042..99f2be9a2 100644 --- a/R/sf.R +++ b/R/sf.R @@ -1,14 +1,11 @@ -large_warn = paste("the supplied feature layer has more points/vertices than the set threshold.", - "using special rendering function, hence things may not behave as expected from a standard leaflet map,", - "e.g. you will likely need to zoom in to popup-query features\n", - "to see the number of points/vertices of the layer use 'npts(x)'", - "to see the threshold for the feature type use 'mapview:::getMaxFeatures(x)'", - "to adjust the threshold use argument 'maxpoints'", - sep = "\n ") +# large_warn = paste("\nthe supplied feature layer seems quite large.\n", +# "would you like to view in the browser instead of RStudio viewer? (recommended)\n") ### sf #################################################################### leaflet_sf <- function(x, map, + pane, + canvas, zcol, cex, lwd, @@ -96,6 +93,7 @@ leaflet_sf <- function(x, leaflet_sfc(sf::st_geometry(x), map = map, + pane = pane, zcol = zcol, color = clrs, col.regions = clrs.regions, @@ -117,6 +115,7 @@ leaflet_sf <- function(x, highlight = highlight, maxpoints = maxpoints, attributes = sf2DataFrame(x, drop_sf_column = TRUE), + canvas = canvas, ...) } @@ -125,6 +124,8 @@ leaflet_sf <- function(x, ### sfc ################################################################### leaflet_sfc <- function(x, map, + pane, + canvas, zcol, cex, lwd, @@ -150,7 +151,7 @@ leaflet_sfc <- function(x, if (!is.null(names(x))) { names(x) = NULL } - # x = x[!is.na(sf::st_dimension(x))] + if (inherits(x, "XY")) x = sf::st_sfc(x) if (!native.crs) x <- checkAdjustProjection(x) @@ -166,29 +167,23 @@ leaflet_sfc <- function(x, } } - m <- initMap(map, map.types, sf::st_crs(x), native.crs) - - if (featureComplexity(x) > maxpoints) { - if (getGeometryType(x) == "ln") clrs <- color else clrs <- col.regions - warning(large_warn) - m <- addLargeFeatures(m, - data = x, - radius = cex, - weight = lwd, - opacity = alpha, - fillOpacity = alpha.regions, - color = clrs, - popup = popup, - label = label, - group = layer.name, - maxpoints = maxpoints, - attributes = attributes, - ...) + m <- initMap(map, map.types, sf::st_crs(x), native.crs, canvas = canvas) + if (!canvas) { + if (!is.null(pane)) { + if (pane == "auto") { + pane = paneName(x) + zindex = zIndex(x) + m = addMapPane(m, pane, zindex) + } + } } else { + pane = NULL + } m <- addFeatures(m, data = x, + pane = pane, radius = cex, weight = lwd, opacity = alpha, @@ -201,17 +196,17 @@ leaflet_sfc <- function(x, highlightOptions = highlight, ...) - } - if (!is.null(map)) m = updateOverlayGroups(m, layer.name) + sclbrpos = getCallEntryFromMap(m, "addScaleBar") + if (length(sclbrpos) > 0 | native.crs) scalebar = FALSE else scalebar = TRUE - funs <- list(if (!native.crs) leaflet::addScaleBar, + funs <- list(if (scalebar) leaflet::addScaleBar, if (homebutton) addHomeButton, if (is.null(map)) mapViewLayersControl, addMouseCoordinates) funs <- funs[!sapply(funs, is.null)] - args <- list(if (!native.crs) list(position = "bottomleft"), + args <- list(if (scalebar) list(position = "bottomleft"), if (homebutton) list(ext = createExtent(x), layer.name = layer.name), if (is.null(map)) list(map.types = map.types, diff --git a/R/stars.R b/R/stars.R index 8b6a5a92a..0f29f9f58 100644 --- a/R/stars.R +++ b/R/stars.R @@ -1,241 +1,251 @@ -#' Add stars layer to a leaflet map -#' -#' @param map a mapview or leaflet object. -#' @param x a stars layer -#' @param colors the color palette (see colorNumeric) or function to use to -#' color the raster values (hint: if providing a function, set na.color -#' to "#00000000" to make NA areas transparent) -#' @param opacity the base opacity of the raster, expressed from 0 to 1 -#' @param attribution the HTML string to show as the attribution for this layer -#' @param layerId the layer id -#' @param group the name of the group this raster image should belong to -#' (see the same parameter under addTiles) -#' @param project if TRUE, automatically project x to the map projection -#' expected by Leaflet (EPSG:3857); if FALSE, it's the caller's responsibility -#' to ensure that x is already projected, and that extent(x) is -#' expressed in WGS84 latitude/longitude coordinates -#' @param method the method used for computing values of the new, -#' projected raster image. "bilinear" (the default) is appropriate for -#' continuous data, "ngb" - nearest neighbor - is appropriate for categorical data. -#' Ignored if project = FALSE. See projectRaster for details. -#' @param maxBytes the maximum number of bytes to allow for the projected image -#' (before base64 encoding); defaults to 4MB. -#' -#' @details -#' This is an adaption of \code{\link{addRasterImage}}. See that documentation -#' for details. -#' -#' @examples -#' \dontrun{ -#' library(stars) -#' library(leaflet) -#' tif = system.file("tif/L7_ETMs.tif", package = "stars") -#' x = st_stars(tif) -#' leaflet() %>% -#' addProviderTiles("OpenStreetMap") %>% -#' addStarsImage(x) -#' } -#' -#' @export addStarsImage -#' -addStarsImage <- function(map, - x, - colors = "Spectral", - opacity = 1, - attribution = NULL, - layerId = NULL, - group = NULL, - project = FALSE, - method = c("bilinear", "ngb"), - maxBytes = 4*1024*1024) { - stopifnot(inherits(x, "stars")) - - if (is.null(group)) group = "stars" - if (is.null(layerId)) layerId = group - if (project) { - projected <- st_transform(x, crs = 4326) - } else { - projected <- x - } - # bounds <- raster::extent(raster::projectExtent(raster::projectExtent(x, crs = sp::CRS(epsg3857)), crs = sp::CRS(epsg4326))) - bb = st_as_sfc(st_bbox(projected)) - bounds = as.numeric(st_bbox(st_transform(bb, 4326))) - - if (!is.function(colors)) { - colors <- colorNumeric(colors, domain = NULL, - na.color = "#00000000", alpha = TRUE) - } - - tileData <- as.numeric(projected[[1]][, , 1]) %>% - colors() %>% grDevices::col2rgb(alpha = TRUE) %>% as.raw() - dim(tileData) <- c(4, as.numeric(nrow(projected)), as.numeric(ncol(projected))) - pngData <- png::writePNG(tileData) - if (length(pngData) > maxBytes) { - stop("Raster image too large; ", - length(pngData), - " bytes is greater than maximum ", - maxBytes, - " bytes") - } - encoded <- base64enc::base64encode(pngData) - uri <- paste0("data:image/png;base64,", encoded) - - latlng <- list( - list(bounds[4], bounds[1]), - list(bounds[2], bounds[3]) - ) - - # map$dependencies <- c(map$dependencies, - # starsDataDependency(jFn = pathDatFn, - # counter = 1, - # group = jsgroup)) - - invokeMethod(map, getMapData(map), "addRasterImage", uri, latlng, opacity, - attribution, layerId, group) %>% - expandLimits(c(bounds[2], bounds[4]), - c(bounds[1], bounds[3])) -} - - -leaflet_stars = function(x, - map, - maxpixels, - col.regions, - at, - na.color, - use.layer.names, - values, - map.types, - alpha.regions, - legend, - legend.opacity, - trim, - verbose, - layer.name, - homebutton, - native.crs, - method, - ...) { - - if (inherits(map, "mapview")) map = mapview2leaflet(map) - if (is.null(layer.name)) layer.name = makeLayerName(x, zcol = NULL) - - if (native.crs) { - stop("native.crs display of stars layers is not (yet) supported", - call. = FALSE) - # plainView(x, - # maxpixels = mapviewGetOption("plainview.maxpixels"), - # col.regions = col.regions, - # at = at, - # na.color = na.color, - # legend = legend, - # verbose = verbose, - # layer.name = layer.name, - # gdal = TRUE, - # ...) - } else { - - # is.fact = raster::is.factor(x) - # ext = raster::extent(raster::projectExtent(x, crs = llcrs)) - - m = initMap(map, map.types, sf::st_crs(x)$proj4string) - # x = rasterCheckSize(x, maxpixels = maxpixels) - # x = starsCheckAdjustProjection(x, method) - ext = createExtent(st_transform(st_as_sfc(st_bbox(x)), crs = 4326)) - - # if (!is.na(raster::projection(x)) & trim) x = trim(x) - - # if (is.fact) x = raster::as.factor(x) - - if (is.null(values)) { - # if (is.fact) { - # at = x@data@attributes[[1]]$ID - # } else { - offset = diff(range(as.numeric(x[[1]][, , 1]), na.rm = TRUE)) * 0.05 - top = max(as.numeric(x[[1]][, , 1]), na.rm = TRUE) + offset - bot = min(as.numeric(x[[1]][, , 1]), na.rm = TRUE) - offset - values = seq(bot, top, length.out = 10) - values = round(values, 5) - # } - } else { - values = round(values, 5) - } - - # if (is.fact) { - # pal = leaflet::colorFactor(palette = col.regions, - # domain = values, - # na.color = na.color) - # # pal2 = pal - # } else { - pal = rasterColors(col.regions, - at = at, - na.color = na.color) - - # if (length(at) > 11) { - # pal2 = leaflet::colorNumeric(palette = col.regions, - # domain = at, - # na.color = na.color) - # } else { - # pal2 = leaflet::colorBin(palette = col.regions, - # bins = length(at), - # domain = at, - # na.color = na.color) - # } - - # } - - if (use.layer.names) { - grp = names(x) - layer.name = names(x) - } else { - grp = layer.name - } - - ## add layers to base map - m = addStarsImage(map = m, - x = x, - colors = pal, - project = FALSE, - opacity = alpha.regions, - group = grp, - layerId = grp, - ...) - m = addImageQuery(m, x, group = grp, layerId = grp, position = "topright") - if (legend) { - stop("legend currently not supported for stars layers", call. = FALSE) - ## add legend - # m = leaflet::addLegend(map = m, - # pal = pal2, - # opacity = legend.opacity, - # values = at, - # title = grp) - - # m = addRasterLegend(x = x, - # map = m, - # title = grp, - # group = grp, - # at = at, - # col.regions = col.regions, - # na.color = na.color) - } - - m = mapViewLayersControl(map = m, - map.types = map.types, - names = grp) - - if (isAvailableInLeaflet()$scl) m = leaflet::addScaleBar(map = m, position = "bottomleft") - m = addMouseCoordinates(m) - - if (homebutton) m = addHomeButton(m, ext, layer.name = layer.name) - - out = new('mapview', object = list(x), map = m) - - return(out) - - } - -} - +# #' Add stars layer to a leaflet map +# #' +# #' @param map a mapview or leaflet object. +# #' @param x a stars layer +# #' @param colors the color palette (see colorNumeric) or function to use to +# #' color the raster values (hint: if providing a function, set na.color +# #' to "#00000000" to make NA areas transparent) +# #' @param opacity the base opacity of the raster, expressed from 0 to 1 +# #' @param attribution the HTML string to show as the attribution for this layer +# #' @param layerId the layer id +# #' @param group the name of the group this raster image should belong to +# #' (see the same parameter under addTiles) +# #' @param project if TRUE, automatically project x to the map projection +# #' expected by Leaflet (EPSG:3857); if FALSE, it's the caller's responsibility +# #' to ensure that x is already projected, and that extent(x) is +# #' expressed in WGS84 latitude/longitude coordinates +# #' @param method the method used for computing values of the new, +# #' projected raster image. "bilinear" (the default) is appropriate for +# #' continuous data, "ngb" - nearest neighbor - is appropriate for categorical data. +# #' Ignored if project = FALSE. See projectRaster for details. +# #' @param maxBytes the maximum number of bytes to allow for the projected image +# #' (before base64 encoding); defaults to 4MB. +# #' +# #' @details +# #' This is an adaption of \code{\link{addRasterImage}}. See that documentation +# #' for details. +# #' +# #' @examples +# #' \dontrun{ +# #' library(stars) +# #' library(leaflet) +# #' tif = system.file("tif/L7_ETMs.tif", package = "stars") +# #' x = read_stars(tif) +# #' leaflet() %>% +# #' addProviderTiles("OpenStreetMap") %>% +# #' addStarsImage(x, project = TRUE) +# #' } +# #' +# #' @export addStarsImage + + + +# addStarsImage <- function(map, +# x, +# colors = "Spectral", +# opacity = 1, +# attribution = NULL, +# layerId = NULL, +# group = NULL, +# project = FALSE, +# method = c("bilinear", "ngb"), +# maxBytes = 4*1024*1024) { +# stopifnot(inherits(x, "stars")) +# +# if (is.null(group)) group = "stars" +# if (is.null(layerId)) layerId = group +# if (project) { +# projected <- st_transform(x, crs = 3857) +# } else { +# projected <- x +# } +# # bounds <- raster::extent(raster::projectExtent(raster::projectExtent(x, crs = sp::CRS(epsg3857)), crs = sp::CRS(epsg4326))) +# bb = st_as_sfc(st_bbox(projected)) +# bounds = as.numeric(st_bbox(st_transform(bb, 4326))) +# +# if (!is.function(colors)) { +# colors <- colorNumeric(colors, domain = NULL, +# na.color = "#00000000", alpha = TRUE) +# } +# if(length(dim(projected)) == 2) layer = projected[[1]] else layer = projected[[1]][, , 1] +# tileData <- as.numeric(layer) %>% +# colors() %>% grDevices::col2rgb(alpha = TRUE) %>% as.raw() +# dim(tileData) <- c(4, as.numeric(nrow(projected)), as.numeric(ncol(projected))) +# pngData <- png::writePNG(tileData) +# if (length(pngData) > maxBytes) { +# stop("Raster image too large; ", +# length(pngData), +# " bytes is greater than maximum ", +# maxBytes, +# " bytes") +# } +# encoded <- base64enc::base64encode(pngData) +# uri <- paste0("data:image/png;base64,", encoded) +# +# latlng <- list( +# list(bounds[4], bounds[1]), +# list(bounds[2], bounds[3]) +# ) +# +# # map$dependencies <- c(map$dependencies, +# # starsDataDependency(jFn = pathDatFn, +# # counter = 1, +# # group = jsgroup)) +# +# invokeMethod(map, getMapData(map), "addRasterImage", uri, latlng, opacity, +# attribution, layerId, group) %>% +# expandLimits(c(bounds[2], bounds[4]), +# c(bounds[1], bounds[3])) +# } +# +# +# leaflet_stars = function(x, +# map, +# maxpixels, +# col.regions, +# at, +# na.color, +# use.layer.names, +# values, +# map.types, +# alpha.regions, +# legend, +# legend.opacity, +# trim, +# verbose, +# layer.name, +# homebutton, +# native.crs, +# method, +# label, +# query.type, +# query.digits, +# query.position, +# query.prefix, +# ...) { +# +# if (inherits(map, "mapview")) map = mapview2leaflet(map) +# if (is.null(layer.name)) layer.name = makeLayerName(x, zcol = NULL) +# +# if (native.crs) { +# stop("native.crs display of stars layers is not (yet) supported", +# call. = FALSE) +# # plainView(x, +# # maxpixels = mapviewGetOption("plainview.maxpixels"), +# # col.regions = col.regions, +# # at = at, +# # na.color = na.color, +# # legend = legend, +# # verbose = verbose, +# # layer.name = layer.name, +# # gdal = TRUE, +# # ...) +# } else { +# +# # is.fact = raster::is.factor(x) +# # ext = raster::extent(raster::projectExtent(x, crs = llcrs)) +# +# m = initMap(map, map.types, sf::st_crs(x)$proj4string) +# # x = rasterCheckSize(x, maxpixels = maxpixels) +# # x = starsCheckAdjustProjection(x, method) +# ext = createExtent(st_transform(st_as_sfc(st_bbox(x)), crs = 4326)) +# +# # if (!is.na(raster::projection(x)) & trim) x = trim(x) +# +# # if (is.fact) x = raster::as.factor(x) +# if(length(dim(x)) == 2) layer = x[[1]] else layer = x[[1]][, , 1] +# if (is.null(values)) { +# # if (is.fact) { +# # at = x@data@attributes[[1]]$ID +# # } else { +# offset = diff(range(as.numeric(layer), na.rm = TRUE)) * 0.05 +# top = max(as.numeric(layer), na.rm = TRUE) + offset +# bot = min(as.numeric(layer), na.rm = TRUE) - offset +# values = seq(bot, top, length.out = 10) +# values = round(values, 5) +# # } +# } else { +# values = round(values, 5) +# } +# +# # if (is.fact) { +# # pal = leaflet::colorFactor(palette = col.regions, +# # domain = values, +# # na.color = na.color) +# # # pal2 = pal +# # } else { +# pal = rasterColors(col.regions, +# at = at, +# na.color = na.color) +# +# # if (length(at) > 11) { +# # pal2 = leaflet::colorNumeric(palette = col.regions, +# # domain = at, +# # na.color = na.color) +# # } else { +# # pal2 = leaflet::colorBin(palette = col.regions, +# # bins = length(at), +# # domain = at, +# # na.color = na.color) +# # } +# +# # } +# +# if (use.layer.names) { +# grp = names(x) +# layer.name = names(x) +# } else { +# grp = layer.name +# } +# x <- st_transform(x, crs = 3857) +# ## add layers to base map +# m = addStarsImage(map = m, +# x = x, +# colors = pal, +# project = FALSE, +# opacity = alpha.regions, +# group = grp, +# layerId = grp, +# ...) +# if (label) +# m = addImageQuery(m, x, group = grp, layerId = grp, +# type = query.type, digits = query.digits, +# position = query.position, prefix = query.prefix) +# if (legend) { +# stop("legend currently not supported for stars layers", call. = FALSE) +# ## add legend +# # m = leaflet::addLegend(map = m, +# # pal = pal2, +# # opacity = legend.opacity, +# # values = at, +# # title = grp) +# +# # m = addRasterLegend(x = x, +# # map = m, +# # title = grp, +# # group = grp, +# # at = at, +# # col.regions = col.regions, +# # na.color = na.color) +# } +# +# m = mapViewLayersControl(map = m, +# map.types = map.types, +# names = grp) +# +# if (isAvailableInLeaflet()$scl) m = leaflet::addScaleBar(map = m, position = "bottomleft") +# m = addMouseCoordinates(m) +# +# if (homebutton) m = addHomeButton(m, ext, layer.name = layer.name) +# +# out = new('mapview', object = list(x), map = m) +# +# return(out) +# +# } +# +# } +# @@ -243,11 +253,12 @@ leaflet_stars = function(x, stars2Array = function(x) { + if(length(dim(x)) == 2) layer = x[[1]] else layer = x[[1]][, , 1] paste( sapply(seq(nrow(x[[1]])), function(i) { paste0( '[', gsub("NA", "null", - paste(as.numeric(x[[1]][, , 1][i, ]), collapse = ",")), ']' + paste(as.numeric(layer[i, ]), collapse = ",")), ']' ) }), collapse = "," diff --git a/R/sync.R b/R/sync.R index 60f227da9..37025466a 100644 --- a/R/sync.R +++ b/R/sync.R @@ -16,9 +16,9 @@ #' @param no.initial.sync whether to sync the initial view (default TRUE). #' #' @examples -#' #' \dontrun{ #' library(sp) +#' library(raster) #' #' data(meuse) #' coordinates(meuse) <- ~x+y @@ -54,7 +54,6 @@ #' latticeView(m1, m2, m3, m4) # not synced #' sync(m1, m2, m3, m4) # synced #' sync(m1, m2, m3, m4, no.initial.sync = FALSE) # all maps zoomed to m4 extent -#' #' } #' #' @export latticeView diff --git a/R/viewRGB.R b/R/viewRGB.R index 7ff4cac3c..cb97a52f2 100644 --- a/R/viewRGB.R +++ b/R/viewRGB.R @@ -18,7 +18,7 @@ if ( !isGeneric('viewRGB') ) { #' @param r integer. Index of the Red channel, between 1 and nlayers(x) #' @param g integer. Index of the Green channel, between 1 and nlayers(x) #' @param b integer. Index of the Blue channel, between 1 and nlayers(x) -#' @param quantiles the upper and lower quantiles used for color stretching +#' @param quantiles the upper and lower quantiles used for color stretching. If set to NULL, no stretching is applied. #' @param map the map to which the layer should be added #' @param maxpixels integer > 0. Maximum number of cells to use for the plot. #' If maxpixels < \code{ncell(x)}, sampleRegular is used before plotting. @@ -27,19 +27,22 @@ if ( !isGeneric('viewRGB') ) { #' for available options. #' @param na.color the color to be used for NA pixels #' @param layer.name the name of the layer to be shown on the map +#' @param method Method used to compute +#' values for the resampled layer that is passed on to leaflet. mapview does +#' projection on-the-fly to ensure correct display and therefore needs to know +#' how to do this projection. The default is 'bilinear' (bilinear interpolation), +#' which is appropriate for continuous variables. The other option, 'ngb' +#' (nearest neighbor), is useful for categorical variables. #' @param ... additional arguments passed on to \code{\link{mapView}} #' #' @author #' Tim Appelhans #' #' @examples -#' \dontrun{ #' library(raster) #' #' viewRGB(poppendorf, 4, 3, 2) # true-color #' viewRGB(poppendorf, 5, 4, 3) # false-color -#' } -#' #' #' @export #' @docType methods @@ -56,24 +59,32 @@ setMethod("viewRGB", signature(x = "RasterStackBrick"), na.color = mapviewGetOption("na.color"), layer.name = deparse(substitute(x, env = parent.frame())), + method = c("bilinear", "ngb"), ...) { + method = match.arg(method) m <- initMap(map, map.types, projection(x)) x <- rasterCheckSize(x, maxpixels) - xout <- rasterCheckAdjustProjection(x) + xout <- rasterCheckAdjustProjection(x, method) mat <- cbind(xout[[r]][], xout[[g]][], xout[[b]][]) - for(i in seq(ncol(mat))){ - z <- mat[, i] - lwr <- stats::quantile(z, quantiles[1], na.rm = TRUE) - upr <- stats::quantile(z, quantiles[2], na.rm = TRUE) - z <- (z - lwr) / (upr - lwr) - z[z < 0] <- 0 - z[z > 1] <- 1 - mat[, i] <- z + if (!is.null(quantiles)) { + + for(i in seq(ncol(mat))){ + z <- mat[, i] + lwr <- stats::quantile(z, quantiles[1], na.rm = TRUE) + upr <- stats::quantile(z, quantiles[2], na.rm = TRUE) + z <- (z - lwr) / (upr - lwr) + z[z < 0] <- 0 + z[z > 1] <- 1 + mat[, i] <- z + } + } else { + # If there is no stretch we just scale the data between 0 and 1 + mat <- apply(mat, 2, scales::rescale) } na_indx <- apply(mat, 1, anyNA) diff --git a/R/xy.R b/R/xy.R index c47cf149c..b9012aecc 100644 --- a/R/xy.R +++ b/R/xy.R @@ -1,11 +1,11 @@ # make interactive scatter plots -xyView = function(x, y, data, type = "p", grid = TRUE, aspect = 1, label, ...) { +xyView = function(x, y, data, type = "p", grid = TRUE, aspect = 1, label, crs = NA, ...) { if (!missing(data)) { # nm = "data" #deparse(substitute(data)) data[[y]] = data[[y]] * aspect - data = sf::st_as_sf(data, coords = c(x, y), remove = FALSE) + data = sf::st_as_sf(data, coords = c(x, y), remove = FALSE, crs = crs) } else if (!missing(x) & missing(y)) { y = x * aspect x = seq_along(y) @@ -20,7 +20,8 @@ xyView = function(x, y, data, type = "p", grid = TRUE, aspect = 1, label, ...) { data = sf::st_as_sf( data.frame(x = x, y = y * aspect), coords = c("x", "y"), - remove = FALSE + remove = FALSE, + crs = crs ) # nm = "data" } @@ -32,7 +33,8 @@ xyView = function(x, y, data, type = "p", grid = TRUE, aspect = 1, label, ...) { data ), to = "LINESTRING" - )[[1]] + )[[1]], + crs = crs ) } @@ -129,10 +131,10 @@ xyGrid = function(x, aspect = 1) { label = as.character(hlabs), group = "y_grid", labelOptions = leaflet::labelOptions( - noHide = T, + noHide = TRUE, direction = "left", textOnly = TRUE, - offset = c(0, -10), + offset = c(-5, 0), opacity = 0.5 ) ) @@ -144,10 +146,10 @@ xyGrid = function(x, aspect = 1) { label = as.character(vlabs), group = "x_grid", labelOptions = leaflet::labelOptions( - noHide = T, - direction = "left", + noHide = TRUE, + direction = "bottom", textOnly = TRUE, - offset = c(-10, 0), + offset = c(0, -10), opacity = 0.5 ) ) diff --git a/inst/htmlwidgets/lib/Leaflet.Sync/L.Map.Sync.js b/inst/htmlwidgets/lib/Leaflet.Sync/L.Map.Sync.js index 1ce09ebc7..a4795da85 100644 --- a/inst/htmlwidgets/lib/Leaflet.Sync/L.Map.Sync.js +++ b/inst/htmlwidgets/lib/Leaflet.Sync/L.Map.Sync.js @@ -5,10 +5,34 @@ (function () { var NO_ANIMATION = { animate: false, - reset: true + reset: true, + disableViewprereset: true }; - L.Map = L.Map.extend({ + L.Sync = function () {}; + /* + * Helper function to compute the offset easily. + * + * The arguments are relative positions with respect to reference and target maps of + * the point to sync. If you provide ratioRef=[0, 1], ratioTarget=[1, 0] will sync the + * bottom left corner of the reference map with the top right corner of the target map. + * The values can be less than 0 or greater than 1. It will sync points out of the map. + */ + L.Sync.offsetHelper = function (ratioRef, ratioTarget) { + var or = L.Util.isArray(ratioRef) ? ratioRef : [0.5, 0.5]; + var ot = L.Util.isArray(ratioTarget) ? ratioTarget : [0.5, 0.5]; + return function (center, zoom, refMap, targetMap) { + var rs = refMap.getSize(); + var ts = targetMap.getSize(); + var pt = refMap.project(center, zoom) + .subtract([(0.5 - or[0]) * rs.x, (0.5 - or[1]) * rs.y]) + .add([(0.5 - ot[0]) * ts.x, (0.5 - ot[1]) * ts.y]); + return refMap.unproject(pt, zoom); + }; + }; + + + L.Map.include({ sync: function (map, options) { this._initSync(); options = L.extend({ @@ -19,28 +43,95 @@ fillOpacity: 0.3, color: '#da291c', fillColor: '#fff' + }, + offsetFn: function (center, zoom, refMap, targetMap) { + // no transformation at all + return center; } }, options); // prevent double-syncing the map: if (this._syncMaps.indexOf(map) === -1) { this._syncMaps.push(map); + this._syncOffsetFns[L.Util.stamp(map)] = options.offsetFn; } if (!options.noInitialSync) { - map.setView(this.getCenter(), this.getZoom(), NO_ANIMATION); + map.setView( + options.offsetFn(this.getCenter(), this.getZoom(), this, map), + this.getZoom(), NO_ANIMATION); } if (options.syncCursor) { - map.cursor = L.circleMarker([0, 0], options.syncCursorMarkerOptions).addTo(map); + if (typeof map.cursor === 'undefined') { + map.cursor = L.circleMarker([0, 0], options.syncCursorMarkerOptions).addTo(map); + } this._cursors.push(map.cursor); this.on('mousemove', this._cursorSyncMove, this); this.on('mouseout', this._cursorSyncOut, this); } + + // on these events, we should reset the view on every synced map + // dragstart is due to inertia + this.on('resize zoomend', this._selfSetView); + this.on('moveend', this._syncOnMoveend); + this.on('dragend', this._syncOnDragend); + return this; + }, + + + // unsync maps from each other + unsync: function (map) { + var self = this; + + if (this._cursors) { + this._cursors.forEach(function (cursor, indx, _cursors) { + if (cursor === map.cursor) { + _cursors.splice(indx, 1); + } + }); + } + + // TODO: hide cursor in stead of moving to 0, 0 + if (map.cursor) { + map.cursor.setLatLng([0, 0]); + } + + if (this._syncMaps) { + this._syncMaps.forEach(function (synced, id) { + if (map === synced) { + delete self._syncOffsetFns[L.Util.stamp(map)]; + self._syncMaps.splice(id, 1); + } + }); + } + + if (!this._syncMaps || this._syncMaps.length == 0) { + // no more synced maps, so these events are not needed. + this.off('resize zoomend', this._selfSetView); + this.off('moveend', this._syncOnMoveend); + this.off('dragend', this._syncOnDragend); + } + return this; }, + // Checks if the map is synced with anything or a specifyc map + isSynced: function (otherMap) { + var has = (this.hasOwnProperty('_syncMaps') && Object.keys(this._syncMaps).length > 0); + if (has && otherMap) { + // Look for this specific map + has = false; + this._syncMaps.forEach(function (synced) { + if (otherMap == synced) { has = true; } + }); + } + return has; + }, + + + // Callbacks for events... _cursorSyncMove: function (e) { this._cursors.forEach(function (cursor) { cursor.setLatLng(e.latlng); @@ -54,32 +145,30 @@ }); }, + _selfSetView: function (e) { + // reset the map, and let setView synchronize the others. + this.setView(this.getCenter(), this.getZoom(), NO_ANIMATION); + }, - // unsync maps from each other - unsync: function (map) { - var self = this; - - if (this._syncMaps) { - this._syncMaps.forEach(function (synced, id) { - if (map === synced) { - self._syncMaps.splice(id, 1); - if (map.cursor) { - map.cursor.removeFrom(map); - } - } + _syncOnMoveend: function (e) { + if (this._syncDragend) { + // This is 'the moveend' after the dragend. + // Without inertia, it will be right after, + // but when inertia is on, we need this to detect that. + this._syncDragend = false; // before calling setView! + this._selfSetView(e); + this._syncMaps.forEach(function (toSync) { + toSync.fire('moveend'); }); } - this.off('mousemove', this._cursorSyncMove, this); - this.off('mouseout', this._cursorSyncOut, this); - - return this; }, - // Checks if the maps is synced with anything - isSynced: function () { - return (this.hasOwnProperty('_syncMaps') && Object.keys(this._syncMaps).length > 0); + _syncOnDragend: function (e) { + // It is ugly to have state, but we need it in case of inertia. + this._syncDragend = true; }, + // overload methods on originalMap to replay interactions on _syncMaps; _initSync: function () { if (this._syncMaps) { @@ -89,15 +178,47 @@ this._syncMaps = []; this._cursors = []; + this._syncOffsetFns = {}; L.extend(originalMap, { setView: function (center, zoom, options, sync) { + // Use this sandwich to disable and enable viewprereset + // around setView call + function sandwich (obj, fn) { + var viewpreresets = []; + var doit = options && options.disableViewprereset && obj && obj._events; + if (doit) { + // The event viewpreresets does an invalidateAll, + // that reloads all the tiles. + // That causes an annoying flicker. + viewpreresets = obj._events.viewprereset; + obj._events.viewprereset = []; + } + var ret = fn(obj); + if (doit) { + // restore viewpreresets event to its previous values + obj._events.viewprereset = viewpreresets; + } + return ret; + } + + // Looks better if the other maps 'follow' the active one, + // so call this before _syncMaps + var ret = sandwich(this, function (obj) { + return L.Map.prototype.setView.call(obj, center, zoom, options); + }); + if (!sync) { originalMap._syncMaps.forEach(function (toSync) { - toSync.setView(center, zoom, options, true); + sandwich(toSync, function (obj) { + return toSync.setView( + originalMap._syncOffsetFns[L.Util.stamp(toSync)](center, zoom, originalMap, toSync), + zoom, options, true); + }); }); } - return L.Map.prototype.setView.call(this, center, zoom, options); + + return ret; }, panBy: function (offset, options, sync) { @@ -116,15 +237,18 @@ }); } return L.Map.prototype._onResize.call(this, event); + }, + + _stop: function (sync) { + L.Map.prototype._stop.call(this); + if (!sync) { + originalMap._syncMaps.forEach(function (toSync) { + toSync._stop(true); + }); + } } }); - originalMap.on('zoomend', function () { - originalMap._syncMaps.forEach(function (toSync) { - toSync.setView(originalMap.getCenter(), originalMap.getZoom(), NO_ANIMATION); - }); - }, this); - originalMap.dragging._draggable._updatePosition = function () { L.Draggable.prototype._updatePosition.call(this); var self = this; @@ -132,10 +256,12 @@ L.DomUtil.setPosition(toSync.dragging._draggable._element, self._newPos); toSync.eachLayer(function (layer) { if (layer._google !== undefined) { - layer._google.setCenter(originalMap.getCenter()); + var offsetFn = originalMap._syncOffsetFns[L.Util.stamp(toSync)]; + var center = offsetFn(originalMap.getCenter(), originalMap.getZoom(), originalMap, toSync); + layer._google.setCenter(center); } }); - toSync.fire('moveend'); + toSync.fire('move'); }); }; } diff --git a/inst/htmlwidgets/lib/Leaflet.Sync/LICENSE b/inst/htmlwidgets/lib/Leaflet.Sync/LICENSE new file mode 100644 index 000000000..2b78b3130 --- /dev/null +++ b/inst/htmlwidgets/lib/Leaflet.Sync/LICENSE @@ -0,0 +1,25 @@ +Copyright (c) 2013-2017 Bjorn Sandvik / Jan Pieter Waagmeester +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the author nor the names of its contributors may be + used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/inst/htmlwidgets/lib/Leaflet.Sync/bower.json b/inst/htmlwidgets/lib/Leaflet.Sync/bower.json index 43e30c1b4..a848553b1 100644 --- a/inst/htmlwidgets/lib/Leaflet.Sync/bower.json +++ b/inst/htmlwidgets/lib/Leaflet.Sync/bower.json @@ -1,6 +1,6 @@ { "name": "Leaflet.Sync", - "version": "0.0.5", + "version": "0.2.2", "homepage": "https://github.com/turban/Leaflet.Sync", "authors": [ "Bjorn Sandvik", diff --git a/inst/htmlwidgets/lib/joda/joda.js b/inst/htmlwidgets/lib/joda/joda.js index e19359726..6bf4666ce 100644 --- a/inst/htmlwidgets/lib/joda/joda.js +++ b/inst/htmlwidgets/lib/joda/joda.js @@ -28,7 +28,7 @@ rasterPicker.old = function(e, x, data) { } }; -rasterPicker.pick = function(event, leafletConfig, digits) { +rasterPicker.pick = function(event, leafletConfig, digits, prefix) { var rasterLayers = this.getRasterLayers(leafletConfig); var pickedLayerData = {}; // collect values of clicked raster layers @@ -39,7 +39,7 @@ rasterPicker.pick = function(event, leafletConfig, digits) { } // render collected hit values var outputWidget = this.getInfoLegend(leafletConfig); - outputWidget.innerHTML = this.renderInfo(pickedLayerData, digits); + outputWidget.innerHTML = this.renderInfo(pickedLayerData, digits, prefix); }; rasterPicker.getInfoLegend = function(leafletConfig) { @@ -130,7 +130,7 @@ rasterPicker.getLayerData = function(rasterHitInfo, latlng, zoom) { return layerData; }; -rasterPicker.renderInfo = function(pickedLayerData, digits) { +rasterPicker.renderInfo = function(pickedLayerData, digits, prefix) { var text = ""; for (var layer_key in pickedLayerData) { var layer = pickedLayerData[layer_key]; @@ -138,9 +138,9 @@ rasterPicker.renderInfo = function(pickedLayerData, digits) { continue; } if(digits === null) { - text += "Layer "+ layer.layerId + ": "+ layer.value+ "
"; + text += prefix+ ""+ layer.layerId + ": "+ layer.value+ "
"; } else { - text += "Layer "+ layer.layerId + ": "+ layer.value.toFixed(digits)+ "
"; + text += prefix+ ""+ layer.layerId + ": "+ layer.value.toFixed(digits)+ "
"; } /*text += "
(lat,lng=" + layer.lat + "," + layer.lng + ")"; text += "
(x,y=" + layer.index.x + "," + layer.index.y + ")"; diff --git a/inst/htmlwidgets/lib/large/L.CanvasTiles.js b/inst/htmlwidgets/lib/large/L.CanvasTiles.js deleted file mode 100644 index 5e7a794ae..000000000 --- a/inst/htmlwidgets/lib/large/L.CanvasTiles.js +++ /dev/null @@ -1,128 +0,0 @@ -L.CanvasTiles = L.TileLayer.Canvas.extend({ - - initialize: function (userDrawFunc, options,callContext) { - this._userDrawFunc = userDrawFunc; - this._callContext = callContext; - L.setOptions(this, options); - - var self = this; - this.drawTile = function (tileCanvas, tilePoint, zoom) { - - this._draw(tileCanvas, tilePoint, zoom); - if (self.options.debug) { - self._drawDebugInfo(tileCanvas, tilePoint, zoom); - } - - }; - return this; - }, - - drawing: function (userDrawFunc) { - this._userDrawFunc = userDrawFunc; - return this; - }, - - params: function (options) { - L.setOptions(this, options); - return this; - }, - - addTo: function (map) { - map.addLayer(this); - return this; - }, - - _drawDebugInfo: function (tileCanvas, tilePoint, zoom) { - - var max = this.options.tileSize; - var g = tileCanvas.getContext('2d'); - g.globalCompositeOperation = 'destination-over'; - g.strokeStyle = '#FFFFFF'; - g.fillStyle = '#FFFFFF'; - g.strokeRect(0, 0, max, max); - g.font = "12px Arial"; - g.fillRect(0, 0, 5, 5); - g.fillRect(0, max - 5, 5, 5); - g.fillRect(max - 5, 0, 5, 5); - g.fillRect(max - 5, max - 5, 5, 5); - g.fillRect(max / 2 - 5, max / 2 - 5, 10, 10); - g.strokeText(tilePoint.x + ' ' + tilePoint.y + ' ' + zoom, max / 2 - 30, max / 2 - 10); - - }, - - /** - * Transforms coordinates to tile space - */ - tilePoint: function (map, coords,tilePoint, tileSize) { - // start coords to tile 'space' - var s = tilePoint.multiplyBy(tileSize); - - // actual coords to tile 'space' - var p = map.project(new L.LatLng(coords[0], coords[1])); - - // point to draw - var x = Math.round(p.x - s.x); - var y = Math.round(p.y - s.y); - return {x: x, - y: y}; - }, - /** - * Creates a query for the quadtree from bounds - */ - _boundsToQuery: function (bounds) { - if (bounds.getSouthWest() == undefined) { return { x: 0, y: 0, width: 0.1, height: 0.1 }; } // for empty data sets - return { - x: bounds.getSouthWest().lng, - y: bounds.getSouthWest().lat, - width: bounds.getNorthEast().lng - bounds.getSouthWest().lng, - height: bounds.getNorthEast().lat - bounds.getSouthWest().lat - }; - }, - - _draw: function (tileCanvas, tilePoint, zoom) { - - var tileSize = this.options.tileSize; - - var nwPoint = tilePoint.multiplyBy(tileSize); - var sePoint = nwPoint.add(new L.Point(tileSize, tileSize)); - - - // padding to draw points that overlap with this tile but their center is in other tile - var pad = new L.Point(this.options.padding, this.options.padding); - - nwPoint = nwPoint.subtract(pad); - sePoint = sePoint.add(pad); - - var bounds = new L.LatLngBounds(this._map.unproject(sePoint), this._map.unproject(nwPoint)); - var zoomScale = 1 / ((40075016.68 / tileSize) / Math.pow(2, zoom)); - // console.time('process'); - - if (this._userDrawFunc) { - this._userDrawFunc.call( - this._callContext, - this, - { - canvas: tileCanvas, - tilePoint: tilePoint, - bounds: bounds, - size: tileSize, - zoomScale: zoomScale, - zoom: zoom, - options: this.options, - } - ); - } - - - // console.timeEnd('process'); - - - }, - - -}); - -L.canvasTiles = function (userDrawFunc, options, callContext) { - return new L.CanvasTiles(userDrawFunc, options, callContext); -}; - diff --git a/inst/htmlwidgets/lib/large/LICENSE b/inst/htmlwidgets/lib/large/LICENSE deleted file mode 100644 index befc12f19..000000000 --- a/inst/htmlwidgets/lib/large/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 Robert Plummer - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - diff --git a/inst/htmlwidgets/lib/large/addLargeFeatures.js b/inst/htmlwidgets/lib/large/addLargeFeatures.js deleted file mode 100644 index b760d9a43..000000000 --- a/inst/htmlwidgets/lib/large/addLargeFeatures.js +++ /dev/null @@ -1,475 +0,0 @@ -LeafletWidget.methods.addLargeFeatures = function(x) { - - //######################################################### - - var map = this; - // var data = eval(x.group); - - addCanvas(); - - // define the first layer of the list to be the default one - //var defaultLayer = L.tileLayer.provider(x.layer[0]).addTo(map); - //var baseLayers = {}; - //for (var i = 0; i < x.layer.length; i++) { - //baseLayers[x.layer[i] ] = L.tileLayer.provider(x.layer[i]); - //} - - // define a dummy layer for the geojson data - //var myLayer = L.geoJson(undefined,{style:style,onEachFeature:onEachFeature}).addTo(map); - - if (eval(x.group).features[0].geometry.type == "Point") { - var myLayer = L.geoJson(undefined, { - pointToLayer: pointToLayer, - style: style, - onEachFeature: onEachFeature - }) - .addTo(map); - } else { - var myLayer = L.geoJson(undefined, { - style: style, - onEachFeature: onEachFeature - }) - .addTo(map); - } - var southWest = L.latLng([x.ymin, x.xmin]), - northEast = L.latLng([x.ymax, x.xmax]), - bounds = L.latLngBounds(southWest, northEast); - map.fitBounds(bounds); - var lzoom = map.getZoom(); - // create a pseudo layer for applying fitBounds - //var mincorner = L.marker([x.ymin, x.xmin]); - //var maxcorner = L.marker([x.ymax, x.xmax]); - //var group = new L.featureGroup([maxcorner, mincorner]); - //map.fitBounds(group.getBounds()); - - //legend.addToMap( pal = x.color, values = x.values.name, opacity = legend.opacity) - - // var data = x[2]; - // var loc = HTMLWidgets.getAttachmentUrl('data', 'jsondata'); - // var data = $.parseJSON(HTMLWidgets.getAttachmentUrl('data', 'jsondata')); - // check if an array of colors (palette) or a single color is provided - if (x.color.length <= 7) { - if (x.color[1].substring(0, 1) != "#") { - var col = x.color; - } - } else { - var col = eval(x.group).features[0].properties.color; - } - // second (first is on R side) coarse spatial zoom adaption - // if there is a - - //var zoom = lzoom; - - - var color = col; - var opacity = x.opacity; - //var globalAlpha = x.alpharegions; - var canvasAlpha = x.canvasOpacity; - var lnWidth = x.weight; - var rad = x.cex; - var tileOptions = { - maxZoom: 21, // max zoom to preserve detail on - maxPoints: 10, // stop slicing each tile below this number of points - tolerance: 1, // simplification tolerance (higher means simpler) - extent: 4096, // tile extent (both width and height) - buffer: 128, // tile buffer on each sidey - debug: 0, // logging level (0 to disable, 1 or 2) - indexMaxZoom: 0, // max zoom in the initial tile index - indexMaxPoints: 1000000, // max number of points per tile in the index - }; - // construct the rtree object - var rt = RTree(); - - // make leaflet circleobjects - function pointToLayer(feature, latlng) { - return L.circleMarker(latlng); - } - - // The onEachFeature function provides functionality when oneEchfeature is activated - function onEachFeature(feature, layer) { - Object.size = function(obj) { - var size = 0, key; - for (key in obj) { - if (obj.hasOwnProperty(key)) size++; - } - return size; - }; - - var len = Object.size(feature.properties)-1; - var i = 1; - var content = ''; - // does this feature have a property named popupContent? - if (feature.properties) { - for (var key in feature.properties) { - if (key !== "color") { - if (i === 1) { - content += ""; - } else if (!isEven(i)) { - content += ""; - } else if (isEven(i)) { - content += ""; - } - i = i + 1; - } - } - var popupContent = x.html + content + ""; - //console.log(popupContent); - layer.bindPopup(popupContent); - } - } - - // The styles of the geojson layer - // it generates specific styles for points lines and polygons - function style(feature) { - - // polygon style - if (feature.geometry.type == "MultiPolygon" || feature.geometry.type == "Polygon") { - return { - fillColor: feature.properties.color, - color: feature.properties.color, - weight: x.weight, - opacity: x.opacity, - fillOpacity: x.alpharegions - }; - } - - // line style - if (feature.geometry.type == "MultiLineString" || feature.geometry.type == "LineString") { - return { - color: feature.properties.color, - weight: x.weight, - opacity: x.opacity, - }; - - } - // point style - if (feature.geometry.type == "MultiPoint" || feature.geometry.type == "Point") { - return { - radius: x.cex, - fillColor: feature.properties.color, - color: feature.properties.color, - weight: x.weight, - opacity: opacity, - fillOpacity: x.alpharegions - }; - } - } - - - /*// function to filter the layer, if not delete the function here and on the var myLayer - function filter(feature, layer) { - if (theFilter != "none") { - layerFilter = feature.height; - if (layerFilter == theFilter) { - return true; - } else { - return false; - } - } else { - return true; - } - }rt.bbox([ - [bounds.getSouthWest() - .lng, bounds.getSouthWest() - .lat - ], - [bounds.getNorthEast() - .lng, bounds.getNorthEast() - .lat - ] - ]) - */ -function countProperties(obj) { - var count = 0; - - for(var prop in obj) { - if(obj.hasOwnProperty(prop)) - ++count; - } - - return count; -} - // function for retrieving the correct box according to the rtree object - var BoxSelect = L.Map.BoxZoom.extend({ - _onMouseUp: function(e) { - this._pane.removeChild(this._box); - this._container.style.cursor = ''; - L.DomUtil.enableTextSelection(); - L.DomEvent - .off(document, 'mousemove', this._onMouseMove) - .off(document, 'mouseup', this._onMouseUp); - var map = this._map, - layerPoint = map.mouseEventToLayerPoint(e); - if (this._startLayerPoint.equals(layerPoint)) { - return; - } - var bounds = new L.LatLngBounds( - map.layerPointToLatLng(this._startLayerPoint), - map.layerPointToLatLng(layerPoint)); - map.fire("boxselectend", { - boxSelectBounds: [ - [bounds.getSouthWest() - .lng, bounds.getSouthWest() - .lat - ], - [bounds.getNorthEast() - .lng, bounds.getNorthEast() - .lat - ] - ] - }); - } - }); - - //construct boxselect object - var boxSelect = new BoxSelect(map); - //add it - boxSelect.enable(); - - map.on("boxselected", function(e) { - var noF = rt.bbox(e.boxSelectBounds).length; - // Define here number of features as tipping point for rtree - if (noF <= x.maxFeatures) { - //if (layerType == "vectortiles") { - map.removeLayer(canvasTiles); - layerType = "geojson"; - //} - myLayer.clearLayers(); - rt.bbox([ - [bounds.getSouthWest() - .lng, bounds.getSouthWest() - .lat - ], - [bounds.getNorthEast() - .lng, bounds.getNorthEast() - .lat - ] - ]); - myLayer.addData(rt.bbox(e.boxSelectBounds)); - } else { - myLayer.clearLayers(); - canvasTiles.addTo(map); - layerType = "vectortiles"; - } - }); - - // recursive call of layerswitch - function showLayer() { - if (map.hasLayer(staticLayer) || map.hasLayer(myLayer)) { - // get number of features in current bounds - var bounds = map.getBounds(); - var noF = rt.bbox([ - [bounds.getSouthWest() - .lng, bounds.getSouthWest() - .lat - ], - [bounds.getNorthEast() - .lng, bounds.getNorthEast() - .lat - ] - ]).length; - - if (noF <= x.maxFeatures) { - //if (layerType == "vectortiles") { - map.removeLayer(canvasTiles); - layerType = "geojson"; - //} - //layerType.clearLayers(); - myLayer.clearLayers(); - var bounds = map.getBounds(); - myLayer.addData(rt.bbox([ - [bounds.getSouthWest() - .lng, bounds.getSouthWest() - .lat - ], - [bounds.getNorthEast() - .lng, bounds.getNorthEast() - .lat - ] - ])).addTo(map); - } else { - myLayer.clearLayers(); - canvasTiles.addTo(map); - layerType = "vectortiles"; - } - } - } - map.on("moveend", function(e) { - showLayer(); - }); - map.on("load", function(e) { - showLayer(); - }); - // Add to the r-tree - rt.geoJSON(eval(x.group)); - - // Add to the GeoJson Vector Tiles - var tileIndex = geojsonvt(eval(x.group), tileOptions); - var canvasTiles = L.tileLayer.canvas(); - - - // Draw the canvas tiles - canvasTiles.drawTile = function(canvas, tilePoint, zoom) { - var ctx = canvas.getContext('2d'); - extent = 4096; - padding = 0; - totalExtent = extent * (1 + padding * 2); - height = canvas.height = canvas.width = 256; - ratio = height / totalExtent; - pad = extent * padding * ratio; - - var x = tilePoint.x; - var y = tilePoint.y; - var z = zoom; - var tile = tileIndex.getTile(z, x, y); - if (typeof tile != "undefined") { - var features = tile.features; - var color = features[0].tags.color; - - // color to the lines - // create gradients - //var grdp = ctx.createRadialGradient(75,50,5,90,60,100); - //var grd = ctx.createLinearGradient(0, 0, 170, 0); - // define opacity - ctx.globalAlpha = canvasAlpha; - // apply gradient to colors - //grd.addColorStop(0, color[0]); - //grd.addColorStop(1, color[color.length-1]); - //define line width - ctx.lineWidth = lnWidth; - // define line color - ctx.strokeStyle = color; - //define fill color - ctx.fillStyle = color; - - for (var i = 0; i < features.length; i++) { - var feature = features[i], - typeChanged = type !== feature.type, - type = feature.type; - - ctx.beginPath(); - // points - if (type === 1) { - /*ctx.globalAlpha=0.7 ; - ctx.lineWidth = 0.0; - ctx.strokeStyle = "black"; - - */ - - for (var j = 0; j < feature.geometry.length; j++) { - var ring = feature.geometry[j]; - ctx.arc(ring[0] * ratio + pad, - ring[1] * ratio + pad, - rad - 1 / zoom * 10, - 0, - 2 * Math.PI); - } - ctx.fillStyle = feature.tags.color; - ctx.strokeStyle = feature.tags.color; - ctx.fill(); - } - // - // lines - /* if (feature.tags.ELEV != "") { - if (feature.tags.ELEV == "1000") { - ctx.strokeStyle = grd; - } else if (feature.tags.ELEV == "2000") { - ctx.strokeStyle = "#00FF00"; - } else { - ctx.globalAlpha=0.3 ; - ctx.strokeStyle = "brown"; - } - } else { - ctx.strokeStyle = "black"; - } - */ - for (var j = 0; j < feature.geometry.length; j++) { - var ring = feature.geometry[j]; - ctx.strokeStyle = feature.tags.color; - - for (var k = 0; k < ring.length; k++) { - var p = ring[k]; - - if (k) ctx.lineTo(p[0] * ratio + pad, p[1] * ratio + pad); - else ctx.moveTo(p[0] * ratio + pad, p[1] * ratio + pad); - } - } - // polygons - if (type === 3) { - ctx.fillStyle = feature.tags.color; - ctx.strokeStyle = feature.tags.color; - ctx.fill(); - - } - ctx.stroke(); - - - } - } - }; - - // create overlay Layers variables - //var overlayLayers = {}; - //overlayLayers[x.layername] = myLayer; - //overlayLayers[x.layername + "_static"] = (canvasTiles).addTo(map); - - staticLayer = (canvasTiles).addTo(map); - - map.layerManager.addLayer(myLayer, null, null, x.layername); - map.layerManager.addLayer(staticLayer, null, null, x.layername); - - //overlayLayers.addTo(tst) - - // ADD LAYER CONTRLS - //var layerControl = L.control.layers(null, overlayLayers, {collapsed: true}).addTo(tst); - //map.setView([x.centerLat[0], x.centerLon[0], x.zoom[0]]); - - showLayer(); - -}; - -// this function is actually not needed I think!! -function addCanvas() { - var newMeta = document.createElement("meta"); - document.head.insertBefore(newMeta, null); - newMeta.name = "viewport"; - newMeta.content = "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"; -} - - -function isEven(n) { - return n % 2 == 0; -} - -/* -, - - - -resize: function(el, width, height, instance) { -} -}); - -// we need to create a new meta tag - - -// we need a new div element because we have to handle -// the mouseover output seperatly - function addElement () { - // generate new div Element - var newDiv = document.createElement("div"); - // insert to DOM - document.body.insertBefore(newDiv, null); - //provide ID and style - newDiv.id = 'lnlt'; - newDiv.style.cssText = 'position: relative;' + - 'bottomleft: 0px;' + - 'background-color: rgba(255, 255, 255, 0.7);' + - 'box-shadow: 0 0 2px #bbb; ' + - 'background-clip: padding-box;' + - 'margin:0; color: #333;' + - 'font: 9px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif;' + - '>
;'; - } - -*/ diff --git a/inst/htmlwidgets/lib/large/addVeryLargePoints.js b/inst/htmlwidgets/lib/large/addVeryLargePoints.js deleted file mode 100644 index 64c2efadd..000000000 --- a/inst/htmlwidgets/lib/large/addVeryLargePoints.js +++ /dev/null @@ -1,135 +0,0 @@ -LeafletWidget.methods.addVeryLargePoints = function(x) { - - //######################################################### - - var map = this; - - // we need a not htmlwidget div in the widget container - // addElement(); - - // initialize the leaflet map staticly at the "el" object - // hard-coding center/zoom here for a non-empty initial view, since there - // is no way for htmlwidgets to pass initial params to initialize() - // so we set maxbounds to the world and center somewhat at 0 Lat 0 Lon - /* - var southWest = L.latLng(-90, -180), - northEast = L.latLng(90, 180), - bounds = L.latLngBounds(southWest, northEast); - var map = new L.map(el, { - center: [0, 0], - maxBounds: bounds - }); - - // we could add more (static) leaflet stuff here ;-) - - // The map is rendered staticly => so there would be no output binding - // for the further handling we generate the binding to el this.getId(el) - if (typeof this.getId === 'undefined') return map; - map.id = this.getId(el); - - // Store the map on the element so we could find it later by ID - $(el).data("leaflet-map", map); - - //return the initial mapsetup to the renderValue function - return map; - - //renderValue: function(el, x, map) { - // return this.doRenderValue(el, x, map); - //}, - - //doRenderValue: function(el, x, map) { -*/ - // we define the first layer of the list to be the default one - /*var defaultLayer = L.tileLayer.provider(x.layer[0]).addTo(map); - var baseLayers = {}; - for (var i = 0; i < x.layer.length; i++) { - baseLayers[x.layer[i]] = L.tileLayer.provider(x.layer[i]); - }*/ - - //focus on the bounds of the input data extent using a virtual marker layer - var mincorner = L.marker([x.ymin, x.xmin]); - var maxcorner = L.marker([x.ymax, x.xmax]); - var group = new L.featureGroup([maxcorner, mincorner]); - map.fitBounds(group.getBounds()); - //var layerControl = L.control.layers(baseLayers).addTo(map); - // get the file locations from the shaders and the static external file - var vertexshader = HTMLWidgets.getAttachmentUrl('vertex-shader'); - var fragmentshader = HTMLWidgets.getAttachmentUrl('fragment-shader'); - var color = x.color; - var layername = x.layername; - - // after reading the shader files data, popuptemplates and shaders are passed to the - // L.Glify leaflet extension that handles the webGL shading process - // big thanks for this to Robert Plummers version of the web gl renderer and his plugin for - // leaflet https://robertleeplummerjr.github.io/Leaflet.glify - if (x.data === 'undefined') { - var data = HTMLWidgets.getAttachmentUrl(x.layername); - wget([fragmentshader, vertexshader, data], function(fragmentshader, vertexshader, data) { - L.glify({ - map: map, - vertexShader: vertexshader, - fragmentShader: fragmentshader, - clickPoint: function(point) { - //set up a standalone popup (use a popup as a layer) - contentToHtml = x.popTemplate; - - for (var i = 0; i < x.cHelp.length; i++) { - if (i == 0) { - contentToHtml += x.cHelp[i] + point.lng + ""; - } - if (i == 1) { - contentToHtml += x.cHelp[i] + point.lat + ""; - } - if (i > 1) { - contentToHtml += x.cHelp[i] + point.a[i - 2] + ""; - } - } - - - - contentToHtml += ""; - L.popup() - .setLatLng(point) - .setContent(contentToHtml) - .openOn(map); - //console.log(point); - }, - data: JSON.parse(data), - color: color - //size: 100 - //baseLayers: baseLayers - - }); - }); - //map.layerManager.addLayer(tst, null, "1", x.layername); - } else { - var data = x.data; - } - -}; - - - //resize: function(el, width, height, instance) {} -//}//); - -// get the files and returns them as text stream -function wget(urls, fn) { - var results = [], - lookup = {}, - complete = 0, - total = urls.length; - - urls.forEach(function(url) { - var i = lookup[url] = results.length, - request = new XMLHttpRequest(); - results.push(null); - request.open('GET', url, true); - request.onload = function() { - if (request.status < 200 && request.status > 400) return; - results[i] = request.responseText; - complete++; - if (complete === total) fn.apply(null, results); - }; - request.send(); - }); -} diff --git a/inst/htmlwidgets/lib/large/fragment-shader.glsl b/inst/htmlwidgets/lib/large/fragment-shader.glsl deleted file mode 100644 index b37f8e15a..000000000 --- a/inst/htmlwidgets/lib/large/fragment-shader.glsl +++ /dev/null @@ -1,21 +0,0 @@ -precision mediump float; -varying vec4 vColor; -void main() { - float border = 0.0; - float radius = 0.4; - vec4 color0 = vec4(0.0, 0.0, 0.0, 0.0); //background - vec4 color1 = vec4(vColor[0], vColor[1], vColor[2], 1); //foreground - - vec2 m = gl_PointCoord.xy - vec2(0.5, 0.5); - float dist = radius - sqrt(m.x * m.x + m.y * m.y); - - float t = 0.0; - if (dist > border) { - t = 1.0; - } else if (dist > 0.0) { - t = dist / border; - } - - //works for overlapping circles if blending is enabled - gl_FragColor = mix(color0, color1, t); -} diff --git a/inst/htmlwidgets/lib/large/geojson-vt-dev.min.js b/inst/htmlwidgets/lib/large/geojson-vt-dev.min.js deleted file mode 100644 index 2a8b77a00..000000000 --- a/inst/htmlwidgets/lib/large/geojson-vt-dev.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.geojsonvt=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c||a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g=c&&o<=d){i.push(k);continue}if(n>d||o=b&&h<=c&&e.push(g)}return e}function f(a,b,c,d,e,f){for(var h=[],i=0;ic?(s.push(e(q,l,b),e(q,l,c)),f||(s=g(h,s,n,o))):k>=b&&s.push(e(q,l,b)):j>c?kc&&(s.push(e(q,l,c)),f||(s=g(h,s,n,o))));q=m[p-1],j=q[d],j>=b&&j<=c&&s.push(q),f&&s[0]!==s[s.length-1]&&s.push(s[0]),g(h,s,n,o)}return h}function g(a,b,c,d){return b.length&&(b.area=c,b.dist=d,a.push(b)),[]}b.exports=d},{}],2:[function(a,b,c){"use strict";function e(a,b){var c=[];if("FeatureCollection"===a.type)for(var d=0;d1)return!1;for(var e=0;e1&&console.time("creation"),u=this.tiles[t]=f(a,s,c,d,v,b===o.maxZoom),p)){p>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",b,c,d,u.numFeatures,u.numPoints,u.numSimplified),console.timeEnd("creation"));var w="z"+b;this.stats[w]=(this.stats[w]||0)+1,this.total++}if(u.source=a,!k(u.features,q,r)){if(g){if(b===o.maxZoom||b===g)continue;var x=1<1&&console.time("clipping");var C,D,E,F,G,H,y=.5*r/q,z=.5-y,A=.5+y,B=1+y;C=D=E=F=null,G=e(a,s,c-y,c+A,0,m),H=e(a,s,c+z,c+B,0,m),G&&(C=e(G,s,d-y,d+A,1,n),D=e(G,s,d+z,d+B,1,n)),H&&(E=e(H,s,d-y,d+A,1,n),F=e(H,s,d+z,d+B,1,n)),p>1&&console.timeEnd("clipping"),C&&j.push(C,b+1,2*c,2*d),D&&j.push(D,b+1,2*c,2*d+1),E&&j.push(E,b+1,2*c+1,2*d),F&&j.push(F,b+1,2*c+1,2*d+1)}}},h.prototype.getTile=function(a,b,c){var d=this.options,e=d.extent,f=d.debug,g=l(a,b,c);if(this.tiles[g])return i(this.tiles[g],e);f>1&&console.log("drilling down to z%d-%d-%d",a,b,c);for(var n,h=a,j=b,m=c;!n&&h>0;)h--,j=Math.floor(j/2),m=Math.floor(m/2),n=this.tiles[l(h,j,m)];if(f>1&&console.log("found parent tile z%d-%d-%d",h,j,m),n&&n.source){if(k(n.features,d.extent,d.buffer))return i(n,e);f>1&&console.time("drilling down"),this.splitTile(n.source,h,j,m,a,b,c),f>1&&console.timeEnd("drilling down")}return i(this.tiles[g],e)}},{"./clip":1,"./convert":2,"./tile":5}],4:[function(a,b,c){"use strict";function d(a,b){var i,j,k,l,c=b*b,d=a.length,f=0,g=d-1,h=[];for(a[f][2]=1,a[g][2]=1;g;){for(j=0,i=f+1;ij&&(l=i,j=k);j>c?(a[l][2]=j,h.push(f),h.push(l),f=l):(g=h.pop(),f=h.pop())}}function e(a,b,c){var d=b[0],e=b[1],f=c[0],g=c[1],h=a[0],i=a[1],j=f-d,k=g-e;if(0!==j||0!==k){var l=((h-d)*j+(i-e)*k)/(j*j+k*k);l>1?(d=f,e=g):l>0&&(d+=j*l,e+=k*l)}return j=h-d,k=i-e,j*j+k*k}b.exports=d},{}],5:[function(a,b,c){"use strict";function d(a,b,c,d,f,g){for(var h={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:c,y:d,z2:b,transformed:!1},i=0;ih)&&(m.push(l),a.numSimplified++),a.numPoints++;g.push(m)}else a.numPoints+=k.length;g.length&&a.features.push({geometry:g,type:f,tags:b.tags||null})}b.exports=d},{}]},{},[3])(3)}); diff --git a/inst/htmlwidgets/lib/large/gh-fork-ribbon.css b/inst/htmlwidgets/lib/large/gh-fork-ribbon.css deleted file mode 100644 index 84af6ac27..000000000 --- a/inst/htmlwidgets/lib/large/gh-fork-ribbon.css +++ /dev/null @@ -1,127 +0,0 @@ -/* Left will inherit from right (so we don't need to duplicate code */ -.github-fork-ribbon { - /* The right and left lasses determine the side we attach our banner to */ - position: absolute; - - /* Add a bit of padding to give some substance outside the "stitching" */ - padding: 2px 0; - - /* Set the base colour */ - background-color: #a00; - - /* Set a gradient: transparent black at the top to almost-transparent black at the bottom */ - background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0, 0, 0, 0.00)), to(rgba(0, 0, 0, 0.15))); - background-image: -webkit-linear-gradient(top, rgba(0, 0, 0, 0.00), rgba(0, 0, 0, 0.15)); - background-image: -moz-linear-gradient(top, rgba(0, 0, 0, 0.00), rgba(0, 0, 0, 0.15)); - background-image: -o-linear-gradient(top, rgba(0, 0, 0, 0.00), rgba(0, 0, 0, 0.15)); - background-image: -ms-linear-gradient(top, rgba(0, 0, 0, 0.00), rgba(0, 0, 0, 0.15)); - background-image: linear-gradient(top, rgba(0, 0, 0, 0.00), rgba(0, 0, 0, 0.15)); - filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,StartColorStr='#000000', EndColorStr='#000000'); - - /* Add a drop shadow */ - -webkit-box-shadow: 0px 2px 3px 0px rgba(0, 0, 0, 0.5); - box-shadow: 0px 2px 3px 0px rgba(0, 0, 0, 0.5); - - z-index: 9999; -} - -.github-fork-ribbon a { - /* Set the font */ - font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; - font-size: 13px; - font-weight: 700; - color: white; - - /* Set the text properties */ - text-decoration: none; - text-shadow: 0 -1px rgba(0,0,0,0.5); - text-align: center; - - /* Set the geometry. If you fiddle with these you'll also need to tweak the top and right values in #github-fork-ribbon. */ - width: 200px; - line-height: 20px; - - /* Set the layout properties */ - display: inline-block; - padding: 2px 0; - - /* Add "stitching" effect */ - border-width: 1px 0; - border-style: dotted; - border-color: rgba(255,255,255,0.7); -} - -.github-fork-ribbon-wrapper { - width: 150px; - height: 150px; - position: absolute; - overflow: hidden; - top: 0; -} - -.github-fork-ribbon-wrapper.left { - left: 0; -} - -.github-fork-ribbon-wrapper.right { - right: 0; -} - -.github-fork-ribbon-wrapper.left-bottom { - position: fixed; - top: inherit; - bottom: 0; - left: 0; -} - -.github-fork-ribbon-wrapper.right-bottom { - position: fixed; - top: inherit; - bottom: 0; - right: 0; -} - -.github-fork-ribbon-wrapper.right .github-fork-ribbon { - top: 42px; - right: -43px; - - /* Rotate the banner 45 degrees */ - -webkit-transform: rotate(45deg); - -moz-transform: rotate(45deg); - -o-transform: rotate(45deg); - transform: rotate(45deg); -} - -.github-fork-ribbon-wrapper.left .github-fork-ribbon { - top: 42px; - left: -43px; - - /* Rotate the banner -45 degrees */ - -webkit-transform: rotate(-45deg); - -moz-transform: rotate(-45deg); - -o-transform: rotate(-45deg); - transform: rotate(-45deg); -} - - -.github-fork-ribbon-wrapper.left-bottom .github-fork-ribbon { - top: 80px; - left: -43px; - - /* Rotate the banner -45 degrees */ - -webkit-transform: rotate(45deg); - -moz-transform: rotate(45deg); - -o-transform: rotate(45deg); - transform: rotate(45deg); -} - -.github-fork-ribbon-wrapper.right-bottom .github-fork-ribbon { - top: 80px; - right: -43px; - - /* Rotate the banner -45 degrees */ - -webkit-transform: rotate(-45deg); - -moz-transform: rotate(-45deg); - -o-transform: rotate(-45deg); - transform: rotate(-45deg); -} \ No newline at end of file diff --git a/inst/htmlwidgets/lib/large/gh-fork-ribbon.ie.css b/inst/htmlwidgets/lib/large/gh-fork-ribbon.ie.css deleted file mode 100644 index 77fcab505..000000000 --- a/inst/htmlwidgets/lib/large/gh-fork-ribbon.ie.css +++ /dev/null @@ -1,68 +0,0 @@ -/* IE voodoo courtesy of http://stackoverflow.com/a/4617511/263871 and - * http://www.useragentman.com/IETransformsTranslator */ -.github-fork-ribbon-wrapper.right .github-fork-ribbon { - /* IE positioning hack (couldn't find a transform-origin alternative for IE) */ - top: -22px; - right: -62px; - - /* IE8+ */ - -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.7071067811865474, M12=-0.7071067811865477, M21=0.7071067811865477, M22=0.7071067811865474, SizingMethod='auto expand')"; - /* IE6 and 7 */ - filter: progid:DXImageTransform.Microsoft.Matrix( - M11=0.7071067811865474, - M12=-0.7071067811865477, - M21=0.7071067811865477, - M22=0.7071067811865474, - SizingMethod='auto expand' - ); -} - -.github-fork-ribbon-wrapper.left .github-fork-ribbon { - top: -22px; - left: -22px; - - /* IE8+ */ - -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.7071067811865483, M12=0.7071067811865467, M21=-0.7071067811865467, M22=0.7071067811865483, SizingMethod='auto expand')"; - /* IE6 and 7 */ - filter: progid:DXImageTransform.Microsoft.Matrix( - M11=0.7071067811865483, - M12=0.7071067811865467, - M21=-0.7071067811865467, - M22=0.7071067811865483, - SizingMethod='auto expand' - ); -} - -.github-fork-ribbon-wrapper.left-bottom .github-fork-ribbon { - /* IE positioning hack (couldn't find a transform-origin alternative for IE) */ - top: 12px; - left: -22px; - - - /* IE8+ */ - -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.7071067811865474, M12=-0.7071067811865477, M21=0.7071067811865477, M22=0.7071067811865474, SizingMethod='auto expand')"; - /* IE6 and 7 */ -/* filter: progid:DXImageTransform.Microsoft.Matrix( - M11=0.7071067811865474, - M12=-0.7071067811865477, - M21=0.7071067811865477, - M22=0.7071067811865474, - SizingMethod='auto expand' - ); -*/} - -.github-fork-ribbon-wrapper.right-bottom .github-fork-ribbon { - top: 12px; - right: -62px; - - /* IE8+ */ - -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.7071067811865483, M12=0.7071067811865467, M21=-0.7071067811865467, M22=0.7071067811865483, SizingMethod='auto expand')"; - /* IE6 and 7 */ - filter: progid:DXImageTransform.Microsoft.Matrix( - M11=0.7071067811865483, - M12=0.7071067811865467, - M21=-0.7071067811865467, - M22=0.7071067811865483, - SizingMethod='auto expand' - ); -} \ No newline at end of file diff --git a/inst/htmlwidgets/lib/large/gl.js b/inst/htmlwidgets/lib/large/gl.js deleted file mode 100644 index c158bf77b..000000000 --- a/inst/htmlwidgets/lib/large/gl.js +++ /dev/null @@ -1,34 +0,0 @@ -var gl = { - ARRAY_BUFFER: new ArrayBuffer(), - STATIC_DRAW: null, - FLOAT: new Float32Array(), - VERTEX_SHADER: null, - FRAGMENT_SHADER: null, - SRC_ALPHA: null, - ONE_MINUS_SRC_ALPHA: null, - BLEND: null, - COLOR_BUFFER_BIT: null, - POINTS: null, - - getUniformLocation: function() {}, - getAttribLocation: function() {}, - viewport: function() {}, - uniformMatrix4fv: function() {}, - createBuffer: function() {}, - bindBuffer: function() {}, - bufferData: function() {}, - vertexAttribPointer: function() {}, - enableVertexAttribArray: function() {}, - redraw: function() {}, - createShader: function() {}, - shaderSource: function() {}, - compileShader: function() {}, - createProgram: function() {}, - attachShader: function() {}, - linkProgram: function() {}, - useProgram: function() {}, - blendFunc: function() {}, - enable: function() {}, - vertexAttrib1f: function() {}, - drawArrays: function() {} -}; \ No newline at end of file diff --git a/inst/htmlwidgets/lib/large/images/layers-2x.png b/inst/htmlwidgets/lib/large/images/layers-2x.png deleted file mode 100644 index a2cf7f9ef..000000000 Binary files a/inst/htmlwidgets/lib/large/images/layers-2x.png and /dev/null differ diff --git a/inst/htmlwidgets/lib/large/images/layers.png b/inst/htmlwidgets/lib/large/images/layers.png deleted file mode 100644 index bca0a0e42..000000000 Binary files a/inst/htmlwidgets/lib/large/images/layers.png and /dev/null differ diff --git a/inst/htmlwidgets/lib/large/jquery.min.js b/inst/htmlwidgets/lib/large/jquery.min.js deleted file mode 100644 index ab28a2472..000000000 --- a/inst/htmlwidgets/lib/large/jquery.min.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! jQuery v1.11.1 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */ -!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l="1.11.1",m=function(a,b){return new m.fn.init(a,b)},n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,o=/^-ms-/,p=/-([\da-z])/gi,q=function(a,b){return b.toUpperCase()};m.fn=m.prototype={jquery:l,constructor:m,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=m.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return m.each(this,a,b)},map:function(a){return this.pushStack(m.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},m.extend=m.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||m.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(m.isPlainObject(c)||(b=m.isArray(c)))?(b?(b=!1,f=a&&m.isArray(a)?a:[]):f=a&&m.isPlainObject(a)?a:{},g[d]=m.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},m.extend({expando:"jQuery"+(l+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===m.type(a)},isArray:Array.isArray||function(a){return"array"===m.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return!m.isArray(a)&&a-parseFloat(a)>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==m.type(a)||a.nodeType||m.isWindow(a))return!1;try{if(a.constructor&&!j.call(a,"constructor")&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(k.ownLast)for(b in a)return j.call(a,b);for(b in a);return void 0===b||j.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(b){b&&m.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(o,"ms-").replace(p,q)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=r(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(n,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(r(Object(a))?m.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(g)return g.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=r(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(f=a[b],b=a,a=f),m.isFunction(a)?(c=d.call(arguments,2),e=function(){return a.apply(b||this,c.concat(d.call(arguments)))},e.guid=a.guid=a.guid||m.guid++,e):void 0},now:function(){return+new Date},support:k}),m.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function r(a){var b=a.length,c=m.type(a);return"function"===c||m.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var s=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+-new Date,v=a.document,w=0,x=0,y=gb(),z=gb(),A=gb(),B=function(a,b){return a===b&&(l=!0),0},C="undefined",D=1<<31,E={}.hasOwnProperty,F=[],G=F.pop,H=F.push,I=F.push,J=F.slice,K=F.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},L="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",N="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",O=N.replace("w","w#"),P="\\["+M+"*("+N+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+O+"))|)"+M+"*\\]",Q=":("+N+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+P+")*)|.*)\\)|)",R=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),S=new RegExp("^"+M+"*,"+M+"*"),T=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),U=new RegExp("="+M+"*([^\\]'\"]*?)"+M+"*\\]","g"),V=new RegExp(Q),W=new RegExp("^"+O+"$"),X={ID:new RegExp("^#("+N+")"),CLASS:new RegExp("^\\.("+N+")"),TAG:new RegExp("^("+N.replace("w","w*")+")"),ATTR:new RegExp("^"+P),PSEUDO:new RegExp("^"+Q),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+L+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ab=/[+~]/,bb=/'|\\/g,cb=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),db=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)};try{I.apply(F=J.call(v.childNodes),v.childNodes),F[v.childNodes.length].nodeType}catch(eb){I={apply:F.length?function(a,b){H.apply(a,J.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function fb(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],!a||"string"!=typeof a)return d;if(1!==(k=b.nodeType)&&9!==k)return[];if(p&&!e){if(f=_.exec(a))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return I.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName&&b.getElementsByClassName)return I.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=9===k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(bb,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+qb(o[l]);w=ab.test(a)&&ob(b.parentNode)||b,x=o.join(",")}if(x)try{return I.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function gb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function hb(a){return a[u]=!0,a}function ib(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function jb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function kb(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||D)-(~a.sourceIndex||D);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function lb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function mb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function nb(a){return hb(function(b){return b=+b,hb(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function ob(a){return a&&typeof a.getElementsByTagName!==C&&a}c=fb.support={},f=fb.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=fb.setDocument=function(a){var b,e=a?a.ownerDocument||a:v,g=e.defaultView;return e!==n&&9===e.nodeType&&e.documentElement?(n=e,o=e.documentElement,p=!f(e),g&&g!==g.top&&(g.addEventListener?g.addEventListener("unload",function(){m()},!1):g.attachEvent&&g.attachEvent("onunload",function(){m()})),c.attributes=ib(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ib(function(a){return a.appendChild(e.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(e.getElementsByClassName)&&ib(function(a){return a.innerHTML="
",a.firstChild.className="i",2===a.getElementsByClassName("i").length}),c.getById=ib(function(a){return o.appendChild(a).id=u,!e.getElementsByName||!e.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if(typeof b.getElementById!==C&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){var c=typeof a.getAttributeNode!==C&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return typeof b.getElementsByTagName!==C?b.getElementsByTagName(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return typeof b.getElementsByClassName!==C&&p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(e.querySelectorAll))&&(ib(function(a){a.innerHTML="",a.querySelectorAll("[msallowclip^='']").length&&q.push("[*^$]="+M+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+M+"*(?:value|"+L+")"),a.querySelectorAll(":checked").length||q.push(":checked")}),ib(function(a){var b=e.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+M+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ib(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",Q)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===e||a.ownerDocument===v&&t(v,a)?-1:b===e||b.ownerDocument===v&&t(v,b)?1:k?K.call(k,a)-K.call(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,f=a.parentNode,g=b.parentNode,h=[a],i=[b];if(!f||!g)return a===e?-1:b===e?1:f?-1:g?1:k?K.call(k,a)-K.call(k,b):0;if(f===g)return kb(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?kb(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},e):n},fb.matches=function(a,b){return fb(a,null,null,b)},fb.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return fb(b,n,null,[a]).length>0},fb.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},fb.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&E.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},fb.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},fb.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=fb.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=fb.selectors={cacheLength:50,createPseudo:hb,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(cb,db),a[3]=(a[3]||a[4]||a[5]||"").replace(cb,db),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||fb.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&fb.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(cb,db).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+M+")"+a+"("+M+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||typeof a.getAttribute!==C&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=fb.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||fb.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?hb(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=K.call(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:hb(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?hb(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:hb(function(a){return function(b){return fb(a,b).length>0}}),contains:hb(function(a){return function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:hb(function(a){return W.test(a||"")||fb.error("unsupported lang: "+a),a=a.replace(cb,db).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:nb(function(){return[0]}),last:nb(function(a,b){return[b-1]}),eq:nb(function(a,b,c){return[0>c?c+b:c]}),even:nb(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:nb(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:nb(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:nb(function(a,b,c){for(var d=0>c?c+b:c;++db;b++)d+=a[b].value;return d}function rb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function sb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function tb(a,b,c){for(var d=0,e=b.length;e>d;d++)fb(a,b[d],c);return c}function ub(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function vb(a,b,c,d,e,f){return d&&!d[u]&&(d=vb(d)),e&&!e[u]&&(e=vb(e,f)),hb(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||tb(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:ub(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=ub(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?K.call(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=ub(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):I.apply(g,r)})}function wb(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=rb(function(a){return a===b},h,!0),l=rb(function(a){return K.call(b,a)>-1},h,!0),m=[function(a,c,d){return!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d))}];f>i;i++)if(c=d.relative[a[i].type])m=[rb(sb(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return vb(i>1&&sb(m),i>1&&qb(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&wb(a.slice(i,e)),f>e&&wb(a=a.slice(e)),f>e&&qb(a))}m.push(c)}return sb(m)}function xb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=G.call(i));s=ub(s)}I.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&fb.uniqueSort(i)}return k&&(w=v,j=t),r};return c?hb(f):f}return h=fb.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=wb(b[c]),f[u]?d.push(f):e.push(f);f=A(a,xb(e,d)),f.selector=a}return f},i=fb.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(cb,db),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(cb,db),ab.test(j[0].type)&&ob(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&qb(j),!a)return I.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,ab.test(a)&&ob(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ib(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ib(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||jb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ib(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||jb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ib(function(a){return null==a.getAttribute("disabled")})||jb(L,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),fb}(a);m.find=s,m.expr=s.selectors,m.expr[":"]=m.expr.pseudos,m.unique=s.uniqueSort,m.text=s.getText,m.isXMLDoc=s.isXML,m.contains=s.contains;var t=m.expr.match.needsContext,u=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,v=/^.[^:#\[\.,]*$/;function w(a,b,c){if(m.isFunction(b))return m.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return m.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(v.test(b))return m.filter(b,a,c);b=m.filter(b,a)}return m.grep(a,function(a){return m.inArray(a,b)>=0!==c})}m.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?m.find.matchesSelector(d,a)?[d]:[]:m.find.matches(a,m.grep(b,function(a){return 1===a.nodeType}))},m.fn.extend({find:function(a){var b,c=[],d=this,e=d.length;if("string"!=typeof a)return this.pushStack(m(a).filter(function(){for(b=0;e>b;b++)if(m.contains(d[b],this))return!0}));for(b=0;e>b;b++)m.find(a,d[b],c);return c=this.pushStack(e>1?m.unique(c):c),c.selector=this.selector?this.selector+" "+a:a,c},filter:function(a){return this.pushStack(w(this,a||[],!1))},not:function(a){return this.pushStack(w(this,a||[],!0))},is:function(a){return!!w(this,"string"==typeof a&&t.test(a)?m(a):a||[],!1).length}});var x,y=a.document,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=m.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a.charAt(0)&&">"===a.charAt(a.length-1)&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||x).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof m?b[0]:b,m.merge(this,m.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:y,!0)),u.test(c[1])&&m.isPlainObject(b))for(c in b)m.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}if(d=y.getElementById(c[2]),d&&d.parentNode){if(d.id!==c[2])return x.find(a);this.length=1,this[0]=d}return this.context=y,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):m.isFunction(a)?"undefined"!=typeof x.ready?x.ready(a):a(m):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),m.makeArray(a,this))};A.prototype=m.fn,x=m(y);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};m.extend({dir:function(a,b,c){var d=[],e=a[b];while(e&&9!==e.nodeType&&(void 0===c||1!==e.nodeType||!m(e).is(c)))1===e.nodeType&&d.push(e),e=e[b];return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),m.fn.extend({has:function(a){var b,c=m(a,this),d=c.length;return this.filter(function(){for(b=0;d>b;b++)if(m.contains(this,c[b]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=t.test(a)||"string"!=typeof a?m(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&m.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?m.unique(f):f)},index:function(a){return a?"string"==typeof a?m.inArray(this[0],m(a)):m.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(m.unique(m.merge(this.get(),m(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){do a=a[b];while(a&&1!==a.nodeType);return a}m.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return m.dir(a,"parentNode")},parentsUntil:function(a,b,c){return m.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return m.dir(a,"nextSibling")},prevAll:function(a){return m.dir(a,"previousSibling")},nextUntil:function(a,b,c){return m.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return m.dir(a,"previousSibling",c)},siblings:function(a){return m.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return m.sibling(a.firstChild)},contents:function(a){return m.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:m.merge([],a.childNodes)}},function(a,b){m.fn[a]=function(c,d){var e=m.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=m.filter(d,e)),this.length>1&&(C[a]||(e=m.unique(e)),B.test(a)&&(e=e.reverse())),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return m.each(a.match(E)||[],function(a,c){b[c]=!0}),b}m.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):m.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(c=a.memory&&l,d=!0,f=g||0,g=0,e=h.length,b=!0;h&&e>f;f++)if(h[f].apply(l[0],l[1])===!1&&a.stopOnFalse){c=!1;break}b=!1,h&&(i?i.length&&j(i.shift()):c?h=[]:k.disable())},k={add:function(){if(h){var d=h.length;!function f(b){m.each(b,function(b,c){var d=m.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&f(c)})}(arguments),b?e=h.length:c&&(g=d,j(c))}return this},remove:function(){return h&&m.each(arguments,function(a,c){var d;while((d=m.inArray(c,h,d))>-1)h.splice(d,1),b&&(e>=d&&e--,f>=d&&f--)}),this},has:function(a){return a?m.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],e=0,this},disable:function(){return h=i=c=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,c||k.disable(),this},locked:function(){return!i},fireWith:function(a,c){return!h||d&&!i||(c=c||[],c=[a,c.slice?c.slice():c],b?i.push(c):j(c)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!d}};return k},m.extend({Deferred:function(a){var b=[["resolve","done",m.Callbacks("once memory"),"resolved"],["reject","fail",m.Callbacks("once memory"),"rejected"],["notify","progress",m.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return m.Deferred(function(c){m.each(b,function(b,f){var g=m.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&m.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?m.extend(a,d):d}},e={};return d.pipe=d.then,m.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&m.isFunction(a.promise)?e:0,g=1===f?a:m.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&m.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;m.fn.ready=function(a){return m.ready.promise().done(a),this},m.extend({isReady:!1,readyWait:1,holdReady:function(a){a?m.readyWait++:m.ready(!0)},ready:function(a){if(a===!0?!--m.readyWait:!m.isReady){if(!y.body)return setTimeout(m.ready);m.isReady=!0,a!==!0&&--m.readyWait>0||(H.resolveWith(y,[m]),m.fn.triggerHandler&&(m(y).triggerHandler("ready"),m(y).off("ready")))}}});function I(){y.addEventListener?(y.removeEventListener("DOMContentLoaded",J,!1),a.removeEventListener("load",J,!1)):(y.detachEvent("onreadystatechange",J),a.detachEvent("onload",J))}function J(){(y.addEventListener||"load"===event.type||"complete"===y.readyState)&&(I(),m.ready())}m.ready.promise=function(b){if(!H)if(H=m.Deferred(),"complete"===y.readyState)setTimeout(m.ready);else if(y.addEventListener)y.addEventListener("DOMContentLoaded",J,!1),a.addEventListener("load",J,!1);else{y.attachEvent("onreadystatechange",J),a.attachEvent("onload",J);var c=!1;try{c=null==a.frameElement&&y.documentElement}catch(d){}c&&c.doScroll&&!function e(){if(!m.isReady){try{c.doScroll("left")}catch(a){return setTimeout(e,50)}I(),m.ready()}}()}return H.promise(b)};var K="undefined",L;for(L in m(k))break;k.ownLast="0"!==L,k.inlineBlockNeedsLayout=!1,m(function(){var a,b,c,d;c=y.getElementsByTagName("body")[0],c&&c.style&&(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),typeof b.style.zoom!==K&&(b.style.cssText="display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1",k.inlineBlockNeedsLayout=a=3===b.offsetWidth,a&&(c.style.zoom=1)),c.removeChild(d))}),function(){var a=y.createElement("div");if(null==k.deleteExpando){k.deleteExpando=!0;try{delete a.test}catch(b){k.deleteExpando=!1}}a=null}(),m.acceptData=function(a){var b=m.noData[(a.nodeName+" ").toLowerCase()],c=+a.nodeType||1;return 1!==c&&9!==c?!1:!b||b!==!0&&a.getAttribute("classid")===b};var M=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,N=/([A-Z])/g;function O(a,b,c){if(void 0===c&&1===a.nodeType){var d="data-"+b.replace(N,"-$1").toLowerCase();if(c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:M.test(c)?m.parseJSON(c):c}catch(e){}m.data(a,b,c)}else c=void 0}return c}function P(a){var b;for(b in a)if(("data"!==b||!m.isEmptyObject(a[b]))&&"toJSON"!==b)return!1;return!0}function Q(a,b,d,e){if(m.acceptData(a)){var f,g,h=m.expando,i=a.nodeType,j=i?m.cache:a,k=i?a[h]:a[h]&&h; -if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||m.guid++:h),j[k]||(j[k]=i?{}:{toJSON:m.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=m.extend(j[k],b):j[k].data=m.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[m.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[m.camelCase(b)])):f=g,f}}function R(a,b,c){if(m.acceptData(a)){var d,e,f=a.nodeType,g=f?m.cache:a,h=f?a[m.expando]:m.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){m.isArray(b)?b=b.concat(m.map(b,m.camelCase)):b in d?b=[b]:(b=m.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!P(d):!m.isEmptyObject(d))return}(c||(delete g[h].data,P(g[h])))&&(f?m.cleanData([a],!0):k.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}m.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?m.cache[a[m.expando]]:a[m.expando],!!a&&!P(a)},data:function(a,b,c){return Q(a,b,c)},removeData:function(a,b){return R(a,b)},_data:function(a,b,c){return Q(a,b,c,!0)},_removeData:function(a,b){return R(a,b,!0)}}),m.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=m.data(f),1===f.nodeType&&!m._data(f,"parsedAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=m.camelCase(d.slice(5)),O(f,d,e[d])));m._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){m.data(this,a)}):arguments.length>1?this.each(function(){m.data(this,a,b)}):f?O(f,a,m.data(f,a)):void 0},removeData:function(a){return this.each(function(){m.removeData(this,a)})}}),m.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=m._data(a,b),c&&(!d||m.isArray(c)?d=m._data(a,b,m.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=m.queue(a,b),d=c.length,e=c.shift(),f=m._queueHooks(a,b),g=function(){m.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return m._data(a,c)||m._data(a,c,{empty:m.Callbacks("once memory").add(function(){m._removeData(a,b+"queue"),m._removeData(a,c)})})}}),m.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.lengthh;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},W=/^(?:checkbox|radio)$/i;!function(){var a=y.createElement("input"),b=y.createElement("div"),c=y.createDocumentFragment();if(b.innerHTML="
a",k.leadingWhitespace=3===b.firstChild.nodeType,k.tbody=!b.getElementsByTagName("tbody").length,k.htmlSerialize=!!b.getElementsByTagName("link").length,k.html5Clone="<:nav>"!==y.createElement("nav").cloneNode(!0).outerHTML,a.type="checkbox",a.checked=!0,c.appendChild(a),k.appendChecked=a.checked,b.innerHTML="",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue,c.appendChild(b),b.innerHTML="",k.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,k.noCloneEvent=!0,b.attachEvent&&(b.attachEvent("onclick",function(){k.noCloneEvent=!1}),b.cloneNode(!0).click()),null==k.deleteExpando){k.deleteExpando=!0;try{delete b.test}catch(d){k.deleteExpando=!1}}}(),function(){var b,c,d=y.createElement("div");for(b in{submit:!0,change:!0,focusin:!0})c="on"+b,(k[b+"Bubbles"]=c in a)||(d.setAttribute(c,"t"),k[b+"Bubbles"]=d.attributes[c].expando===!1);d=null}();var X=/^(?:input|select|textarea)$/i,Y=/^key/,Z=/^(?:mouse|pointer|contextmenu)|click/,$=/^(?:focusinfocus|focusoutblur)$/,_=/^([^.]*)(?:\.(.+)|)$/;function ab(){return!0}function bb(){return!1}function cb(){try{return y.activeElement}catch(a){}}m.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m._data(a);if(r){c.handler&&(i=c,c=i.handler,e=i.selector),c.guid||(c.guid=m.guid++),(g=r.events)||(g=r.events={}),(k=r.handle)||(k=r.handle=function(a){return typeof m===K||a&&m.event.triggered===a.type?void 0:m.event.dispatch.apply(k.elem,arguments)},k.elem=a),b=(b||"").match(E)||[""],h=b.length;while(h--)f=_.exec(b[h])||[],o=q=f[1],p=(f[2]||"").split(".").sort(),o&&(j=m.event.special[o]||{},o=(e?j.delegateType:j.bindType)||o,j=m.event.special[o]||{},l=m.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&m.expr.match.needsContext.test(e),namespace:p.join(".")},i),(n=g[o])||(n=g[o]=[],n.delegateCount=0,j.setup&&j.setup.call(a,d,p,k)!==!1||(a.addEventListener?a.addEventListener(o,k,!1):a.attachEvent&&a.attachEvent("on"+o,k))),j.add&&(j.add.call(a,l),l.handler.guid||(l.handler.guid=c.guid)),e?n.splice(n.delegateCount++,0,l):n.push(l),m.event.global[o]=!0);a=null}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m.hasData(a)&&m._data(a);if(r&&(k=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=_.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=m.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,n=k[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),i=f=n.length;while(f--)g=n[f],!e&&q!==g.origType||c&&c.guid!==g.guid||h&&!h.test(g.namespace)||d&&d!==g.selector&&("**"!==d||!g.selector)||(n.splice(f,1),g.selector&&n.delegateCount--,l.remove&&l.remove.call(a,g));i&&!n.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||m.removeEvent(a,o,r.handle),delete k[o])}else for(o in k)m.event.remove(a,o+b[j],c,d,!0);m.isEmptyObject(k)&&(delete r.handle,m._removeData(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,l,n,o=[d||y],p=j.call(b,"type")?b.type:b,q=j.call(b,"namespace")?b.namespace.split("."):[];if(h=l=d=d||y,3!==d.nodeType&&8!==d.nodeType&&!$.test(p+m.event.triggered)&&(p.indexOf(".")>=0&&(q=p.split("."),p=q.shift(),q.sort()),g=p.indexOf(":")<0&&"on"+p,b=b[m.expando]?b:new m.Event(p,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=q.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:m.makeArray(c,[b]),k=m.event.special[p]||{},e||!k.trigger||k.trigger.apply(d,c)!==!1)){if(!e&&!k.noBubble&&!m.isWindow(d)){for(i=k.delegateType||p,$.test(i+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),l=h;l===(d.ownerDocument||y)&&o.push(l.defaultView||l.parentWindow||a)}n=0;while((h=o[n++])&&!b.isPropagationStopped())b.type=n>1?i:k.bindType||p,f=(m._data(h,"events")||{})[b.type]&&m._data(h,"handle"),f&&f.apply(h,c),f=g&&h[g],f&&f.apply&&m.acceptData(h)&&(b.result=f.apply(h,c),b.result===!1&&b.preventDefault());if(b.type=p,!e&&!b.isDefaultPrevented()&&(!k._default||k._default.apply(o.pop(),c)===!1)&&m.acceptData(d)&&g&&d[p]&&!m.isWindow(d)){l=d[g],l&&(d[g]=null),m.event.triggered=p;try{d[p]()}catch(r){}m.event.triggered=void 0,l&&(d[g]=l)}return b.result}},dispatch:function(a){a=m.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(m._data(this,"events")||{})[a.type]||[],k=m.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=m.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,g=0;while((e=f.handlers[g++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(e.namespace))&&(a.handleObj=e,a.data=e.data,c=((m.event.special[e.origType]||{}).handle||e.handler).apply(f.elem,i),void 0!==c&&(a.result=c)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!=this;i=i.parentNode||this)if(1===i.nodeType&&(i.disabled!==!0||"click"!==a.type)){for(e=[],f=0;h>f;f++)d=b[f],c=d.selector+" ",void 0===e[c]&&(e[c]=d.needsContext?m(c,this).index(i)>=0:m.find(c,this,null,[i]).length),e[c]&&e.push(d);e.length&&g.push({elem:i,handlers:e})}return h]","i"),hb=/^\s+/,ib=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,jb=/<([\w:]+)/,kb=/\s*$/g,rb={option:[1,""],legend:[1,"
","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],_default:k.htmlSerialize?[0,"",""]:[1,"X
","
"]},sb=db(y),tb=sb.appendChild(y.createElement("div"));rb.optgroup=rb.option,rb.tbody=rb.tfoot=rb.colgroup=rb.caption=rb.thead,rb.th=rb.td;function ub(a,b){var c,d,e=0,f=typeof a.getElementsByTagName!==K?a.getElementsByTagName(b||"*"):typeof a.querySelectorAll!==K?a.querySelectorAll(b||"*"):void 0;if(!f)for(f=[],c=a.childNodes||a;null!=(d=c[e]);e++)!b||m.nodeName(d,b)?f.push(d):m.merge(f,ub(d,b));return void 0===b||b&&m.nodeName(a,b)?m.merge([a],f):f}function vb(a){W.test(a.type)&&(a.defaultChecked=a.checked)}function wb(a,b){return m.nodeName(a,"table")&&m.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function xb(a){return a.type=(null!==m.find.attr(a,"type"))+"/"+a.type,a}function yb(a){var b=pb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function zb(a,b){for(var c,d=0;null!=(c=a[d]);d++)m._data(c,"globalEval",!b||m._data(b[d],"globalEval"))}function Ab(a,b){if(1===b.nodeType&&m.hasData(a)){var c,d,e,f=m._data(a),g=m._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;e>d;d++)m.event.add(b,c,h[c][d])}g.data&&(g.data=m.extend({},g.data))}}function Bb(a,b){var c,d,e;if(1===b.nodeType){if(c=b.nodeName.toLowerCase(),!k.noCloneEvent&&b[m.expando]){e=m._data(b);for(d in e.events)m.removeEvent(b,d,e.handle);b.removeAttribute(m.expando)}"script"===c&&b.text!==a.text?(xb(b).text=a.text,yb(b)):"object"===c?(b.parentNode&&(b.outerHTML=a.outerHTML),k.html5Clone&&a.innerHTML&&!m.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):"input"===c&&W.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):"option"===c?b.defaultSelected=b.selected=a.defaultSelected:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}}m.extend({clone:function(a,b,c){var d,e,f,g,h,i=m.contains(a.ownerDocument,a);if(k.html5Clone||m.isXMLDoc(a)||!gb.test("<"+a.nodeName+">")?f=a.cloneNode(!0):(tb.innerHTML=a.outerHTML,tb.removeChild(f=tb.firstChild)),!(k.noCloneEvent&&k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||m.isXMLDoc(a)))for(d=ub(f),h=ub(a),g=0;null!=(e=h[g]);++g)d[g]&&Bb(e,d[g]);if(b)if(c)for(h=h||ub(a),d=d||ub(f),g=0;null!=(e=h[g]);g++)Ab(e,d[g]);else Ab(a,f);return d=ub(f,"script"),d.length>0&&zb(d,!i&&ub(a,"script")),d=h=e=null,f},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,l,n=a.length,o=db(b),p=[],q=0;n>q;q++)if(f=a[q],f||0===f)if("object"===m.type(f))m.merge(p,f.nodeType?[f]:f);else if(lb.test(f)){h=h||o.appendChild(b.createElement("div")),i=(jb.exec(f)||["",""])[1].toLowerCase(),l=rb[i]||rb._default,h.innerHTML=l[1]+f.replace(ib,"<$1>")+l[2],e=l[0];while(e--)h=h.lastChild;if(!k.leadingWhitespace&&hb.test(f)&&p.push(b.createTextNode(hb.exec(f)[0])),!k.tbody){f="table"!==i||kb.test(f)?""!==l[1]||kb.test(f)?0:h:h.firstChild,e=f&&f.childNodes.length;while(e--)m.nodeName(j=f.childNodes[e],"tbody")&&!j.childNodes.length&&f.removeChild(j)}m.merge(p,h.childNodes),h.textContent="";while(h.firstChild)h.removeChild(h.firstChild);h=o.lastChild}else p.push(b.createTextNode(f));h&&o.removeChild(h),k.appendChecked||m.grep(ub(p,"input"),vb),q=0;while(f=p[q++])if((!d||-1===m.inArray(f,d))&&(g=m.contains(f.ownerDocument,f),h=ub(o.appendChild(f),"script"),g&&zb(h),c)){e=0;while(f=h[e++])ob.test(f.type||"")&&c.push(f)}return h=null,o},cleanData:function(a,b){for(var d,e,f,g,h=0,i=m.expando,j=m.cache,l=k.deleteExpando,n=m.event.special;null!=(d=a[h]);h++)if((b||m.acceptData(d))&&(f=d[i],g=f&&j[f])){if(g.events)for(e in g.events)n[e]?m.event.remove(d,e):m.removeEvent(d,e,g.handle);j[f]&&(delete j[f],l?delete d[i]:typeof d.removeAttribute!==K?d.removeAttribute(i):d[i]=null,c.push(f))}}}),m.fn.extend({text:function(a){return V(this,function(a){return void 0===a?m.text(this):this.empty().append((this[0]&&this[0].ownerDocument||y).createTextNode(a))},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?m.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||m.cleanData(ub(c)),c.parentNode&&(b&&m.contains(c.ownerDocument,c)&&zb(ub(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++){1===a.nodeType&&m.cleanData(ub(a,!1));while(a.firstChild)a.removeChild(a.firstChild);a.options&&m.nodeName(a,"select")&&(a.options.length=0)}return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return m.clone(this,a,b)})},html:function(a){return V(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a)return 1===b.nodeType?b.innerHTML.replace(fb,""):void 0;if(!("string"!=typeof a||mb.test(a)||!k.htmlSerialize&&gb.test(a)||!k.leadingWhitespace&&hb.test(a)||rb[(jb.exec(a)||["",""])[1].toLowerCase()])){a=a.replace(ib,"<$1>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(m.cleanData(ub(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,m.cleanData(ub(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,n=this,o=l-1,p=a[0],q=m.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&nb.test(p))return this.each(function(c){var d=n.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(i=m.buildFragment(a,this[0].ownerDocument,!1,this),c=i.firstChild,1===i.childNodes.length&&(i=c),c)){for(g=m.map(ub(i,"script"),xb),f=g.length;l>j;j++)d=i,j!==o&&(d=m.clone(d,!0,!0),f&&m.merge(g,ub(d,"script"))),b.call(this[j],d,j);if(f)for(h=g[g.length-1].ownerDocument,m.map(g,yb),j=0;f>j;j++)d=g[j],ob.test(d.type||"")&&!m._data(d,"globalEval")&&m.contains(h,d)&&(d.src?m._evalUrl&&m._evalUrl(d.src):m.globalEval((d.text||d.textContent||d.innerHTML||"").replace(qb,"")));i=c=null}return this}}),m.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){m.fn[a]=function(a){for(var c,d=0,e=[],g=m(a),h=g.length-1;h>=d;d++)c=d===h?this:this.clone(!0),m(g[d])[b](c),f.apply(e,c.get());return this.pushStack(e)}});var Cb,Db={};function Eb(b,c){var d,e=m(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:m.css(e[0],"display");return e.detach(),f}function Fb(a){var b=y,c=Db[a];return c||(c=Eb(a,b),"none"!==c&&c||(Cb=(Cb||m("