qgis_algorithm_search_by_word.R 1.4 KB

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