qgis_algorithm_search_by_word.R 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #' QGIS-i algoritmi leidmine fraasi järele
  2. #'
  3. #' Funktsioon leiab fraasi järele QGIS-i algoritmid.
  4. #' @param str string otsitav algoritmi fraas.
  5. #' @return Table found algorithms. Help for the selected algorithm.
  6. #' @return A array of all database schemas.
  7. #' @seealso [qgisprocess::qgis_algorithms()]
  8. #' @keywords qgis, help
  9. #' @export
  10. #' @examples
  11. #' \dontrun{
  12. #'
  13. #' qgis_algorithm_search_by_word(str = "clip")
  14. #' algorithm <- "native:clip"
  15. #' # Read help.
  16. #' qgisprocess::qgis_show_help(algorithm = algorithm)
  17. #'
  18. #' qgis_algorithm_search_by_word(str = "centroid")
  19. #' qgis_algorithm_search_by_word(str = "filedownloader")
  20. #' qgis_algorithm_search_by_word(str = "")
  21. #' qgis_algorithm_search_by_word()
  22. #'
  23. #' }
  24. qgis_algorithm_search_by_word <- function(str = NULL) {
  25. if (is.null(str) || str == "") {
  26. return(NULL)
  27. }
  28. algs <- qgisprocess::qgis_algorithms(query = FALSE, quiet = TRUE)
  29. ids <- grep(str, algs$algorithm)
  30. algs.id <- methods::cbind2(ids, algs[ids, ])
  31. colnames(algs.id) <- c("id", colnames(algs))
  32. print(algs.id)
  33. i <- 1
  34. # Juhendi näitamine
  35. if (nrow(algs.id) > 1) {
  36. while (T) {
  37. num <- readline(sprintf(
  38. "Millist juhendit soovid vaadata (%s)? > ",
  39. paste(seq(1:nrow(algs.id)), collapse = ",")
  40. ))
  41. num <- as.numeric(num)
  42. if (num %in% seq(1:nrow(algs.id))) {
  43. i <- num
  44. break
  45. }
  46. }
  47. }
  48. qgisprocess::qgis_show_help(algs.id[i, "algorithm"])
  49. cat("\n----------------\n")
  50. cat("\nValitud algoritm:\n")
  51. cat(algs.id[i, "algorithm"])
  52. cat("\n\n----------------\n")
  53. cat("\n\n")
  54. }