Giter Site home page Giter Site logo

copernicusopencsharp's Introduction

CopernicusOpen CSharp

This repository contains the source code of nuget packet of Copernicus Satellite for .NET. http://copernicus.eu

Setup

Methods

/// <summary>
/// Method to get metadata of all resource or specific resource
/// </summary>
/// <param name="options">Enumerable of possible resources</param>
/// <param name="format">Enumerable of possible formats to get data</param>
/// <param name="id">id for get a specific product</param>
/// <returns></returns>
Task<string> GetDataAsync(Entites options = Entites.Products, Format format = Format.json, string id = null);
 /// <summary>
 /// Method to download and save the metadata into a file.
 /// </summary>
 /// <param name="path">Destination of downloaded file</param>
 /// <param name="options">Resource to download</param>
 /// <param name="id">Id of resource</param>
 /// <returns>Return true for success</returns>
Task<bool> 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:

using CopernicusOpenCSharp;

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

You can access the data information using this call:

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

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

/// <summary>
/// Method to return a .Net object from json string. AllData.
/// </summary>
/// <param name="json">MetaData returned from GetDataAsync.</param>
/// <returns>return the .net object for all data.</returns>
public static Query ExtractJson(this string json);

/// <summary>
/// Method to return a .Net object from json string. Specific data.
/// </summary>
/// <param name="json">MetaData returned from GetDataAsync</param>
/// <returns>return the .net object for all data.</returns>
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:

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.

using CopernicusOpenCSharp;

static Progress<double> MyProgress = new Progress<double>();
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);
}

copernicusopencsharp's People

Contributors

pictos avatar

Watchers

Ronny Witzgall avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.