## ----include=FALSE------------------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>", fig.width = 6, fig.height = 4)
helper <- if (file.exists("vignettes/real-example-helpers.R")) {
  "vignettes/real-example-helpers.R"
} else {
  "real-example-helpers.R"
}
source(helper)
real_mode <- bt_real_examples_enabled()

## ----setup, include=FALSE, eval=bt_real_examples_enabled()--------------------
# real <- bt_real_example_setup()
# real_aoi <- real$aoi

## ----extract, eval=bt_real_examples_enabled()---------------------------------
# result <- bluertopo(
#   real_aoi,
#   layers = "elevation",
#   resolution = "native",
#   coverage = "fill",
#   details = TRUE,
#   progress = FALSE,
#   quiet = TRUE
# )

## ----object-summary, echo=FALSE, eval=bt_real_examples_enabled()--------------
# rasters <- bt_rasters(result$data)
# object_summary <- data.frame(
#   element = c(
#     "object type",
#     "result$data class",
#     "number of layers",
#     "layer names",
#     "CRS summary",
#     "resolution",
#     "source count"
#   ),
#   value = c(
#     if (inherits(result$data, "SpatRasterCollection")) "SpatRasterCollection" else "SpatRaster",
#     paste(class(result$data), collapse = ", "),
#     sum(vapply(rasters, terra::nlyr, numeric(1L))),
#     paste(unique(unlist(lapply(rasters, names), use.names = FALSE)), collapse = ", "),
#     paste(unique(vapply(rasters, function(r) {
#       paste0("EPSG:", terra::crs(r, describe = TRUE)$code)
#     }, "")), collapse = ", "),
#     paste(unique(vapply(rasters, function(r) paste(round(terra::res(r), 3), collapse = " x "), "")), collapse = "; "),
#     length(unique(unlist(lapply(rasters, terra::sources), use.names = FALSE)))
#   ),
#   stringsAsFactors = FALSE
# )
# 
# bt_display_table(object_summary)

## ----source-table, echo=FALSE, eval=bt_real_examples_enabled()----------------
# bt_display_table(bt_sources_table(result$data))

## ----coverage-table, echo=FALSE, eval=bt_real_examples_enabled()--------------
# bt_display_table(bt_coverage_table(result$coverage))

## ----provenance-table, echo=FALSE, eval=bt_real_examples_enabled()------------
# bt_display_table(bt_catalog_table(real))

## ----elevation-figure, echo=FALSE, eval=bt_real_examples_enabled(), fig.cap="BlueTopo bathymetry for New York Harbor, displayed with hillshade, contours, and the example-area boundary.", fig.alt="BlueTopo bathymetry for New York Harbor with hillshade, contours, and the example-area boundary."----
# bt_plot_bathy_map(result$data, real_aoi, main = "New York Harbor BlueTopo bathymetry")

