Oyster Harvest Area Closure Analysis 0.1
Prediction and analysis of NSW oyster harvest area closures.
Loading...
Searching...
No Matches
precipitation.h File Reference
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <libpq-fe.h>
#include "http.h"
#include "WillyWeather/forecast.h"
#include "WillyWeather/location.h"
#include "utils.h"
Include dependency graph for precipitation.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  WW_Rainfall_TypeDef
 Rainfall forecast for a day. More...
 
struct  WW_RainfallForecast_TypeDef
 Holds daily forecast rainfall information from Willy Weather. More...
 

Macros

#define WW_RANGE_CODE_SIZE   6
 Willy Weather range code (e.g. 0-15 or 5-10 or <0) max size. More...
 
#define WW_MAX_DAILY_RAINFALL_RESULTS   9
 Max number of daily rainfall forecast results from Willy Weather. More...
 
#define WW_MAX_TS_SIZE   30
 Max timestamp size. More...
 

Functions

CURLcode WillyWeather_GetRainfallForecast (WW_Location_TypeDef *location, WW_RainfallForecast_TypeDef *daily_rainfall)
 Gets the rainfall forecast (next 7 days inc today) for a location. More...
 
void WillyWeather_RainfallToDB (WW_Location_TypeDef *location, WW_RainfallForecast_TypeDef *forecast, PGconn *psql_conn)
 Rainfall to PostgreSQL table method. More...
 

Macro Definition Documentation

◆ WW_MAX_DAILY_RAINFALL_RESULTS

#define WW_MAX_DAILY_RAINFALL_RESULTS   9

Max number of daily rainfall forecast results from Willy Weather.

◆ WW_MAX_TS_SIZE

#define WW_MAX_TS_SIZE   30

Max timestamp size.

◆ WW_RANGE_CODE_SIZE

#define WW_RANGE_CODE_SIZE   6

Willy Weather range code (e.g. 0-15 or 5-10 or <0) max size.

Function Documentation

◆ WillyWeather_GetRainfallForecast()

CURLcode WillyWeather_GetRainfallForecast ( WW_Location_TypeDef location,
WW_RainfallForecast_TypeDef rainfall_forecast 
)

Gets the rainfall forecast (next 7 days inc today) for a location.

Get forecast precipitation data from Willy Weather.

Willy Weather provides forecast rainfall probability and amount as a range e.g. 10-15 mm 90 %. These data are provided for the past 2 days, the current day and the next 6 days (9 days in total). A location needs to be provided along with a daily rainfall struct to hold the responses.

// Get location by name
const char* search_location = "Batemans";
WW_Location_TypeDef location_info = {0};
WillyWeather_GetLocationByName(search_location, &location_info);
// Get rainfall for a location
WW_RainfallForecast_TypeDef rainfall_forecast = {0};
WillyWeather_GetRainfallForecast(&location_info, &rainfall_forecast);
CURLcode WillyWeather_GetLocationByName(char *name, WW_Location_TypeDef *location_info)
Get an ID describing a location from Willy Weather.
Definition: location.c:26
CURLcode WillyWeather_GetRainfallForecast(WW_Location_TypeDef *location, WW_RainfallForecast_TypeDef *rainfall_forecast)
Gets the rainfall forecast (next 7 days inc today) for a location.
Definition: precipitation.c:28
Location data from Willy Weather request.
Definition: location.h:24
Holds daily forecast rainfall information from Willy Weather.
Definition: precipitation.h:38
See also
https://www.willyweather.com.au/api/docs/v2.html#forecast-get-rainfall
Parameters
locationLocation struct (see location.h).
daily_rainfallDaily rainfall forecast struct to hold responses.
Returns
Curl code representing HTTP errors that may have occured.

◆ WillyWeather_RainfallToDB()

void WillyWeather_RainfallToDB ( WW_Location_TypeDef location,
WW_RainfallForecast_TypeDef forecast,
PGconn *  psql_conn 
)

Rainfall to PostgreSQL table method.

Write Willy Weather forecast for a particular location to PostgreSQL table.

The target table is called weather_ww.

Parameters
locationLocation information for Willy Weather dataset.
forecastWilly Weather weather forecast.
psql_connPostgreSQL connection handler.