17#include <gdal/ogr_core.h>
22#define BASEURL "https://cds.climate.copernicus.eu/api"
72size_t writeString(
char *ptr,
size_t size,
size_t nmemb,
void *userdata);
85size_t discardWrite(
char *ptr,
size_t size,
size_t nmemb,
void *userdata);
135 const size_t yearsElements,
const size_t monthsElements,
const size_t daysElements,
136 const size_t hoursElements,
const OGREnvelope *aoi);
163char *slurpAndGetString(
const char *input,
const char *key);
187 const char *outputPath,
const int *subsetYears,
const int *subsetMonths,
const int *subsetDays,
188 const int *subsetHours,
const size_t yearsElements,
const size_t monthsElements,
189 const size_t daysElements,
const size_t hoursElements,
const unsigned int maxAttempts);
214 const int *hours,
const size_t yearsElements,
const size_t monthsElements,
215 const size_t daysElements,
const size_t hoursElements,
const OGREnvelope *aoi,
252 unsigned int maxAttempts);
266 const char *outputPath,
const option_t
size_t discardWrite(char *ptr, size_t size, size_t nmemb, void *userdata)
Discard delivered data from API request.
int cdsWaitForProduct(CURL *handle, const char *requestId, const option_t *options, unsigned int maxAttempts)
Wait for a product request to be downloadable with a binary exponential backoff.
productStatus cdsGetProductStatus(CURL *handle, const char *requestId, const option_t *options)
Query the CDS API for the status of a previously created product request.
char * cdsRequestProduct(CURL *handle, const int *years, const int *months, const int *days, const int *hours, const size_t yearsElements, const size_t monthsElements, const size_t daysElements, const size_t hoursElements, const OGREnvelope *aoi, const option_t *options)
Perform product request with CDS API.
int download(CURL *handle, const option_t *options, const OGREnvelope *aoi)
Perform product request and download of ERA-5 products.
int cdsDownloadProduct(CURL *handle, const char *requestId, const char *outputPath, const option_t *options)
Download data related to previously made request to local file.
int binaryExponentialBackoff(int attempt)
Compute binary exponential backoff.
int handleDownloadChain(CURL *handle, const option_t *options, const OGREnvelope *aoi, const char *outputPath, const int *subsetYears, const int *subsetMonths, const int *subsetDays, const int *subsetHours, const size_t yearsElements, const size_t monthsElements, const size_t daysElements, const size_t hoursElements, const unsigned int maxAttempts)
Wrapper around chain of API requests needed to perform a download.
CURL * newHandleWithOptions(struct curl_slist **list, const option_t *options)
Create a new cURL handle and initialize it.
json_t * jsonArrayFromIntegers(const int *arr, size_t elements, const char *formatString)
Convert an array of integers to their string representations with customizable formats.
int cdsDeleteProductRequest(CURL *handle, const char *requestId, const option_t *options)
Delete a prodcut request from personal CDS space.
int initializeHandle(CURL **handle, const struct curl_slist *headerList)
Initialize cURL handle in place.
json_t * getKeyRecursively(json_t *root, const char *key)
Search JSON object recursively for a key with DFS and return first occurence.
size_t writeString(char *ptr, size_t size, size_t nmemb, void *userdata)
Concatenate chunked response from API request into string.
struct curl_slist * customHeader(struct curl_slist *list, const option_t *options)
Create a new header list for cURL with CDS API token field.
char * constructStringRequest(const int *years, const int *months, const int *days, const int *hours, const size_t yearsElements, const size_t monthsElements, const size_t daysElements, const size_t hoursElements, const OGREnvelope *aoi)
Construct a JSON object for CDS API product request.