| 1 |
#.onLoad <- function(lib, pkg) { |
| 2 |
# require(methods) |
| 3 |
#} |
| 4 |
.spOptions <- new.env(FALSE, globalenv()) |
| 5 |
assign("ll_warn", FALSE, envir = .spOptions) |
| 6 |
assign("ll_TOL", 0.25, envir = .spOptions) |
| 7 |
assign("ReplCRS_warn", TRUE, envir = .spOptions) |
| 8 |
assign("Polypath", TRUE, envir = .spOptions) |
| 9 |
assign("PolypathRule", "winding", envir = .spOptions) |
| 10 |
assign("col.regions", bpy.colors(), envir = .spOptions) |
| 11 |
assign("evolution_status", 2L, envir=.spOptions) # fixed changed 2.1-0 |
| 12 |
assign("startup_message", "none", envir=.spOptions) # https://github.com/serafinialessio/mapping/issues/3 |
| 13 |
|
| 14 |
#.sp_CRS_cache <- new.env(FALSE, globalenv()) |
| 15 |
#assign("CRS_CACHE", list(), envir=.sp_CRS_cache) |
| 16 |
.sp_CRS_cache <- new.env(hash=TRUE, globalenv()) |
| 17 |
|
| 18 |
.onLoad <- function(lib, pkg) { |
| 19 |
load_stuff() |
| 20 |
if (get("startup_message", envir=.spOptions) == "load") |
| 21 |
smess_func() |
| 22 |
} |
| 23 |
|
| 24 |
.onAttach <- function(lib, pkg) { |
| 25 |
if (get("startup_message", envir=.spOptions) == "attach") |
| 26 |
smess_func() |
| 27 |
} |
| 28 |
|
| 29 |
|
| 30 |
load_stuff <- function() { |
| 31 |
startup_message <- unlist(options("sp_startup_message")) |
| 32 |
if (!is.null(startup_message)) { |
| 33 |
startup_message <- as.character(startup_message) |
| 34 |
stopifnot(is.character(startup_message)) |
| 35 |
stopifnot(isTRUE(startup_message %in% c("attach", "load", "none"))) |
| 36 |
assign("startup_message", unname(startup_message), envir=.spOptions) |
| 37 |
} else { |
| 38 |
startup_message <- Sys.getenv("_SP_STARTUP_MESSAGE_") |
| 39 |
if (nchar(startup_message) > 0L) { |
| 40 |
startup_message <- as.character(startup_message) |
| 41 |
stopifnot(is.character(startup_message)) |
| 42 |
stopifnot(isTRUE(startup_message %in% c("attach", "load", "none"))) |
| 43 |
assign("startup_message", unname(startup_message), envir=.spOptions) |
| 44 |
} |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
smess_func <- function() { |
| 49 |
where <- get("startup_message", envir=.spOptions) |
| 50 |
Smess <- paste0("The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,\nwhich was just ", where, "ed, were retired in October 2023.\nPlease refer to R-spatial evolution reports for details, especially\nhttps://r-spatial.org/r/2023/05/15/evolution4.html.\nIt may be desirable to make the sf package available;\npackage maintainers should consider adding sf to Suggests:.\n") |
| 51 |
packageStartupMessage(Smess, appendLF = FALSE) |
| 52 |
} |
| 53 |
|
| 54 |
.onUnload <- function(libpath) |
| 55 |
library.dynam.unload("sp", libpath) |