Quellcode durchsuchen

Lisatud kontroll, et kas loodav tabel eksisteerib andmebaasis või mitte.

Ardo Kubjas vor 3 Jahren
Ursprung
Commit
c1813cdd01
5 geänderte Dateien mit 303 neuen und 189 gelöschten Zeilen
  1. 20 1
      R/pk_lisame_jooned.R
  2. 15 3
      R/pk_lisame_polygoonid.R
  3. 22 5
      R/pk_lisame_punktid.R
  4. 59 14
      R/pk_lisame_ruudustikud.R
  5. 187 166
      R/pk_sellest_alustame_db_loomist.R

+ 20 - 1
R/pk_lisame_jooned.R

@@ -103,6 +103,16 @@ pk_lisame_jooned <- function(obj = NULL, conf = NULL) {
     rbind(andmed, data.frame("schema" = "eesti", "table" = "sild_j"))
   andmed <-
     rbind(andmed, data.frame("schema" = "eesti", "table" = "sygavus_j"))
+  andmed <-
+    rbind(andmed, data.frame("schema" = "minu_teed", "table" = "links"))
+  andmed <-
+    rbind(andmed,
+          data.frame("schema" = "minu_teed", "table" = "teedevork"))
+  andmed <-
+    rbind(andmed,
+          data.frame("schema" = "minu_teed", "table" = "gtfs_lines"))
+  ## Tabelid mis on juba andmebaasis ja mida ümber ei kirjutata.
+  olemasolevad_tabelid <- ruut::db_schema_tablenames(conf = conf)
   for (intersect in intersect_layers) {
     conf$table <- intersect
     conf$schema <- obj
@@ -118,7 +128,16 @@ pk_lisame_jooned <- function(obj = NULL, conf = NULL) {
       cat("\n\n\n==========================================\n\n")
       cat(sprintf("Tabel: %s.%s", andmed[i, "schema"], andmed[i, "table"]))
       cat("\n==========================================\n\n")
-      ## teeregister_wfs andmebaasis on importimisel geomeetria välja tähistus 'geometry'.
+      ## Kui olemasolev tabel eksisteerib andmebaasis, siis jätame arvutused
+      ## selle tabeliga vahele.
+      uus_tabel <- sprintf("data_l_%s_%s",
+                           strtrim(as.character(andmed$schema[i]), 2),
+                           andmed$table[i])
+      if (uus_tabel %in% olemasolevad_tabelid) {
+        cat("\nTabel on juba andmebaasis olemas.\n")
+        next
+      }
+      ## Osadel tabelitel andmebaasisvõib olla geomeetria välja tähistus 'geometry'.
       geom <- "geom"
       # if (andmed$schema[i] %in% c("gtfs")) geom <- "geometry"
       conf$table <- andmed$table[i]

+ 15 - 3
R/pk_lisame_polygoonid.R

@@ -125,8 +125,8 @@ pk_lisame_polygoonid <- function(obj = NULL, conf = NULL) {
     )
   andmed <-
     rbind(andmed, data.frame("schema" = "eesti", "table" = "mullakaart"))
-
-
+  ## Tabelid mis on juba andmebaasis ja mida ümber ei kirjutata.
+  olemasolevad_tabelid <- ruut::db_schema_tablenames(conf = conf)
   for (intersect in intersect_layers) {
     conf$table <- intersect
     conf$schema <- obj
@@ -138,8 +138,20 @@ pk_lisame_polygoonid <- function(obj = NULL, conf = NULL) {
         checkPrimaryKeyUnicity = TRUE,
         key = "id"
       )
-
     for (i in 1:nrow(andmed)) {
+      cat("\n\n\n==========================================\n\n")
+      cat(sprintf("Tabel: %s.%s", andmed[i, "schema"], andmed[i, "table"]))
+      cat("\n==========================================\n\n")
+      ## Kui olemasolev tabel eksisteerib andmebaasis, siis jätame arvutused
+      ## selle tabeliga vahele.
+      uus_tabel <- sprintf("data_a_%s_%s",
+                           strtrim(as.character(andmed$schema[i]), 2),
+                           andmed$table[i])
+      if (uus_tabel %in% olemasolevad_tabelid) {
+        cat("\nTabel on juba andmebaasis olemas.\n")
+        next
+      }
+      ## Osadel tabelitel andmebaasisvõib olla geomeetria välja tähistus 'geometry'.
       geom <- "geom"
       # if (andmed$schema[i] %in% c("teeregister_wfs"))  geom <- "geometry" else geom <- "geom"
       conf$table <- andmed$table[i]

+ 22 - 5
R/pk_lisame_punktid.R

@@ -105,6 +105,13 @@ pk_lisame_punktid <- function(obj = NULL, conf = NULL) {
     rbind(andmed, data.frame("schema" = "eesti", "table" = "kirik_p"))
   andmed <-
     rbind(andmed, data.frame("schema" = "eesti", "table" = "kohanimi"))
+  andmed <-
+    rbind(andmed, data.frame("schema" = "minu_teed", "table" = "nodes"))
+  andmed <-
+    rbind(andmed,
+          data.frame("schema" = "minu_teed", "table" = "gtfs_stops"))
+  ## Tabelid mis on juba andmebaasis ja mida ümber ei kirjutata.
+  olemasolevad_tabelid <- ruut::db_schema_tablenames(conf = conf)
   for (intersect in intersect_layers) {
     conf$table <- intersect
     conf$schema <- obj
@@ -117,11 +124,21 @@ pk_lisame_punktid <- function(obj = NULL, conf = NULL) {
         key = "id"
       )
     for (i in 1:nrow(andmed)) {
-      ## teeregister_wfs andmebaasis on importimisel geomeetria välja tähistus 'geometry'.
-      if (andmed$schema[i] %in% c("gtfs"))
-        geom <- "geometry"
-      else
-        geom <- "geom"
+      cat("\n\n\n==========================================\n\n")
+      cat(sprintf("Tabel: %s.%s", andmed[i, "schema"], andmed[i, "table"]))
+      cat("\n==========================================\n\n")
+      ## Kui olemasolev tabel eksisteerib andmebaasis, siis jätame arvutused
+      ## selle tabeliga vahele.
+      uus_tabel <- sprintf("data_p_%s_%s",
+                           strtrim(as.character(andmed$schema[i]), 2),
+                           andmed$table[i])
+      if (uus_tabel %in% olemasolevad_tabelid) {
+        cat("\nTabel on juba andmebaasis olemas.\n")
+        next
+      }
+      ## Osadel tabelitel andmebaasisvõib olla geomeetria välja tähistus 'geometry'.
+      geom <- "geom"
+      # if (andmed$schema[i] %in% c("gtfs")) geom <- "geometry"
       conf$table <- andmed$table[i]
       conf$schema <- andmed$schema[i]
       input <- ruut::construct_to_gpkg_output_postgres_str(

+ 59 - 14
R/pk_lisame_ruudustikud.R

@@ -25,7 +25,9 @@ pk_lisame_ruudustikud <- function(obj = NULL, conf = NULL) {
   conf <- vars$conf
   ## Konfiguratsiooni muutujale väärtuste omistamine, kui seda pole antud.
   if (!any("a00_piir" %in% ruut::db_schema_tablenames(conf = conf))) {
-    cat("\nAndmebaas loomata. Palun funktsiooniga ruut::pk_sellest_alustame_db_loomist() andmebaasi loomist.\n")
+    cat(
+      "\nAndmebaas loomata. Palun funktsiooniga ruut::pk_sellest_alustame_db_loomist() andmebaasi loomist.\n"
+    )
     return(NULL)
   }
 
@@ -35,25 +37,68 @@ pk_lisame_ruudustikud <- function(obj = NULL, conf = NULL) {
   # cat(ruut::qgis_show_help(algorithm = algorithm))
   ## -------------------- Loop -----------------------
   intersect_layers <- c("a00_bb2") # c("piir", "bb", "bb2")
-  ruudud <- c("epk10t_grid", "epk2t_grid", "epk02t_grid") # "epk10t", "epk2t"
+  ruudud <-
+    c("epk10t_grid", "epk2t_grid", "epk02t_grid") # "epk10t", "epk2t"
   conf$schema <- "maaamet"
+  ## Tabelid mis on juba andmebaasis ja mida ümber ei kirjutata.
+  conf$schema <- obj
+  olemasolevad_tabelid <- ruut::db_schema_tablenames(conf = conf)
   # ruudud <- c("epk02t_grid")
   for (intersect in intersect_layers) {
     conf$table <- intersect
     conf$schema <- obj
-    intersect_layer <- ruut::construct_to_gpkg_output_postgres_str(conf = conf, geometry_type = "Polygon", srid = 3301, checkPrimaryKeyUnicity = TRUE, key = "id")
+    intersect_layer <-
+      ruut::construct_to_gpkg_output_postgres_str(
+        conf = conf,
+        geometry_type = "Polygon",
+        srid = 3301,
+        checkPrimaryKeyUnicity = TRUE,
+        key = "id"
+      )
     for (ruut in ruudud) {
-      conf$table <- ruut
-      conf$schema <- "maaamet"
-      input <- ruut::construct_to_gpkg_output_postgres_str(conf = conf, geometry_type = "MultiPolygon", checkPrimaryKeyUnicity = T, key = "id", srid = 3301)
-      conf$table <- sprintf("bb2_%s", ruut)
-      conf$schema <- obj
-      output <- ruut::construct_to_gpkg_output_postgres_str(conf = conf, geometry_field = "geom", geometry_type = NULL, srid = 3301, checkPrimaryKeyUnicity = FALSE, key = "id")
-      ## ------------------- QGIS: qgisprocess ----------------------
-      str <- paste0("{ 'INPUT' : '", input, "', 'INTERSECT' : '", intersect_layer, "', 'OUTPUT' : '", output, "', 'PREDICATE' : [5,6] }")
-      cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
-      cat(sprintf("\n%s\n", cmd))
-      system(cmd)
+      ## Kui olemasolev tabel eksisteerib andmebaasis, siis jätame arvutused
+      ## selle tabeliga vahele.
+      uus_tabel <- sprintf("bb2_%s", ruut)
+      if (uus_tabel %in% olemasolevad_tabelid) {
+        cat(sprintf("\nTabel %s on juba andmebaasis olemas.\n", uus_tabel))
+      } else {
+        conf$table <- ruut
+        conf$schema <- "maaamet"
+        input <-
+          ruut::construct_to_gpkg_output_postgres_str(
+            conf = conf,
+            geometry_type = "MultiPolygon",
+            checkPrimaryKeyUnicity = T,
+            key = "id",
+            srid = 3301
+          )
+        conf$table <- uus_tabel
+        conf$schema <- obj
+        output <-
+          ruut::construct_to_gpkg_output_postgres_str(
+            conf = conf,
+            geometry_field = "geom",
+            geometry_type = NULL,
+            srid = 3301,
+            checkPrimaryKeyUnicity = FALSE,
+            key = "id"
+          )
+        ## ------------------- QGIS: qgisprocess ----------------------
+        str <-
+          paste0(
+            "{ 'INPUT' : '",
+            input,
+            "', 'INTERSECT' : '",
+            intersect_layer,
+            "', 'OUTPUT' : '",
+            output,
+            "', 'PREDICATE' : [5,6] }"
+          )
+        cmd <-
+          ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
+        cat(sprintf("\n%s\n", cmd))
+        system(cmd)
+      }
     }
   }
   ## Layers list

+ 187 - 166
R/pk_sellest_alustame_db_loomist.R

@@ -34,7 +34,7 @@ pk_sellest_alustame_db_loomist <-
            obj = NULL,
            conf = NULL) {
     ## ----------- argumentide vastavuse kontroll -----------
-    if (is.null(pk) || !sf::st_is_valid(pk)) {
+    if (is.null(pk)) {
       cat("\nPalun kontrolli geomeetrilise kujundi \u00F%igsust.\n")
       # return(NULL)
     }
@@ -47,189 +47,210 @@ pk_sellest_alustame_db_loomist <-
     pk <- vars$pk
     conf <- vars$conf
     # attributes(pk)$names <- attributes(pk)$sf_column <- "geom"
-
+    ## Tabelid mis on juba andmebaasis ja mida ümber ei kirjutata.
+    olemasolevad_tabelid <- ruut::db_schema_tablenames(conf = conf)
 
     ## --------------------- programmi osa ------------------------
 
     ## 1. Piirjoone salvestamine
-    pk <- sf::st_transform(pk, 3301)
-    # Write to gpkg and check validity
-    sf::write_sf(
-      pk,
-      dsn = vars$tmp_gpkg_file,
-      layer = vars$conf$gpkg_table,
-      driver = "gpkg",
-      fid_column_name = "fid",
-      delete_dsn = T
-    )
-    # Geomeetria parandamine
-    # ruut::qgis_algorithm_search_by_word("fix")
-    algorithm <- "native:fixgeometries"
-    input <- vars$tmp_gpkg_file_input_1 # ajutine fail
-    output <- vars$tmp_gpkg_file_output_2 # ajutine fail
-    str <-
-      sprintf("{ 'INPUT' : '%s', 'OUTPUT' : '%s' }", input, output)
-    cmd <-
-      ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
-    system(cmd)
-    ## Multipart to singlepart
-    # ruut::qgis_algorithm_search_by_word("singlepart")
-    algorithm <- "native:multiparttosingleparts"
-    input <- vars$tmp_gpkg_file_input_2 # ajutine fail
-    output <- vars$tmp_gpkg_file_output_1 # ajutine fail
-    str <-  sprintf("{
+    ## Kui olemasolev tabel eksisteerib andmebaasis, siis jätame arvutused
+    ## selle tabeliga vahele.
+    uus_tabel <- "a00_piir"
+    if (uus_tabel %in% olemasolevad_tabelid) {
+      cat(sprintf("\nTabel %s on juba andmebaasis olemas.\n", uus_tabel))
+    } else {
+      pk <- sf::st_transform(pk, 3301)
+      # Write to gpkg and check validity
+      sf::write_sf(
+        pk,
+        dsn = vars$tmp_gpkg_file,
+        layer = vars$conf$gpkg_table,
+        driver = "gpkg",
+        fid_column_name = "fid",
+        delete_dsn = T
+      )
+      # Geomeetria parandamine
+      # ruut::qgis_algorithm_search_by_word("fix")
+      algorithm <- "native:fixgeometries"
+      input <- vars$tmp_gpkg_file_input_1 # ajutine fail
+      output <- vars$tmp_gpkg_file_output_2 # ajutine fail
+      str <-
+        sprintf("{ 'INPUT' : '%s', 'OUTPUT' : '%s' }", input, output)
+      cmd <-
+        ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
+      system(cmd)
+      ## Multipart to singlepart
+      # ruut::qgis_algorithm_search_by_word("singlepart")
+      algorithm <- "native:multiparttosingleparts"
+      input <- vars$tmp_gpkg_file_input_2 # ajutine fail
+      output <- vars$tmp_gpkg_file_output_1 # ajutine fail
+      str <-  sprintf("{
   'INPUT' : '%s',
   'OUTPUT' : '%s'
 }", input, output)
-    cmd <-
-      ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
-    system(cmd)
-    # Write to postgis
-    ruut::db_create_new_schema(conf = conf)
-    # conn <- ruut::db_connect(conf = conf)
-    # DBI::dbDisconnect(conn)
-    # Eemaldame üleliigsed veerud
-    # ruut::qgis_algorithm_search_by_word("Drop")
-    algorithm <- "native:deletecolumn"
-    input <- vars$tmp_gpkg_file_input_1
-    conf$table <- "a00_piir"
-    output <-
-      ruut::construct_to_gpkg_output_postgres_str(
-        conf = conf,
-        geometry_field = "geom",
-        geometry_type = "Polygon",
-        srid = 3301,
-        checkPrimaryKeyUnicity = FALSE,
-        key = "id"
-      )
-    cmd <-
-      sprintf(
-        "qgis_process run %s --COLUMN='fid' --INPUT='%s' --OUTPUT='%s' ",
-        algorithm,
-        input,
-        output
-      )
-    system(cmd)
+      cmd <-
+        ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
+      system(cmd)
+      # Write to postgis
+      ruut::db_create_new_schema(conf = conf)
+      # conn <- ruut::db_connect(conf = conf)
+      # DBI::dbDisconnect(conn)
+      # Eemaldame üleliigsed veerud
+      # ruut::qgis_algorithm_search_by_word("Drop")
+      algorithm <- "native:deletecolumn"
+      input <- vars$tmp_gpkg_file_input_1
+      conf$table <- uus_tabel
+      output <-
+        ruut::construct_to_gpkg_output_postgres_str(
+          conf = conf,
+          geometry_field = "geom",
+          geometry_type = "Polygon",
+          srid = 3301,
+          checkPrimaryKeyUnicity = FALSE,
+          key = "id"
+        )
+      cmd <-
+        sprintf(
+          "qgis_process run %s --COLUMN='fid' --INPUT='%s' --OUTPUT='%s' ",
+          algorithm,
+          input,
+          output
+        )
+      system(cmd)
+    }
 
     ## 2. Piirikasti salvestamine
-    ## konstrueerime EXTENT, HSPACING ja VSPACING väärtused piirikasti konstrueerimiseks.
-    pk_attributes <- attributes(pk$geom)
-    extent <-
-      sprintf(
-        "%s,%s,%s,%s [EPSG:3301]",
-        round((pk_attributes$bbox["xmin"] / 100), digits = 0) * 100,
-        ceiling((pk_attributes$bbox["xmax"] / 100)) * 100,
-        round((pk_attributes$bbox["ymin"] / 100), digits = 0) * 100,
-        ceiling((pk_attributes$bbox["ymax"] / 100)) * 100
-      )
-    hspacing <-
-      (ceiling((pk_attributes$bbox["xmax"] / 100)) * 100) - (round((pk_attributes$bbox["xmin"] / 100), digits = 0) * 100)
-    vspacing <-
-      (ceiling((pk_attributes$bbox["ymax"] / 100)) * 100) - (round((pk_attributes$bbox["ymin"] / 100), digits = 0) * 100)
-    conf$table <- "a00_piir_bb"
-    output <-
-      ruut::construct_to_gpkg_output_postgres_str(
-        conf = conf,
-        geometry_field = "geom",
-        geometry_type = NULL,
-        srid = 3301,
-        checkPrimaryKeyUnicity = FALSE,
-        key = "id"
-      )
-    # ruut::qgis_algorithm_search_by_word(str = "grid")
-    algorithm <- "native:creategrid"
-    # cat(ruut::qgis_show_help(algorithm = algorithm))
-    cmd <-
-      sprintf(
-        "qgis_process run %s --CRS=\"EPSG:3301\" --EXTENT=\"%s\" --HOVERLAY=0 --HSPACING=%s --TYPE=2 --VOVERLAY=0 --VSPACING=%s --OUTPUT=\"%s\"",
-        algorithm,
-        extent,
-        hspacing,
-        vspacing,
-        output
-      )
-    cat(sprintf("\n%s\n", cmd))
-    system(cmd)
+    ## Kui olemasolev tabel eksisteerib andmebaasis, siis jätame arvutused
+    ## selle tabeliga vahele.
+    uus_tabel <- "a00_piir_bb"
+    if (uus_tabel %in% olemasolevad_tabelid) {
+      cat(sprintf("\nTabel %s on juba andmebaasis olemas.\n", uus_tabel))
+    } else {
+      ## konstrueerime EXTENT, HSPACING ja VSPACING väärtused piirikasti konstrueerimiseks.
+      pk_attributes <- attributes(pk$geom)
+      extent <-
+        sprintf(
+          "%s,%s,%s,%s [EPSG:3301]",
+          round((pk_attributes$bbox["xmin"] / 100), digits = 0) * 100,
+          ceiling((pk_attributes$bbox["xmax"] / 100)) * 100,
+          round((pk_attributes$bbox["ymin"] / 100), digits = 0) * 100,
+          ceiling((pk_attributes$bbox["ymax"] / 100)) * 100
+        )
+      hspacing <-
+        (ceiling((pk_attributes$bbox["xmax"] / 100)) * 100) - (round((pk_attributes$bbox["xmin"] / 100), digits = 0) * 100)
+      vspacing <-
+        (ceiling((pk_attributes$bbox["ymax"] / 100)) * 100) - (round((pk_attributes$bbox["ymin"] / 100), digits = 0) * 100)
+      conf$table <- uus_tabel
+      output <-
+        ruut::construct_to_gpkg_output_postgres_str(
+          conf = conf,
+          geometry_field = "geom",
+          geometry_type = NULL,
+          srid = 3301,
+          checkPrimaryKeyUnicity = FALSE,
+          key = "id"
+        )
+      # ruut::qgis_algorithm_search_by_word(str = "grid")
+      algorithm <- "native:creategrid"
+      # cat(ruut::qgis_show_help(algorithm = algorithm))
+      cmd <-
+        sprintf(
+          "qgis_process run %s --CRS=\"EPSG:3301\" --EXTENT=\"%s\" --HOVERLAY=0 --HSPACING=%s --TYPE=2 --VOVERLAY=0 --VSPACING=%s --OUTPUT=\"%s\"",
+          algorithm,
+          extent,
+          hspacing,
+          vspacing,
+          output
+        )
+      cat(sprintf("\n%s\n", cmd))
+      system(cmd)
+    }
 
     ## 3. epk2t piirikasti konstrueerimine ja salvestamine s.t kuhu mahuvad sisse
     ## meie piirkonna epk2t (1x1km) ruudud.
-
-    ## 3.1 Leiame piirikastiga seotud epk2t ruudud
-    # ruut::qgis_algorithm_search_by_word(str = "extract")
-    algorithm <- "native:extractbylocation"
-    # cat(ruut::qgis_show_help(algorithm = algorithm))
-    conf$table <- "epk2t_grid"
-    conf$schema <- "maaamet"
-    input <- ruut::construct_to_gpkg_output_postgres_str(
-      conf = conf,
-      geometry_type = "Polygon",
-      srid = 3301,
-      checkPrimaryKeyUnicity = TRUE,
-      key = "id",
-      geometry_field = "geom"
-    )
-    conf$table <- "a00_piir_bb"
-    conf$schema <- obj
-    intersect <-
-      ruut::construct_to_gpkg_output_postgres_str(
+    ## Kui olemasolev tabel eksisteerib andmebaasis, siis jätame arvutused
+    ## selle tabeliga vahele.
+    uus_tabel <- "a00_bb2"
+    if (uus_tabel %in% olemasolevad_tabelid) {
+      cat(sprintf("\nTabel %s on juba andmebaasis olemas.\n", uus_tabel))
+    } else {
+      ## 3.1 Leiame piirikastiga seotud epk2t ruudud
+      # ruut::qgis_algorithm_search_by_word(str = "extract")
+      algorithm <- "native:extractbylocation"
+      # cat(ruut::qgis_show_help(algorithm = algorithm))
+      conf$table <- "epk2t_grid"
+      conf$schema <- "maaamet"
+      input <- ruut::construct_to_gpkg_output_postgres_str(
         conf = conf,
         geometry_type = "Polygon",
         srid = 3301,
         checkPrimaryKeyUnicity = TRUE,
-        key = "id"
-      )
-    output <- vars$tmp_gpkg_file_output_1 # ajutine fail
-    str <-
-      sprintf(
-        "{ 'INPUT' : '%s', 'INTERSECT' : '%s', 'OUTPUT' : '%s', 'PREDICATE' : [5,6] }",
-        input,
-        intersect,
-        output
+        key = "id",
+        geometry_field = "geom"
       )
-    cmd <-
-      ruut::construct_qgis_output_result_to_better_format(str, algorithm)
-    system(cmd)
+      conf$table <- "a00_piir_bb"
+      conf$schema <- obj
+      intersect <-
+        ruut::construct_to_gpkg_output_postgres_str(
+          conf = conf,
+          geometry_type = "Polygon",
+          srid = 3301,
+          checkPrimaryKeyUnicity = TRUE,
+          key = "id"
+        )
+      output <- vars$tmp_gpkg_file_output_1 # ajutine fail
+      str <-
+        sprintf(
+          "{ 'INPUT' : '%s', 'INTERSECT' : '%s', 'OUTPUT' : '%s', 'PREDICATE' : [5,6] }",
+          input,
+          intersect,
+          output
+        )
+      cmd <-
+        ruut::construct_qgis_output_result_to_better_format(str, algorithm)
+      system(cmd)
 
-    ## 3.2 Ajutise faili abil epk2t piirikasti konstrueerimine
-    test_layer_obj <-
-      sf::read_sf(dsn = vars$tmp_gpkg_file, layer = "test_layer_1")
-    pk_attributes <- attributes(test_layer_obj$geom)
-    extent <-
-      sprintf(
-        "%s,%s,%s,%s [EPSG:3301]",
-        round((pk_attributes$bbox["xmin"] / 100), digits = 0) * 100,
-        ceiling((pk_attributes$bbox["xmax"] / 100)) * 100,
-        round((pk_attributes$bbox["ymin"] / 100), digits = 0) * 100,
-        ceiling((pk_attributes$bbox["ymax"] / 100)) * 100
-      )
-    hspacing <-
-      (ceiling((pk_attributes$bbox["xmax"] / 100)) * 100) - (round((pk_attributes$bbox["xmin"] / 100), digits = 0) * 100)
-    vspacing <-
-      (ceiling((pk_attributes$bbox["ymax"] / 100)) * 100) - (round((pk_attributes$bbox["ymin"] / 100), digits = 0) * 100)
-    conf$table <- "a00_bb2"
-    output <-
-      ruut::construct_to_gpkg_output_postgres_str(
-        conf = conf,
-        geometry_field = "geom",
-        geometry_type = NULL,
-        srid = 3301,
-        checkPrimaryKeyUnicity = FALSE,
-        key = "id"
-      )
-    # ruut::qgis_algorithm_search_by_word(str = "grid")
-    algorithm <- "native:creategrid"
-    # cat(ruut::qgis_show_help(algorithm = algorithm))
-    cmd <-
-      sprintf(
-        "qgis_process run %s --CRS=\"EPSG:3301\" --EXTENT=\"%s\" --HOVERLAY=0 --HSPACING=%s --TYPE=2 --VOVERLAY=0 --VSPACING=%s --OUTPUT=\"%s\"",
-        algorithm,
-        extent,
-        hspacing,
-        vspacing,
-        output
-      )
-    cat(sprintf("\n%s\n", cmd))
-    system(cmd)
+      ## 3.2 Ajutise faili abil epk2t piirikasti konstrueerimine
+      test_layer_obj <-
+        sf::read_sf(dsn = vars$tmp_gpkg_file, layer = "test_layer_1")
+      pk_attributes <- attributes(test_layer_obj$geom)
+      extent <-
+        sprintf(
+          "%s,%s,%s,%s [EPSG:3301]",
+          round((pk_attributes$bbox["xmin"] / 100), digits = 0) * 100,
+          ceiling((pk_attributes$bbox["xmax"] / 100)) * 100,
+          round((pk_attributes$bbox["ymin"] / 100), digits = 0) * 100,
+          ceiling((pk_attributes$bbox["ymax"] / 100)) * 100
+        )
+      hspacing <-
+        (ceiling((pk_attributes$bbox["xmax"] / 100)) * 100) - (round((pk_attributes$bbox["xmin"] / 100), digits = 0) * 100)
+      vspacing <-
+        (ceiling((pk_attributes$bbox["ymax"] / 100)) * 100) - (round((pk_attributes$bbox["ymin"] / 100), digits = 0) * 100)
+      conf$table <- uus_tabel
+      output <-
+        ruut::construct_to_gpkg_output_postgres_str(
+          conf = conf,
+          geometry_field = "geom",
+          geometry_type = NULL,
+          srid = 3301,
+          checkPrimaryKeyUnicity = FALSE,
+          key = "id"
+        )
+      # ruut::qgis_algorithm_search_by_word(str = "grid")
+      algorithm <- "native:creategrid"
+      # cat(ruut::qgis_show_help(algorithm = algorithm))
+      cmd <-
+        sprintf(
+          "qgis_process run %s --CRS=\"EPSG:3301\" --EXTENT=\"%s\" --HOVERLAY=0 --HSPACING=%s --TYPE=2 --VOVERLAY=0 --VSPACING=%s --OUTPUT=\"%s\"",
+          algorithm,
+          extent,
+          hspacing,
+          vspacing,
+          output
+        )
+      cat(sprintf("\n%s\n", cmd))
+      system(cmd)
+    }
 
     ## Layers list
     conf$schema <- obj