From 1a9e57b7291859025019d4b8d4ee013b45692223 Mon Sep 17 00:00:00 2001 From: Pete Gadomski Date: Mon, 28 Oct 2024 10:52:53 -0600 Subject: [PATCH] feat: move catalog config to toml --- config.toml | 7 +++++++ src/lib.rs | 6 ++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/config.toml b/config.toml index 4d2ea1c..e519ad4 100644 --- a/config.toml +++ b/config.toml @@ -1,3 +1,10 @@ +[catalog] +type = "Catalog" # will this be unnecessary once https://github.com/stac-utils/stac-rs/pull/498 is released? +stac_version = "1.1.0" +id = "heystac" +description = "A curated geospatial asset discovery experience™" +links = [] + [catalogs.microsoft-pc] href = "https://planetarycomputer.microsoft.com/api/stac/v1" title = "Microsoft Planetary Computer" diff --git a/src/lib.rs b/src/lib.rs index ba4ebd7..f6495b4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,11 +8,9 @@ use std::{ path::Path, }; -const CATALOG_ID: &str = "heystac"; -const CATALOG_DESCRIPTION: &str = "A curated geospatial asset discovery experience™"; - #[derive(Debug, Deserialize)] pub struct Config { + catalog: Catalog, catalogs: HashMap, } @@ -32,7 +30,7 @@ impl Config { } pub fn write_catalog(&self, path: impl AsRef) -> Result<()> { - let mut catalog = Catalog::new(CATALOG_ID, CATALOG_DESCRIPTION); + let mut catalog = self.catalog.clone(); for (id, catalog_config) in &self.catalogs { let mut link = Link::child(&catalog_config.href).title(Some(catalog_config.title.clone()));