Skip to content

Commit

Permalink
print proj version before problem
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsumner committed Jun 6, 2024
1 parent 278fdd4 commit f3497ef
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 5 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
12 changes: 10 additions & 2 deletions R/vapour-gdal-library.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand All @@ -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() {
Expand Down
15 changes: 14 additions & 1 deletion inst/include/gdallibrary/gdallibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions man/GDAL-library.Rd

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

4 changes: 3 additions & 1 deletion man/vapour_crs_is_lonlat.Rd

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

5 changes: 4 additions & 1 deletion src/00_gdal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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},
Expand Down

0 comments on commit f3497ef

Please sign in to comment.