Skip to content

Commit

Permalink
fix: order the catalogs
Browse files Browse the repository at this point in the history
Fixes #5
  • Loading branch information
gadomski committed Oct 28, 2024
1 parent e8ddc91 commit c158090
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
17 changes: 10 additions & 7 deletions app/catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,24 @@
"rel": "child",
"type": "application/json",
"title": "Microsoft Planetary Computer",
"heystac:id": "microsoft-pc"
"heystac:id": "microsoft-pc",
"heystac:index": 0
},
{
"href": "https://landsatlook.usgs.gov/stac-server",
"href": "https://earth-search.aws.element84.com/v1",
"rel": "child",
"type": "application/json",
"title": "USGS Landsat",
"heystac:id": "usgs-landsat"
"title": "Earth Search by Element 84",
"heystac:id": "earth-search-aws",
"heystac:index": 1
},
{
"href": "https://earth-search.aws.element84.com/v1",
"href": "https://landsatlook.usgs.gov/stac-server",
"rel": "child",
"type": "application/json",
"title": "Earth Search by Element 84",
"heystac:id": "earth-search-aws"
"title": "USGS Landsat",
"heystac:id": "usgs-landsat",
"heystac:index": 2
}
]
}
3 changes: 3 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
[catalogs.microsoft-pc]
href = "https://planetarycomputer.microsoft.com/api/stac/v1"
title = "Microsoft Planetary Computer"
index = 0

[catalogs.earth-search-aws]
href = "https://earth-search.aws.element84.com/v1"
title = "Earth Search by Element 84"
index = 1

[catalogs.usgs-landsat]
href = "https://landsatlook.usgs.gov/stac-server"
title = "USGS Landsat"
index = 2
10 changes: 10 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub struct Config {
struct CatalogConfig {
href: String,
title: String,
index: usize,
}

impl Config {
Expand All @@ -37,8 +38,17 @@ impl Config {
Link::child(&catalog_config.href).title(Some(catalog_config.title.clone()));
link.additional_fields
.insert("heystac:id".into(), id.as_str().into());
link.additional_fields
.insert("heystac:index".into(), catalog_config.index.into());
catalog.links.push(link);
}
catalog.links.sort_by_key(|c| {
c.additional_fields
.get("heystac:index")
.unwrap()
.as_i64()
.unwrap()
});
let file = File::create(path)?;
serde_json::to_writer_pretty(file, &catalog).map_err(Error::from)
}
Expand Down

0 comments on commit c158090

Please sign in to comment.