Skip to content

Commit

Permalink
more coverage for eo extension
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelmathot committed May 31, 2021
1 parent c9fe721 commit ab73316
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/DotNetStac.Test/Extensions/EoExtensionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ public void CreateEoExtension()
item.Links.Add(StacLink.CreateSelfLink(new Uri("http://cool-sat.com/catalog/CS3-20160503_132130_04/CS3-20160503_132130_04.json")));
item.SetCollection("CS3", new Uri("http://cool-sat.com/catalog.json"));

item.Assets.Add("analytic", new StacAsset(item, new Uri("relative-path/to/analytic.tif", UriKind.Relative), null, "4-Band Analytic", null));
var asset = new StacAsset(item, new Uri("relative-path/to/analytic.tif", UriKind.Relative), null, "4-Band Analytic", null);

asset.EoExtension().CloudCover = 0;

item.Assets.Add("analytic",asset);
item.Assets.Add("thumbnail", StacAsset.CreateThumbnailAsset(item, new Uri("http://cool-sat.com/catalog/CS3-20160503_132130_04/thumbnail.png"), null, "Thumbnail"));

// item.BoundingBoxes = new double[4] { -122.59750209, 37.48803556, -122.2880486, 37.613537207 };
Expand All @@ -106,6 +110,7 @@ public void CreateEoExtension()
eo.CloudCover = 0;

Assert.Equal<double>(0, eo.CloudCover);
Assert.Equal<double>(0, double.Parse(asset.Properties["eo:cloud_cover"].ToString()));

var actualJson = StacConvert.Serialize(item);

Expand All @@ -116,6 +121,11 @@ public void CreateEoExtension()
ValidateJson(expectedJson);

JsonAssert.AreEqual(expectedJson, actualJson);

asset.EoExtension().Bands = null;

Assert.Null(asset.GetProperty("eo:bands"));

}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
"assets": {
"analytic": {
"href": "relative-path/to/analytic.tif",
"title": "4-Band Analytic"
"title": "4-Band Analytic",
"eo:cloud_cover": 0.0
},
"thumbnail": {
"href": "http://cool-sat.com/catalog/CS3-20160503_132130_04/thumbnail.png",
Expand Down
3 changes: 2 additions & 1 deletion src/DotNetStac/Extensions/Eo/EoStacExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ public class EoStacExtension : StacPropertiesContainerExtension, IStacExtension
/// Extension identifier and schema url
public const string JsonSchemaUrl = "https://stac-extensions.github.io/eo/v1.0.0/schema.json";

private static IDictionary<string, Type> itemFields;
private const string BandsField = "eo:bands";
private const string CloudCoverField = "eo:cloud_cover";

private static IDictionary<string, Type> itemFields;

internal EoStacExtension(IStacPropertiesContainer stacpropertiesContainer) : base(JsonSchemaUrl, stacpropertiesContainer)
{
itemFields = new Dictionary<string, Type>();
Expand Down

0 comments on commit ab73316

Please sign in to comment.