|
Oyster Harvest Area Closure Analysis 0.1
Prediction and analysis of NSW oyster harvest area closures.
|
#include "BOM/stations.h"Functions | |
| static int8_t | BOM_ParseStations (Utils_ReqData_TypeDef *stream, BOM_WeatherStations_TypeDef *stations) |
| Parse .txt file into a BOM_Stations struct. More... | |
| 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... | |
| 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.
| latitude | Latitude of interest. |
| longitude | Longitude of interest. |
| stations | List of stations to search through. |
| 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.
| stations | List of weather stations to popultate. |
| 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
| filename | Location of BOM weather stations .txt file. |
| stations | Stations object to populate. |
|
static |
Parse .txt file into a BOM_Stations struct.
Parse BOM weather station .txt file from FTP server.
This function saves the downloaded raw text stream from the BOM FTP server into a temporary file (under the tmp) directory. This then calls BOM_LoadStationsFromTxt() to populate the list of BOM weather stations.
| stream | Raw response from BOM FTP server download. |
| stations | Stations object to populate. |