diff --git a/CHANGELOG.md b/CHANGELOG.md index 2905716d..1af84a61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). -## [1.6.3](https://github.com/Terradue/DotNetStac/compare/1.6.2...1.6.3) +## [1.6.3](https://github.com/Terradue/DotNetStac/compare/1.6.3...1.6.3) + +### Commits + +- null geometry must be serialized [`6b56f04`](https://github.com/Terradue/DotNetStac/commit/6b56f0445446a92164c1bf596bc4887a3e43e40d) + +## [1.6.3](https://github.com/Terradue/DotNetStac/compare/1.6.2...1.6.3) - 2022-12-02 ### Commits diff --git a/README.md b/README.md index c1ccae60..a1446743 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,9 @@

-![Build Status](https://github.com/Terradue/DotNetStac/actions/workflows/build.yaml/badge.svg?branch=hotfix/1.6.3) +![Build Status](https://github.com/Terradue/DotNetStac/actions/workflows/build.yaml/badge.svg?branch=hotfix/1.6.4) [![NuGet](https://img.shields.io/nuget/vpre/DotNetStac)](https://www.nuget.org/packages/DotNetStac/) -[![codecov](https://codecov.io/gh/Terradue/DotNetStac/branch/hotfix/1.6.3/graph/badge.svg)](https://codecov.io/gh/Terradue/DotNetStac) +[![codecov](https://codecov.io/gh/Terradue/DotNetStac/branch/hotfix/1.6.4/graph/badge.svg)](https://codecov.io/gh/Terradue/DotNetStac) [![Gitter](https://img.shields.io/gitter/room/SpatioTemporal-Asset-Catalog/Lobby?color=yellow)](https://gitter.im/SpatioTemporal-Asset-Catalog/Lobby) [![License](https://img.shields.io/badge/license-AGPL3-blue.svg)](LICENSE) [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/Terradue/DotNetStac/master?filepath=example.ipynb) diff --git a/src/DotNetStac.Test/Collection/CollectionTests.cs b/src/DotNetStac.Test/Collection/CollectionTests.cs index a18f7ae3..c0d22712 100644 --- a/src/DotNetStac.Test/Collection/CollectionTests.cs +++ b/src/DotNetStac.Test/Collection/CollectionTests.cs @@ -311,7 +311,7 @@ public void SerializeSimpleCollection() { var simpleItemJson = GetJson("Collection", "CanSerializeMinimalSample"); var simpleItem = StacConvert.Deserialize(simpleItemJson); - StacCollection simpleCollection = StacCollection.Create("simple-collection", "Simple Collection", + StacCollection simpleCollection = StacCollection.Create("simple-collection", "Simple Collection", new Dictionary { { new Uri("item1", UriKind.Relative), simpleItem } }, "various"); var newJson = JsonConvert.SerializeObject(simpleCollection); ValidateJson(newJson); diff --git a/src/DotNetStac.Test/Item/ItemTests.cs b/src/DotNetStac.Test/Item/ItemTests.cs index 7fca07ae..00c10501 100644 --- a/src/DotNetStac.Test/Item/ItemTests.cs +++ b/src/DotNetStac.Test/Item/ItemTests.cs @@ -162,7 +162,7 @@ public void CanSerializeExtendedSample() // item.BoundingBoxes = new double[4] { -122.59750209, 37.48803556, -122.2880486, 37.613537207 }; item.BoundingBoxes = item.GetBoundingBoxFromGeometryExtent(); - + var actualJson = StacConvert.Serialize(item); @@ -448,5 +448,22 @@ public void EmptyProviders() Assert.NotNull(item.Providers); } + + [Fact] + public void EmptyGeometry() + { + var json = GetJson("Item"); + + var item = StacConvert.Deserialize(json); + + Assert.Null(item.Geometry); + + json = StacConvert.Serialize(item); + + JToken token = JToken.Parse(json); + + Assert.NotNull(token.Children().FirstOrDefault(c => c.Path == "geometry")); + + } } } diff --git a/src/DotNetStac.Test/Resources/Item/ItemTests_EmptyGeometry.json b/src/DotNetStac.Test/Resources/Item/ItemTests_EmptyGeometry.json new file mode 100644 index 00000000..b9800922 --- /dev/null +++ b/src/DotNetStac.Test/Resources/Item/ItemTests_EmptyGeometry.json @@ -0,0 +1,108 @@ +{ + "stac_version": "1.0.0", + "stac_extensions": [ + "https://stac-extensions.github.io/version/v1.0.0/schema.json", + "https://terradue.github.io/disaster/v1.0.0/schema.json" + ], + "type": "Feature", + "id": "act-2", + "geometry": null, + "properties": { + "disaster:class": "Activation", + "cpe:status": { + "stage": "notificationNew", + "message": null, + "link": null + }, + "updated": "2022-06-23T12:31:13.5064407Z", + "title": "[Act-2/Call-2] ONF Fires Monitoring", + "disaster:activation_id": 2, + "disaster:call_ids": [ + 2 + ], + "cpe:pm_user_id": "fpacini", + "disaster:type": [ + "Fire" + ], + "disaster:region": [ + "South France" + ], + "disaster:country": "FRA", + "datetime": "2022-06-21T07:30:00Z", + "cpe:cos2_xml": "\n\n 2\n gdaonf\n 2022-06-21T07:30:00Z\n 2022-06-21T07:55:39Z\n ONF Fires Monitoring\n desc\n 2\n fpacini\n fire\n https://www.terradue.com\n FRA\n South France\n \n false\n s3://mcube-catalog/activations/act-2/act-2.kml\n \n \n 43.192\n 3.009\n \n false\n", + "created": "2022-06-21T07:30:00Z", + "cpe:activation_status": "open", + "description": "
\n\n## [Act-2/Call-2] ONF Fires Monitoring\n\n**21/06/2022 07:30:00**\n\n[Link on disastercharter.org](https://www.terradue.com/)\n\n
desc
", + "providers": [ + { + "name": "gdaonf", + "roles": [ + "producer" + ] + } + ], + "cpe:notified": [ + "2022-06-21T15:08:45.7088154Z", + "2022-06-23T12:30:21.3505743Z" + ], + "cpe:notification_source": "cos2", + "version": "6" + }, + "bbox": [ + 3.009, + 43.192, + 3.009, + 43.192 + ], + "assets": { + "icon": { + "type": "image/png", + "roles": [ + "thumbnail" + ], + "title": "placemark", + "href": "s3://mcube-catalog/activations/act-2/fire.png", + "file:size": 11452 + }, + "area1": { + "type": "application/vnd.google-earth.kml+xml", + "roles": [ + "area", + "metadata" + ], + "title": "Area 1", + "href": "s3://mcube-catalog/activations/act-2/act-2.kml", + "file:size": 1591 + } + }, + "links": [ + { + "type": "text/html", + "rel": "about", + "title": "Disaster Charter Web Page", + "href": "https://www.terradue.com" + }, + { + "type": "application/geo+json", + "rel": "item", + "title": "[Area] South of France", + "href": "areas/South_of_France.json" + }, + { + "type": "application/geo+json", + "rel": "item", + "title": "[Area] Corse", + "href": "areas/Corse.json" + }, + { + "type": "application/geo+json", + "rel": "self", + "href": "s3://mcube-catalog/activations/act-2/act-2.json" + }, + { + "type": "application/json", + "rel": "root", + "href": "s3://mcube-catalog/catalog.json" + } + ] +} \ No newline at end of file diff --git a/src/DotNetStac/DotNetStac.csproj b/src/DotNetStac/DotNetStac.csproj index 040d6505..8cd5312f 100644 --- a/src/DotNetStac/DotNetStac.csproj +++ b/src/DotNetStac/DotNetStac.csproj @@ -4,7 +4,7 @@ DotNetStac Terradue .Net library for working with any SpatioTemporal Asset Catalog LICENSE - 1.6.3 + 1.6.4 Emmanuel Mathot emmanuelmathot Terradue diff --git a/src/DotNetStac/StacItem.cs b/src/DotNetStac/StacItem.cs index 16fe839c..7b30e830 100644 --- a/src/DotNetStac/StacItem.cs +++ b/src/DotNetStac/StacItem.cs @@ -16,7 +16,7 @@ namespace Stac /// /// STAC Item Object implementing STAC Item spec (https://github.com/radiantearth/stac-spec/blob/master/item-spec/item-spec.md) /// - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore, MemberSerialization = MemberSerialization.OptIn)] + [JsonObject(MemberSerialization = MemberSerialization.OptIn)] public partial class StacItem : GeoJSON.Net.Feature.Feature, IStacObject, ICloneable { public const string MEDIATYPE = "application/geo+json";