Explorar el Código

Minu teed 'muud teed' ebaoluliste väljade eemaldamine.

Ardo Kubjas hace 5 años
padre
commit
6525d8d104
Se han modificado 1 ficheros con 26 adiciones y 5 borrados
  1. 26 5
      R/minu_teed_muud_teed.R

+ 26 - 5
R/minu_teed_muud_teed.R

@@ -91,7 +91,7 @@ minu_teed_muud_teed <- function(conf = NULL) {
   system(cmd)
   cat(sprintf("\n-------------\nLoodi andmebaas '%s'.\n", conf$table))
 
-  ##  ----------------- 3.1 Riigiteede alg- ja lõpppunkt -----------------------
+  ##  ----------------- 3.1 Muude teede alg- ja lõpppunkt ----------------------
   # ruut::qgis_algorithm_search_by_word("vertices")
   algorithm <- "native:extractspecificvertices"
   # ruut::qgis_show_help(algorithm = algorithm)
@@ -102,11 +102,22 @@ minu_teed_muud_teed <- function(conf = NULL) {
   system(cmd)
   cat(sprintf("\n-------------\nLoodi andmebaas '%s'.\n", output))
 
-  ## ------------------ 3.2 Copy temp gpkg file to postgis ---------------------
+
+  ## ------------------- 3.2 Eemaldame ebavajalikud veerud ---------------------
+  # ruut::qgis_algorithm_search_by_word("retain")
+  algorithm <- "native:retainfields"
+  # ruut::qgis_show_help(algorithm = algorithm)
+  input <- vars$tmp_gpkg_file_input_6
+  output <- vars$tmp_gpkg_file_output_7
+  cmd <- sprintf("qgis_process run %s  --FIELDS='tyyp' --FIELDS='tyyp_t' --FIELDS='tee' --FIELDS='nimetus' --INPUT='%s' --OUTPUT='%s' ", algorithm, input, output)
+  system(cmd)
+  cat(sprintf("\n-------------\nLoodi andmebaas '%s'.\n", output))
+
+  ## ------------------ 3.3 Copy temp gpkg file to postgis ---------------------
   conf$schema <- "minu_teed"
   conf$table <- "teedevork_kt_p"
   PG <- ruut::construct_ogr2ogr_PG_connect_str(conf = conf)
-  cmd <- sprintf("ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL %s -lco DIM=2 %s %s -overwrite -nlt %s -lco GEOMETRY_NAME=geom -lco FID=fid -nln %s.%s -nlt PROMOTE_TO_MULTI", PG, vars$tmp_gpkg_file, vars$layer_6, "POINT", conf$schema, conf$table)
+  cmd <- sprintf("ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL %s -lco DIM=2 %s %s -overwrite -nlt %s -lco GEOMETRY_NAME=geom -lco FID=id -nln %s.%s -nlt PROMOTE_TO_MULTI", PG, vars$tmp_gpkg_file, vars$layer_7, "POINT", conf$schema, conf$table)
   system(cmd)
   cat(sprintf("\n-------------\nLoodi andmebaas '%s'.\n", conf$table))
 
@@ -148,11 +159,21 @@ minu_teed_muud_teed <- function(conf = NULL) {
   system(cmd)
   cat(sprintf("\n-------------\nLoodi andmebaas '%s'.\n", output))
 
-  ## ------------------ 4.5 Copy temp gpkg file to postgis ---------------------
+  ## ------------------- 4.5 Eemaldame ebavajalikud veerud ---------------------
+  # ruut::qgis_algorithm_search_by_word("retain")
+  algorithm <- "native:retainfields"
+  # ruut::qgis_show_help(algorithm = algorithm)
+  input <- vars$tmp_gpkg_file_input_5
+  output <- vars$tmp_gpkg_file_output_6
+  cmd <- sprintf("qgis_process run %s  --FIELDS='tyyp' --FIELDS='tyyp_t' --FIELDS='tee' --FIELDS='nimetus' --INPUT='%s' --OUTPUT='%s' ", algorithm, input, output)
+  system(cmd)
+  cat(sprintf("\n-------------\nLoodi andmebaas '%s'.\n", output))
+
+  ## ------------------ 4.6 Copy temp gpkg file to postgis ---------------------
   conf$schema <- "minu_teed"
   conf$table <- "teedevork_kt_numbrita_p"
   PG <- ruut::construct_ogr2ogr_PG_connect_str(conf = conf)
-  cmd <- sprintf("ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL %s -lco DIM=2 %s %s -overwrite -nlt %s -lco GEOMETRY_NAME=geom -lco FID=fid -nln %s.%s -nlt PROMOTE_TO_MULTI", PG, vars$tmp_gpkg_file, vars$layer_5, "POINT", conf$schema, conf$table)
+  cmd <- sprintf("ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL %s -lco DIM=2 %s %s -overwrite -nlt %s -lco GEOMETRY_NAME=geom -lco FID=id -nln %s.%s -nlt PROMOTE_TO_MULTI", PG, vars$tmp_gpkg_file, vars$layer_6, "POINT", conf$schema, conf$table)
   system(cmd)
   cat(sprintf("\n-------------\nLoodi andmebaas '%s'.\n", conf$table))
 }