Skip to content

Commit c4a337a

Browse files
authored
sf_rescale01_x <- scales::rescale (#5475)
1 parent 42a764d commit c4a337a

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

R/coord-sf.R

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
9393
# transform and normalize regular position data
9494
data <- transform_position(
9595
sf_transform_xy(data, target_crs, source_crs),
96-
function(x) sf_rescale01_x(x, panel_params$x_range),
97-
function(x) sf_rescale01_x(x, panel_params$y_range)
96+
function(x) rescale(x, from = panel_params$x_range),
97+
function(x) rescale(x, from = panel_params$y_range)
9898
)
9999

100100
transform_position(data, squish_infinite, squish_infinite)
@@ -250,10 +250,10 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
250250

251251
# Rescale graticule for panel grid
252252
sf::st_geometry(graticule) <- sf_rescale01(sf::st_geometry(graticule), x_range, y_range)
253-
graticule$x_start <- sf_rescale01_x(graticule$x_start, x_range)
254-
graticule$x_end <- sf_rescale01_x(graticule$x_end, x_range)
255-
graticule$y_start <- sf_rescale01_x(graticule$y_start, y_range)
256-
graticule$y_end <- sf_rescale01_x(graticule$y_end, y_range)
253+
graticule$x_start <- rescale(graticule$x_start, from = x_range)
254+
graticule$x_end <- rescale(graticule$x_end, from = x_range)
255+
graticule$y_start <- rescale(graticule$y_start, from = y_range)
256+
graticule$y_end <- rescale(graticule$y_end, from = y_range)
257257

258258
list2(
259259
x_range = x_range,
@@ -405,11 +405,6 @@ sf_rescale01 <- function(x, x_range, y_range) {
405405
sf::st_normalize(x, c(x_range[1], y_range[1], x_range[2], y_range[2]))
406406
}
407407

408-
# normalize position data (variable x is x or y position)
409-
sf_rescale01_x <- function(x, range) {
410-
(x - range[1]) / diff(range)
411-
}
412-
413408
# different limits methods
414409
calc_limits_bbox <- function(method, xlim, ylim, crs, default_crs) {
415410
if (any(!is.finite(c(xlim, ylim))) && method != "geometry_bbox") {

0 commit comments

Comments
 (0)