Skip to content

Commit

Permalink
remove deps
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsumner committed Dec 24, 2023
1 parent 1cc5967 commit a3c700a
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 6 deletions.
11 changes: 7 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
Package: dsn
Title: Data Source Name Helpers for Use With GDAL
Version: 0.0.1.9010
Title: Data Source Name and Description Helpers for Use With 'GDAL'
Version: 0.0.1.9011
Authors@R:
person("Michael", "Sumner", , "[email protected]", role = c("aut", "cre"))
Description: Simple helpers for GDAL data source names (DSN), for prefix and suffix and other handling.
c(person("Michael", "Sumner", , "[email protected]", role = c("aut", "cre")),
person("Matt", "Dowle", role = "ctb", comment = "wrote the source code used here in C_addr, originally in data.table"))
Description: Simple helpers for 'GDAL' data source names ('DSN'), prefix and
suffix and other handling. 'GDAL' is the Geospatial Data Abstraction Library,
not used by this package directly.
License: MIT + file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ export(unvsicurl)
export(vrtcon)
export(vsicurl)
importFrom(lobstr,obj_addr)
useDynLib(dsn, .registration = TRUE)
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# dev

* New internal C_addr, to replace lobstr import.

* `vsicurl()` gains pc_url_signing with the `sign` arg (GDAL >= 3.5).

* All data source functions have been removed to spatial.datasources.
* All data source functions have been removed to hypertidy/sds, so countrycode no longer needed.

* New `nsdic_seaice()` for the GeoTIFF images.

Expand Down
6 changes: 6 additions & 0 deletions R/dsn-package.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#' @keywords internal
"_PACKAGE"
## usethis namespace: start
#' @useDynLib dsn, .registration = TRUE
## usethis namespace: end
NULL
19 changes: 18 additions & 1 deletion R/mem.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ mem <- function(x, extent = NULL, projection = "") {
offset <- c(Int32 = 4, Float64 = 8, Byte = 1)[type]
gt <- ext_dim(extent, dimension)

addr <- as.double(lobstr::obj_addr(x)) + 6 * offset
addr <- as.double(addr(x)) + 6 * offset

spatialref <- ""

Expand All @@ -60,3 +60,20 @@ mem <- function(x, extent = NULL, projection = "") {
dsn

}



#' Get address of object
#'
#' This is primarily for use by mem().
#'
#' Adapted from data.table::address
#'
#' @param x object to get address of
#'
#' @return address as a string
#'
#' @noRd
addr <- function(x) {
.Call("C_addr", x = x, PACKAGE = "dsn")
}
28 changes: 28 additions & 0 deletions man/dsn-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.o
*.so
*.dll
9 changes: 9 additions & 0 deletions src/addr.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <Rinternals.h>

SEXP C_addr(SEXP x)
{
// A better way than : http://stackoverflow.com/a/10913296/403310
char buffer[32];
snprintf(buffer, 32, "%p", (void *)x);
return(Rf_mkString(buffer));
}
17 changes: 17 additions & 0 deletions src/init.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <Rinternals.h>
#include <R_ext/Rdynload.h>



/* .Call calls */
extern SEXP C_addr(SEXP x);

static const R_CallMethodDef CallEntries[] = {
{"C_addr", (DL_FUNC) &C_addr, 1},
{NULL, NULL, 0}
};

void R_init_addr(DllInfo *dll) {
R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);
R_useDynamicSymbols(dll, FALSE);
}

0 comments on commit a3c700a

Please sign in to comment.