Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

address #2436 #2437

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: sf
Version: 1.0-17
Version: 1.0-18
Title: Simple Features for R
Authors@R:
c(person(given = "Edzer",
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# version 1.0-18

* fix build failure with GDAL < 3.4.0 #2436

# version 1.0-17

* add `st_transform()` method for `bbox` objects; this uses OGRCoordinateTransformation::TransformBounds(), densifying first and antemeridian proof; #2415
Expand Down
5 changes: 4 additions & 1 deletion R/transform.R
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@ st_transform.sfg = function(x, crs = st_crs(x), ...) {
#' @param densify integer, number of points for discretizing lines between bounding box corner points; see Details
#' @details the method for `bbox` objects densifies lines for geographic coordinates along Cartesian lines, not great circle arcs
st_transform.bbox = function(x, crs, ..., densify = 21) {
st_bbox(CPL_transform_bounds(x, st_crs(crs), densify), crs = crs)
if (sf_extSoftVersion()["GDAL"] >= "3.4.0")
st_bbox(CPL_transform_bounds(x, st_crs(crs), densify), crs = crs)
else
stop("method not available for GDAL: ", sf_extSoftVersion()["GDAL"])
}

#' @name st_transform
Expand Down
18 changes: 11 additions & 7 deletions src/gdal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,17 @@ Rcpp::List CPL_transform(Rcpp::List sfc, Rcpp::List crs,
Rcpp::NumericVector CPL_transform_bounds(Rcpp::NumericVector bb, Rcpp::List crs_dst,
int densify_pts = 21) {

Rcpp::NumericVector ret(4);
ret[0] = 0.0;
ret[1] = 0.0;
ret[2] = 0.0;
ret[3] = 0.0;
Rcpp::CharacterVector names(4);
names(0) = "xmin";
names(1) = "ymin";
names(2) = "xmax";
names(3) = "ymax";
ret.attr("names") = names;
#if GDAL_VERSION_NUM >= 3040000
if (bb.size() != 4)
Rcpp::stop("bb should have length 4");
Expand All @@ -693,17 +704,10 @@ Rcpp::NumericVector CPL_transform_bounds(Rcpp::NumericVector bb, Rcpp::List crs_
int success = ct->TransformBounds(bb[0], bb[1], bb[2], bb[3], &xmin, &ymin, &xmax, &ymax, densify_pts);
if (!success)
Rcpp::stop("transform_bounds(): failures encountered"); // #nocov
Rcpp::NumericVector ret(4);
ret[0] = xmin;
ret[1] = ymin;
ret[2] = xmax;
ret[3] = ymax;
Rcpp::CharacterVector names(4);
names(0) = "xmin";
names(1) = "ymin";
names(2) = "xmax";
names(3) = "ymax";
ret.attr("names") = names;
ct->DestroyCT(ct);
dst->Release();
src->Release();
Expand Down
Loading