Skip to content

Commit

Permalink
Proper assets cloning for Stac Item and Collection
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelmathot committed Sep 26, 2022
1 parent 9d34069 commit 8f51df3
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

<h3 align="center">

![Build Status](https://github.com/Terradue/DotNetStac/actions/workflows/build.yaml/badge.svg?branch=release/1.4.1)
![Build Status](https://github.com/Terradue/DotNetStac/actions/workflows/build.yaml/badge.svg?branch=develop)
[![NuGet](https://img.shields.io/nuget/vpre/DotNetStac)](https://www.nuget.org/packages/DotNetStac/)
[![codecov](https://codecov.io/gh/Terradue/DotNetStac/branch/release/1.4.1/graph/badge.svg)](https://codecov.io/gh/Terradue/DotNetStac)
[![codecov](https://codecov.io/gh/Terradue/DotNetStac/branch/develop/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)
Expand Down
2 changes: 1 addition & 1 deletion src/DotNetStac.Test/DotNetStac.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
<IsPublishable>false</IsPublishable>
<!-- <CodeAnalysisRuleSet>$(SolutionDir)StyleCop.ruleset</CodeAnalysisRuleSet> -->
Expand Down
2 changes: 2 additions & 0 deletions src/DotNetStac.Test/Item/ItemTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ public void ItemClone()
var clonedJson = StacConvert.Serialize(simpleItemClone);
ValidateJson(clonedJson);

JsonAssert.AreEqual(clonedJson, simpleJson);

var expectedJson = GetJson("Item");
JsonAssert.AreEqual(simpleJson, expectedJson);

Expand Down
3 changes: 2 additions & 1 deletion src/DotNetStac/StacCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public StacCollection(StacCollection stacCollection)
this.Links = new Collection<StacLink>(stacCollection.Links.ToList());
this.Summaries = new Dictionary<string, Stac.Collection.IStacSummaryItem>(stacCollection.Summaries);
this.Properties = new Dictionary<string, object>(stacCollection.Properties);
this.Assets = new Dictionary<string, StacAsset>(stacCollection.Assets);
this.Assets = new Dictionary<string, StacAsset>(stacCollection.Assets.Select(a => new KeyValuePair<string, StacAsset>(a.Key, new StacAsset(a.Value, this)))
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value));
this.License = stacCollection.License;
this.Keywords = new Collection<string>(stacCollection.Keywords);
this.Extent = new StacExtent(stacCollection.Extent);
Expand Down
5 changes: 3 additions & 2 deletions src/DotNetStac/StacItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ public StacItem(StacItem stacItem) : base(Preconditions.CheckNotNull(stacItem, "
this.StacExtensions = new SortedSet<string>(stacItem.StacExtensions);
this.Root = new StacItemRootPropertyContainer(this);
this.StacVersion = stacItem.StacVersion;
this.Links = new ObservableCollection<StacLink>(stacItem.Links);
this.Links = new ObservableCollection<StacLink>(stacItem.Links.Select(l => new StacLink(l)));
(Links as ObservableCollection<StacLink>).CollectionChanged += LinksCollectionChanged;
this.Assets = new Dictionary<string, StacAsset>(stacItem.Assets);
this.Assets = new Dictionary<string, StacAsset>(stacItem.Assets.Select(a => new KeyValuePair<string, StacAsset>(a.Key, new StacAsset(a.Value, this)))
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value));
this.Collection = stacItem.Collection;
}

Expand Down

0 comments on commit 8f51df3

Please sign in to comment.