Open elipousson opened 3 months ago
I really like the use of httr2::url_parse()
@elipousson what do you think about something along the lines of this?
# get the url
url <- "https://geodata.md.gov/imap/rest/services/Boundaries/MD_PhysicalBoundaries/FeatureServer/1/query?outFields=*&where=1%3D1"
# parse the url
parsed_url <- httr2::url_parse(url)
# enumerate known path types
known_content_types <- c("FeatureServer", "MapServer", "ImageServer", "GeocodeServer")
# make regex
content_pattern <- paste(known_content_types, collapse = "|")
# extrect kind from URL
url_type <- stringr::str_extract(parsed_url$path, content_pattern)
url_type
#> [1] "FeatureServer"
Created on 2024-08-06 with reprex v2.1.0
Is your feature request related to a problem? Please describe.
When I copy a GeoService URL from a layer information page on a ArcGIS Hub site, it always has a default query appended "/query?outFields=*&where=1%3D1". The URL returns an error that isn't even very helpful at figuring out what went wrong.
Describe the solution you'd like
If possible, I'd like to see arcgislayers support queries passed as part of the URL. This would also be handy for setting up filtered views interactively with a non-R user and then reusing the generated URL rather than needing to reconstruct the query separately.
Either way, it may be helpful to add appropriate warning or error messages for URLs an appended query to avoid confusion by users.
This reprex illustrates a basic potential solution that could be incorporated into
arc_select()
:Created on 2024-08-06 with reprex v2.1.0
Describe alternatives you've considered
This may be related to the URL validation proposed for arcgisutils so could be incorporated into that package instead: https://github.com/R-ArcGIS/arcgisutils/issues/31