## ----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

## ----download, eval=bt_real_examples_enabled()--------------------------------
# manifest <- bluertopo_download(
#   real_aoi,
#   path = real$download_dir,
#   resolution = "native",
#   coverage = "fill",
#   rat = TRUE,
#   verify = "sha256",
#   on_exists = "verify",
#   progress = FALSE,
#   quiet = TRUE
# )

## ----manifest-table, echo=FALSE, eval=bt_real_examples_enabled()--------------
# bt_display_table(bt_manifest_table(manifest))

## ----reuse, echo=FALSE, eval=bt_real_examples_enabled()-----------------------
# reused <- bluertopo_download(
#   real_aoi,
#   path = real$download_dir,
#   resolution = "native",
#   coverage = "fill",
#   rat = TRUE,
#   verify = "sha256",
#   on_exists = "verify",
#   progress = FALSE,
#   quiet = TRUE
# )
# 
# reuse_df <- as.data.frame(reused)
# reuse_summary <- aggregate(
#   verified ~ status,
#   data = reuse_df,
#   FUN = function(x) sum(x %in% TRUE)
# )
# names(reuse_summary) <- c("status", "verified_count")
# reuse_summary$count <- as.integer(table(reuse_df$status)[reuse_summary$status])
# reuse_summary <- reuse_summary[c("status", "count", "verified_count")]
# 
# bt_display_table(reuse_summary)

## ----manifest-files, echo=FALSE, eval=bt_real_examples_enabled()--------------
# bt_display_table(bt_manifest_files_table(real$download_dir))

## ----source-domain-summary, echo=FALSE, eval=bt_real_examples_enabled()-------
# bt_display_table(bt_source_domain_summary(manifest))

## ----status-bars, echo=FALSE, eval=bt_real_examples_enabled(), fig.cap="SHA-256 verified download status counts for the selected BlueTopo assets.", fig.alt="Bar plot of downloaded and reused BlueTopo asset statuses."----
# status_counts <- bt_status_counts(manifest)
# barplot(
#   stats::setNames(status_counts$count, status_counts$status),
#   col = "#005f73",
#   ylab = "asset count",
#   main = "First-call download statuses"
# )

