|
Oyster Harvest Area Closure Analysis 0.1
Prediction and analysis of NSW oyster harvest area closures.
|
#include <curl/curl.h>#include <cjson/cJSON.h>#include <time.h>#include <libpq-fe.h>#include <log.h>#include "FoodAuthority/harvest_area.h"#include "transform.h"#include "http.h"#include "utils.h"#include "WillyWeather/location.h"#include "BOM/stations.h"Go to the source code of this file.
Data Structures | |
| struct | FA_HarvestAreas_TypeDef |
| Holds a list of oyster harvest areas (and their status) in NSW. More... | |
Macros | |
| #define | FA_DEFAULT_DIRECTORY "datasets/nsw_food_authority" |
| Harvest areas directory. More... | |
| #define | FA_DEFAULT_FILENAME "datasets/nsw_food_authority/statuses.csv" |
| Harvest area statuses filename. More... | |
| #define | FA_MAX_NUMBER_HARVEST_AREAS 120 |
| Maxiumum number of oyster harvest areas in response. More... | |
Functions | |
| 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... | |
| #define FA_DEFAULT_DIRECTORY "datasets/nsw_food_authority" |
Harvest areas directory.
| #define FA_DEFAULT_FILENAME "datasets/nsw_food_authority/statuses.csv" |
Harvest area statuses filename.
| #define FA_MAX_NUMBER_HARVEST_AREAS 120 |
Maxiumum number of oyster harvest areas in response.
| 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. |
| 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. |