-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from ncss-tech/horizon-id-madness
Horizon id madness
- Loading branch information
Showing
26 changed files
with
720 additions
and
308 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,9 @@ importFrom(methods, | |
setMethod, | ||
as, | ||
show, | ||
slot | ||
slot, | ||
.hasSlot, | ||
slotNames | ||
) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
# test for valid SPC, based on presence / absense of slots as compared to | ||
# class prototype | ||
# likely only used between major versions of aqp where internal structure of SPC has changed | ||
checkSPC <- function(x) { | ||
|
||
# get slot names from prototype | ||
sn <- slotNames(x) | ||
|
||
# test for all slots in the prototype | ||
s.test <- sapply(sn, function(i) .hasSlot(x, name=i)) | ||
|
||
# a valid object will have all slots present | ||
if(all(s.test)) { | ||
res <- TRUE | ||
} else { | ||
res <- FALSE | ||
} | ||
|
||
return(res) | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# repair an SPC by breaking into pieces and re-assembling | ||
# likely only used to fix outdated SPC objects that are missing slots | ||
rebuildSPC <- function(x) { | ||
|
||
# break into pieces as list | ||
x.list <- suppressWarnings(as(x, 'list')) | ||
|
||
# seed object for new SPC | ||
res <- x.list$horizons | ||
|
||
# init SPC from pieces | ||
# note: using depths<- because it will generate a horizon ID | ||
fm <- as.formula(sprintf("%s ~ %s + %s", x.list$idcol, x.list$depthcols[1], x.list$depthcols[2])) | ||
depths(res) <- fm | ||
|
||
# add additional pieces | ||
metadata(res) <- x.list$metadata | ||
site(res) <- x.list$site | ||
res@sp <- x.list$sp | ||
diagnostic_hz(res) <- x.list$diagnostic | ||
|
||
return(res) | ||
} | ||
|
Oops, something went wrong.