Oyster Harvest Area Closure Analysis 0.1
Prediction and analysis of NSW oyster harvest area closures.
Loading...
Searching...
No Matches
tide.h File Reference
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <curl/curl.h>
#include <cjson/cJSON.h>
#include <log.h>
#include "WillyWeather/authenticate.h"
#include "WillyWeather/location.h"
#include "WillyWeather/forecast.h"
#include "http.h"
#include "utils.h"
Include dependency graph for tide.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  WW_TideDataset_TypeDef
 Tide data from Willy Weather request. More...
 

Functions

CURLcode WillyWeather_GetTides (uint16_t location_id, const char *start_date, uint16_t n_days, WW_TideDataset_TypeDef *tides)
 Get the tides data from Willy Weather. More...
 
uint8_t WillyWeather_TidesToCSV (WW_Location_TypeDef *location_info, WW_TideDataset_TypeDef *dataset)
 Write tide dataset to csv files in specific directory. More...
 
WW_TideDataset_TypeDef WW_TidesFromCSV (const char *filename)
 Load tide dataset from cache (.csv or .txt) More...
 

Function Documentation

◆ WillyWeather_GetTides()

CURLcode WillyWeather_GetTides ( uint16_t  location_id,
const char *  start_date,
uint16_t  n_days,
WW_TideDataset_TypeDef tides 
)

Get the tides data from Willy Weather.

Get calculated high and low tides from Willy Weather.

Willy Weather provides tide data for coastal regions. These data consist of high and low tides (and timestamps) grouped by day. This function extracts relevent high, low and maximum daily tides and appends them to a tides struct (WW_TideDataset_TypeDef).

           ,-'''-.─────── High Tide (HT)
         ,-'   ▲   `-.
       ,'      │      `.
     ,'        │        `.
    /          │          \
   /           │           \

-—+---------—│---------—-----------------------— Tide Diff │ \ / │ \ / MAX(TD = HT - LT) │ ‘. ,’ │ ‘. ,’ │ ‘-. ,-’ ▼ Low Tide (LT) ───‘-,,,-’

const char *start_date = "2022-05-01";
WillyWeather_GetForecast(ww_token, 1215, WW_FORECAST_TIDE, start_date, 10);
#define WW_FORECAST_TIDE
Tides.
Definition: forecast.h:11
See also
https://www.willyweather.com.au/api/docs/v2.html#forecast-get-tides
Note
Requires valid access token. See authenticate.h for method to authenticate with Willy Weather.
Parameters
location_idLocation index provided by Willy Weather.
start_dateStart date (e.g. YYYY-MM-DD HH:MM:SS).
n_daysNumber of days from the start date (basically end date).
Returns
CURLcode result integer.

◆ WillyWeather_TidesToCSV()

uint8_t WillyWeather_TidesToCSV ( WW_Location_TypeDef location_info,
WW_TideDataset_TypeDef dataset 
)

Write tide dataset to csv files in specific directory.

Create output CSV files with tide data from a particular location.

Build tide directories and then for each of low, high and daily tide values build .csv files. Spaces in filenames are handled by this function and replaced with '-'.

Parameters
location_infoLocation struct for filename.
datasetDataset to write to .csv files.
Returns
Error code. OK = 0 ... ERROR = 1

◆ WW_TidesFromCSV()

WW_TideDataset_TypeDef WW_TidesFromCSV ( const char *  filename)

Load tide dataset from cache (.csv or .txt)

Build tide dataset from cache (.csv or .txt)

Requires the following format Unix;Date;Values

Parameters
filenameFilename (and path) of .csv or .txt file to open.
Returns
Tide dataset with values, timestamps and count