Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/pictos/copernicusopencsharp


https://github.com/pictos/copernicusopencsharp

copernicus satellite

Last synced: 24 days ago
JSON representation

Awesome Lists containing this project

README

        

# CopernicusOpen CSharp

This repository contains the source code of nuget packet of Copernicus Satellite for .NET.

## Setup

- Available on NuGet:
- Install into your core project.

### Methods

```csharp
///
/// Method to get metadata of all resource or specific resource
///
/// Enumerable of possible resources
/// Enumerable of possible formats to get data
/// id for get a specific product
///
Task GetDataAsync(Entites options = Entites.Products, Format format = Format.json, string id = null);
///
/// Method to download and save the metadata into a file.
///
/// Destination of downloaded file
/// Resource to download
/// Id of resource
/// Return true for success
Task DownloadData(string path, string id = null, Entites options = Entites.Products);
```

### API Usage

To gain access to the resources from Copernicus simply create an instance from service, like this:

```csharp
using CopernicusOpenCSharp;

CopernicusService service = new CopernicusService("userName", "password");
```

- You can get the userName and password follow this steps

You can access the data information using this call:

```csharp
string id = "'fea3cd38-918d-4974-8586-2578cbb07844'";
var test = await service.GetDataAsync(id: id);
```

If the 'id = null' the Service return all data from selected Entites.

## Extention Methods

```csharp
///
/// Method to save MetaData in external file.
///
/// MetaData
/// Destination where you save the file
/// Specifies how the operating system
/// True if success, False if is not
public static bool SaveData(this string data,string path, FileMode fileMode = FileMode.Create);

///
/// Method to return a .Net object from json string. AllData.
///
/// MetaData returned from GetDataAsync.
/// return the .net object for all data.
public static Query ExtractJson(this string json);

///
/// Method to return a .Net object from json string. Specific data.
///
/// MetaData returned from GetDataAsync
/// return the .net object for all data.
public static QueryId ExtractJsonId(this string json);
```

With this extentions methods you can be more productive.

For ex. to get a Model Class for data with ID, you can do:

```csharp
using CopernicusOpenCSharp.Extensions;

var teste = await service.GetDataAsync(id: id);
var test2 = teste.ExtractJsonId();
```

## Download File

You can download the MetaData and expose the the percentage progress. Using the ProgressChanged event to do this.

```csharp
using CopernicusOpenCSharp;

static Progress MyProgress = new Progress();
static double old = 0;

public static async Task Teste()
{
MyProgress.ProgressChanged += (sender, value) =>
{
value = Math.Round(value, 2);

if (value != old)
{
Console.WriteLine($"{value} %");
}

old = value;
};
CopernicusService service = new CopernicusService("userName", "password");
string id = "'fea3cd38-918d-4974-8586-2578cbb07844'";

var download = await service.DownloadMetaDataAsync(@"C:\Users\Teste\Desktop\", MyProgress, id: id);
}
```