Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion R/addSource.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' @param map the [mapgl::maplibre()] or [mapgl::mapboxgl()] map to add the
#' data source to.
#' @param id a unique `ID` for the data source.
#' @param data a `sf`, `wk`, `geos` or `SpatVector` object.
#' @param data a `sf`, `wk`, `geos`, `SpatVector` or `duckspatial_df` object.
#' @param file a valid local file path to a `geoarrow` or `geoparquet` file to be
#' added to the map. Ignored if `data` is supplied.
#' @param url a URL to a remotely hosted `geoarrow` or `geoparquet` file to be
Expand Down Expand Up @@ -34,6 +34,23 @@
#' ## <link id="pt-geoarrowWidget-attachment" rel="attachment" href="lib/pt-0.0.1/pt.arrow"/>
#' m
#'
#' @tests tinytest
#'
#' stream_method = function(x, ..., native = FALSE) native
#' registerS3method(
#' "as_nanoarrow_array_stream"
#' , "deckglgeoarrow_test_duckspatial_df"
#' , stream_method
#' , envir = asNamespace("nanoarrow")
#' )
#'
#' data = structure(
#' list()
#' , class = c("deckglgeoarrow_test_duckspatial_df", "duckspatial_df")
#' )
#'
#' expect_identical(deckglgeoarrow:::parseGeoarrow(data), TRUE)
#'
#' @export
#'
addSource = function(
Expand Down
4 changes: 4 additions & 0 deletions R/internals.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ parseGeoarrow = function(
return(data)
}

if (inherits(data, "duckspatial_df")) {
return(nanoarrow::as_nanoarrow_array_stream(data, native = TRUE))
}

if (inherits(data, "SpatVector")) {
stopifnot(
"need package 'terra' to handle 'SpatVector'" =
Expand Down
19 changes: 19 additions & 0 deletions inst/tinytest/test-addSource.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# File created by roxut; edit the function definition file, not this file

# Test found in addSource.R:37 (file:line)


stream_method = function(x, ..., native = FALSE) native
registerS3method(
"as_nanoarrow_array_stream"
, "deckglgeoarrow_test_duckspatial_df"
, stream_method
, envir = asNamespace("nanoarrow")
)

data = structure(
list()
, class = c("deckglgeoarrow_test_duckspatial_df", "duckspatial_df")
)

expect_identical(deckglgeoarrow:::parseGeoarrow(data), TRUE)
2 changes: 1 addition & 1 deletion man/addSource.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading