|
Oyster Harvest Area Closure Analysis 0.1
Prediction and analysis of NSW oyster harvest area closures.
|
#include "FoodAuthority/harvest_areas.h"Functions | |
| static int8_t | FA_ParseListResponse (char *data, FA_HarvestAreas_TypeDef *harvest_areas) |
| CURLcode | FA_GetHarvestAreas (FA_HarvestAreas_TypeDef *harvest_areas) |
| Get a list of oyster harvest areas in NSW Australia. More... | |
| int8_t | FA_HarvestAreasToCSV (FA_HarvestAreas_TypeDef *harvest_areas) |
| Push harvest areas list into a .csv file. More... | |
| void | FA_HarvestAreasToDB (FA_HarvestAreas_TypeDef *harvest_areas, PGconn *psql_conn) |
| Push harvest area statuses to DB. More... | |
| void | FA_CreateLocationsLookupDB (PGconn *psql_conn) |
| Create unique harvest area locations lookup table in DB. More... | |
| void | FA_UniqueLocationsFromDB (T_LocationsLookup_TypeDef *locations, PGconn *psql_conn) |
| Get Unique harvest area locations from DB. More... | |
| void FA_CreateLocationsLookupDB | ( | PGconn * | psql_conn | ) |
Create unique harvest area locations lookup table in DB.
Build a harvest area / locations lookup table in PostgreSQL database.
To make it easier to query datasources a lookup table is created using this function that matches a program name to the closest BOM weather station, Willy Weather location and other relevant information.
| psql_conn | PostgreSQL connection handler. |
| CURLcode FA_GetHarvestAreas | ( | FA_HarvestAreas_TypeDef * | harvest_areas | ) |
Get a list of oyster harvest areas in NSW Australia.
Request list of harvest areas (and status) from NSW Food Authority.
End product of this function is a list of harvest areas with their status (open, closed etc.).
| harvest_areas | List of harvest areas to populate. |
| int8_t FA_HarvestAreasToCSV | ( | FA_HarvestAreas_TypeDef * | harvest_areas | ) |
Push harvest areas list into a .csv file.
| void FA_HarvestAreasToDB | ( | FA_HarvestAreas_TypeDef * | harvest_areas, |
| PGconn * | psql_conn | ||
| ) |
Push harvest area statuses to DB.
Takes a list of harvest area statuses and passess them into a PSQL table.
The current time is taken to reference all values against. Ideally when querying these data the program should sort by the "time_processed" and this will provide a historical look at harvest area status at a particular site.
| harvest_areas | Basically a list of harvest areas. |
| psql_conn | A connection handler for PostrgreSQL. |
|
static |
Takes a raw text XML input of all harvest areas across NSW from NSW Food Authority and converts the text into a list of harvest area objects.
NSW Food Authority provides data regarding harvest area status as a raw XML endpoint. First the string "-row" is identified as this divides the raw text into each individual harvest areas. Then the '-' in "-row" is replaced with a newline character. This results in each harvest area being put on seperate lines. These data are saved to a file and then read from the same file using fgets() to get results line by line. These lines are then passed individually to FA_ParseResponse() to construct FA_HarvestArea_TypeDef's.
| data | Raw XML text from NSW FA JSON request. |
| harvest_areas | List of harvest areas. |
| void FA_UniqueLocationsFromDB | ( | T_LocationsLookup_TypeDef * | locations, |
| PGconn * | psql_conn | ||
| ) |
Get Unique harvest area locations from DB.
Load unique locations from lookup table in PostgreSQL database.
Load all the relevent locations from the lookup table (only 20 something locations to load).
| locations | Lookup table locations from PostgreSQL table. |
| psql_conn | PostgreSQL database connection. |