Oyster Harvest Area Closure Analysis 0.1
Prediction and analysis of NSW oyster harvest area closures.
Loading...
Searching...
No Matches
harvest_area.h File Reference
#include <curl/curl.h>
#include <cjson/cJSON.h>
#include <time.h>
#include <log.h>
#include "http.h"
#include "utils.h"
Include dependency graph for harvest_area.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  FA_HarvestArea_TypeDef
 Harvest area status information. More...
 

Macros

#define FA_MAX_BUFFER   150
 Buffer size for each HTML value from NSW Food Authority. More...
 
#define FA_HA_CLYDE_MOONLIGHT   "Moonlight"
 Moonlight harvest area. More...
 
#define FA_HA_CLYDE_ROCKY_PT   "Rocky"
 Rocky point harvest area. More...
 
#define FA_HA_CLYDE_WATERFALL   "Waterfall"
 Waterfall harvest area. More...
 

Functions

CURLcode FA_GetHarvestAreaStatus (const char *harvest_name, FA_HarvestArea_TypeDef *ha_status)
 Harvest area of interest status information. More...
 
void FA_ParseResponse (char *data, FA_HarvestArea_TypeDef *harvest_area)
 Parse HTML data to populate status information data. More...
 

Macro Definition Documentation

◆ FA_HA_CLYDE_MOONLIGHT

#define FA_HA_CLYDE_MOONLIGHT   "Moonlight"

Moonlight harvest area.

◆ FA_HA_CLYDE_ROCKY_PT

#define FA_HA_CLYDE_ROCKY_PT   "Rocky"

Rocky point harvest area.

◆ FA_HA_CLYDE_WATERFALL

#define FA_HA_CLYDE_WATERFALL   "Waterfall"

Waterfall harvest area.

◆ FA_MAX_BUFFER

#define FA_MAX_BUFFER   150

Buffer size for each HTML value from NSW Food Authority.

Function Documentation

◆ FA_GetHarvestAreaStatus()

CURLcode FA_GetHarvestAreaStatus ( const char *  harvest_name,
FA_HarvestArea_TypeDef harvest_area 
)

Harvest area of interest status information.

Gets harvest area status information from NSW Food Authority.

NSW Food Authority provides a JSON response with XML data as values. The XML data basically contains generic cards that are used on the NSW FA website. This function parses out the relevent XML data and used helper functions to pull out a struct containing relevent data.

FA_HarvestAreaStatus_TypeDef harvest_area;
CURLcode FA_GetHarvestAreaStatus(const char *harvest_name, FA_HarvestArea_TypeDef *harvest_area)
Harvest area of interest status information.
Definition: harvest_area.c:32
#define FA_HA_CLYDE_MOONLIGHT
Moonlight harvest area.
Definition: harvest_area.h:16

The havest area names for Batemans Bay are as follow:

  • Waterfall
  • Moonlight
  • Rocky (representing Rocky Point)

Other harvest areas can be checked using this function (just need to know their name and use it as the harvest_name variable.

Parameters
harvest_nameName of harvest area.
harvest_areaHarvest area struct to populate with status information.
Returns
Code representing CURL response status.

◆ FA_ParseResponse()

void FA_ParseResponse ( char *  data,
FA_HarvestArea_TypeDef harvest_area 
)

Parse HTML data to populate status information data.

Takes a character array containing HTML data and formats a struct containing relevent harvest area status information.

Search terms are taken from the HTML input and the corresponding values (i.e. the text between relevent tags) are added to the corresponding struct.

Parameters
dataThe string to parse.
harvest_areaThe struct to populate with values.

Convert time to tm struct