Skip to content

Commit

Permalink
Merge branch 'hotfix/1.6.3' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelmathot committed Dec 2, 2022
2 parents 3803f07 + c5883c6 commit 9bce3fc
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 109 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.2](https://github.com/Terradue/DotNetStac/compare/1.6.1...1.6.2)
## [1.6.3](https://github.com/Terradue/DotNetStac/compare/1.6.2...1.6.3)

### Commits

- PropertyObservableCollection can be either list or array [`1101abf`](https://github.com/Terradue/DotNetStac/commit/1101abf85c46ffc06f18bce837abd957371b248b)

## [1.6.2](https://github.com/Terradue/DotNetStac/compare/1.6.1...1.6.2) - 2022-11-08

### Commits

Expand Down
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.6.2)
![Build Status](https://github.com/Terradue/DotNetStac/actions/workflows/build.yaml/badge.svg?branch=hotfix/1.6.3)
[![NuGet](https://img.shields.io/nuget/vpre/DotNetStac)](https://www.nuget.org/packages/DotNetStac/)
[![codecov](https://codecov.io/gh/Terradue/DotNetStac/branch/release/1.6.2/graph/badge.svg)](https://codecov.io/gh/Terradue/DotNetStac)
[![codecov](https://codecov.io/gh/Terradue/DotNetStac/branch/hotfix/1.6.3/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
11 changes: 11 additions & 0 deletions src/DotNetStac.Test/Collection/CollectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,17 @@ public void CollectionTimeSeries()
ValidateJson(newJson);
}

[Fact]
public void SerializeSimpleCollection()
{
var simpleItemJson = GetJson("Collection", "CanSerializeMinimalSample");
var simpleItem = StacConvert.Deserialize<StacItem>(simpleItemJson);
StacCollection simpleCollection = StacCollection.Create("simple-collection", "Simple Collection",
new Dictionary<Uri, StacItem> { { new Uri("item1", UriKind.Relative), simpleItem } }, "various");
var newJson = JsonConvert.SerializeObject(simpleCollection);
ValidateJson(newJson);
}


}
}
38 changes: 38 additions & 0 deletions src/DotNetStac.Test/Item/ItemTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public void CanDeserializeMinimalSample()
Assert.Equal("http://cool-sat.com/catalog/CS3-20160503_132130_04/thumbnail.png", item.Assets["thumbnail"].Uri.ToString());
Assert.Equal("Thumbnail", item.Assets["thumbnail"].Title);
Assert.Contains("thumbnail", item.Assets["thumbnail"].Roles);

}

[Fact]
Expand Down Expand Up @@ -161,6 +162,8 @@ 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);

ValidateJson(actualJson);
Expand All @@ -175,6 +178,39 @@ public void CanSerializeExtendedSample()
Assert.Null(item.Collection);
}

[Fact]
public void CanAddProvider()
{
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);

StacProvider provider = new StacProvider("test");
provider.Description = "test";
provider.Uri = new Uri("http://test.com");
properties.Add("providers", new StacProvider[] { provider });

Assert.NotNull(item.Providers);

var actualJson = StacConvert.Serialize(item);
}

[Fact]
public void CanManageDates()
{
Expand All @@ -200,6 +236,8 @@ public void CanDeserializeS2CogSample()

Assert.NotNull(item.Properties);

Assert.NotNull(item.Providers);

Assert.Equal("1.0.0", item.StacVersion);

}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"stac_version": "1.0.0",
"type": "Feature",
"id": "CS3-20160503_132130_04",
"collection": "CS3",
"bbox": [
-122.59750209,
37.48803556,
-122.2880486,
37.613537207
],
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-122.308150179,
37.488035566
],
[
-122.597502109,
37.538869539
],
[
-122.576687533,
37.613537207
],
[
-122.288048600,
37.562818007
],
[
-122.308150179,
37.488035566
]
]
]
},
"properties": {
"datetime": "2016-05-03T13:21:30.040Z",
},
"links": [
{
"rel": "self",
"href": "http://cool-sat.com/catalog/CS3-20160503_132130_04/CS3-20160503_132130_04.json"
},
{
"rel": "collection",
"href": "http://cool-sat.com/catalog.json"
}
],
"assets": {
"analytic": {
"href": "relative-path/to/analytic.tif",
"title": "4-Band Analytic"
},
"thumbnail": {
"href": "http://cool-sat.com/catalog/CS3-20160503_132130_04/thumbnail.png",
"title": "Thumbnail",
"roles": [
"thumbnail"
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,19 @@
"eo:cloud_cover": 0,
"sentinel:valid_cloud_cover": false,
"created": "2020-08-31T09:57:42.772Z",
"updated": "2020-08-31T09:57:42.772Z"
"updated": "2020-08-31T09:57:42.772Z",
"providers": [
{
"name": "ESA/EC (Copernicus)",
"description": "The Copernicus Sentinel-2 mission comprises a constellation of two polar-orbiting satellites placed in the same sun-synchronous orbit, phased at 180° to each other. It aims at monitoring variability in land surface conditions, and its wide swath width (290 km) and high revisit time (10 days at the equator with one satellite, and 5 days with 2 satellites under cloud-free conditions which results in 2-3 days at mid-latitudes) will support monitoring of Earth's surface changes.",
"roles": [
"producer",
"processor",
"licensor"
],
"url": "https://sentinel.esa.int/web/sentinel/missions/sentinel-2"
}
]
},
"collection": "sentinel-s2-l2a-cogs",
"assets": {
Expand Down
2 changes: 1 addition & 1 deletion src/DotNetStac/DotNetStac.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Title>DotNetStac</Title>
<Description>Terradue .Net library for working with any SpatioTemporal Asset Catalog</Description>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<VersionPrefix>1.6.2</VersionPrefix>
<VersionPrefix>1.6.3</VersionPrefix>
<Authors>Emmanuel Mathot</Authors>
<Authors>emmanuelmathot</Authors>
<Company>Terradue</Company>
Expand Down
12 changes: 10 additions & 2 deletions src/DotNetStac/StacAccessorsHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,17 @@ public static T GetProperty<T>(this IDictionary<string, object> properties, stri

public static PropertyObservableCollection<T> GetObservableCollectionProperty<T>(this IStacPropertiesContainer propertiesContainer, string key)
{
List<T> array = propertiesContainer.GetProperty<List<T>>(key);
List<T> array = new List<T>();
try
{
array = propertiesContainer.GetProperty<List<T>>(key);
}
catch
{
array = propertiesContainer.GetProperty<T[]>(key)?.ToList();
}
PropertyObservableCollection<T> observableCollection = new PropertyObservableCollection<T>(propertiesContainer, key);
if (array != null && array.Count > 0)
if (array != null && array.Count() > 0)
{
observableCollection.AddRange<T>(array);
}
Expand Down
102 changes: 0 additions & 102 deletions src/DotNetStac/StacCollection.CommonMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,107 +57,5 @@ public string License
[JsonIgnore]
public Collection<StacProvider> Providers => this.GetObservableCollectionProperty<StacProvider>("providers");

public string Platform
{
get => this.GetProperty<string>("platform");
set => this.SetProperty("platform", value);
}

public IEnumerable<string> Instruments
{
get => this.GetProperty<string[]>("instruments");
set => this.SetProperty("instruments", value);
}

public string Constellation
{
get => this.GetProperty<string>("constellation");
set => this.SetProperty("constellation", value);
}

public string Mission
{
get => this.GetProperty<string>("mission");
set => this.SetProperty("mission", value);
}

public double? Gsd
{
get => this.GetProperty<double>("gsd");
set
{
if (value == 0) this.RemoveProperty("gsd");
else
this.SetProperty("gsd", value);
}
}

public DateTime Created
{
get => this.GetProperty<DateTime>("created");
set => this.SetProperty("created", value);
}

public DateTime Updated
{
get => this.GetProperty<DateTime>("updated");
set => this.SetProperty("updated", value);
}

public Itenso.TimePeriod.ITimePeriod DateTime
{
get
{
if (this.Properties.ContainsKey("datetime"))
{
if (this.Properties["datetime"] is DateTime?)
return new Itenso.TimePeriod.TimeInterval((DateTime)this.Properties["datetime"]);
else
{
try
{
return new Itenso.TimePeriod.TimeInterval(System.DateTime.Parse(this.Properties["datetime"].ToString()));
}
catch (Exception e)
{
if (this.Properties.ContainsKey("start_datetime") && this.Properties.ContainsKey("end_datetime"))
{
if (this.Properties["start_datetime"] is DateTime? && this.Properties["end_datetime"] is DateTime?)
return new Itenso.TimePeriod.TimeInterval((DateTime)this.Properties["start_datetime"],
(DateTime)this.Properties["end_datetime"]);
throw new FormatException(string.Format("start_datetime and/or end_datetime are not a valid: {0}", e.Message), e);
}
throw new FormatException(string.Format("datetime is not a valid", e.Message), e);
}
}
}
return Itenso.TimePeriod.TimeInterval.Anytime;
}
set
{
// datetime, start_datetime, end_datetime
if (value.IsAnytime)
{
this.RemoveProperty("start_datetime");
this.RemoveProperty("end_datetime");
this.SetProperty("datetime", null);
}

if (value.IsMoment)
{
this.RemoveProperty("start_datetime");
this.RemoveProperty("end_datetime");
this.SetProperty("datetime", value.Start);
}
else
{
this.SetProperty("datetime", value.Start);
this.SetProperty("start_datetime", value.Start);
this.SetProperty("end_datetime", value.End);
}
}
}


}
}

0 comments on commit 9bce3fc

Please sign in to comment.