Переглянути джерело

Muudetud 'minu_teed_riigiteed_valjapaasud'.

Ardo Kubjas 5 роки тому
батько
коміт
ec9055a86d
1 змінених файлів з 41 додано та 1 видалено
  1. 41 1
      R/minu_teed_riigiteed_valjapaasud.R

+ 41 - 1
R/minu_teed_riigiteed_valjapaasud.R

@@ -93,9 +93,49 @@ minu_teed_riigiteed_valjapaasud <- function(conf = NULL) {
 
   ## ------------------ 1.5 Copy temp gpkg file to postgis ---------------------
   conf$schema <- "minu_teed"
-  conf$table <- "teedevork_riigiteed_exits"
+  conf$table <- "teedevork_exits_muud_teed"
   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=id -nln %s.%s -nlt PROMOTE_TO_MULTI", PG, vars$tmp_gpkg_file, vars$layer_4, "POINT", conf$schema, conf$table)
   system(cmd)
   cat(sprintf("\n-------------\nLoodi andmebaas '%s'.\n", conf$table))
+
+
+  ## ------------ 1.6 Riigiteede omavahelised lõikumispunktd -------------------
+  # ruut::qgis_algorithm_search_by_word("intersections")
+  algorithm <- "native:lineintersections"
+  # ruut::qgis_show_help(algorithm = algorithm)
+  conf$schema <- "minu_teed"
+  conf$table <- "teedevork_riigiteed"
+  input <- ruut::construct_to_gpkg_output_postgres_str(
+    conf = conf, geometry_type = "MultiLineString", srid = 3301,
+    checkPrimaryKeyUnicity = TRUE, key = "id", geometry_field = "geom"
+  )
+  conf$schema <- "minu_teed"
+  conf$table <- "teedevork_riigiteed"
+  intersect <- ruut::construct_to_gpkg_output_postgres_str(
+    conf = conf, geometry_type = "MultiLineString", srid = 3301,
+    checkPrimaryKeyUnicity = TRUE, key = "id", geometry_field = "geom"
+  )
+  output <- vars$tmp_gpkg_file_output_1
+  cmd <- sprintf("qgis_process run %s  --INPUT='%s' --INPUT_FIELDS='tyyp' --INTERSECT='%s' --INTERSECT_FIELDS='id' --INTERSECT_FIELDS='tyyp_t' --INTERSECT_FIELDS='tee' --INTERSECT_FIELDS='nimetus' --INTERSECT_FIELDS_PREFIX=\"\" --OUTPUT='%s' ", algorithm, input, intersect, output)
+  system(cmd)
+  cat(sprintf("\n-------------\nLoodi andmebaas '%s'.\n", output))
+
+  ## ------------------ 1.7 Kustutame ebaolulised väljad -----------------------
+  # ruut::qgis_algorithm_search_by_word("delete")
+  algorithm <- "native:deletecolumn"
+  # ruut::qgis_show_help(algorithm = algorithm)
+  input <- vars$tmp_gpkg_file_input_1
+  output <- vars$tmp_gpkg_file_output_2
+  cmd <- sprintf("qgis_process run %s  --COLUMN='id' --COLUMN='layer' --COLUMN='path' --INPUT='%s' --OUTPUT='%s' ", algorithm, input, output)
+  system(cmd)
+  cat(sprintf("\n-------------\nLoodi andmebaas '%s'.\n", output))
+
+  ## ------------------ 1.8 Copy temp gpkg file to postgis ---------------------
+  conf$schema <- "minu_teed"
+  conf$table <- "teedevork_exits_riigiteed"
+  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=id -nln %s.%s -nlt PROMOTE_TO_MULTI", PG, vars$tmp_gpkg_file, vars$layer_2, "POINT", conf$schema, conf$table)
+  system(cmd)
+  cat(sprintf("\n-------------\nLoodi andmebaas '%s'.\n", conf$table))
 }