Skip to content

Commit

Permalink
pass check without errors; #1146
Browse files Browse the repository at this point in the history
  • Loading branch information
edzer committed Nov 29, 2019
1 parent 245e30f commit 59d3591
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/gdal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ bool crs_is_na(Rcpp::List crs) {
OGRSpatialReference *OGRSrs_from_crs(Rcpp::List crs) {
OGRSpatialReference *dest = NULL;
Rcpp::CharacterVector p4s = crs[1];
Rcpp::CharacterVector wkt2 = crs[2];
Rcpp::CharacterVector wkt2 = Rcpp::CharacterVector::create(NA_STRING);
if (crs.size() > 2)
wkt2 = crs[2];
if (!(Rcpp::CharacterVector::is_na(p4s[0]) && Rcpp::CharacterVector::is_na(wkt2[0]))) {
dest = new OGRSpatialReference;
dest = handle_axis_order(dest);
Expand Down Expand Up @@ -277,13 +279,18 @@ Rcpp::List create_crs(OGRSpatialReference *ref) {
crs(2) = Rcpp::CharacterVector::create(NA_STRING);
} else {
const char *cp;
bool epsg_is_na = true;
if (ref->AutoIdentifyEPSG() == OGRERR_NONE &&
(cp = ref->GetAuthorityCode(NULL)) != NULL)
(cp = ref->GetAuthorityCode(NULL)) != NULL) {
crs(0) = atoi(cp);
else
epsg_is_na = false;
} else
crs(0) = NA_INTEGER;
crs(1) = p4s_from_spatial_reference(ref);
crs(2) = CPL_wkt2_from_epsg(crs(0));
if (epsg_is_na)
crs(2) = Rcpp::CharacterVector::create(NA_STRING);
else
crs(2) = CPL_wkt2_from_epsg(crs(0));
}
Rcpp::CharacterVector nms(3);
nms(0) = "epsg";
Expand Down Expand Up @@ -458,8 +465,10 @@ Rcpp::List CPL_wrap_dateline(Rcpp::List sfc, Rcpp::CharacterVector opt, bool qui
Rcpp::List CPL_crs_from_proj4string(Rcpp::CharacterVector p4s) {
OGRSpatialReference ref;
handle_axis_order(&ref);
if (ref.importFromProj4(p4s[0]) == OGRERR_NONE)
if (ref.importFromProj4((const char *) p4s[0]) == OGRERR_NONE) {
// Rcpp::Rcout << "got here" << std::endl;
return create_crs(&ref);
}
else {
const char *cp = p4s[0];
Rf_warning("GDAL cannot import PROJ.4 string `%s': returning missing CRS\n", cp);
Expand Down

0 comments on commit 59d3591

Please sign in to comment.