R/qgis_printlayoutmapextenttolayer.R

Defines functions qgis_printlayoutmapextenttolayer

Documented in qgis_printlayoutmapextenttolayer

##' QGIS Algorithm provided by QGIS (native c++) Print layout map extent to layer (native:printlayoutmapextenttolayer). Creates a polygon layer containing the extent of a print layout map item. This algorithm creates a polygon layer containing the extent of a print layout map item (or items), with attributes specifying the map size (in layout units), scale and rotation.  If the map item parameter is specified, then only the matching map extent will be exported. If it is not specified, all map extents from the layout will be exported.  Optionally, a specific output CRS can be specified. If it is not specified, the original map item CRS will be used.
##'
##' @title QGIS algorithm - Print layout map extent to layer
##'
##' @param LAYOUT `layout` - Print layout. Name of print layout in current project.
##' @param MAP `layoutitem` - Map item. UUID or item id of layout item.
##' @param CRS `crs` - Override CRS. CRS as an auth ID (e.g. 'EPSG:3111'). CRS as a PROJ4 string (e.g. 'PROJ4:…'). CRS as a WKT string (e.g. 'WKT:…'). Path to a layer. The CRS of the layer is used..
##' @param OUTPUT `sink` - Extent. Path for new vector layer.
##' @param ... further parameters passed to `qgisprocess::qgis_run_algorithm()`
##' @param .complete_output logical specifying if complete out of `qgisprocess::qgis_run_algorithm()` should be used (`TRUE`) or first output (most likely the main) should read (`FALSE`). Default value is `TRUE`.
##' @param .quiet logical specifying if parameter `.quiet` for `qgisprocess::qgis_run_algorithm()` Default value is `TRUE`.
##' @param .messages logical specifying if messages from `qgisprocess::qgis_run_algorithm()` should be printed (`TRUE`) or not (`FALSE`). Default value is `FALSE`.
##'
##' @details
##' ## Outputs description
##' * HEIGHT - outputNumber - Map height
##' * OUTPUT - outputVector - Extent
##' * ROTATION - outputNumber - Map rotation
##' * SCALE - outputNumber - Map scale
##' * WIDTH - outputNumber - Map width
##'
##'
##' @export
##' @md
##' @importFrom qgisprocess qgis_run_algorithm

qgis_printlayoutmapextenttolayer <- function(LAYOUT = qgisprocess:::qgis_default_value(), MAP = qgisprocess:::qgis_default_value(), CRS = qgisprocess:::qgis_default_value(), OUTPUT = qgisprocess:::qgis_default_value(),..., .complete_output = .complete_output_option(), .quiet = .quiet_option(), .messages = .message_option()) {

  check_algorithm_necessities("native:printlayoutmapextenttolayer")

  if (.messages){
    output <- qgisprocess::qgis_run_algorithm("native:printlayoutmapextenttolayer", `LAYOUT` = LAYOUT, `MAP` = MAP, `CRS` = CRS, `OUTPUT` = OUTPUT,..., .quiet = .quiet)
  } else {
    suppressMessages(
      output <- qgisprocess::qgis_run_algorithm("native:printlayoutmapextenttolayer", `LAYOUT` = LAYOUT, `MAP` = MAP, `CRS` = CRS, `OUTPUT` = OUTPUT,..., .quiet = .quiet)
      )
  }

  if (.complete_output) {
    return(output)
  }
  else{
    qgisprocess::qgis_extract_output(output, "HEIGHT")
  }
}
JanCaha/r_package_qgis documentation built on April 4, 2024, 8:10 p.m.