Skip to content

Commit

Permalink
add GEOS runtime vs compile time version check; #844
Browse files Browse the repository at this point in the history
  • Loading branch information
edzer committed Sep 13, 2018
1 parent 5799c3a commit daadcee
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# version 0.7-0

* all GEOS routines are now more robust against memory leaks, by using unique pointers; #822, #845, by Dan Baston

* `st_buffer` receives the buffer styles `endCapStyle`, `joinStyle` and `mitreLimit`; #833, #842 by Mike Sumner

# version 0.6-4
Expand Down
4 changes: 2 additions & 2 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ CPL_geos_op2 <- function(op, sfcx, sfcy) {
.Call('_sf_CPL_geos_op2', PACKAGE = 'sf', op, sfcx, sfcy)
}

CPL_geos_version <- function(b = FALSE) {
.Call('_sf_CPL_geos_version', PACKAGE = 'sf', b)
CPL_geos_version <- function(runtime = FALSE, capi = FALSE) {
.Call('_sf_CPL_geos_version', PACKAGE = 'sf', runtime, capi)
}

CPL_geos_dist <- function(sfc0, sfc1, which, par) {
Expand Down
2 changes: 2 additions & 0 deletions R/init.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ setOldClass("sfg")
.onAttach = function(libname, pkgname) {
m = paste0("Linking to GEOS ", CPL_geos_version(), ", GDAL ", CPL_gdal_version(), ", proj.4 ", CPL_proj_version())
packageStartupMessage(m)
if (grep(sf:::CPL_geos_version(FALSE, TRUE), sf:::CPL_geos_version(TRUE)) != 1)
packageStartupMessage("WARNING: different compile-time and runtime versions for GEOS")
}

#' Provide the external dependencies versions of the libraries linked to sf
Expand Down
11 changes: 6 additions & 5 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,13 +590,14 @@ BEGIN_RCPP
END_RCPP
}
// CPL_geos_version
std::string CPL_geos_version(bool b);
RcppExport SEXP _sf_CPL_geos_version(SEXP bSEXP) {
std::string CPL_geos_version(bool runtime, bool capi);
RcppExport SEXP _sf_CPL_geos_version(SEXP runtimeSEXP, SEXP capiSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< bool >::type b(bSEXP);
rcpp_result_gen = Rcpp::wrap(CPL_geos_version(b));
Rcpp::traits::input_parameter< bool >::type runtime(runtimeSEXP);
Rcpp::traits::input_parameter< bool >::type capi(capiSEXP);
rcpp_result_gen = Rcpp::wrap(CPL_geos_version(runtime, capi));
return rcpp_result_gen;
END_RCPP
}
Expand Down Expand Up @@ -996,7 +997,7 @@ static const R_CallMethodDef CallEntries[] = {
{"_sf_CPL_geos_op", (DL_FUNC) &_sf_CPL_geos_op, 10},
{"_sf_CPL_geos_voronoi", (DL_FUNC) &_sf_CPL_geos_voronoi, 4},
{"_sf_CPL_geos_op2", (DL_FUNC) &_sf_CPL_geos_op2, 3},
{"_sf_CPL_geos_version", (DL_FUNC) &_sf_CPL_geos_version, 1},
{"_sf_CPL_geos_version", (DL_FUNC) &_sf_CPL_geos_version, 2},
{"_sf_CPL_geos_dist", (DL_FUNC) &_sf_CPL_geos_dist, 4},
{"_sf_CPL_geos_nearest_feature", (DL_FUNC) &_sf_CPL_geos_nearest_feature, 2},
{"_sf_CPL_geos_nearest_points", (DL_FUNC) &_sf_CPL_geos_nearest_points, 3},
Expand Down
11 changes: 9 additions & 2 deletions src/geos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -792,8 +792,15 @@ Rcpp::List CPL_geos_op2(std::string op, Rcpp::List sfcx, Rcpp::List sfcy) {
}

// [[Rcpp::export]]
std::string CPL_geos_version(bool b = false) {
return GEOS_VERSION;
std::string CPL_geos_version(bool runtime = false, bool capi = false) {
if (runtime)
return GEOSversion();
else {
if (capi)
return GEOS_CAPI_VERSION;
else
return GEOS_VERSION;
}
}

// [[Rcpp::export]]
Expand Down

0 comments on commit daadcee

Please sign in to comment.