Skip to content

Commit

Permalink
Merge branch 'hotfix/1.6.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelmathot committed Feb 3, 2023
2 parents a33f4a2 + fb433b8 commit 0b0e8ba
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 13 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.4](https://github.com/Terradue/DotNetStac/compare/1.6.4...1.6.4)
## [1.6.6](https://github.com/Terradue/DotNetStac/compare/1.6.5...1.6.6)

### Commits

- Fix start_datetime and end_datetime when datetime is null [`52d4b52`](https://github.com/Terradue/DotNetStac/commit/52d4b52a5bc92508cf69c5f6bdbb69c8fdf5ca6a)

## [1.6.5](https://github.com/Terradue/DotNetStac/compare/1.6.4...1.6.5) - 2022-12-12

### 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=hotfix/1.6.5)
![Build Status](https://github.com/Terradue/DotNetStac/actions/workflows/build.yaml/badge.svg?branch=hotfix/1.6.6)
[![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.5/graph/badge.svg)](https://codecov.io/gh/Terradue/DotNetStac)
[![codecov](https://codecov.io/gh/Terradue/DotNetStac/branch/hotfix/1.6.6/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
14 changes: 14 additions & 0 deletions src/DotNetStac.Test/Item/ItemTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -481,5 +481,19 @@ public void EmptyDate()
Assert.Throws<FormatException>(() => item.DateTime);

}

[Fact]
public void NullDateTimeButStartAndEnd()
{
var json = GetJson("Item");

ValidateJson(json);

var item = StacConvert.Deserialize<StacItem>(json);

Assert.Equal(DateTime.Parse("1972-12-01T00:00:00Z").ToUniversalTime(), item.DateTime.Start.ToUniversalTime());

}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"stac_version": "1.0.0",
"stac_extensions": [],
"type": "Feature",
"id": "snowgrid_meanHS_1973",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
96.69999999999999,
48.19999999999973
],
[
96.69999999999999,
52.19999999999999
],
[
102.80000000000038,
52.19999999999999
],
[
102.80000000000038,
48.19999999999973
],
[
96.69999999999999,
48.19999999999973
]
]
]
},
"properties": {
"start_datetime": "1972-12-01T00:00:00Z",
"end_datetime": "1973-05-31T00:00:00Z",
"datetime": null,
"description": "Name | Value \n---- | ----- \nAgency | **ZAMG** \n Product | **snowgrid_meanHS_1973** \nDescription | **Seasonal mean of snow height.** \n Start Date | **1972-12-01T00:00:00Z** \nEnd Date | **1973-05-31T00:00:00Z** \n",
"title": "Mean snow height (HS) (meanHS) - 1973",
"license": "CC-BY-SA-3.0",
"mission": "SNOWGRID-CL",
"platform": "SNOWGRID-CL"
},
"bbox": [
96.69999999999999,
48.19999999999973,
102.80000000000038,
52.19999999999999
],
"assets": {
"snowgrid_meanHS_1973": {
"href": "https://store.terradue.com/temporary-uploads/livio/indices_cog/snowgrid/meanHS/GDA-AID-DR_UC7-ADBMON_Product_SNOWGRID-CL-meanHS-V01_IronDzud-Khuvsgul-1973.tif",
"type": "image/tiff; application=geotiff",
"title": "Mean snow height (HS) (meanHS) - 1973",
"description": "Seasonal mean of snow height.",
"roles": [
"data",
"overview"
]
}
},
"links": [
{
"rel": "root",
"href": "../catalog.json",
"type": "application/json"
},
{
"rel": "parent",
"href": "../catalog.json",
"type": "application/json"
}
]
}
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.5</VersionPrefix>
<VersionPrefix>1.6.6</VersionPrefix>
<Authors>Emmanuel Mathot</Authors>
<Authors>emmanuelmathot</Authors>
<Company>Terradue</Company>
Expand Down
14 changes: 5 additions & 9 deletions src/DotNetStac/StacItem.CommonMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,12 @@ public Itenso.TimePeriod.ITimePeriod DateTime
if (!this.Properties.ContainsKey("datetime") || (!this.Properties.ContainsKey("start_datetime") && !this.Properties.ContainsKey("end_datetime")))
throw new FormatException("One of datetime, start_datetime and/or end_datetime are required", nre);
}
catch (Exception e)
if (this.Properties.ContainsKey("start_datetime") && this.Properties.ContainsKey("end_datetime"))
{
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);
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"));
}
}
}
Expand Down

0 comments on commit 0b0e8ba

Please sign in to comment.