Skip to content

Commit

Permalink
Merge branch 'release/0.8.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelmathot committed May 21, 2021
2 parents 32d123e + 15d7887 commit a0b7d7b
Show file tree
Hide file tree
Showing 24 changed files with 160 additions and 62 deletions.
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## [v0.8.1]

### Added

- Root fields accessor for Stac Item
- Extensible raster object

### Fixed

- gsd as double
- null value handling (e.g. proj:epsg)
- ObservationDirection as enum

### Changed

## [v0.8.0]

Stac 1.0.0-rc.4 compatible release
Expand Down Expand Up @@ -56,7 +71,8 @@ At the moment of this release, the STAC specification is 1.0.0-rc.4 and minor ch

- Cloned assets

[Unreleased]: <https://github.com/Terradue/DotnetStac/compare/0.8.0...HEAD>
[Unreleased]: <https://github.com/Terradue/DotnetStac/compare/0.8.1...HEAD>
[v0.8.0]: <https://github.com/Terradue/DotnetStac/tree/0.8.1>
[v0.8.0]: <https://github.com/Terradue/DotnetStac/tree/0.8.0>
[v0.7.0]: <https://github.com/Terradue/DotnetStac/tree/0.7.0>
[v0.6.2]: <https://github.com/Terradue/DotnetStac/tree/0.6.2>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"stac_extensions": [
"https://stac-extensions.github.io/eo/v1.0.0/schema.json",
"https://stac-extensions.github.io/sat/v1.0.0/schema.json",
"https://stac-extensions.github.io/projection/v1.0.0/schema.json",
"https://stac-extensions.github.io/sat/v1.0.0/schema.json",
"https://stac-extensions.github.io/view/v1.0.0/schema.json"
],
"stac_version": "1.0.0-rc.4",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"stac_extensions": [
"https://stac-extensions.github.io/eo/v1.0.0/schema.json",
"https://stac-extensions.github.io/sat/v1.0.0/schema.json",
"https://stac-extensions.github.io/processing/v1.0.0/schema.json",
"https://stac-extensions.github.io/projection/v1.0.0/schema.json",
"https://stac-extensions.github.io/view/v1.0.0/schema.json",
"https://stac-extensions.github.io/processing/v1.0.0/schema.json"
"https://stac-extensions.github.io/sat/v1.0.0/schema.json",
"https://stac-extensions.github.io/view/v1.0.0/schema.json"
],
"stac_version": "1.0.0-rc.4",
"links": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"stac_extensions": [
"https://stac-extensions.github.io/eo/v1.0.0/schema.json",
"https://stac-extensions.github.io/sat/v1.0.0/schema.json",
"https://stac-extensions.github.io/projection/v1.0.0/schema.json",
"https://stac-extensions.github.io/view/v1.0.0/schema.json"
],
"stac_version": "1.0.0-rc.4",
Expand Down Expand Up @@ -181,8 +180,6 @@
"description": "dummy",
"eo:cloud_cover": 0.0,
"sat:absolute_orbit": 28267,
"proj:epsg": 32638,
"proj:wkt2": "PROJCS[\"WGS 84 / UTM zone 38N\", GEOGCS[\"WGS 84\", DATUM[\"World Geodetic System 1984\", SPHEROID[\"WGS 84\", 6378137, 298.257223563, AUTHORITY[\"EPSG\", \"7030\"]], AUTHORITY[\"EPSG\", \"6326\"]], PRIMEM[\"Greenwich\", 0, AUTHORITY[\"EPSG\", \"8901\"]], UNIT[\"degree\", 0.017453292519943295, AUTHORITY[\"EPSG\", \"9102\"]], AUTHORITY[\"EPSG\", \"4326\"]], UNIT[\"metre\", 1, AUTHORITY[\"EPSG\", \"9001\"]], PROJECTION[\"UTM38N\", AUTHORITY[\"EPSG\", \"32638\"]], PARAMETER[\"latitude_of_origin\", 0], PARAMETER[\"central_meridian\", 45], PARAMETER[\"scale_factor\", 0.9996], PARAMETER[\"false_easting\", 500000], PARAMETER[\"false_northing\", 0], AUTHORITY[\"EPSG\", \"32638\"], AXIS[\"East\", EAST], AXIS[\"North\", NORTH]]",
"view:off_nadir": 0.0,
"view:incidence_angle": 2.140217373,
"view:azimuth": 82.308110583,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"stac_extensions": [
"https://stac-extensions.github.io/eo/v1.0.0/schema.json",
"https://stac-extensions.github.io/sat/v1.0.0/schema.json",
"https://stac-extensions.github.io/projection/v1.0.0/schema.json",
"https://stac-extensions.github.io/sat/v1.0.0/schema.json",
"https://stac-extensions.github.io/view/v1.0.0/schema.json"
],
"stac_version": "1.0.0-rc.4",
Expand Down Expand Up @@ -181,7 +181,7 @@
"description": "dummy",
"eo:cloud_cover": 0.0,
"sat:absolute_orbit": 28267,
"proj:epsg": 32638,
"proj:epsg": null,
"proj:wkt2": "GEOCCS[\"WGS84 Geocentric\", DATUM[\"World Geodetic System 1984\", SPHEROID[\"WGS 84\", 6378137, 298.257223563, AUTHORITY[\"EPSG\", \"7030\"]], AUTHORITY[\"EPSG\", \"6326\"]], PRIMEM[\"Greenwich\", 0, AUTHORITY[\"EPSG\", \"8901\"]], UNIT[\"metre\", 1, AUTHORITY[\"EPSG\", \"9001\"]], AXIS[\"X\", OTHER], AXIS[\"Y\", OTHER], AXIS[\"Z\", OTHER]]",
"view:off_nadir": 0.0,
"view:incidence_angle": 2.140217373,
Expand Down
1 change: 1 addition & 0 deletions src/DotNetStac/Common/Statistics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace Stac.Common
/// <summary>
/// Statistics Object
/// </summary>
[JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)]
public class Statistics
{
private IDictionary<string, object> properties;
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>0.8.0</VersionPrefix>
<VersionPrefix>0.8.1</VersionPrefix>
<!-- <VersionSuffix>alpha</VersionSuffix> -->
<Authors>Emmanuel Mathot</Authors>
<Authors>emmanuelmathot</Authors>
Expand Down
17 changes: 1 addition & 16 deletions src/DotNetStac/Extensions/Eo/EoBandCommonName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,21 @@ namespace Stac.Extensions.Eo
/// </summary>
public enum EoBandCommonName
{
unknow,
coastal,
blue,
green,
red,
yellow,
pan,
rededge,
rededge70,
rededge74,
rededge76,
rededge78,
nir,
nir08,
nir09,
swir12,
cirrus,
swir16,
swir155,
swir165,
swir173,
swir22,
swir215,
swir220,
swir225,
swir23,
swir37,
lwir,
lwir11,
lwir12,
alpha
lwir12
}
}
11 changes: 10 additions & 1 deletion src/DotNetStac/Extensions/Eo/EoStacExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,16 @@ public double CloudCover
public EoBandObject[] Bands
{
get { return StacPropertiesContainer.GetProperty<EoBandObject[]>(BandsField); }
set { StacPropertiesContainer.SetProperty(BandsField, value); DeclareStacExtension(); }
set
{
if (value == null || value.Count() == 0)
StacPropertiesContainer.RemoveProperty(BandsField);
else
{
StacPropertiesContainer.SetProperty(BandsField, value);
DeclareStacExtension();
}
}
}

/// <summary>
Expand Down
8 changes: 4 additions & 4 deletions src/DotNetStac/Extensions/File/FileStacExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,19 @@ public Multiformats.Hash.Multihash Checksum
/// The name of the facility that produced the data.
/// </summary>
/// <value></value>
public uint HeaderSize
public uint? HeaderSize
{
get { return StacPropertiesContainer.GetProperty<uint>(HeaderSizeField); }
get { return StacPropertiesContainer.GetProperty<uint?>(HeaderSizeField); }
set { StacPropertiesContainer.SetProperty(HeaderSizeField, value); DeclareStacExtension(); }
}

/// <summary>
/// The name of the facility that produced the data.
/// </summary>
/// <value></value>
public ulong Size
public ulong? Size
{
get { return StacPropertiesContainer.GetProperty<ulong>(SizeField); }
get { return StacPropertiesContainer.GetProperty<ulong?>(SizeField); }
set { StacPropertiesContainer.SetProperty(SizeField, value); DeclareStacExtension(); }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public void SetCoordinateSystem(CoordinateSystem coordinateSystem)
{
if (coordinateSystem.AuthorityCode > 0)
Epsg = coordinateSystem.AuthorityCode;
else
Epsg = null;
Wkt2 = coordinateSystem.WKT;
}

Expand Down
12 changes: 7 additions & 5 deletions src/DotNetStac/Extensions/Raster/RasterBandObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ namespace Stac.Extensions.Raster
/// of the Raster extension
/// </summary>
[JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)]
public class RasterBand
public class RasterBand : IStacPropertiesContainer
{

IDictionary<string, object> properties;
private double? nodata;
private RasterSampling sampling;
private DataType dataType;
private RasterSampling? sampling;
private DataType? dataType;
private string unit;
private double? scale;
private double? offset;
Expand All @@ -41,15 +41,15 @@ public RasterBand()
/// </summary>
[JsonProperty("sampling")]
[JsonConverter(typeof(StringEnumConverter))]
public RasterSampling Sampling { get => sampling; set => sampling = value; }
public RasterSampling? Sampling { get => sampling; set => sampling = value; }

/// <summary>
/// The data type of the band.
/// </summary>
/// <value></value>
[JsonProperty("data_type")]
[JsonConverter(typeof(StringEnumConverter))]
public DataType DataType { get => dataType; set => dataType = value; }
public DataType? DataType { get => dataType; set => dataType = value; }

/// <summary>
/// The actual number of bits used for this band.
Expand Down Expand Up @@ -104,5 +104,7 @@ public RasterBand()
[JsonExtensionData]
public IDictionary<string, object> Properties { get => properties; set => properties = value; }

[JsonIgnore]
public IStacObject StacObjectContainer => null;
}
}
1 change: 1 addition & 0 deletions src/DotNetStac/Extensions/Raster/RasterHistogram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Stac.Extensions.Raster
/// <summary>
/// The histogram object provides with distribution of pixel values in the band. Those values are sampled in buckets.
/// </summary>
[JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)]
public class RasterHistogram
{
/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/DotNetStac/Extensions/Raster/RasterStacExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static class RasterStacExtensionExtensions
/// <summary>
/// Initilize a EoStacExtension class from a STAC asset
/// </summary>
public static RasterStacExtension RasterStacExtension(this StacAsset stacAsset)
public static RasterStacExtension RasterExtension(this StacAsset stacAsset)
{
return new RasterStacExtension(stacAsset);
}
Expand Down
21 changes: 21 additions & 0 deletions src/DotNetStac/Extensions/Sar/ObservationDirection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Stac.Extensions.Sar
{
/// <summary>
/// Antenna obervation direction
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public enum ObservationDirection
{
/// left
[EnumMember(Value = "left")]
Left,

/// right
[EnumMember(Value = "right")]
Right
}
}
4 changes: 2 additions & 2 deletions src/DotNetStac/Extensions/Sar/SarStacExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ public double LooksEquivalentNumber
set { StacPropertiesContainer.SetProperty(LooksEquivalentNumberField, value); DeclareStacExtension(); }
}

public string ObservationDirection
public ObservationDirection? ObservationDirection
{
get { return StacPropertiesContainer.GetProperty<string>(ObservationDirectionField); }
get { return StacPropertiesContainer.GetProperty<ObservationDirection?>(ObservationDirectionField); }
set { StacPropertiesContainer.SetProperty(ObservationDirectionField, value); DeclareStacExtension(); }
}

Expand Down
10 changes: 10 additions & 0 deletions src/DotNetStac/StacAccessorsHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ public static T GetProperty<T>(this IDictionary<string, object> properties, stri
return (T)Convert.ChangeType(@object, typeof(T));
}

public static void RemoveProperty(this IStacPropertiesContainer propertiesContainer, string key)
{
propertiesContainer.Properties.RemoveProperty(key);
}

public static void RemoveProperty(this IDictionary<string, object> properties, string key)
{
properties.Remove(key);
}

public static IEnumerable<StacLink> GetChildrenLinks(this IStacParent stacCatalog)
{
return stacCatalog.Links.Where(l => l.RelationshipType == "child");
Expand Down
11 changes: 9 additions & 2 deletions src/DotNetStac/StacAsset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Stac.Converters;
using Newtonsoft.Json;
using System.Net.Mime;
using System.Runtime.Serialization;

namespace Stac
{
Expand Down Expand Up @@ -85,7 +86,7 @@ public static StacAsset CreateMetadataAsset(IStacObject stacObject, Uri uri, Con
internal StacAsset()
{
properties = new Dictionary<string, object>();
Roles = new Collection<string>();
Roles = new SortedSet<string>();
}

/// <summary>
Expand Down Expand Up @@ -157,7 +158,7 @@ public ContentType MediaType
/// </summary>
/// <value></value>
[JsonProperty("roles")]
public Collection<string> Roles
public ICollection<string> Roles
{
get;
private set;
Expand Down Expand Up @@ -236,5 +237,11 @@ public bool ShouldSerializeStacExtensions()
// don't serialize the Manager property if an employee is their own manager
return Roles.Count > 0;
}

[OnDeserialized]
internal void OnDeserializedMethod(StreamingContext context)
{
Roles = new SortedSet<string>(Roles);
}
}
}
3 changes: 2 additions & 1 deletion src/DotNetStac/StacCatalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public StacCatalog(string id, string description, IEnumerable<StacLink> links =
this.Links = new Collection<StacLink>(links.ToList());
this.Properties = new Dictionary<string, object>();
this.Summaries = new Dictionary<string, Stac.Collection.IStacSummaryItem>();
this.StacExtensions = new Collection<string>();
this.StacExtensions = new SortedSet<string>();
}

# region IStacObject
Expand Down Expand Up @@ -133,6 +133,7 @@ internal void OnDeserializedMethod(StreamingContext context)
{
link.Parent = this;
}
StacExtensions = new SortedSet<string>(StacExtensions);
}

public bool ShouldSerializeSummaries()
Expand Down
4 changes: 2 additions & 2 deletions src/DotNetStac/StacCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ namespace Stac
/// <summary>
/// STAC Collection Object implementing STAC Collection spec (https://github.com/radiantearth/stac-spec/blob/master/collection-spec/collection-spec.md)
/// </summary>
[JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)]
public class StacCollection : IStacObject, IStacParent, IStacCatalog
{
public const string MEDIATYPE = "application/json";
Expand Down Expand Up @@ -43,7 +42,7 @@ public StacCollection(string id,
else
this.Assets = new Dictionary<string, StacAsset>(assets);
this.Summaries = new Dictionary<string, Stac.Collection.IStacSummaryItem>();
this.StacExtensions = new Collection<string>();
this.StacExtensions = new SortedSet<string>();
this.Providers = new Collection<StacProvider>();
this.License = license;
this.Keywords = new Collection<string>();
Expand Down Expand Up @@ -167,6 +166,7 @@ internal void OnDeserializedMethod(StreamingContext context)
{
link.Parent = this;
}
StacExtensions = new SortedSet<string>(StacExtensions);
}

#pragma warning disable 1591
Expand Down
Loading

0 comments on commit a0b7d7b

Please sign in to comment.