Skip to content

Commit

Permalink
clear if data is 0 rows - #252
Browse files Browse the repository at this point in the history
  • Loading branch information
dcooley committed Jan 27, 2020
1 parent 84fc88b commit 93eebed
Show file tree
Hide file tree
Showing 16 changed files with 64 additions and 2 deletions.
4 changes: 4 additions & 0 deletions R/map_layer_arc.R
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ add_arc <- function(
brush_radius = NULL
) {

if( nrow( data ) == 0 ) {
return( clear_arc( map, layer_id ) )
}

l <- list()
l[["origin"]] <- force(origin)
l[["destination"]] <- force(destination)
Expand Down
4 changes: 4 additions & 0 deletions R/map_layer_column.R
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ add_column <- function(
brush_radius = NULL
) {

if( nrow( data ) == 0 ) {
return( clear_column( map, layer_id ) )
}

l <- list()
l[["polyline"]] <- force( polyline )
l[["lon"]] <- force( lon )
Expand Down
5 changes: 5 additions & 0 deletions R/map_layer_geojson.R
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,11 @@ add_geojson <- function(
l[["data_type"]] <- NULL

if( tp == "sf" ) {

if( nrow( data ) == 0 ) {
return( clear_geojson( map, layer_id ) )
}

shape <- rcpp_geojson_geojson( data, l, "geometry", digits)
jsfunc <- "add_geojson_sf"
} else if ( tp == "geojson" ) {
Expand Down
4 changes: 4 additions & 0 deletions R/map_layer_greatcircle.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ add_greatcircle <- function(
) {
brush_radius = NULL

if( nrow( data ) == 0 ) {
return( clear_greatcircle( map, layer_id ) )
}

l <- list()
l[["origin"]] <- force(origin)
l[["destination"]] <- force(destination)
Expand Down
4 changes: 4 additions & 0 deletions R/map_layer_grid.R
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ add_grid <- function(
brush_radius = NULL
) {

if( nrow( data ) == 0 ) {
return( clear_grid( map, layer_id ) )
}

l <- list()
l[["lon"]] <- force( lon )
l[["lat"]] <- force( lat )
Expand Down
4 changes: 3 additions & 1 deletion R/map_layer_heatmap.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ add_heatmap <- function(
transitions = NULL
) {

#experimental_layer("heatmap")
if( nrow( data ) == 0 ) {
return( clear_heatmap( map, layer_id ) )
}

l <- list()
l[["polyline"]] <- force( polyline )
Expand Down
4 changes: 4 additions & 0 deletions R/map_layer_hexagon.R
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ add_hexagon <- function(
brush_radius = NULL
) {

if( nrow( data ) == 0 ) {
return( clear_hexagon( map, layer_id ) )
}

l <- list()
l[["polyline"]] <- force( polyline )
l[["lon"]] <- force( lon )
Expand Down
4 changes: 4 additions & 0 deletions R/map_layer_line.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ add_line <- function(
transitions = NULL
) {

if( nrow( data ) == 0 ) {
return( clear_line( map, layer_id ) )
}

l <- list()
l[["origin"]] <- force( origin )
l[["destination"]] <- force( destination)
Expand Down
4 changes: 4 additions & 0 deletions R/map_layer_mesh.R
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ add_mesh2 <- function(
#if( is.null( stroke_colour )) stroke_colour <- fill_colour
experimental_layer( "mesh" )

if( nrow( data ) == 0 ) {
return( clear_mesh( map, layer_id ) )
}

if(!inherits(data, "mesh3d")) {
stop("mapdeck - expecting mesh3d object")
}
Expand Down
4 changes: 4 additions & 0 deletions R/map_layer_path.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ add_path <- function(
transitions = NULL
) {

if( nrow( data ) == 0 ) {
return( clear_path( map, layer_id ) )
}

l <- list()
l[["polyline"]] <- force( polyline )
l[["stroke_colour"]] <- force( stroke_colour)
Expand Down
4 changes: 4 additions & 0 deletions R/map_layer_pointcloud.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ add_pointcloud <- function(
brush_radius = NULL
) {

if( nrow( data ) == 0 ) {
return( clear_pointcloud( map, layer_id ) )
}

l <- list()
l[["lon"]] <- force( lon )
l[["lat"]] <- force( lat )
Expand Down
4 changes: 3 additions & 1 deletion R/map_layer_polygon.R
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ add_polygon <- function(
transitions = NULL
) {

#if( is.null( stroke_colour )) stroke_colour <- fill_colour
if( nrow( data ) == 0 ) {
return( clear_polygon( map, layer_id ) )
}

l <- list()
l[["polyline"]] <- force( polyline )
Expand Down
4 changes: 4 additions & 0 deletions R/map_layer_scatterplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ add_scatterplot <- function(
brush_radius = NULL
) {

if( nrow( data ) == 0 ) {
return( clear_scatterplot( map, layer_id ) )
}

l <- list()
l[["lon"]] <- force(lon)
l[["lat"]] <- force(lat)
Expand Down
5 changes: 5 additions & 0 deletions R/map_layer_screengrid.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ add_screengrid <- function(
focus_layer = FALSE,
digits = 6
) {

if( nrow( data ) == 0 ) {
return( clear_screengrid( map, layer_id ) )
}

brush_radius = NULL
l <- list()
l[["polyline"]] <- force( polyline )
Expand Down
4 changes: 4 additions & 0 deletions R/map_layer_text.R
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ add_text <- function(
brush_radius = NULL
) {

if( nrow( data ) == 0 ) {
return( clear_text( map, layer_id ) )
}

l <- list()
l[["lon"]] <- force( lon )
l[["lat"]] <- force( lat )
Expand Down
4 changes: 4 additions & 0 deletions R/map_layer_trips.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ add_trips <- function(

experimental_layer("trips")

if( nrow( data ) == 0 ) {
return( clear_trips( map, layer_id ) )
}

l <- list()
l[["stroke_colour"]] <- force( stroke_colour )
l[["stroke_width"]] <- force( stroke_width )
Expand Down

0 comments on commit 93eebed

Please sign in to comment.