Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fails on Landsat catalog #3

Open
brentfraser opened this issue Dec 23, 2020 · 6 comments
Open

fails on Landsat catalog #3

brentfraser opened this issue Dec 23, 2020 · 6 comments

Comments

@brentfraser
Copy link

When using the landsat catalog (https://landsat-stac.s3.amazonaws.com/catalog.json) DotNetStac 0.5.7 fails (tried in Jupyter Notebook). Granted the STAC version of the catalog is 0.6 so maybe it's too old.

@emmanuelmathot
Copy link
Contributor

Hello. Indeed, the library has not been extensively tested on version prior to 1.0.0-beta1. Nevertheless, it should support previous version. I will have a check with that landsat catalog.

@emmanuelmathot
Copy link
Contributor

emmanuelmathot commented Dec 23, 2020

It works using StacFactory to load the catalog at first. You can use the UpgradeToCurrentVersion() method on all IStacObject interface to upgrade the object to the latest version.

IStacCatalog cat06 = await StacFactory.LoadUriAsync(GetUri("https://landsat-stac.s3.amazonaws.com/catalog.json")) as IStacCatalog;
StacCatalog cat = cat06.UpgradeToCurrentVersion();
var children = cat.GetChildren();
IStacCatalog subcat06 = children.FirstOrDefault().Value;
StacCatalog subcat = subcat06.UpgradeToCurrentVersion();

I anyway discovered a small issue with sub collections. This is fixed in version 0.5.8

@brentfraser
Copy link
Author

Nice! Thanks!

@brentfraser
Copy link
Author

brentfraser commented Dec 23, 2020

Perhaps a runtime configuration setting in DotNetStac would be a better solution than requiring a "UpgradeToCurrentVersion" before calling every parse method?

@brentfraser
Copy link
Author

Using the notebook as a guide example, I do:

        public static void ListChildrensItemsAndAssets(IStacCatalog catalog, string prefix = "", int limit = 2)
        {
            // Get children first (sub catalogs and collections)
            foreach (var child_any_version in catalog.GetChildren().Values.Take(limit) )
            {
                IStacCatalog child = child_any_version.UpgradeToCurrentVersion();
                Console.Out.WriteLine(prefix + child.Id + ": " + child.Description);

                foreach (var item_any_version in child.GetItems().Values.Take(limit))
                {
                    IStacItem item = item_any_version.UpgradeToCurrentVersion();
                    Console.Out.WriteLine(prefix + " " + item.Id);
                    foreach (var asset in item.Assets.Values)
                    {
                        Console.Out.WriteLine(prefix + " *[" + asset.MediaType + "] " + asset.Uri);
                    }
                }

                ListChildrensItemsAndAssets(child, prefix + " ");
            }
        }

Note the IStacItem item = item_any_version.UpgradeToCurrentVersion();. The landsat catalog generates:

System.IO.InvalidDataException
  HResult=0x80131501
  Message=The document is not a STAC document. No 'stac_version' property found
  Source=DotNetStac
  StackTrace:
   at Stac.Item.StacItem.LoadStacItem(JToken jsonRoot) in src\DotNetStac\Item\StacItem.Helper.cs:line 43
   at Stac.Item.StacItem.LoadJToken(JToken jsonRoot, Uri uri) in src\DotNetStac\Item\StacItem.Helper.cs:line 33
   at Stac.StacFactory.<>c__DisplayClass0_0.<LoadUriAsync>b__0(Task`1 json) in src\DotNetStac\StacFactory.cs:line 21
   at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)

An Item should not require a stac_version?

@emmanuelmathot
Copy link
Contributor

right, in v0.6.0 stac_version field was not part of the spec (https://github.com/radiantearth/stac-spec/blob/v0.6.0/item-spec/item-spec.md). Will correct that in the next version

emmanuelmathot added a commit that referenced this issue Mar 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants