Skip to content

Commit e15a997

Browse files
authored
fix(check_crs_terra): Prefix terra:crs() call (#894)
1 parent d8c9794 commit e15a997

File tree

2 files changed

+5
-22
lines changed

2 files changed

+5
-22
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# leaflet (development version)
22

3+
* Fixed #893: Correctly call `terra::crs()` when checking the CRS of a `SpatVector` object in `pointData()` or `polygonData()` (thanks @mkoohafkan, #894).
4+
35
# leaflet 2.2.1
46

57
* When `addProviderTiles()` is used with `{leaflet.providers}` version 2.0.0 or later, the `leaflet-providers` HTML dependency produced can be correctly cached by knitr. When used with older versions of `{leaflet.providers}`, the HTML dependency uses temp files that break knitr's caching mechanism (thanks @qdread, @jaredlander; #884).

R/normalize-terra.R

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,29 +50,10 @@ polygonData.SpatVector <- function(obj) {
5050

5151

5252
# helpers -----------------------------------------------------------------
53-
assure_crs_terra <- function(x) {
53+
check_crs_terra <- function(x) {
5454
stopifnot(is_installed("terra"))
5555

56-
prj <- raster::crs(x, proj = TRUE)
57-
58-
if (is.na(prj) || (prj == "")) {
59-
# Don't have enough information to check
60-
warning("SpatVector layer is not long-lat data", call. = FALSE)
61-
return(x)
62-
}
63-
64-
if (terra::is.lonlat(x, perhaps = TRUE, warn = FALSE)) {
65-
if (!grepl("+datum=WGS84", prj, fixed = TRUE)) {
66-
x <- terra::project(x, "+proj=longlat +datum=WGS84")
67-
}
68-
return(x)
69-
}
70-
71-
terra::project(x, "+proj=longlat +datum=WGS84")
72-
}
73-
74-
check_crs_terra <- function(x) {
75-
crs <- crs(x)
56+
crs <- terra::crs(x)
7657

7758
# Don't have enough information to check
7859
if (is.na(crs) || (crs==""))
@@ -82,7 +63,7 @@ check_crs_terra <- function(x) {
8263
warning("SpatVector layer is not long-lat data", call. = FALSE)
8364
}
8465

85-
prj <- crs(x, proj=TRUE)
66+
prj <- terra::crs(x, proj=TRUE)
8667
if (!grepl("+datum=WGS84", prj, fixed = TRUE)) {
8768
warning(
8869
"SpatVector layer has inconsistent datum (", prj, ").\n",

0 commit comments

Comments
 (0)