Jelajahi Sumber

Lisatud 'qgis_algorithm_search_by_word'.

Ardo Kubjas 5 tahun lalu
induk
melakukan
a0b056099b
4 mengubah file dengan 84 tambahan dan 1 penghapusan
  1. 1 1
      DESCRIPTION
  2. 1 0
      NAMESPACE
  3. 51 0
      R/qgis_algorithm_search_by_word.R
  4. 31 0
      man/qgis_algorithm_search_by_word.Rd

+ 1 - 1
DESCRIPTION

@@ -12,4 +12,4 @@ Encoding: UTF-8
 LazyData: true
 Roxygen: list(markdown = TRUE)
 RoxygenNote: 7.1.1.9000
-Imports: qgisprocess, DBI, pool, RPostgreSQL, sf, raster, stars, rgdal, tidyverse, inborutils, rvest, seleniumPipes, rjson
+Imports: qgisprocess, DBI, pool, RPostgreSQL, sf, raster, stars, rgdal, tidyverse, inborutils, rvest, seleniumPipes, rjson, methods

+ 1 - 0
NAMESPACE

@@ -10,3 +10,4 @@ export(db_is_shema_exist)
 export(db_table_colnames)
 export(get_config)
 export(pk_bbox)
+export(qgis_algorithm_search_by_word)

+ 51 - 0
R/qgis_algorithm_search_by_word.R

@@ -0,0 +1,51 @@
+#' QGIS-i algoritmi leidmine fraasi järele
+#'
+#' Funktsioon leiab fraasi järele QGIS-i algoritmid.
+#' @param str	string otsitav fras.
+#' @keywords qgis, help
+#' @export
+#' @examples
+#' ## Not run:
+#' ##
+#' ## qgis_algorithm_search_by_word(str = "clip")
+#' ## algorithm <- "native:clip"
+#' ## # Read help.
+#' ## qgisprocess::qgis_show_help(algorithm = algorithm)
+#' ##
+#' ## qgis_algorithm_search_by_word(str = "centroid")
+#' ## qgis_algorithm_search_by_word(str = "filedownloader")
+#' ## qgis_algorithm_search_by_word(str = "")
+#' ## qgis_algorithm_search_by_word()
+#' ##
+#' ## End(**Not run**)
+qgis_algorithm_search_by_word <- function(str = NULL) {
+  if (is.null(str) || str == "") {
+    return(NULL)
+  }
+  algs <- qgisprocess::qgis_algorithms(query = FALSE, quiet = TRUE)
+  ids <- grep(str, algs$algorithm)
+  algs.id <- methods::cbind2(ids, algs[ids, ])
+  colnames(algs.id) <- c("id", colnames(algs))
+  print(algs.id)
+  i <- 1
+  # Juhendi näitamine
+  if (nrow(algs.id) > 1) {
+    while (T) {
+      num <- readline(sprintf(
+        "Millist juhendit soovid vaadata (%s)? > ",
+        paste(seq(1:nrow(algs.id)), collapse = ",")
+      ))
+      num <- as.numeric(num)
+      if (num %in% seq(1:nrow(algs.id))) {
+        i <- num
+        break
+      }
+    }
+  }
+  qgisprocess::qgis_show_help(algs.id[i, "algorithm"])
+  cat("\n----------------\n")
+  cat("\nValitud algoritm:\n")
+  cat(algs.id[i, "algorithm"])
+  cat("\n\n----------------\n")
+  cat("\n\n")
+}

+ 31 - 0
man/qgis_algorithm_search_by_word.Rd

@@ -0,0 +1,31 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/qgis_algorithm_search_by_word.R
+\name{qgis_algorithm_search_by_word}
+\alias{qgis_algorithm_search_by_word}
+\title{QGIS-i algoritmi leidmine fraasi järele}
+\usage{
+qgis_algorithm_search_by_word(str = NULL)
+}
+\arguments{
+\item{str}{string otsitav fras.}
+}
+\description{
+Funktsioon leiab fraasi järele QGIS-i algoritmid.
+}
+\examples{
+## Not run:
+##
+## qgis_algorithm_search_by_word(str = "clip")
+## algorithm <- "native:clip"
+## # Read help.
+## qgisprocess::qgis_show_help(algorithm = algorithm)
+##
+## qgis_algorithm_search_by_word(str = "centroid")
+## qgis_algorithm_search_by_word(str = "filedownloader")
+## qgis_algorithm_search_by_word(str = "")
+## qgis_algorithm_search_by_word()
+##
+## End(**Not run**)
+}
+\keyword{help}
+\keyword{qgis,}