Skip to content

Commit

Permalink
StacLink clone
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelmathot committed Oct 31, 2023
1 parent 0a29ee6 commit aaace21
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 13 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.7.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.7.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
8 changes: 4 additions & 4 deletions docs/docfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"src": ".."
}
],
"dest": "api",
"dest": "lib",
"disableGitFeatures": false,
"disableDefaultFilter": false
}
Expand All @@ -21,8 +21,8 @@
"content": [
{
"files": [
"api/**.yml",
"api/index.md"
"lib/**.yml",
"lib/index.md"
]
},
{
Expand All @@ -44,7 +44,7 @@
"overwrite": [
{
"files": [
"apidoc/**.md"
"libdoc/**.md"
],
"exclude": [
"obj/**",
Expand Down
8 changes: 4 additions & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ In a nutshell, the library allows serialization/desrialization of STAC JSON docu

## Reference API

Looking for the reference API docs, go directly to [https://terradue.github.io/DotNetStac/api/].
Looking for the reference API docs, go directly to [https://terradue.github.io/DotNetStac/lib/].

## Getting Started

Expand All @@ -33,7 +33,7 @@ dotnet add package DotNetStac

### Deserialization of STAC documents

The (de)serialiation methods are wrapped in methods in [class `StacConvert`](https://terradue.github.io/DotNetStac/api/Stac.StacConvert.html) that is the main entry point from/to JSON/.Net.
The (de)serialiation methods are wrapped in methods in [class `StacConvert`](https://terradue.github.io/DotNetStac/lib/Stac.StacConvert.html) that is the main entry point from/to JSON/.Net.

Let's start reading a STAC catalog online. Please note that DotNetStac does not provide with data access middleware. You can integrate own data access or you can test the [`Stars` SDK](https://github.com/Terradue/Stars) that provides with integrated functions to manipulate STAC objects and their storage.

Expand Down Expand Up @@ -63,7 +63,7 @@ Please note the following:

* `GetChildrenLinks` and `GetItemLinks` are the recommanded ways to get the links for navigating through the tree.
* The previous functions as the rest of the library does not alter the `Uri`s. It is then up to the developer to resolve the relative ones. As in the code, Uri class provides with all the necessary methods to easily join a base Url with a relative one.
* The `StacConvert.Deserialize<>` methods allows to specify the interfaces to ease the deserialization when the STAC type is unknown: [`IStacObject`](https://terradue.github.io/DotNetStac/api/Stac.IStacObject.html) and [`IStacCatalog`](https://terradue.github.io/DotNetStac/api/Stac.IStacCatalog.html).
* The `StacConvert.Deserialize<>` methods allows to specify the interfaces to ease the deserialization when the STAC type is unknown: [`IStacObject`](https://terradue.github.io/DotNetStac/lib/Stac.IStacObject.html) and [`IStacCatalog`](https://terradue.github.io/DotNetStac/lib/Stac.IStacCatalog.html).

```csharp
using System.Linq;
Expand Down Expand Up @@ -281,7 +281,7 @@ using System.Collections.Generic;

#### Collection generation from a set of Items

[`StacCollection` class](https://terradue.github.io/DotNetStac/api/Stac.StacCollection.html) has static methods allowing the automatic generation of a collection from a set of `StacItem`. The following code loads the items of [the examples folder from STAC repository](https://github.com/radiantearth/stac-spec/tree/master/examples) and generates the corresponding collection with
[`StacCollection` class](https://terradue.github.io/DotNetStac/lib/Stac.StacCollection.html) has static methods allowing the automatic generation of a collection from a set of `StacItem`. The following code loads the items of [the examples folder from STAC repository](https://github.com/radiantearth/stac-spec/tree/master/examples) and generates the corresponding collection with
- **Spatial and temporal extent** from geometry and time merge of the items
- **Fields summaries** with stats objects or value sets of the items' fields values

Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions docs/toc.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- name: Articles
href: articles/
- name: Api Documentation
href: api/
homepage: api/index.md
- name: Library Documentation
href: lib/
homepage: lib/index.md
93 changes: 93 additions & 0 deletions src/DotNetStac.Test/Common/StacAccessorsHelpersTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
// File Name: StacAccessorsHelpersTests.cs

using System.Collections.Generic;
using System.Runtime.Serialization;
using GeoJSON.Net.Geometry;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Stac.Collection;
using Stac.Common;
using Xunit;
Expand Down Expand Up @@ -88,5 +91,95 @@ public void LazyEnumParseTests()

Assert.Equal(test3, StacAccessorsHelpers.LazyEnumParse(typeof(Enum3), "Cql2Json"));
}

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

item.SetProperty("disaster:type", DisasterType.Volcano);

var itemJson = StacConvert.Serialize(item);

item = StacConvert.Deserialize<StacItem>(itemJson);

Assert.Equal("volcano", item.GetProperty<string>("disaster:type"));
}

[JsonConverter(typeof(StringEnumConverter))]
public enum DisasterType
{

[EnumMember(Value = "earthquake")]
Earthquake,

[EnumMember(Value = "fire")]
Fire,

[EnumMember(Value = "flood")]
Flood,

[EnumMember(Value = "flood_large")]
[System.Obsolete("Use Flood instead")]
FloodLarge,

[EnumMember(Value = "flood_flash")]
[System.Obsolete("Use Flood instead")]
FloodFlash,

[EnumMember(Value = "ice")]
Ice,

[EnumMember(Value = "landslide")]
Landslide,

[EnumMember(Value = "storm_hurricane")]
StormHurricane,

[EnumMember(Value = "storm_hurricane_rural")]
[System.Obsolete("Use StormHurricane instead")]
StormHurricaneRural,

[EnumMember(Value = "storm_hurricane_urban")]
[System.Obsolete("Use StormHurricane instead")]
StormHurricaneUrban,

[EnumMember(Value = "tsunami")]
Tsunami,

[EnumMember(Value = "oil_spill")]
OilSpill,

[EnumMember(Value = "volcano")]
Volcano,

/// <remarks/>
[EnumMember(Value = "snow_hazard")]
SnowHazard,

[EnumMember(Value = "explosive_event")]
ExplosiveEvent,

/// <remarks/>
Other,
}
}
}
1 change: 1 addition & 0 deletions src/DotNetStac/StacLink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public StacLink(StacLink source)
this.ContentType = source.ContentType;
this.Parent = source.Parent;
this.Length = source.Length;
this.AdditionalProperties = source.AdditionalProperties;
}

/// <summary>
Expand Down

0 comments on commit aaace21

Please sign in to comment.