Skip to content

Commit

Permalink
Merge pull request #116 from mdsumner/main
Browse files Browse the repository at this point in the history
fix crs strings
  • Loading branch information
mdsumner authored Sep 2, 2024
2 parents 6386ab2 + 2ff1cee commit 8d0acf7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# dev

* Fixed bug in crs detection (#115) .
* Removed rgdal.

* Changed underlying method of getting background bathymetry for SOmap_auto().
Expand Down
11 changes: 8 additions & 3 deletions R/new_automap.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,13 @@ automap_maker <-
tgt_prj <- NULL
xy <- NULL
llxy <- NULL
if (!is.null(target) && substr(trimws(target, which = "left"), 1, 1) == "+") {
## whoa we have an actual PROJ.4 string
is_a_crs <- function(x) {
test <- try(sf::st_crs(x), silent = TRUE)
!inherits(test, "try-error")
}
if (!is.null(target) && is_a_crs(target)){

## whoa we have an actual crs string
if (!is.null(centre_lon) || !is.null(centre_lat)) {
warning("'target' provided looks like a PROJ so centre_lon/centre_lat ignored")
centre_lon <- centre_lat <- NULL
Expand All @@ -152,7 +157,7 @@ automap_maker <-
}

## we gave it a grid, but also a target family
if (!is.null(target) && !grepl("^\\+", target) && (length(c(centre_lon, centre_lat)) < 2)) {
if (!is.null(target) && !is_a_crs(target) && (length(c(centre_lon, centre_lat)) < 2)) {
## get the centre lon and lat from the input

cpts <- spbabel::sptable(spex::spex(x))[-1, c("x_", "y_")]
Expand Down
Binary file modified tests/testthat/Rplots.pdf
Binary file not shown.

0 comments on commit 8d0acf7

Please sign in to comment.