|
|
@@ -37,24 +37,31 @@ pk_lisame_polygoonid <- function(obj = NULL, conf = NULL) {
|
|
|
## -------------------- Loop -----------------------
|
|
|
intersect_layers <- c("a00_bb2") # c("piir", "bb", "bb2")
|
|
|
andmed <- data.frame("schema" = character(0), "table" = character(0))
|
|
|
- andmed <- rbind(andmed, data.frame("schema" = "osm_shp", "table" = "landuse_a"))
|
|
|
andmed <- rbind(andmed, data.frame("schema" = "maaamet", "table" = "asustusyksus"))
|
|
|
andmed <- rbind(andmed, data.frame("schema" = "maaamet", "table" = "shp_katastriyksus"))
|
|
|
andmed <- rbind(andmed, data.frame("schema" = "osm_shp", "table" = "buildings_a"))
|
|
|
- andmed <- rbind(andmed, data.frame("schema" = "osm_shp", "table" = "water_a"))
|
|
|
+ andmed <- rbind(andmed, data.frame("schema" = "osm_shp", "table" = "landuse_a"))
|
|
|
+ andmed <- rbind(andmed, data.frame("schema" = "osm_shp", "table" = "natural_a"))
|
|
|
+ andmed <- rbind(andmed, data.frame("schema" = "osm_shp", "table" = "places_a"))
|
|
|
andmed <- rbind(andmed, data.frame("schema" = "osm_shp", "table" = "pofw_a"))
|
|
|
andmed <- rbind(andmed, data.frame("schema" = "osm_shp", "table" = "pois_a"))
|
|
|
- andmed <- rbind(andmed, data.frame("schema" = "osm_shp", "table" = "natural_a"))
|
|
|
- andmed <- rbind(andmed, data.frame("schema" = "eesti", "table" = "e_201_meri_a_dissolved"))
|
|
|
- andmed <- rbind(andmed, data.frame("schema" = "eesti", "table" = "e_202_seisuveekogu_a_dissolved"))
|
|
|
- andmed <- rbind(andmed, data.frame("schema" = "eesti", "table" = "e_203_vooluveekogu_a_dissolved"))
|
|
|
+ andmed <- rbind(andmed, data.frame("schema" = "osm_shp", "table" = "traffic_a"))
|
|
|
+ andmed <- rbind(andmed, data.frame("schema" = "osm_shp", "table" = "transport_a"))
|
|
|
+ andmed <- rbind(andmed, data.frame("schema" = "osm_shp", "table" = "water_a"))
|
|
|
+ # andmed <- rbind(andmed, data.frame("schema" = "eesti", "table" = "e_201_meri_a_dissolved"))
|
|
|
+ # andmed <- rbind(andmed, data.frame("schema" = "eesti", "table" = "e_202_seisuveekogu_a_dissolved"))
|
|
|
+ # andmed <- rbind(andmed, data.frame("schema" = "eesti", "table" = "e_203_vooluveekogu_a_dissolved"))
|
|
|
+ # andmed <- rbind(andmed, data.frame("schema" = "eesti", "table" = "e_305_puittaimestik_a_dissolved"))
|
|
|
+ # andmed <- rbind(andmed, data.frame("schema" = "eesti", "table" = "e_306_margala_a_dissolved"))
|
|
|
+ andmed <- rbind(andmed, data.frame("schema" = "eesti", "table" = "e_201_meri_a"))
|
|
|
+ andmed <- rbind(andmed, data.frame("schema" = "eesti", "table" = "e_202_seisuveekogu_a"))
|
|
|
+ andmed <- rbind(andmed, data.frame("schema" = "eesti", "table" = "e_203_vooluveekogu_a"))
|
|
|
andmed <- rbind(andmed, data.frame("schema" = "eesti", "table" = "e_301_muu_kolvik_a"))
|
|
|
andmed <- rbind(andmed, data.frame("schema" = "eesti", "table" = "e_301_muu_kolvik_ka"))
|
|
|
andmed <- rbind(andmed, data.frame("schema" = "eesti", "table" = "e_302_ou_a"))
|
|
|
andmed <- rbind(andmed, data.frame("schema" = "eesti", "table" = "e_303_haritav_maa_a"))
|
|
|
andmed <- rbind(andmed, data.frame("schema" = "eesti", "table" = "e_304_lage_a"))
|
|
|
- andmed <- rbind(andmed, data.frame("schema" = "eesti", "table" = "e_305_puittaimestik_a_dissolved"))
|
|
|
- andmed <- rbind(andmed, data.frame("schema" = "eesti", "table" = "e_306_margala_a_dissolved"))
|
|
|
+ andmed <- rbind(andmed, data.frame("schema" = "eesti", "table" = "e_305_puittaimestik_a"))
|
|
|
andmed <- rbind(andmed, data.frame("schema" = "eesti", "table" = "e_306_margala_ka"))
|
|
|
andmed <- rbind(andmed, data.frame("schema" = "eesti", "table" = "e_307_turbavali_a"))
|
|
|
andmed <- rbind(andmed, data.frame("schema" = "eesti", "table" = "e_401_hoone_ka"))
|
|
|
@@ -78,14 +85,30 @@ pk_lisame_polygoonid <- function(obj = NULL, conf = NULL) {
|
|
|
conf = conf, geometry_type = "Polygon", srid = 3301,
|
|
|
checkPrimaryKeyUnicity = TRUE, key = "id", geometry_field = geom
|
|
|
)
|
|
|
+ # Geomeetria parandamine
|
|
|
+ # ruut::qgis_algorithm_search_by_word("fix")
|
|
|
+ algorithm <- "native:fixgeometries"
|
|
|
+ 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)
|
|
|
+ # Ühisosa leidmine ja salvestamine ajutiseks failiks.
|
|
|
+ algorithm <- "native:intersection"
|
|
|
+ input <- vars$tmp_gpkg_file_input_1
|
|
|
+ output <- vars$tmp_gpkg_file_output_2 # ajutine fail
|
|
|
+ str <- paste0("{ 'INPUT' : '", input, "', 'INPUT_FIELDS' : [], 'OUTPUT' : '", output, "', 'OVERLAY' : '", intersect_layer, "', 'OVERLAY_FIELDS' : [], 'OVERLAY_FIELDS_PREFIX' : '' }")
|
|
|
+ cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
|
|
|
+ cat(sprintf("\n%s\n\n", cmd))
|
|
|
+ system(cmd)
|
|
|
## Andmebaasi tabeli nimi: 2 esimest tähte tuleb schema nimest millest on andmed võetud, siis '_a_' s.o 'area' mis tähistab polügoone.
|
|
|
+ # Eemaldame üleliigsed veerud ja salvestame postgis andmebaasi.
|
|
|
+ # ruut::qgis_algorithm_search_by_word("Drop")
|
|
|
+ algorithm <- "native:deletecolumn"
|
|
|
+ input <- vars$tmp_gpkg_file_input_2
|
|
|
conf$table <- sprintf("data_a_%s_%s", strtrim(as.character(andmed$schema[i]), 2), andmed$table[i])
|
|
|
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")
|
|
|
- str <- paste0("{ 'INPUT' : '", input, "', 'INPUT_FIELDS' : [], 'OUTPUT' : '", output, "', 'OVERLAY' : '", intersect_layer, "', 'OVERLAY_FIELDS' : [], 'OVERLAY_FIELDS_PREFIX' : '' }")
|
|
|
- algorithm <- "native:intersection"
|
|
|
- cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
|
|
|
- cat(sprintf("\n%s\n\n", cmd))
|
|
|
+ cmd <- sprintf("qgis_process run %s --COLUMN='fid' --COLUMN='id_2' --COLUMN='left' --COLUMN='top' --COLUMN='right' --COLUMN='bottom' --INPUT='%s' --OUTPUT='%s' ", algorithm, input, output)
|
|
|
system(cmd)
|
|
|
|
|
|
## Filtreerime mõned andmetabelid eraldi alamkihtideks
|
|
|
@@ -100,7 +123,7 @@ pk_lisame_polygoonid <- function(obj = NULL, conf = NULL) {
|
|
|
input <- ruut::construct_to_gpkg_output_postgres_str(conf = conf, geometry_type = "MultiPolygon", srid = 3301, checkPrimaryKeyUnicity = TRUE, key = "id")
|
|
|
# sf::st_read(dsn = conn, layer = c(conf$schema, parent_table))
|
|
|
conf$table <- sprintf("%s_%s", parent_table, table_suffix)
|
|
|
- output <- ruut::construct_to_gpkg_output_postgres_str(conf = conf, geometry_field = "geom", geometry_type = "Polygon", srid = 3301, checkPrimaryKeyUnicity = FALSE, key = "id")
|
|
|
+ output <- ruut::construct_to_gpkg_output_postgres_str(conf = conf, geometry_field = "geom", geometry_type = "MultiPolygon", srid = 3301, checkPrimaryKeyUnicity = FALSE, key = "id")
|
|
|
str <- paste0("{ 'INPUT' : '", input, "', 'INTERSECT' : '", intersect_layer, "', 'OUTPUT' : '", output, "', FIELD : 'code', OPERATOR : 0, VALUE : '", landuse_a$code[k], "' }")
|
|
|
algorithm <- "native:extractbyattribute"
|
|
|
cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
|
|
|
@@ -121,7 +144,7 @@ pk_lisame_polygoonid <- function(obj = NULL, conf = NULL) {
|
|
|
input <- ruut::construct_to_gpkg_output_postgres_str(conf = conf, geometry_type = "MultiPolygon", srid = 3301, checkPrimaryKeyUnicity = TRUE, key = "id")
|
|
|
# sf::st_read(dsn = conn, layer = c(conf$schema, parent_table))
|
|
|
conf$table <- sprintf("%s_%s", parent_table, table_suffix)
|
|
|
- output <- ruut::construct_to_gpkg_output_postgres_str(conf = conf, geometry_field = "geom", geometry_type = "Polygon", srid = 3301, checkPrimaryKeyUnicity = FALSE, key = "id")
|
|
|
+ output <- ruut::construct_to_gpkg_output_postgres_str(conf = conf, geometry_field = "geom", geometry_type = "MultiPolygon", srid = 3301, checkPrimaryKeyUnicity = FALSE, key = "id")
|
|
|
str <- paste0("{ 'INPUT' : '", input, "', 'INTERSECT' : '", intersect_layer, "', 'OUTPUT' : '", output, "', FIELD : 'tyyp', OPERATOR : 0, VALUE : '", alamobjektid$tyyp[k], "' }")
|
|
|
algorithm <- "native:extractbyattribute"
|
|
|
cmd <- ruut::construct_qgis_output_result_to_better_format(str = str, algorithm = algorithm)
|
|
|
@@ -135,7 +158,7 @@ pk_lisame_polygoonid <- function(obj = NULL, conf = NULL) {
|
|
|
conf$schema <- obj
|
|
|
input <- ruut::construct_to_gpkg_output_postgres_str(conf = conf, geometry_type = "MultiPolygon", srid = 3301, checkPrimaryKeyUnicity = TRUE, key = "id")
|
|
|
conf$table <- sprintf("data_p_%s_%s_%s", strtrim(as.character(andmed$schema[i]), 2), andmed$table[i], table_suffix)
|
|
|
- output <- ruut::construct_to_gpkg_output_postgres_str(conf = conf, geometry_field = "geom", geometry_type = "Polygon", srid = 3301, checkPrimaryKeyUnicity = FALSE, key = "id")
|
|
|
+ output <- ruut::construct_to_gpkg_output_postgres_str(conf = conf, geometry_field = "geom", geometry_type = "Point", srid = 3301, checkPrimaryKeyUnicity = FALSE, key = "id")
|
|
|
str <- sprintf("{ 'ALL_PARTS' : False, 'INPUT' : '%s', 'OUTPUT' : '%s' }", input, output)
|
|
|
# ruut::qgis_algorithm_search_by_word("centroid")
|
|
|
algorithm <- "native:centroids"
|