From 15aaee57fae0168abbb7b518d93018bb0c1847aa Mon Sep 17 00:00:00 2001 From: salvafern Date: Mon, 2 May 2022 12:30:25 +0200 Subject: [PATCH] Error when large URL #16 --- R/viewparams.R | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/R/viewparams.R b/R/viewparams.R index e6dafdb..7ade9f3 100644 --- a/R/viewparams.R +++ b/R/viewparams.R @@ -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) } @@ -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) @@ -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))")