Skip to content

Commit

Permalink
Merge pull request #3 from Permian-Global-Research/asset-name-bug
Browse files Browse the repository at this point in the history
not all assets are named dataset - adding elevation
  • Loading branch information
h-a-graham authored Oct 11, 2024
2 parents 545d733 + 4431eb9 commit 8065dbe
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 6 additions & 1 deletion R/mpc_srcs.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ mpc_dtm_src <- function(aoi,

if (isTRUE(sign_items)) it_obj <- sign_mpc(it_obj, subscription_key)

urls <- rstac::assets_url(it_obj, "data")
# select either elevation or data, whicever present
av_assets <- rstac::items_assets(it_obj)
desired_assets <- c("data", "elevation")
selected_asset <- intersect(av_assets, desired_assets)[1]

urls <- rstac::assets_url(it_obj, selected_asset)

if (isTRUE(vsicurl)) {
urls <- sapply(
Expand Down
12 changes: 12 additions & 0 deletions tests/testthat/test-mpc_srcs.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,16 @@ test_that("mpc_dtm_src works", {

nc_urls_nokey <- mpc_dtm_src(nc_sf, subscription_key = "")
expect_equal(length(nc_urls_nokey), 37)

box <- c(-121.772, 45.321, -121.611, 45.419)

lapply(c(
"cop-dem-glo-30", "cop-dem-glo-90",
"alos-dem", "nasadem"
), function(x) {
expect_silent(
durl <- mpc_dtm_src(box, collection = x)
)
expect_true(length(durl) > 0)
})
})

0 comments on commit 8065dbe

Please sign in to comment.