Skip to content

Commit 95e29fa

Browse files
committed
kind instructions from @clauswilke
1 parent c6f6565 commit 95e29fa

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

R/layer-sf.R

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ LayerSf <- ggproto("LayerSf", Layer,
3939
# automatically determine the legend type
4040
if (is.na(self$show.legend) || isTRUE(self$show.legend)) {
4141
if (is_sf(data)) {
42-
if (sf_geometry_type(data) %in% c("POINT", "MULTIPOINT"))
42+
geometry_type <- sf_geometry_type(data)
43+
if (geometry_type %in% c("POINT", "MULTIPOINT"))
4344
self$geom_params$legend <- "point"
44-
else if (sf_geometry_type(data) %in% c("LINESTRING", "MULTILINESTRING",
45+
else if (geometry_type %in% c("LINESTRING", "MULTILINESTRING",
4546
"CIRCULARSTRING", "COMPOUNDCURVE",
4647
"CURVE", "MULTICURVE"))
4748
self$geom_params$legend <- "line"
@@ -76,7 +77,7 @@ scale_type.sfc <- function(x) "identity"
7677

7778
# helper function to determine the geometry type of sf object
7879
sf_geometry_type <- function(sf) {
79-
geometry_type <- unique(as.vector(sf::st_geometry_type(sf)))
80-
if (length(geometry_type) != 1) geometry_type <- "blend"
80+
geometry_type <- unique(as.character(sf::st_geometry_type(sf)))
81+
if (length(geometry_type) != 1) geometry_type <- "other"
8182
geometry_type
8283
}

0 commit comments

Comments
 (0)