Skip to content

Commit

Permalink
Error when large URL #16
Browse files Browse the repository at this point in the history
  • Loading branch information
salvafern committed May 2, 2022
1 parent ae2a8ca commit 15aaee5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions R/viewparams.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ build_viewparams <- function(mrgid = NULL, geometry = NULL, dasid = NULL,
query <- paste0("where:", query, ";context:0100", filter_aphia)
# message(query)
query <- build_encode(query)

# Assert length
too_long <- nchar(query) < 2000

if(too_long){
stop("Large queries are not yet supported. Please reduce the number of possible values.")
}

return(query)
}

Expand Down Expand Up @@ -120,6 +128,8 @@ build_filter_geo <- function(mrgid = NULL, polygon = NULL){
polygon <- sf::st_as_sfc(polygon)
}



# Geometry collection check
geom_type <- sf::st_geometry_type(polygon, by_geometry = FALSE)

Expand All @@ -140,6 +150,12 @@ build_filter_geo <- function(mrgid = NULL, polygon = NULL){

polygon <- sf::st_as_text(sf::st_geometry(polygon))

# Assert length polygon
too_long <- nchar(polygon) > 1500
if(too_long){
stop("Complex geometries are not yet supported. Please reduce the number of vertices.")
}

# Perform
polygon <- gsub(",", "\\,", polygon, fixed = TRUE)
polygon_query <- paste0("(ST_Intersects(ST_SetSRID(ST_GeomFromText('", polygon, "')\\,4326)\\,+up.the_geom))")
Expand Down

0 comments on commit 15aaee5

Please sign in to comment.