Skip to content

Commit

Permalink
Merge branch 'release/1.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelmathot committed Oct 27, 2022
2 parents 3d11c93 + 560f5fc commit a64c860
Show file tree
Hide file tree
Showing 15 changed files with 886 additions and 7 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,19 @@ 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.5.0](https://github.com/Terradue/DotNetStac/compare/1.4.5...1.5.0)
## [1.6.0](https://github.com/Terradue/DotNetStac/compare/1.5.0...1.6.0)

add datacube extension support

### Merged

- add datacube extension support [`#17`](https://github.com/Terradue/DotNetStac/pull/17)

### Commits

- linting code [`72b74d2`](https://github.com/Terradue/DotNetStac/commit/72b74d283c1b2dc1168684b7e867bbd1ee8bf6a7)

## [1.5.0](https://github.com/Terradue/DotNetStac/compare/1.4.5...1.5.0) - 2022-10-26

### 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.5.0)
![Build Status](https://github.com/Terradue/DotNetStac/actions/workflows/build.yaml/badge.svg?branch=release/1.6.0)
[![NuGet](https://img.shields.io/nuget/vpre/DotNetStac)](https://www.nuget.org/packages/DotNetStac/)
[![codecov](https://codecov.io/gh/Terradue/DotNetStac/branch/release/1.5.0/graph/badge.svg)](https://codecov.io/gh/Terradue/DotNetStac)
[![codecov](https://codecov.io/gh/Terradue/DotNetStac/branch/release/1.6.0/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
134 changes: 134 additions & 0 deletions src/DotNetStac.Test/Extensions/DatacubeExtensionTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mime;
using GeoJSON.Net.Geometry;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Stac.Extensions.Datacube;
using Stac.Extensions.Eo;
using Xunit;

namespace Stac.Test.Extensions
{
public class DatacubeExtensionTests : TestBase
{
[Fact]
public void Datacube123()
{
var json = GetJson("Extensions");

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

Assert.IsType<StacItem>(item);
Assert.Equal(6, item.DatacubeStacExtension().Dimensions.Count);
Assert.Equal(2, item.DatacubeStacExtension().Variables.Count);
}

[Fact]
public void Sample1()
{
var json = GetJson("Extensions");

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

Assert.IsType<StacItem>(item);
Assert.Equal(3, item.DatacubeStacExtension().Dimensions.Count);
Assert.Equal(7, item.DatacubeStacExtension().Variables.Count);
}

[Fact]
public void CanSerializeDatacube123()
{
var originalJson = GetJson("Extensions", "Datacube123");

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.2880486),
new Position(37.488035566,-122.308150179)
}
};
var geometry = new Polygon(new LineString[] { new LineString(coordinates[0]) });
var properties = new Dictionary<string, object>();
StacItem item = new StacItem("datacube-123", geometry, properties);

item.StacExtensions.Add("https://stac-extensions.github.io/datacube/v2.1.0/schema.json");
item.SetProperty("title", "Multi-dimensional data cube 123 in a STAC Item.");
item.SetProperty("datetime", "2016-05-03T13:21:30.040Z");

var xdim = new DatacubeDimensionSpatialHorizontal();
xdim.Axis = DatacubeAxis.x;
xdim.Type = "spatial";
xdim.Extent = new double[] { -122.59750209, -122.2880486 };
xdim.ReferenceSystem = 4326;
item.DatacubeStacExtension().Dimensions.Add("x", xdim);

var ydim = new DatacubeDimensionSpatialHorizontal();
ydim.Axis = DatacubeAxis.y;
ydim.Type = "spatial";
ydim.Extent = new double[] { 37.48803556, 37.613537207 };
ydim.ReferenceSystem = 4326;
item.DatacubeStacExtension().Dimensions.Add("y", ydim);

var pressure_levelsDim = new DatacubeDimensionSpatialVertical();
pressure_levelsDim.Axis = DatacubeAxis.z;
pressure_levelsDim.Type = "spatial";
pressure_levelsDim.Extent = new double[] { 0, 1000 };
pressure_levelsDim.Step = 100.0;
pressure_levelsDim.Unit = "Pa";
item.DatacubeStacExtension().Dimensions.Add("pressure_levels", pressure_levelsDim);

var metered_levelsDim = new DatacubeDimensionSpatialVertical();
metered_levelsDim.Axis = DatacubeAxis.z;
metered_levelsDim.Type = "spatial";
metered_levelsDim.Values = new double[] { 0, 10, 25, 50, 100, 1000 };
metered_levelsDim.Unit = "m";
item.DatacubeStacExtension().Dimensions.Add("metered_levels", metered_levelsDim);

var timeDim = new DatacubeDimensionTemporal();
timeDim.Type = "temporal";
timeDim.Values = new string[] { "2016-05-03T13:21:30.040Z" };
item.DatacubeStacExtension().Dimensions.Add("time", timeDim);

var spectralDim = new DatacubeDimensionAdditional();
spectralDim.Type = "bands";
spectralDim.Values = new string[] { "red", "green", "blue" };
item.DatacubeStacExtension().Dimensions.Add("spectral", spectralDim);

var tempVar = new DatacubeVariable();
tempVar.Dimensions = new string[] { "time", "y", "x", "pressure_levels" };
tempVar.Type = DatacubeVariableType.data;
item.DatacubeStacExtension().Variables.Add("temp", tempVar);

var colorVar = new DatacubeVariable();
colorVar.Dimensions = new string[] { };
colorVar.Type = DatacubeVariableType.auxiliary;
colorVar.Values = new string[] { "red", "green", "blue" };
item.DatacubeStacExtension().Variables.Add("color", colorVar);

var dataAsset = new StacAsset(item, new Uri("http://cool-sat.com/catalog/datacube-123/data.nc"), null, "netCDF Data cube", new ContentType("application/netcdf"));
item.Assets.Add("data", dataAsset);

var thumbnailAsset = new StacAsset(item, new Uri("http://cool-sat.com/catalog/datacube-123/thumbnail.png"), null, "Thumbnail", new ContentType("image/png"));
item.Assets.Add("thumbnail", thumbnailAsset);

var link = new StacLink(new Uri("http://cool-sat.com/catalog/datacube-123/item.json"), "self", null, null);
item.Links.Add(link);

var json2 = StacConvert.Serialize(item);

Console.WriteLine("Generated JSON : ");
Console.WriteLine(json2);

// ValidateJson(json2);

JsonAssert.AreEqual(originalJson, json2);
}

}
}
3 changes: 2 additions & 1 deletion src/DotNetStac.Test/Extensions/RasterExtensionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ namespace Stac.Test.Extensions
public class RasterExtensionTests : TestBase
{
[Fact]
public void Iris(){
public void Iris()
{
var json = GetJson("Extensions");

var item = StacConvert.Deserialize<IStacObject>(json);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
{
"stac_version": "1.0.0",
"stac_extensions": [
"https://stac-extensions.github.io/datacube/v2.1.0/schema.json"
],
"id": "datacube-123",
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-122.308150179,
37.488035566
],
[
-122.597502109,
37.538869539
],
[
-122.576687533,
37.613537207
],
[
-122.2880486,
37.562818007
],
[
-122.308150179,
37.488035566
]
]
]
},
"bbox": [
-122.597502109,
37.488035566,
-122.2880486,
37.613537207
],
"properties": {
"title": "Multi-dimensional data cube 123 in a STAC Item.",
"datetime": "2016-05-03T13:21:30.040Z",
"cube:dimensions": {
"x": {
"type": "spatial",
"axis": "x",
"extent": [
-122.59750209,
-122.2880486
],
"reference_system": 4326
},
"y": {
"type": "spatial",
"axis": "y",
"extent": [
37.48803556,
37.613537207
],
"reference_system": 4326
},
"pressure_levels": {
"type": "spatial",
"axis": "z",
"extent": [
0.0,
1000.0
],
"step": 100.0,
"unit": "Pa"
},
"metered_levels": {
"type": "spatial",
"axis": "z",
"values": [
0.0,
10.0,
25.0,
50.0,
100.0,
1000.0
],
"unit": "m"
},
"time": {
"type": "temporal",
"values": [
"2016-05-03T13:21:30.040Z"
]
},
"spectral": {
"type": "bands",
"values": [
"red",
"green",
"blue"
]
}
},
"cube:variables": {
"temp": {
"dimensions": [
"time",
"y",
"x",
"pressure_levels"
],
"type": "data"
},
"color": {
"dimensions": [],
"type": "auxiliary",
"values": [
"red",
"green",
"blue"
]
}
}
},
"assets": {
"data": {
"href": "http://cool-sat.com/catalog/datacube-123/data.nc",
"type": "application/netcdf",
"title": "netCDF Data cube"
},
"thumbnail": {
"href": "http://cool-sat.com/catalog/datacube-123/thumbnail.png",
"type": "image/png",
"title": "Thumbnail"
}
},
"links": [
{
"rel": "self",
"href": "http://cool-sat.com/catalog/datacube-123/item.json"
}
]
}
Loading

0 comments on commit a64c860

Please sign in to comment.