|
@@ -0,0 +1,46 @@
|
|
|
|
|
+#' Funktsioonid
|
|
|
|
|
+#'
|
|
|
|
|
+
|
|
|
|
|
+# -----------------------------------------------------------------------
|
|
|
|
|
+## Funktsioon: piirkonna piir
|
|
|
|
|
+pk_piir <- function(obj){
|
|
|
|
|
+ # obj - objekti nimetus (näiteks: valga)
|
|
|
|
|
+ conn <- ruut::db_connect()
|
|
|
|
|
+ q <- sprintf("SELECT * FROM %s.%s_piir", conf$schema, tolower(obj))
|
|
|
|
|
+ cat(sprintf("\n-----------------\n%s\n\n", q))
|
|
|
|
|
+ sf::st_read(conn, query = q)
|
|
|
|
|
+}
|
|
|
|
|
+# pk_piir(obj = "valga")
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+# -----------------------------------------------------------------------
|
|
|
|
|
+## Funktsioon: piirkonna piiri piirikasti (boundary box) loomine
|
|
|
|
|
+create_pk_piir_bb <- function(obj) {
|
|
|
|
|
+ # obj - objekti nimetus (näiteks: valga)
|
|
|
|
|
+ # ruut::qgis_algorithm_search_by_word(str = "extract")
|
|
|
|
|
+ algorithm <- "native:extractbylocation"
|
|
|
|
|
+ # cat(qgisprocess::qgis_show_help(algorithm = algorithm))
|
|
|
|
|
+ result <- qgisprocess::qgis_run_algorithm(
|
|
|
|
|
+ algorithm = algorithm,
|
|
|
|
|
+ INPUT = 'postgres://dbname=\'data\' host=localhost port=6432 user=\'osm\' sslmode=disable authcfg=0i30k14 key=\'fid\' srid=4326 type=Polygon checkPrimaryKeyUnicity=\'1\' table=\"maaamet\".\"epk10t\" (geometry)',
|
|
|
|
|
+ INTERSECT = sprintf('postgres://dbname=\'data\' host=localhost port=6432 user=\'osm\' sslmode=disable authcfg=0i30k14 key=\'ogc_fid\' srid=4326 type=Polygon checkPrimaryKeyUnicity=\'1\' table=\"xxx_artikkel_210127\".\"%s_piir\" (geometry)', obj),
|
|
|
|
|
+ OUTPUT = qgisprocess::qgis_tmp_vector(),
|
|
|
|
|
+ PREDICATE = 0,
|
|
|
|
|
+ .quiet = TRUE
|
|
|
|
|
+ )
|
|
|
|
|
+ result
|
|
|
|
|
+}
|
|
|
|
|
+# create_pk_piir_bb(obj = objektid[i])
|
|
|
|
|
+
|
|
|
|
|
+## Funktsioon: piirkonna piiri piirikasti (boundary box) lugemine
|
|
|
|
|
+pk_piir_bb <- function(obj){
|
|
|
|
|
+ # obj - objekti nimetus (näiteks: valga)
|
|
|
|
|
+ conn <- ruut::db_connect()
|
|
|
|
|
+ q <- sprintf("SELECT * FROM %s.%s_epk10t", conf$schema, tolower(obj))
|
|
|
|
|
+ cat(sprintf("\n-----------------\n%s\n\n", q))
|
|
|
|
|
+ sf::st_read(conn, query = q)
|
|
|
|
|
+}
|
|
|
|
|
+# pk_piir_bb(obj = "valga")
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+# -----------------------------------------------------------------------
|