Skip to content

Commit

Permalink
proper StacItem Clone
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelmathot committed Nov 25, 2020
1 parent 555f388 commit 06225ba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 5 additions & 3 deletions src/DotNetStac/Extensions/StacExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Stac.Extensions
{
public class StacExtensions : Dictionary<string, IStacExtension>
public class StacExtensions : Dictionary<string, IStacExtension>, IEnumerable<IStacExtension>
{
public StacExtensions(IEnumerable<IStacExtension> stacExtensions = null)
{
Expand All @@ -33,7 +33,9 @@ public void Add(IStacExtension extension)
Add(extension.Id, extension);
}



IEnumerator<IStacExtension> IEnumerable<IStacExtension>.GetEnumerator()
{
return this.Values.GetEnumerator();
}
}
}
8 changes: 4 additions & 4 deletions src/DotNetStac/Item/StacItem.Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ public StacItem(IGeometryObject geometry, object properties, string id = null) :
}

public StacItem(StacItem stacItem) : this(Preconditions.CheckNotNull(stacItem).Geometry,
Preconditions.CheckNotNull(stacItem).Properties,
new Dictionary<string, object>(Preconditions.CheckNotNull(stacItem).Properties),
Preconditions.CheckNotNull(stacItem).Id)
{
this.stacExtensionsStrings = stacItem.stacExtensionsStrings;
this.stacVersion = stacItem.stacVersion;
this.links = stacItem.links;
this.assets = stacItem.assets;
this.links = new Collection<StacLink>(stacItem.links);
this.assets = new Dictionary<string, StacAsset>(stacItem.assets);
this.collection = stacItem.collection;
this.sourceUri = stacItem.sourceUri;
this.extensions = stacItem.extensions;
this.extensions = new StacExtensions(stacItem.extensions);
}

[JsonProperty("stac_extensions")]
Expand Down

0 comments on commit 06225ba

Please sign in to comment.