File: Class-ST.R

package info (click to toggle)
r-cran-spacetime 1.3-3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,240 kB
  • sloc: sh: 13; makefile: 2
file content (26 lines) | stat: -rw-r--r-- 949 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
setClass("ST",
  slots = c(sp = "Spatial", time = "xts", endTime = "POSIXct"),
  validity = function(object) {
    stopifnot(length(object@sp) >= 1)
	stopifnot(nrow(object@time) >= 1)
	stopifnot(nrow(object@time) == length(object@endTime))
	# do the time zones, if set, match?
	tz1 = tzone(object@time)
	tz2 = tzone(object@endTime)
	tz1.set = (!is.null(tz1) && !nchar(tz1)==0)
	tz2.set = (!is.null(tz2) && !nchar(tz2)==0)
	stopifnot(tz1.set == tz2.set)
	if (tz1.set)
		stopifnot(tz1 == tz2)
	if (any(names(object@time) %in% names(object@sp)))
		stop("name conflict: attribute names in sp and time slot must differ")
	return(TRUE)
  }
)

.checkAttrIsUnique = function(sp, time, data) {
	if (any(names(sp) %in% names(data)))
		stop("name conflict: attribute name(s) in data already present in sp slot of ST object")
	if (any(names(time) %in% names(data)))
		stop("name conflict: attribute name(s) in data already present in time slot of ST object")
}