-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix Atlas Issue Ref #94 checks if using Atlas and whether the shape is invalid if so it sets the precision * Close #96 - expanded warning message * Update NEWS * Bump package version
- Loading branch information
1 parent
8a4b590
commit 154a9db
Showing
11 changed files
with
256 additions
and
189 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 |
---|---|---|
|
@@ -11,7 +11,7 @@ Suggests: knitr, | |
VignetteBuilder: knitr | ||
Type: Package | ||
Title: Distance Sampling Survey Design | ||
Version: 1.0.1 | ||
Version: 1.0.2 | ||
Authors@R: c( | ||
person("Laura", "Marshall", email = "[email protected]", role = c("aut", "cre")), | ||
person("Rexstad", "Eric", email = "[email protected]", role = "ctb")) | ||
|
@@ -59,6 +59,7 @@ Collate: | |
'generate.systematic.points.R' | ||
'get.intersection.points.R' | ||
'line.coords.as.dataframe.R' | ||
'mat.mult.R' | ||
'point.coords.as.dataframe.R' | ||
'run.coverage.R' | ||
'write.transects.R' |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,37 @@ | ||
#' @importFrom utils sessionInfo | ||
#' @importFrom sf st_make_valid st_set_precision st_is_valid | ||
mat.mult <- function(x,y){ | ||
# Internal function for performing matrix multiplication with atlas checks for validity | ||
# reverse rotation | ||
unrotate <- x*y | ||
# if we are using atlas and the shape is not valid | ||
if(grepl("atlas", sessionInfo()$BLAS) && is.na(sf::st_is_valid(unrotate))){ | ||
# validity flag | ||
is.valid <- FALSE | ||
# counter | ||
index <- 1 | ||
# Precision values to try | ||
precision <- c(1e10,1e9,1e8,1e7,1e6,1e5,1e4) | ||
# turn it into and sfc shape | ||
tmp <- sf::st_sfc(unrotate) | ||
# Keep trying to fix across a range of precision values | ||
while(!is.valid && index <= length(precision)){ | ||
tmp2 <- try(sf::st_make_valid(sf::st_set_precision(tmp, precision[index])), silent = TRUE) | ||
if(inherits(tmp2, "try-error")){ | ||
# If the problem is not fixed try a lower precision | ||
index <- index + 1 | ||
}else{ | ||
# Otherwise it is fixed continue | ||
is.valid <- TRUE | ||
tmp <- tmp2 | ||
} | ||
} | ||
# What if none of the precisions succeed? | ||
if(!is.valid){ | ||
stop("Problem with matrix multiplication due to BLAS/ATLAS setup. dssd has tried to resolve this issue by reducing the precision to 1e4 (see ?sf::st_precision) but differences persist in what should be identical coordinates.", call. = FALSE) | ||
} | ||
# extract shape again | ||
unrotate <- tmp[[1]] | ||
} | ||
return(unrotate) | ||
} |