Przeglądaj źródła

Vahekoopia pärast 'beter' asendamist 'better'.

Ardo Kubjas 5 lat temu
rodzic
commit
ffd04b8f9c

+ 1 - 1
NAMESPACE

@@ -2,7 +2,7 @@
 
 
 export(cat_function)
 export(cat_function)
 export(construct_ogr2ogr_PG_connect_str)
 export(construct_ogr2ogr_PG_connect_str)
-export(construct_qgis_output_result_to_beter_format)
+export(construct_qgis_output_result_to_better_format)
 export(construct_to_gpkg_output_file_str)
 export(construct_to_gpkg_output_file_str)
 export(construct_to_gpkg_output_postgres_str)
 export(construct_to_gpkg_output_postgres_str)
 export(convert_sf2qgis)
 export(convert_sf2qgis)

+ 3 - 1
R/construct_qgis_output_result_to_better_format.R

@@ -28,7 +28,7 @@
 #' 'OUTPUT' : 'postgres://dbname=\'data\' host=localhost port=6432 user=\'osm\' password=\'osm\'
 #' 'OUTPUT' : 'postgres://dbname=\'data\' host=localhost port=6432 user=\'osm\' password=\'osm\'
 #' sslmode=disable table=\"data\".\"test22\" (geom)', 'SEGMENTS' : 5 }"
 #' sslmode=disable table=\"data\".\"test22\" (geom)', 'SEGMENTS' : 5 }"
 #'
 #'
-#' cmd <- ruut::construct_qgis_output_result_to_beter_format(str = str, algorithm = algorithm)
+#' cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
 #' system(cmd)
 #' system(cmd)
 #'
 #'
 #' }
 #' }
@@ -58,6 +58,8 @@ construct_qgis_output_result_to_better_format <- function(str = "", algorithm =
   str <- gsub("[]]", "", str)
   str <- gsub("[]]", "", str)
   # Asendame ="[]'
   # Asendame ="[]'
   str <- gsub("=\"([ a-zA-Z0-9_ ]*)'", "='\\1'", str)
   str <- gsub("=\"([ a-zA-Z0-9_ ]*)'", "='\\1'", str)
+  # Muutuja väärtuste ümbert 2-kordsed ülakomad asendada 1-kordsete ülakomadega
+  str <- gsub("=\\\\\"([a-zA-Z0-9_]*)\\\\\"", "='\\1'", str)
   cat(str)
   cat(str)
   str
   str
 }
 }

+ 2 - 2
R/construct_to_gpkg_output_file_str.R

@@ -4,7 +4,7 @@
 #' @param conf A list() of configuration variables. Default values \code{\link[ruut]{get_config}}.
 #' @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 geometry_field str A geometri field name. Default: "geom".
 #' @param is_input_str TRUE/FALSE kui tulemusena väljastatakse import, siis TRUE.
 #' @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_beter_format()],[ruut::construct_to_gpkg_output_file_str()]
+#' @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".
 #' @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
 #' @keywords qgis_process
 #' @export
 #' @export
@@ -29,7 +29,7 @@
 #' 'INPUT' : '", input, "', 'JOIN_STYLE' : 1, 'MITER_LIMIT' : 2,
 #' 'INPUT' : '", input, "', 'JOIN_STYLE' : 1, 'MITER_LIMIT' : 2,
 #' 'OUTPUT' : '", output, "', 'SEGMENTS' : 5 }")
 #' 'OUTPUT' : '", output, "', 'SEGMENTS' : 5 }")
 #' algorithm <- "native:buffer"
 #' algorithm <- "native:buffer"
-#' cmd <- ruut::construct_qgis_output_result_to_beter_format(str = str, algorithm = algorithm)
+#' cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
 #' system(cmd)
 #' system(cmd)
 #' }
 #' }
 construct_to_gpkg_output_file_str <- function(conf = NULL, geometry_field = "geom", is_input_str = TRUE) {
 construct_to_gpkg_output_file_str <- function(conf = NULL, geometry_field = "geom", is_input_str = TRUE) {

+ 3 - 3
R/construct_to_gpkg_output_postgres_str.R

@@ -7,9 +7,9 @@
 #' @param srid CRS Default: 3301. Other: 4326.
 #' @param srid CRS Default: 3301. Other: 4326.
 #' @param checkPrimaryKeyUnicity TRUE/FALSE.
 #' @param checkPrimaryKeyUnicity TRUE/FALSE.
 #' @param key str A primary key ID, usally 'id'.
 #' @param key str A primary key ID, usally 'id'.
-#' @seealso [ruut::db_connect()], [ruut::get_config()], [ruut::construct_ogr2ogr_PG_connect_str()], [ruut::construct_qgis_output_result_to_beter_format()],[ruut::construct_to_gpkg_output_file_str()]
+#' @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 "postgres://dbname='%s' host=%s port=%s user='%s' password='%s' sslmode=%s key='id' srid=3301  checkPrimaryKeyUnicity='1' table=\"%s\".\"%s\" (geom)".
 #' @return A string "postgres://dbname='%s' host=%s port=%s user='%s' password='%s' sslmode=%s key='id' srid=3301  checkPrimaryKeyUnicity='1' table=\"%s\".\"%s\" (geom)".
-#' @seealso [ruut::construct_ogr2ogr_PG_connect_str()], [ruut::construct_qgis_output_result_to_beter_format()]
+#' @seealso [ruut::construct_ogr2ogr_PG_connect_str()], [ruut::construct_qgis_output_result_to_better_format()]
 #' @keywords qgis_process
 #' @keywords qgis_process
 #' @export
 #' @export
 #' @examples
 #' @examples
@@ -34,7 +34,7 @@
 #' 'INPUT' : '", input, "', 'JOIN_STYLE' : 1, 'MITER_LIMIT' : 2,
 #' 'INPUT' : '", input, "', 'JOIN_STYLE' : 1, 'MITER_LIMIT' : 2,
 #' 'OUTPUT' : '", output, "', 'SEGMENTS' : 5 }")
 #' 'OUTPUT' : '", output, "', 'SEGMENTS' : 5 }")
 #' algorithm <- "native:buffer"
 #' algorithm <- "native:buffer"
-#' cmd <- ruut::construct_qgis_output_result_to_beter_format(str = str, algorithm = algorithm)
+#' cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
 #' system(cmd)
 #' system(cmd)
 #' }
 #' }
 construct_to_gpkg_output_postgres_str <- function(conf = NULL, geometry_field = "geom", geometry_type = NULL, srid = NULL, checkPrimaryKeyUnicity = FALSE, key = NULL) {
 construct_to_gpkg_output_postgres_str <- function(conf = NULL, geometry_field = "geom", geometry_type = NULL, srid = NULL, checkPrimaryKeyUnicity = FALSE, key = NULL) {

+ 6 - 24
R/gpkg_piirkonnale_polygoonide_lisamine.R

@@ -68,51 +68,33 @@ gpkg_piirkonnale_polygoonide_lisamine <- function(obj = NULL, gpkg_home = "/tmp"
       )
       )
       ## !!! Trikk: alguses leiame ühisosaga piirkonnad
       ## !!! Trikk: alguses leiame ühisosaga piirkonnad
       ## ------------------- QGIS: qgisprocess ----------------------
       ## ------------------- QGIS: qgisprocess ----------------------
-      str <- paste0("{ 'INPUT' : '", input, "', 'INTERSECT' : '", intersect_layer, "', 'OUTPUT' : '", tmp_gpkg_file_output, "', 'PREDICATE' : [0] }")
+      str <- paste0("{ 'INPUT' : '", input, "', 'INTERSECT' : '", intersect_layer, "', 'OUTPUT' : '", tmp_gpkg_file, "', 'PREDICATE' : [0] }")
       algorithm <- "native:extractbylocation"
       algorithm <- "native:extractbylocation"
       cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
       cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
       cat(sprintf("\n%s\n", cmd))
       cat(sprintf("\n%s\n", cmd))
       system(cmd)
       system(cmd)
       ## !!! Trikk jätkub: edasi leiame alles ühisosa
       ## !!! Trikk jätkub: edasi leiame alles ühisosa
-      str <- paste0("{ 'INPUT' : '", tmp_gpkg_file_input, "', 'OVERLAY' : '", intersect_layer, "', 'OUTPUT' : '", output, "', 'INPUT_FIELDS' : '', 'OVERLAY_FIELDS' : '', 'OVERLAY_FIELDS_PREFIX' : '' }")
-      str <- paste0("{ 'INPUT' : '", tmp_gpkg_file_input, "', 'INPUT_FIELDS' : ['id','osm_id','code','fclass','name'], 'OUTPUT' : '", output, "', 'OVERLAY' : '", intersect_layer, "', 'OVERLAY_FIELDS' : ['fid','id','left','top','right','bottom'], 'OVERLAY_FIELDS_PREFIX' : '' }")
+      str <- paste0("{ 'INPUT' : '", tmp_gpkg_file, "', 'OVERLAY' : '", intersect_layer, "', 'OUTPUT' : '", output, "', 'INPUT_FIELDS' : '', 'OVERLAY_FIELDS' : '', 'OVERLAY_FIELDS_PREFIX' : '' }")
+      str <- paste0("{ 'INPUT' : '", tmp_gpkg_file_input, "', 'INPUT_FIELDS' : [], 'OUTPUT' : '", output, "', 'OVERLAY' : '", intersect_layer, "', 'OVERLAY_FIELDS' : [], 'OVERLAY_FIELDS_PREFIX' : '' }")
       algorithm <- "native:intersection"
       algorithm <- "native:intersection"
       cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
       cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
       cat(sprintf("\n%s\n", cmd))
       cat(sprintf("\n%s\n", cmd))
       system(cmd)
       system(cmd)
-
-
-
       ## Filtreerime maakasutuse kihi 'landuse-a' eraldi alamkihtideks
       ## Filtreerime maakasutuse kihi 'landuse-a' eraldi alamkihtideks
       if (andmed$table[i] == "landuse_a") {
       if (andmed$table[i] == "landuse_a") {
         landuse_a <- unique(as.data.frame(sf::read_sf(dsn = dsn, layer = sprintf("%s_landuse_a", intersect), as_tibble = T))[, c("code", "fclass")])
         landuse_a <- unique(as.data.frame(sf::read_sf(dsn = dsn, layer = sprintf("%s_landuse_a", intersect), as_tibble = T))[, c("code", "fclass")])
         parent_table <- conf$gpkg_table
         parent_table <- conf$gpkg_table
         for (k in 1:nrow(landuse_a)) {
         for (k in 1:nrow(landuse_a)) {
           table_suffix <- landuse_a$fclass[k]
           table_suffix <- landuse_a$fclass[k]
-          conf$gpkg_table <- sprintf("%s_%s", parent_table, table_suffix)
+          conf$gpkg_table <- parent_table
           input <- ruut::construct_to_gpkg_output_file_str(conf = conf, is_input_str = TRUE)
           input <- ruut::construct_to_gpkg_output_file_str(conf = conf, is_input_str = TRUE)
-          sprintf("%s_%s",conf$gpkg_table, table_suffix)
+          conf$gpkg_table <- sprintf("%s_%s",conf$gpkg_table, table_suffix)
           output <- ruut::construct_to_gpkg_output_file_str(conf = conf, is_input_str = FALSE)
           output <- ruut::construct_to_gpkg_output_file_str(conf = conf, is_input_str = FALSE)
-          str <- paste0("{ 'INPUT' : '", input, "', 'INTERSECT' : '", intersect_layer, "', 'OUTPUT' : '", tmp_gpkg_file, "', FIELD : 'code', OPERATOR : 0, VALUE : '", landuse_a$code[k], "' }")
+          str <- paste0("{ 'INPUT' : '", input, "', 'INTERSECT' : '", intersect_layer, "', 'OUTPUT' : '", output, "', FIELD : 'code', OPERATOR : 0, VALUE : '", landuse_a$code[k], "' }")
           algorithm <- "native:extractbyattribute"
           algorithm <- "native:extractbyattribute"
           cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
           cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
           cat(sprintf("\n%s\n", cmd))
           cat(sprintf("\n%s\n", cmd))
           system(cmd)
           system(cmd)
-
-
-
-
-
-          result <- qgisprocess::qgis_run_algorithm(
-            algorithm = "native:extractbyattribute",
-            FIELD = "code",
-            OPERATOR = 0, # 0 s.o '='
-            VALUE = landuse_a$code[k],
-            INPUT = sprintf("%s|layername=%s_%s", dsn, intersect, andmed$table[i]),
-            OUTPUT = output,
-            FAIL_OUTPUT = qgisprocess::qgis_tmp_vector()
-            # .quiet = TRUE
-          )
         }
         }
       }
       }
     }
     }

+ 5 - 5
man/construct_qgis_output_result_to_beter_format.Rd → man/construct_qgis_output_result_to_better_format.Rd

@@ -1,10 +1,10 @@
 % Generated by roxygen2: do not edit by hand
 % Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/construct_qgis_output_result_to_beter_format.R
-\name{construct_qgis_output_result_to_beter_format}
-\alias{construct_qgis_output_result_to_beter_format}
+% Please edit documentation in R/construct_qgis_output_result_to_better_format.R
+\name{construct_qgis_output_result_to_better_format}
+\alias{construct_qgis_output_result_to_better_format}
 \title{QGIS-i funktsiooni väljundist uue sisendiks vajaliku fraasi konstrueerimine}
 \title{QGIS-i funktsiooni väljundist uue sisendiks vajaliku fraasi konstrueerimine}
 \usage{
 \usage{
-construct_qgis_output_result_to_beter_format(
+construct_qgis_output_result_to_better_format(
   str = "",
   str = "",
   algorithm = "xxxxxxxxxx"
   algorithm = "xxxxxxxxxx"
 )
 )
@@ -43,7 +43,7 @@ str <- "{ 'DISSOLVE' : False, 'DISTANCE' : 100, 'END_CAP_STYLE' : 2,
 'OUTPUT' : 'postgres://dbname=\'data\' host=localhost port=6432 user=\'osm\' password=\'osm\'
 'OUTPUT' : 'postgres://dbname=\'data\' host=localhost port=6432 user=\'osm\' password=\'osm\'
 sslmode=disable table=\"data\".\"test22\" (geom)', 'SEGMENTS' : 5 }"
 sslmode=disable table=\"data\".\"test22\" (geom)', 'SEGMENTS' : 5 }"
 
 
-cmd <- ruut::construct_qgis_output_result_to_beter_format(str = str, algorithm = algorithm)
+cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
 system(cmd)
 system(cmd)
 
 
 }
 }

+ 2 - 2
man/construct_to_gpkg_output_file_str.Rd

@@ -44,11 +44,11 @@ str <- paste0("{ 'DISSOLVE' : False, 'DISTANCE' : 100, 'END_CAP_STYLE' : 2,
 'INPUT' : '", input, "', 'JOIN_STYLE' : 1, 'MITER_LIMIT' : 2,
 'INPUT' : '", input, "', 'JOIN_STYLE' : 1, 'MITER_LIMIT' : 2,
 'OUTPUT' : '", output, "', 'SEGMENTS' : 5 }")
 'OUTPUT' : '", output, "', 'SEGMENTS' : 5 }")
 algorithm <- "native:buffer"
 algorithm <- "native:buffer"
-cmd <- ruut::construct_qgis_output_result_to_beter_format(str = str, algorithm = algorithm)
+cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
 system(cmd)
 system(cmd)
 }
 }
 }
 }
 \seealso{
 \seealso{
-\code{\link[=db_connect]{db_connect()}}, \code{\link[=get_config]{get_config()}}, \code{\link[=construct_ogr2ogr_PG_connect_str]{construct_ogr2ogr_PG_connect_str()}}, \code{\link[=construct_qgis_output_result_to_beter_format]{construct_qgis_output_result_to_beter_format()}},\code{\link[=construct_to_gpkg_output_file_str]{construct_to_gpkg_output_file_str()}}
+\code{\link[=db_connect]{db_connect()}}, \code{\link[=get_config]{get_config()}}, \code{\link[=construct_ogr2ogr_PG_connect_str]{construct_ogr2ogr_PG_connect_str()}}, \code{\link[=construct_qgis_output_result_to_better_format]{construct_qgis_output_result_to_better_format()}},\code{\link[=construct_to_gpkg_output_file_str]{construct_to_gpkg_output_file_str()}}
 }
 }
 \keyword{qgis_process}
 \keyword{qgis_process}

+ 3 - 3
man/construct_to_gpkg_output_postgres_str.Rd

@@ -54,13 +54,13 @@ str <- paste0("{ 'DISSOLVE' : False, 'DISTANCE' : 100, 'END_CAP_STYLE' : 2,
 'INPUT' : '", input, "', 'JOIN_STYLE' : 1, 'MITER_LIMIT' : 2,
 'INPUT' : '", input, "', 'JOIN_STYLE' : 1, 'MITER_LIMIT' : 2,
 'OUTPUT' : '", output, "', 'SEGMENTS' : 5 }")
 'OUTPUT' : '", output, "', 'SEGMENTS' : 5 }")
 algorithm <- "native:buffer"
 algorithm <- "native:buffer"
-cmd <- ruut::construct_qgis_output_result_to_beter_format(str = str, algorithm = algorithm)
+cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
 system(cmd)
 system(cmd)
 }
 }
 }
 }
 \seealso{
 \seealso{
-\code{\link[=db_connect]{db_connect()}}, \code{\link[=get_config]{get_config()}}, \code{\link[=construct_ogr2ogr_PG_connect_str]{construct_ogr2ogr_PG_connect_str()}}, \code{\link[=construct_qgis_output_result_to_beter_format]{construct_qgis_output_result_to_beter_format()}},\code{\link[=construct_to_gpkg_output_file_str]{construct_to_gpkg_output_file_str()}}
+\code{\link[=db_connect]{db_connect()}}, \code{\link[=get_config]{get_config()}}, \code{\link[=construct_ogr2ogr_PG_connect_str]{construct_ogr2ogr_PG_connect_str()}}, \code{\link[=construct_qgis_output_result_to_better_format]{construct_qgis_output_result_to_better_format()}},\code{\link[=construct_to_gpkg_output_file_str]{construct_to_gpkg_output_file_str()}}
 
 
-\code{\link[=construct_ogr2ogr_PG_connect_str]{construct_ogr2ogr_PG_connect_str()}}, \code{\link[=construct_qgis_output_result_to_beter_format]{construct_qgis_output_result_to_beter_format()}}
+\code{\link[=construct_ogr2ogr_PG_connect_str]{construct_ogr2ogr_PG_connect_str()}}, \code{\link[=construct_qgis_output_result_to_better_format]{construct_qgis_output_result_to_better_format()}}
 }
 }
 \keyword{qgis_process}
 \keyword{qgis_process}

+ 1 - 1
man/qgis_algorithm_search_by_word.Rd

@@ -23,7 +23,7 @@ Funktsioon leiab fraasi järele QGIS-i algoritmid.
 qgis_algorithm_search_by_word(str = "clip")
 qgis_algorithm_search_by_word(str = "clip")
 algorithm <- "native:clip"
 algorithm <- "native:clip"
 # Read help.
 # Read help.
-qgisprocess::qgis_show_help(algorithm = algorithm)
+ruut::qgis_show_help(algorithm = algorithm)
 
 
 qgis_algorithm_search_by_word(str = "centroid")
 qgis_algorithm_search_by_word(str = "centroid")
 qgis_algorithm_search_by_word(str = "filedownloader")
 qgis_algorithm_search_by_word(str = "filedownloader")