-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e083b45
commit fddef27
Showing
1 changed file
with
23 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,23 @@ | ||
# PLACEHOLDER | ||
TODO: Add .NET projects to the *src* folder and run `docfx` to generate **REAL** *API Documentation*! | ||
# DotNetStac API | ||
|
||
Main entry point API is `StacConvert.Deserialize<IStacObject>`, which deserializes a Stac Object (Catalog, COllection or Item) that implements `IStacObject`: | ||
|
||
```csharp | ||
using Stac; | ||
using Stac.Schemas; | ||
using System; | ||
using System.Net; | ||
using Newtonsoft.Json.Schema; | ||
|
||
var webc = new WebClient(); | ||
Uri catalogUri = new Uri("https://raw.githubusercontent.com/radiantearth/stac-spec/master/examples/catalog.json"); | ||
StacValidator stacValidator = new StacValidator(new JSchemaUrlResolver()); | ||
|
||
// StacConvert.Deserialize is the helper to start loading any STAC document | ||
var json = webc.DownloadString(catalogUri); | ||
bool valid = stacValidator.ValidateJson(json); | ||
StacCatalog catalog = StacConvert.Deserialize<StacCatalog>(json); | ||
|
||
Console.Out.WriteLine(catalog.Id + ": " + catalog.Description + (valid ? " [VALID]" : "[INVALID]")); | ||
Console.Out.WriteLine(catalog.StacVersion); | ||
``` |