public void CreateEoExtension() { var coordinates = new[] { new List <IPosition> { new Position(37.488035566, -122.308150179), new Position(37.538869539, -122.597502109), new Position(37.613537207, -122.576687533), new Position(37.562818007, -122.288048600), new Position(37.488035566, -122.308150179) } }; var geometry = new Polygon(new LineString[] { new LineString(coordinates[0]) }); var properties = new Dictionary <string, object>(); properties.Add("datetime", DateTime.Parse("2016-05-03T13:21:30.040Z").ToUniversalTime()); StacItem item = new StacItem("CS3-20160503_132130_04", geometry, properties); 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")); 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 }; item.BoundingBoxes = item.GetBoundingBoxFromGeometryExtent(); EoStacExtension eo = item.EoExtension(); eo.CloudCover = 0; Assert.Equal <double>(0.0, eo.CloudCover.Value); Assert.Equal <double>(0.0, double.Parse(asset.Properties["eo:cloud_cover"].ToString())); var actualJson = StacConvert.Serialize(item); ValidateJson(actualJson); var expectedJson = GetJson("Item"); ValidateJson(expectedJson); JsonAssert.AreEqual(expectedJson, actualJson); asset.EoExtension().Bands = null; Assert.Null(asset.GetProperty("eo:bands")); }
public void CanSerializeMinimalSample() { var coordinates = new[] { new List <IPosition> { new Position(37.488035566, -122.308150179), new Position(37.538869539, -122.597502109), new Position(37.613537207, -122.576687533), new Position(37.562818007, -122.288048600), new Position(37.488035566, -122.308150179) } }; var geometry = new Polygon(new LineString[] { new LineString(coordinates[0]) }); var properties = new Dictionary <string, object>(); properties.Add("collection", "CS3"); StacItem item = new StacItem("CS3-20160503_132130_04", geometry, properties); item.DateTime = new Itenso.TimePeriod.TimeInterval(DateTime.Parse("2016-05-03T13:21:30.040Z")); item.Links.Add(StacLink.CreateSelfLink(new Uri("http://cool-sat.com/catalog/CS3-20160503_132130_04/CS3-20160503_132130_04.json"))); item.SetCollection("cool-sat", 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)); 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 }; item.BoundingBoxes = item.GetBoundingBoxFromGeometryExtent(); var actualJson = StacConvert.Serialize(item); ValidateJson(actualJson); var expectedJson = GetJson("Item"); ValidateJson(expectedJson); JsonAssert.AreEqual(expectedJson, actualJson); item.Links.Remove(item.Links.First(l => l.RelationshipType == "collection")); Assert.Null(item.Collection); }