Oyster Harvest Area Closure Analysis 0.1
Prediction and analysis of NSW oyster harvest area closures.
Loading...
Searching...
No Matches
stations.h File Reference
#include <math.h>
#include <ctype.h>
#include "ftp.h"
#include "utils.h"
Include dependency graph for stations.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  BOM_WeatherStation_TypeDef
 BOM weather station (id, state, name, latitude, longitude) More...
 
struct  BOM_WeatherStations_TypeDef
 BOM weather stations list and count. More...
 

Macros

#define BOM_STATION_MAX_RESPONSES   500
 Max number of BOM sites to hold. More...
 
#define BOM_STATION_ID_SIZE   7
 BOM site id size (length) More...
 
#define BOM_STATION_STATE_SIZE   4
 BOM state identifier size (length) More...
 
#define BOM_STATION_NAME_SIZE   150
 BOM site name size (length) More...
 
#define BOM_STATION_FILENAME_SIZE   150
 BOM filename max size. More...
 
#define BOM_FTP_STATIONS_URL   "ftp://ftp.bom.gov.au/anon/gen/clim_data/IDCKWCDEA0/tables/stations_db.txt"
 Static location of BOM sites .txt file on BOM FTP server. More...
 

Functions

CURLcode BOM_GetWeatherStations (BOM_WeatherStations_TypeDef *stations)
 Get a list of NSW BOM weather stations. More...
 
int8_t BOM_LoadStationsFromTxt (const char *filename, BOM_WeatherStations_TypeDef *stations)
 Load BOM station list from cached .txt file (obtained from BOM FTP server) More...
 
int16_t BOM_ClosestStationIndex (double latitude, double longitude, BOM_WeatherStations_TypeDef *stations)
 Index of the closest BOM station to a define latitude and longitude. More...
 

Macro Definition Documentation

◆ BOM_FTP_STATIONS_URL

#define BOM_FTP_STATIONS_URL   "ftp://ftp.bom.gov.au/anon/gen/clim_data/IDCKWCDEA0/tables/stations_db.txt"

Static location of BOM sites .txt file on BOM FTP server.

◆ BOM_STATION_FILENAME_SIZE

#define BOM_STATION_FILENAME_SIZE   150

BOM filename max size.

◆ BOM_STATION_ID_SIZE

#define BOM_STATION_ID_SIZE   7

BOM site id size (length)

◆ BOM_STATION_MAX_RESPONSES

#define BOM_STATION_MAX_RESPONSES   500

Max number of BOM sites to hold.

◆ BOM_STATION_NAME_SIZE

#define BOM_STATION_NAME_SIZE   150

BOM site name size (length)

◆ BOM_STATION_STATE_SIZE

#define BOM_STATION_STATE_SIZE   4

BOM state identifier size (length)

Function Documentation

◆ BOM_ClosestStationIndex()

int16_t BOM_ClosestStationIndex ( double  latitude,
double  longitude,
BOM_WeatherStations_TypeDef stations 
)

Index of the closest BOM station to a define latitude and longitude.

Gets an index to the closest BOM weather station in reference to a provided latitude and longitude.

Parameters
latitudeLatitude of interest.
longitudeLongitude of interest.
stationsList of stations to search through.
Returns
Index of closest BOM station to provided lat and long.

◆ BOM_GetWeatherStations()

CURLcode BOM_GetWeatherStations ( BOM_WeatherStations_TypeDef stations)

Get a list of NSW BOM weather stations.

Get a list of NSW BOM weather station.

The BOM provides a list of weather stations as a .txt file on their FTP server. This function extracts the NSW locations and appends them to a list of stations within BOM_WeatherStations_TypeDef.

Parameters
stationsList of weather stations to popultate.
Returns
Curl error code.

◆ BOM_LoadStationsFromTxt()

int8_t BOM_LoadStationsFromTxt ( const char *  filename,
BOM_WeatherStations_TypeDef stations 
)

Load BOM station list from cached .txt file (obtained from BOM FTP server)

Reads a .txt from file to parse out a list of weather station.

A .txt file is loaded from a temporary directory. fgets() is used to parse the file line by line into a buffer. The buffer is scanned using sscanf() to extract each relevent weather station. Only NSW weather stations are used to populate a list of stations (provided). Weather stations that contain "AWS" have this string removed in their filename. This filename should correspond to the location in BOM's FTP server where historical data is found. E.g. .../filename/filename-date.csv or .../moyura_airport/moyura_airport-202206.csv

Parameters
filenameLocation of BOM weather stations .txt file.
stationsStations object to populate.
Returns
Error status code.