diff --git a/NAMESPACE b/NAMESPACE index eefe027..3a4c7b5 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -18,6 +18,7 @@ export(vapour_get_config) export(vapour_layer_extent) export(vapour_layer_info) export(vapour_layer_names) +export(vapour_proj_version) export(vapour_raster_gcp) export(vapour_raster_info) export(vapour_read_attributes) diff --git a/R/RcppExports.R b/R/RcppExports.R index e28effa..f0f165f 100644 --- a/R/RcppExports.R +++ b/R/RcppExports.R @@ -53,6 +53,10 @@ version_gdal_cpp <- function() { .Call('_vapour_version_gdal_cpp', PACKAGE = 'vapour') } +version_proj_cpp <- function() { + .Call('_vapour_version_proj_cpp', PACKAGE = 'vapour') +} + vsi_list_gdal_cpp <- function(dsn) { .Call('_vapour_vsi_list_gdal_cpp', PACKAGE = 'vapour', dsn) } diff --git a/R/vapour-gdal-library.R b/R/vapour-gdal-library.R index a4ca91a..40000f0 100644 --- a/R/vapour-gdal-library.R +++ b/R/vapour-gdal-library.R @@ -85,10 +85,12 @@ vapour_srs_wkt <- function(crs) { #' @export #' #' @examples +#' vapour_proj_version() +#' vapour_crs_is_lonlat("EPSG:4326") #' vapour_srs_wkt("+proj=laea") #' vapour_crs_is_lonlat("+proj=laea +type=crs") #' vapour_crs_is_lonlat("+proj=longlat +type=crs") -#' vapour_crs_is_lonlat("+init=EPSG:4326") +#' vapour_crs_is_lonlat("EPSG:4326") #' vapour_crs_is_lonlat("OGC:CRS84") #' vapour_crs_is_lonlat("WGS84") #' vapour_crs_is_lonlat("NAD27") @@ -166,7 +168,7 @@ vapour_geom_summary <- function(dsource, layer = 0L, sql = "", limit_n = NULL, s #' long name and other properties use `vapour_all_drivers()` and match on 'driver'. #' #' @export -#' @aliases vapour_all_drivers vapour_driver +#' @aliases vapour_all_drivers vapour_driver vapour_proj_version #' @rdname GDAL-library #' @return please see Details, character vectors or lists of character vectors #' @examples @@ -181,6 +183,12 @@ vapour_geom_summary <- function(dsource, layer = 0L, sql = "", limit_n = NULL, s vapour_gdal_version <- function() { version_gdal_cpp() } + +#' @rdname GDAL-library +#' @export +vapour_proj_version <- function() { + paste0(version_proj_cpp(), collapse = ".") +} #' @rdname GDAL-library #' @export vapour_all_drivers <- function() { diff --git a/inst/include/gdallibrary/gdallibrary.h b/inst/include/gdallibrary/gdallibrary.h index c5e7856..169edcc 100644 --- a/inst/include/gdallibrary/gdallibrary.h +++ b/inst/include/gdallibrary/gdallibrary.h @@ -5,7 +5,7 @@ #include "gdal_priv.h" #include "CollectorList.h" #include "gdalraster/gdalraster.h" - +#include "ogr_srs_api.h" namespace gdallibrary { using namespace Rcpp; @@ -97,6 +97,19 @@ inline R_xlen_t force_layer_feature_count(OGRLayer *poLayer) { } return out; } +inline IntegerVector proj_version() +{ + Rcpp::IntegerVector out(3); + + + int num1; int num2; int num3; + OSRGetPROJVersion(&num1, &num2, &num3); + out[0] = num1; + out[1] = num2; + out[2] = num3; + return out; +} + inline CharacterVector gdal_version() { Rcpp::CharacterVector out(1); diff --git a/man/GDAL-library.Rd b/man/GDAL-library.Rd index 2ffc69b..f065c23 100644 --- a/man/GDAL-library.Rd +++ b/man/GDAL-library.Rd @@ -4,10 +4,13 @@ \alias{vapour_gdal_version} \alias{vapour_all_drivers} \alias{vapour_driver} +\alias{vapour_proj_version} \title{GDAL version and drivers.} \usage{ vapour_gdal_version() +vapour_proj_version() + vapour_all_drivers() vapour_driver(dsource) diff --git a/man/vapour_crs_is_lonlat.Rd b/man/vapour_crs_is_lonlat.Rd index e87e660..44e2e17 100644 --- a/man/vapour_crs_is_lonlat.Rd +++ b/man/vapour_crs_is_lonlat.Rd @@ -16,10 +16,12 @@ logical value \code{TRUE} for lonlat, \code{FALSE} otherwise Returns \code{TRUE} if this is longitude latitude data. Missing, malformed, zero-length values are disallowed. } \examples{ +vapour_proj_version() +vapour_crs_is_lonlat("EPSG:4326") vapour_srs_wkt("+proj=laea") vapour_crs_is_lonlat("+proj=laea +type=crs") vapour_crs_is_lonlat("+proj=longlat +type=crs") -vapour_crs_is_lonlat("+init=EPSG:4326") +vapour_crs_is_lonlat("EPSG:4326") vapour_crs_is_lonlat("OGC:CRS84") vapour_crs_is_lonlat("WGS84") vapour_crs_is_lonlat("NAD27") diff --git a/src/00_gdal.cpp b/src/00_gdal.cpp index 44bddfb..ee2b567 100644 --- a/src/00_gdal.cpp +++ b/src/00_gdal.cpp @@ -57,7 +57,10 @@ LogicalVector register_gdal_cpp() { CharacterVector version_gdal_cpp() { return gdallibrary::gdal_version(); } - +// [[Rcpp::export]] +IntegerVector version_proj_cpp() { + return gdallibrary::proj_version(); +} // [[Rcpp::export]] CharacterVector vsi_list_gdal_cpp(CharacterVector dsn) { return gdallibrary::gdal_vsi_list(dsn); diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp index daf0858..77a0ed5 100644 --- a/src/RcppExports.cpp +++ b/src/RcppExports.cpp @@ -163,6 +163,16 @@ BEGIN_RCPP return rcpp_result_gen; END_RCPP } +// version_proj_cpp +IntegerVector version_proj_cpp(); +RcppExport SEXP _vapour_version_proj_cpp() { +BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; + Rcpp::RNGScope rcpp_rngScope_gen; + rcpp_result_gen = Rcpp::wrap(version_proj_cpp()); + return rcpp_result_gen; +END_RCPP +} // vsi_list_gdal_cpp CharacterVector vsi_list_gdal_cpp(CharacterVector dsn); RcppExport SEXP _vapour_vsi_list_gdal_cpp(SEXP dsnSEXP) { @@ -767,6 +777,7 @@ static const R_CallMethodDef CallEntries[] = { {"_vapour_crs_is_lonlat_cpp", (DL_FUNC) &_vapour_crs_is_lonlat_cpp, 1}, {"_vapour_register_gdal_cpp", (DL_FUNC) &_vapour_register_gdal_cpp, 0}, {"_vapour_version_gdal_cpp", (DL_FUNC) &_vapour_version_gdal_cpp, 0}, + {"_vapour_version_proj_cpp", (DL_FUNC) &_vapour_version_proj_cpp, 0}, {"_vapour_vsi_list_gdal_cpp", (DL_FUNC) &_vapour_vsi_list_gdal_cpp, 1}, {"_vapour_feature_count_gdal_cpp", (DL_FUNC) &_vapour_feature_count_gdal_cpp, 4}, {"_vapour_projection_info_gdal_cpp", (DL_FUNC) &_vapour_projection_info_gdal_cpp, 3},