1
#' @include RcppExports.R raptr-internal.R misc.R generics.R RapReliableOpts.R RapUnreliableOpts.R RapData.R
2
NULL
3

4
#' RapUnsolved: An S4 class to represent RAP inputs
5
#'
6
#' This class is used to store RAP input data and input parameters.
7
#'
8
#' @slot opts [RapReliableOpts()] or [RapUnreliableOpts()]
9
#'   object used to store input parameters.
10
#'
11
#' @slot data [RapData()] object used to store input data.
12
#'
13
#'
14
#' @seealso  [RapReliableOpts-class],
15
#'   [RapUnreliableOpts-class], [RapData-class].
16
#'
17
#' @name RapUnsolved-class
18
#'
19
#' @rdname RapUnsolved-class
20
#'
21
#' @exportClass RapUnsolved
22
methods::setClass("RapUnsolved",
23
                  methods::representation(opts = "RapOpts", data = "RapData"))
24

25
#' Create a new RapUnsolved object
26
#'
27
#' This function creates a [RapUnsolved()] object using a
28
#' [GurobiOpts()], a [RapReliableOpts()] or
29
#' [RapUnreliableOpts()] object, and a [RapData()] object.
30
#'
31
#' @param opts [RapReliableOpts()] or [RapUnreliableOpts()]
32
#'   object.
33
#'
34
#' @param data [RapData()] object.
35
#'
36
#' @return [RapUnsolved()] object.
37
#'
38
#' @seealso [RapReliableOpts-class],
39
#'   [RapUnreliableOpts-class], [RapData-class].
40
#'
41
#' @examples
42
#' \dontrun{
43
#' # set random number generator seed
44
#' set.seed(500)
45
#'
46
#' # load data
47
#' data(cs_pus, cs_spp)
48
#'
49
#' # create inputs for RapUnsolved
50
#' ro <- RapUnreliableOpts()
51
#' rd <- make.RapData(cs_pus[seq_len(10), ], cs_spp, NULL,
52
#'                    include.geographic.space = TRUE,n.demand.points = 5L)
53
#'
54
#' # create RapUnsolved object
55
#' ru <- RapUnsolved(ro, rd)
56
#'
57
#' # print object
58
#' print(ru)
59
#' }
60
#' @export
61
RapUnsolved <- function(opts, data) {
62 4
  methods::new("RapUnsolved", opts = opts, data = data)
63
}
64

65
#' @method print RapUnsolved
66
#'
67
#' @rdname print
68
#'
69
#' @export
70
print.RapUnsolved <- function(x, ...) {
71 0
  message("RapUnsolved object\n")
72 0
  message("Parameters")
73 0
  print(x@opts, header = FALSE)
74 0
  message("Data")
75 0
  print.RapData(x@data, header = FALSE)
76 0
  invisible()
77
}
78

79
#' @rdname show
80
#'
81
#' @usage \S4method{show}{RapUnsolved}(object)
82
#'
83
#' @name show
84
#'
85
#' @aliases show,RapUnsolved-method
86
methods::setMethod("show", "RapUnsolved",
87 0
                   function(object) print.RapUnsolved(object))
88

89
#' @rdname spp.plot
90
#'
91
#' @method spp.plot RapUnsolved
92
#'
93
#' @export
94
spp.plot.RapUnsolved <- function(x, species, prob.color.palette = "YlGnBu",
95
                                 pu.color.palette = c("#4D4D4D", "#00FF00",
96
                                                      "#FFFF00", "#FF0000"),
97
                                 basemap = "none",
98
                                 alpha = ifelse(basemap == "none", 1, 0.7),
99
                                 grayscale = FALSE, main = NULL,
100
                                 force.reset = FALSE, ...) {
101
  # set title
102 0
  if (is.null(main)) {
103 0
    if ("name" %in% names(x@data@species) & is.numeric(species)) {
104 0
      main <- paste0(x@data@species$name[species])
105 0
    } else if (is.numeric(species)) {
106 0
      main <- paste0("Species ", species)
107
    } else {
108 0
      main <- paste0(species)
109
    }
110
  }
111 0
  spp.plot(x = x@data, species = species,
112 0
           prob.color.palette = prob.color.palette,
113 0
           pu.color.palette = pu.color.palette, basemap = basemap,
114 0
           alpha = alpha, grayscale = grayscale, main = main,
115 0
           force.reset = force.reset, ...)
116
}
117

118
#' @rdname space.plot
119
#'
120
#' @method space.plot RapUnsolved
121
#'
122
#' @export
123
space.plot.RapUnsolved <- function(x, species, space=1,
124
                                   pu.color.palette = c("#4D4D4D4D",
125
                                                        "#00FF0080",
126
                                                        "#FFFF0080",
127
                                                        "#FF00004D"),
128
                                   main=NULL, ...) {
129
  # set title
130 0
  if (is.null(main)) {
131 0
    if ("name" %in% names(x@data@species) & is.numeric(species)) {
132 0
      main <- paste0(x@data@species$name[species], " in space ", space)
133 0
    } else if (is.numeric(species)) {
134 0
      main <- paste0("Species ", species, " in space ", space)
135
    } else {
136 0
      main <- paste0(species, " in space ", space)
137
    }
138
  }
139 0
  space.plot.RapData(x@data, species, space, pu.color.palette, main, ...)
140
}

Read our documentation on viewing source code .

Loading