public override IReadOnlyList <IResource> GetRoutes(ICredentials credentials) { StacRouter stacRouter = new StacRouter(credentials); return(StacCatalog.GetChildren(this.Uri, stacRouter).Select(child => new StacCatalogNode(child.Value, child.Key)).Cast <IResource>() .Concat(StacCatalog.GetItems(this.Uri, stacRouter).Select(item => new StacItemNode(item.Value, item.Key))) .ToList()); }
public void CatalogStacObjectLink() { var simpleJson = GetJson("Catalog", "CanDeserializeMinimalSample"); ValidateJson(simpleJson); StacCatalog simpleCollection = StacConvert.Deserialize <StacCatalog>(simpleJson); StacObjectLink stacObjectLink = (StacObjectLink)StacLink.CreateObjectLink(simpleCollection, new Uri("file:///test")); }
//[Fact] public void Deserialize() { Uri catalogUri = new Uri("https://landsat-stac.s3.amazonaws.com/catalog.json"); StacCatalog catalog = StacConvert.Deserialize <StacCatalog>(httpClient.GetStringAsync(catalogUri).GetAwaiter().GetResult()); Console.Out.WriteLine(catalog.Id); Console.Out.WriteLine(catalog.StacVersion); ListChildrensItemsAndAssets(catalog, catalogUri); }
public void LoadRootCatalog() { var json = GetUseCaseJson("catalog.json"); ValidateJson(json); catalog = StacConvert.Deserialize <StacCatalog>(json); Assert.NotNull(catalog); Assert.Equal("sentinel-stac", catalog.Id); }
public void CanDeserializeBaseCatalogExample() { var json = httpClient.GetStringAsync($"https://raw.githubusercontent.com/radiantearth/stac-spec/v{Versions.StacVersionList.Current}/examples/catalog.json").GetAwaiter().GetResult(); StacCatalog catalog = StacConvert.Deserialize <StacCatalog>(json); Assert.NotNull(catalog); Assert.Equal(Versions.StacVersionList.Current.ToString(), catalog.StacVersion.ToString()); string catalog2json = StacConvert.Serialize(catalog); JsonAssert.AreEqual(json, catalog2json); }
public void CanSerializeMinimalSample() { StacCatalog collection = new StacCatalog("NAIP", "Catalog of NAIP Imagery"); collection.Links.Add(StacLink.CreateSelfLink(new Uri("https://www.fsa.usda.gov/naip/catalog.json"))); collection.Links.Add(new StacLink(new Uri("https://www.fsa.usda.gov/naip/30087/catalog.json"), "child", null, null)); collection.Links.Add(StacLink.CreateRootLink(new Uri("https://www.fsa.usda.gov/catalog.json"))); var actualJson = JsonConvert.SerializeObject(collection); Console.WriteLine(actualJson); var expectedJson = GetJson("Catalog"); ValidateJson(expectedJson); ValidateJson(actualJson); JsonAssert.AreEqual(expectedJson, actualJson); }
public void CatalogClone() { var simpleJson = GetJson("Catalog", "CanDeserializeMinimalSample"); ValidateJson(simpleJson); StacCatalog simpleCollection = StacConvert.Deserialize <StacCatalog>(simpleJson); StacCatalog simpleCollectionClone = new StacCatalog(simpleCollection); var clonedJson = JsonConvert.SerializeObject(simpleCollectionClone); ValidateJson(clonedJson); JsonAssert.AreEqual(simpleJson, clonedJson); simpleCollectionClone = (StacCatalog)simpleCollection.Clone(); clonedJson = JsonConvert.SerializeObject(simpleCollectionClone); ValidateJson(clonedJson); JsonAssert.AreEqual(simpleJson, clonedJson); }
public static StacCatalogNode CreateUnlocatedNode(StacCatalog catalog) { return(new StacCatalogNode(catalog, new Uri(catalog.Id + ".json", UriKind.Relative))); }