Skip to content

Commit

Permalink
closes #2415
Browse files Browse the repository at this point in the history
  • Loading branch information
edzer committed Jul 31, 2024
1 parent 4ba1f3c commit 6e13be9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ S3method(st_snap,sfg)
S3method(st_sym_difference,sf)
S3method(st_sym_difference,sfc)
S3method(st_sym_difference,sfg)
S3method(st_transform,bbox)
S3method(st_transform,sf)
S3method(st_transform,sfc)
S3method(st_transform,sfg)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# version 1.0-17

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

* `st_filter.sf()` correctly scopes `x` and `y` arguments using !! operator; #2416

* `[.sfc` and `[<-.sfc` use matrix/array type subsetting for `sfc` objects that have a `dim` attribute
Expand Down
8 changes: 8 additions & 0 deletions R/transform.R
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,14 @@ st_transform.sfg = function(x, crs = st_crs(x), ...) {
structure(st_transform(x, crs, ...)[[1]], crs = crs)
}

#' @name st_transform
#' @export
#' @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)
}

#' @name st_transform
#' @export
st_wrap_dateline = function(x, options, quiet) UseMethod("st_wrap_dateline")
Expand Down
7 changes: 7 additions & 0 deletions man/st_transform.Rd

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

6 changes: 6 additions & 0 deletions src/gdal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,12 @@ Rcpp::NumericVector CPL_transform_bounds(Rcpp::NumericVector bb, Rcpp::List crs_
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

0 comments on commit 6e13be9

Please sign in to comment.