Skip to content

Commit

Permalink
Move CRS responsibility from GuideAxis to CoordSf (#5440)
Browse files Browse the repository at this point in the history
* Move CRS responsibility to CoordSf

* Fix typo
  • Loading branch information
teunbrand authored Oct 2, 2023
1 parent 72dcfad commit ad33741
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
15 changes: 10 additions & 5 deletions R/coord-sf.R
Original file line number Diff line number Diff line change
Expand Up @@ -255,19 +255,24 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
graticule$y_start <- sf_rescale01_x(graticule$y_start, y_range)
graticule$y_end <- sf_rescale01_x(graticule$y_end, y_range)

list(
list2(
x_range = x_range,
y_range = y_range,
graticule = graticule,
crs = params$crs,
default_crs = params$default_crs,
viewscales = viewscales
!!!viewscales
)
},

setup_panel_guides = function(self, panel_params, guides, params = list()) {
params <- Coord$setup_panel_guides(panel_params$viewscales, guides, params)
c(params, panel_params)
train_panel_guides = function(self, panel_params, layers, params = list()) {
# The guide positions are already in the target CRS, so we mask the default
# CRS to prevent a double transformation.
panel_params$guides <- ggproto_parent(Coord, self)$train_panel_guides(
vec_assign(panel_params, "default_crs", panel_params["crs"]),
layers, params
)$guides
panel_params
},

backtransform_range = function(self, panel_params) {
Expand Down
5 changes: 0 additions & 5 deletions R/guide-axis.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,6 @@ GuideAxis <- ggproto(
return(params)
}

if (inherits(coord, "CoordSf")) {
# Positions already given in target crs
panel_params$default_crs <- panel_params$crs
}

aesthetics <- names(key)[!grepl("^\\.", names(key))]
if (!all(c("x", "y") %in% aesthetics)) {
other_aesthetic <- setdiff(c("x", "y"), aesthetics)
Expand Down

0 comments on commit ad33741

Please sign in to comment.