diff --git a/CHANGELOG.md b/CHANGELOG.md index d431a9af..de9a512a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Added - Root fields accessor for Stac Item +- Extensible raster object ### Fixed diff --git a/src/DotNetStac/Extensions/Raster/RasterBandObject.cs b/src/DotNetStac/Extensions/Raster/RasterBandObject.cs index 790a4007..8e88c46f 100644 --- a/src/DotNetStac/Extensions/Raster/RasterBandObject.cs +++ b/src/DotNetStac/Extensions/Raster/RasterBandObject.cs @@ -10,7 +10,7 @@ namespace Stac.Extensions.Raster /// of the Raster extension /// [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class RasterBand + public class RasterBand : IStacPropertiesContainer { IDictionary properties; @@ -104,5 +104,6 @@ public RasterBand() [JsonExtensionData] public IDictionary Properties { get => properties; set => properties = value; } + public IStacObject StacObjectContainer => null; } } \ No newline at end of file diff --git a/src/DotNetStac/StacAsset.cs b/src/DotNetStac/StacAsset.cs index ab00afde..edbb1270 100644 --- a/src/DotNetStac/StacAsset.cs +++ b/src/DotNetStac/StacAsset.cs @@ -6,6 +6,7 @@ using Stac.Converters; using Newtonsoft.Json; using System.Net.Mime; +using System.Runtime.Serialization; namespace Stac { @@ -85,7 +86,7 @@ public static StacAsset CreateMetadataAsset(IStacObject stacObject, Uri uri, Con internal StacAsset() { properties = new Dictionary(); - Roles = new Collection(); + Roles = new SortedSet(); } /// @@ -157,7 +158,7 @@ public ContentType MediaType /// /// [JsonProperty("roles")] - public Collection Roles + public ICollection Roles { get; private set; @@ -236,5 +237,11 @@ public bool ShouldSerializeStacExtensions() // don't serialize the Manager property if an employee is their own manager return Roles.Count > 0; } + + [OnDeserialized] + internal void OnDeserializedMethod(StreamingContext context) + { + Roles = new SortedSet(Roles); + } } } \ No newline at end of file diff --git a/src/DotNetStac/StacItem.cs b/src/DotNetStac/StacItem.cs index 8c594465..cc120d74 100644 --- a/src/DotNetStac/StacItem.cs +++ b/src/DotNetStac/StacItem.cs @@ -32,7 +32,7 @@ public StacItem(string id, Links = new ObservableCollection(); (Links as ObservableCollection).CollectionChanged += LinksCollectionChanged; Assets = new Dictionary(); - + } public StacItem(StacItem stacItem) : base(Preconditions.CheckNotNull(stacItem, "stacItem").Geometry, @@ -46,7 +46,6 @@ public StacItem(StacItem stacItem) : base(Preconditions.CheckNotNull(stacItem, " (Links as ObservableCollection).CollectionChanged += LinksCollectionChanged; this.Assets = new Dictionary(stacItem.Assets); this.Collection = stacItem.Collection; - } private void LinksCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) @@ -113,7 +112,14 @@ public ICollection Links /// The id of the STAC Collection this Item references to /// /// gets the collection id - public string Collection { get => Root.GetProperty("collection"); set => Root.SetProperty("collection", value); } + public string Collection + { + get => Root.GetProperty("collection"); + set + { + if (value != null) Root.SetProperty("collection", value); + } + } /// /// Item root extended data @@ -135,6 +141,7 @@ internal void OnDeserializedMethod(StreamingContext context) { asset.ParentStacObject = this; } + StacExtensions = new SortedSet(StacExtensions); } [OnSerializing] @@ -142,7 +149,7 @@ internal void OnSerializingMethod(StreamingContext context) { if (BoundingBoxes == null) BoundingBoxes = this.GetBoundingBoxFromGeometryExtent(); - StacExtensions = new SortedSet(StacExtensions); + } public bool ShouldSerializeStacExtensions() @@ -153,5 +160,10 @@ public bool ShouldSerializeStacExtensions() [JsonIgnore] public IStacObject StacObjectContainer => this; + + public object RasterExtension() + { + throw new NotImplementedException(); + } } } diff --git a/src/DotNetStac/StacObjectLink.cs b/src/DotNetStac/StacObjectLink.cs index 2cebedaf..d5f79dc4 100644 --- a/src/DotNetStac/StacObjectLink.cs +++ b/src/DotNetStac/StacObjectLink.cs @@ -53,5 +53,6 @@ public override Uri Uri set; } + public IStacObject StacObject => stacObject; } }