| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- #' 'qgisprocess' funktsiooonides GPKG INPUT/OUTPUT konstrueerimine GPKG kujule salvestamiseks
- #'
- #' See funktsioon konstrueerib 'qgisprocess' funktsioonides enamasti INPUT/OUTPUT/OVERLAY parameetri argumentide kasutatava fraasi, mis on vajalik postgresql andmebaasiga ühendamiseks.
- #' @param conf A list() of configuration variables. Default values \code{\link[ruut]{get_config}}.
- #' @param geometry_field str A geometri field name. Default: "geom".
- #' @param is_input_str TRUE/FALSE kui tulemusena väljastatakse import, siis TRUE.
- #' @seealso [ruut::db_connect()], [ruut::get_config()], [ruut::construct_ogr2ogr_PG_connect_str()], [ruut::construct_qgis_output_result_to_better_format()],[ruut::construct_to_gpkg_output_file_str()]
- #' @return A string OUTPUT: "ogr:dbname='/data/gpkg/artiklid/artikkel_210127_valga_matsalu_lahemaa/test.gpkg' table=\"uus_epk200t_bb\"", INPUT: "/data/gpkg/artiklid/artikkel_210127_valga_matsalu_lahemaa/test.gpkg|layername=uus_epk200t_bb".
- #' @keywords qgis_process
- #' @export
- #' @examples
- #' \dontrun{
- #'
- #' conf <- ruut::get_config()
- #' conf$gpkg_home <- "/data/gpkg/artiklid/artikkel_210127_valga_matsalu_lahemaa"
- #' conf$gpkg_file <- "matsalu"
- #' conf$gpkg_table <- "piir"
- #' input <- ruut::construct_to_gpkg_output_file_str(
- #' conf = conf, is_input_str = TRUE
- #' )
- #' conf$gpkg_home <- "/data/gpkg/artiklid/artikkel_210127_valga_matsalu_lahemaa"
- #' conf$gpkg_file <- "mooduli_ruut_test"
- #' conf$gpkg_table <- "layerOne"
- #' output <- ruut::construct_to_gpkg_output_file_str(
- #' conf = conf, geometry_field = "geom", is_input_str = FALSE
- #' )
- #'
- #' str <- paste0("{ 'DISSOLVE' : False, 'DISTANCE' : 100, 'END_CAP_STYLE' : 2,
- #' 'INPUT' : '", input, "', 'JOIN_STYLE' : 1, 'MITER_LIMIT' : 2,
- #' 'OUTPUT' : '", output, "', 'SEGMENTS' : 5 }")
- #' algorithm <- "native:buffer"
- #' cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
- #' system(cmd)
- #' }
- construct_to_gpkg_output_file_str <- function(conf = NULL, geometry_field = "geom", is_input_str = TRUE) {
- if (is.null(conf)) conf <- ruut::get_config()
- dsn <- sprintf("%s/%s.gpkg", conf$gpkg_home, conf$gpkg_file)
- if (is_input_str) {
- input <- sprintf("%s|layername=%s", dsn, conf$gpkg_table)
- input
- }
- else {
- ogr <- sprintf("ogr:dbname='%s'", dsn)
- output <- sprintf('%s table=\"%s\" (%s)', ogr, conf$gpkg_table, geometry_field)
- output
- }
- }
|