From c00ce9418060b8701482207ac73b697edeeaa97e Mon Sep 17 00:00:00 2001 From: Michael Uleysky Date: Fri, 9 Aug 2024 13:51:02 +1000 Subject: [PATCH] The names of products and datasets are obtained from the href field, not the title field --- src/copcat.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/copcat.cpp b/src/copcat.cpp index 7ed9a72..15cdf3d 100644 --- a/src/copcat.cpp +++ b/src/copcat.cpp @@ -48,9 +48,14 @@ RetVal> CopernicusCatalog::ProductList() const for(Json::ArrayIndex i = 0; i < links.size(); i++) { const auto& rel = links[i]["rel"]; - const auto& titl = links[i]["title"]; + const auto& href = links[i]["href"]; - if(rel.type() == Json::stringValue && titl.type() == Json::stringValue && rel.asString() == "child") out.emplace_back(titl.asString().c_str()); + if(rel.type() == Json::stringValue && href.type() == Json::stringValue && rel.asString() == "child") + { + auto str = href.asString(); + str.erase(str.find('/')); + out.emplace_back(str.c_str()); + } } return out; } @@ -66,9 +71,8 @@ RetVal CopernicusCatalog::ProductURL(const MString& prod) const for(Json::ArrayIndex i = 0; i < links.size(); i++) { - const auto& titl = links[i]["title"]; const auto& href = links[i]["href"]; - if(titl.type() == Json::stringValue && href.type() == Json::stringValue && titl.asString().c_str() == prod) return DirName(caturl) + "/" + MString(href.asString().c_str()); + if(href.type() == Json::stringValue && href.asString() == (prod + "/product.stac.json").Buf()) return DirName(caturl) + "/" + MString(href.asString().c_str()); } return {pref, "unknown product: " + prod}; } @@ -94,9 +98,14 @@ RetVal> CopernicusCatalog::DatasetList(const MString& prod) for(Json::ArrayIndex i = 0; i < links.size(); i++) { const auto& rel = links[i]["rel"]; - const auto& titl = links[i]["title"]; + const auto& href = links[i]["href"]; - if(rel.type() == Json::stringValue && titl.type() == Json::stringValue && rel.asString() == "item") out.emplace_back(titl.asString().c_str()); + if(rel.type() == Json::stringValue && href.type() == Json::stringValue && rel.asString() == "item") + { + auto str = href.asString(); + str.erase(str.find('/')); + out.emplace_back(str.c_str()); + } } return out; } @@ -120,9 +129,8 @@ RetVal CopernicusCatalog::DatasetURL(const MString& prod, const MString for(Json::ArrayIndex i = 0; i < links.size(); i++) { - const auto& titl = links[i]["title"]; const auto& href = links[i]["href"]; - if(titl.type() == Json::stringValue && href.type() == Json::stringValue && titl.asString().c_str() == dataset) return DirName(url) + "/" + MString(href.asString().c_str()); + if(href.type() == Json::stringValue && href.asString() == (dataset + "/dataset.stac.json").Buf()) return DirName(url) + "/" + MString(href.asString().c_str()); } return {pref, "unknown dataset: " + dataset}; }