|
|
@@ -41,6 +41,10 @@ gpkg_sellest_alustame_gpkg_loomist <- function(pk = NULL, obj = NULL, gpkg_home
|
|
|
conf$gpkg_home <- gpkg_home
|
|
|
conf$gpkg_file <- obj
|
|
|
|
|
|
+ tmp_gpkg_file <- tempfile(fileext = ".gpkg")
|
|
|
+ tmp_gpkg_file_output <- ruut::construct_to_gpkg_output_file_str(conf = conf, is_input_str = F)
|
|
|
+ tmp_gpkg_file_input <- ruut::construct_to_gpkg_output_file_str(conf = conf, is_input_str = T)
|
|
|
+
|
|
|
## ----------- argumentide vastavuse kontroll -----------
|
|
|
if (is.null(pk) || !sf::st_is_valid(pk)) {
|
|
|
cat("\nPalun kontrolli geomeetrilise kujundi \u00F%igsust.\n")
|
|
|
@@ -77,6 +81,37 @@ gpkg_sellest_alustame_gpkg_loomist <- function(pk = NULL, obj = NULL, gpkg_home
|
|
|
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
|
|
|
+ str <- "{ 'INPUT' : 'postgres://dbname=\'data\' host=localhost port=6432 user=\'osm\' sslmode=disable authcfg=0i30k14 key=\'id\' srid=3301 type=MultiPolygon checkPrimaryKeyUnicity=\'1\' table=\"maaamet\".\"epk2t_grid\" (geom)', 'INTERSECT' : '/data/gpkg/artiklid/artikkel_210127_valga_matsalu_lahemaa/marja.gpkg|layername=bb', 'OUTPUT' : 'TEMPORARY_OUTPUT', 'PREDICATE' : [5,6] }"
|
|
|
+ # 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$gpkg_table <- "bb"
|
|
|
+ intersect <- ruut::construct_to_gpkg_output_file_str(conf = conf, is_input_str = TRUE)
|
|
|
+ str <- sprintf("{ 'INPUT' : '%s', 'INTERSECT' : '%s', 'OUTPUT' : '%s', 'PREDICATE' : [5,6] }", input, intersect, tmp_gpkg_file_output)
|
|
|
+ cmd <- ruut::construct_qgis_output_result_to_better_format(str, algorithm)
|
|
|
+ system(cmd)
|
|
|
+ test_layer_obj <- sf::read_sf(dsn = dsn, layer = "test_layer")
|
|
|
+ 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$gpkg_table <- "bb2"
|
|
|
+ output <- ruut::construct_to_gpkg_output_file_str(conf = conf, is_input_str = F)
|
|
|
+ # 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
|
|
|
sf::st_layers(dsn = dsn)
|
|
|
}
|