Skip to content

Commit a07adc6

Browse files
authored
Merge pull request #2437 from rsbivand/issue2436
address #2436
2 parents 061196e + 93a25fd commit a07adc6

4 files changed

Lines changed: 20 additions & 9 deletions

File tree

‎DESCRIPTION‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: sf
2-
Version: 1.0-17
2+
Version: 1.0-18
33
Title: Simple Features for R
44
Authors@R:
55
c(person(given = "Edzer",

‎NEWS.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# version 1.0-18
2+
3+
* fix build failure with GDAL < 3.4.0 #2436
4+
15
# version 1.0-17
26

37
* add `st_transform()` method for `bbox` objects; this uses OGRCoordinateTransformation::TransformBounds(), densifying first and antemeridian proof; #2415

‎R/transform.R‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,10 @@ st_transform.sfg = function(x, crs = st_crs(x), ...) {
170170
#' @param densify integer, number of points for discretizing lines between bounding box corner points; see Details
171171
#' @details the method for `bbox` objects densifies lines for geographic coordinates along Cartesian lines, not great circle arcs
172172
st_transform.bbox = function(x, crs, ..., densify = 21) {
173-
st_bbox(CPL_transform_bounds(x, st_crs(crs), densify), crs = crs)
173+
if (sf_extSoftVersion()["GDAL"] >= "3.4.0")
174+
st_bbox(CPL_transform_bounds(x, st_crs(crs), densify), crs = crs)
175+
else
176+
stop("method not available for GDAL: ", sf_extSoftVersion()["GDAL"])
174177
}
175178

176179
#' @name st_transform

‎src/gdal.cpp‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,17 @@ Rcpp::List CPL_transform(Rcpp::List sfc, Rcpp::List crs,
673673
Rcpp::NumericVector CPL_transform_bounds(Rcpp::NumericVector bb, Rcpp::List crs_dst,
674674
int densify_pts = 21) {
675675

676+
Rcpp::NumericVector ret(4);
677+
ret[0] = 0.0;
678+
ret[1] = 0.0;
679+
ret[2] = 0.0;
680+
ret[3] = 0.0;
681+
Rcpp::CharacterVector names(4);
682+
names(0) = "xmin";
683+
names(1) = "ymin";
684+
names(2) = "xmax";
685+
names(3) = "ymax";
686+
ret.attr("names") = names;
676687
#if GDAL_VERSION_NUM >= 3040000
677688
if (bb.size() != 4)
678689
Rcpp::stop("bb should have length 4");
@@ -693,17 +704,10 @@ Rcpp::NumericVector CPL_transform_bounds(Rcpp::NumericVector bb, Rcpp::List crs_
693704
int success = ct->TransformBounds(bb[0], bb[1], bb[2], bb[3], &xmin, &ymin, &xmax, &ymax, densify_pts);
694705
if (!success)
695706
Rcpp::stop("transform_bounds(): failures encountered"); // #nocov
696-
Rcpp::NumericVector ret(4);
697707
ret[0] = xmin;
698708
ret[1] = ymin;
699709
ret[2] = xmax;
700710
ret[3] = ymax;
701-
Rcpp::CharacterVector names(4);
702-
names(0) = "xmin";
703-
names(1) = "ymin";
704-
names(2) = "xmax";
705-
names(3) = "ymax";
706-
ret.attr("names") = names;
707711
ct->DestroyCT(ct);
708712
dst->Release();
709713
src->Release();

0 commit comments

Comments
 (0)