Skip to content

Commit ad33741

Browse files
authored
Move CRS responsibility from GuideAxis to CoordSf (#5440)
* Move CRS responsibility to CoordSf * Fix typo
1 parent 72dcfad commit ad33741

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

R/coord-sf.R

+10-5
Original file line numberDiff line numberDiff line change
@@ -255,19 +255,24 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
255255
graticule$y_start <- sf_rescale01_x(graticule$y_start, y_range)
256256
graticule$y_end <- sf_rescale01_x(graticule$y_end, y_range)
257257

258-
list(
258+
list2(
259259
x_range = x_range,
260260
y_range = y_range,
261261
graticule = graticule,
262262
crs = params$crs,
263263
default_crs = params$default_crs,
264-
viewscales = viewscales
264+
!!!viewscales
265265
)
266266
},
267267

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

273278
backtransform_range = function(self, panel_params) {

R/guide-axis.R

-5
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,6 @@ GuideAxis <- ggproto(
135135
return(params)
136136
}
137137

138-
if (inherits(coord, "CoordSf")) {
139-
# Positions already given in target crs
140-
panel_params$default_crs <- panel_params$crs
141-
}
142-
143138
aesthetics <- names(key)[!grepl("^\\.", names(key))]
144139
if (!all(c("x", "y") %in% aesthetics)) {
145140
other_aesthetic <- setdiff(c("x", "y"), aesthetics)

0 commit comments

Comments
 (0)