address.h
1 /*
2  * address.h
3  *
4  * Created on: 31 May 2018
5  * Author: billy
6  */
7 
8 #ifndef TOOLS_GRASSROOTS_GEOCODER_INCLUDE_ADDRESS_H_
9 #define TOOLS_GRASSROOTS_GEOCODER_INCLUDE_ADDRESS_H_
10 
12 #include "coordinate.h"
13 #include "jansson.h"
14 
21 typedef struct Address
22 {
27  char *ad_name_s;
28 
32  char *ad_street_s;
33 
34 
38  char *ad_town_s;
39 
40 
44  char *ad_county_s;
45 
49  char *ad_country_s;
50 
55 
61 
69  char *ad_gps_s;
70 
76 
77 
83 
84 
90 
91  double64 *ad_elevation_p;
92 } Address;
93 
94 
95 
96 #ifndef DOXYGEN_SHOULD_SKIP_THIS
97 
98 #ifdef ALLOCATE_ADDRESS_TAGS
99  #define ADDRESS_PREFIX GRASSROOTS_GEOCODER_API
100  #define ADDRESS_VAL(x) = x
101 #else
102  #define ADDRESS_PREFIX extern
103  #define ADDRESS_VAL(x)
104 #endif
105 
106 #endif /* #ifndef DOXYGEN_SHOULD_SKIP_THIS */
107 
108 
109 ADDRESS_PREFIX const char *AD_ADDRESS_S ADDRESS_VAL ("Address");
110 
117 ADDRESS_PREFIX const char *AD_GPS_S ADDRESS_VAL ("GPS");
118 
119 
126 ADDRESS_PREFIX const char *AD_POSTCODE_S ADDRESS_VAL ("Postal code");
127 
128 
136 ADDRESS_PREFIX const char *AD_STREET_S ADDRESS_VAL ("Street");
137 
144 ADDRESS_PREFIX const char *AD_TOWN_S ADDRESS_VAL ("Town");
145 
146 
153 ADDRESS_PREFIX const char *AD_COUNTY_S ADDRESS_VAL ("County");
154 
155 
162 ADDRESS_PREFIX const char *AD_COUNTRY_S ADDRESS_VAL ("Country");
163 
164 
165 
171 ADDRESS_PREFIX const char *AD_LOCATION_S ADDRESS_VAL ("location");
172 
173 
179 ADDRESS_PREFIX const char *AD_CENTRE_LOCATION_S ADDRESS_VAL ("centre");
180 
186 ADDRESS_PREFIX const char *AD_NORTH_EAST_LOCATION_S ADDRESS_VAL ("north_east_bound");
187 
188 
194 ADDRESS_PREFIX const char *AD_SOUTH_WEST_LOCATION_S ADDRESS_VAL ("south_west_bound");
195 
196 
197 #ifdef __cplusplus
198 extern "C"
199 {
200 #endif
201 
219 GRASSROOTS_GEOCODER_API Address *AllocateAddress (const char *name_s, const char *street_s, const char *town_s, const char *county_s, const char *country_s, const char *postcode_s, const char *country_code_s, const char *gps_s);
220 
221 
229 GRASSROOTS_GEOCODER_API void FreeAddress (Address *address_p);
230 
231 
239 GRASSROOTS_GEOCODER_API void ClearAddress (Address *address_p);
240 
241 
251 GRASSROOTS_GEOCODER_API char *GetAddressAsString (const Address *address_p);
252 
253 
263 GRASSROOTS_GEOCODER_API char *GetAddressAsDelimitedString (const Address *address_p, const char *sep_s);
264 
265 
276 GRASSROOTS_GEOCODER_API json_t *GetAddressAsJSON (const Address *address_p);
277 
278 
287 GRASSROOTS_GEOCODER_API Address *GetAddressFromJSON (const json_t *address_json_p);
288 
298 GRASSROOTS_GEOCODER_API bool ConvertAddressToJSON (const Address *address_p, json_t *dest_p);
299 
300 
312 GRASSROOTS_GEOCODER_API bool ParseAddressForSchemaOrg (const Address *address_p, json_t *values_p, const char *address_key_s);
313 
314 
315 GRASSROOTS_GEOCODER_API Address *ParseSchemaOrgAddress (const json_t *values_p, const char *address_key_s);
316 
317 
332 GRASSROOTS_GEOCODER_API bool SetAddressCentreCoordinate (Address *address_p, const double64 latitude, const double64 longitude, const double64 *elevation_p);
333 
334 
349 GRASSROOTS_GEOCODER_API bool SetAddressNorthEastCoordinate (Address *address_p, const double64 latitude, const double64 longitude, const double64 *elevation_p);
350 
351 
366 GRASSROOTS_GEOCODER_API bool SetAddressSouthWestCoordinate (Address *address_p, const double64 latitude, const double64 longitude, const double64 *elevation_p);
367 
368 
369 
370 #ifdef __cplusplus
371 }
372 #endif
373 
374 #endif /* TOOLS_GRASSROOTS_GEOCODER_INCLUDE_ADDRESS_H_ */
json_t * GetAddressAsJSON(const Address *address_p)
Get the JSON representation of an Address.
const char * AD_CENTRE_LOCATION_S
The key for the central location object for a given record.
Definition: address.h:179
const char * AD_NORTH_EAST_LOCATION_S
The key for the north-eastern bounds for the location object for a given record.
Definition: address.h:186
const char * AD_SOUTH_WEST_LOCATION_S
The key for the south-western bounds for the location object for a given record.
Definition: address.h:194
bool SetAddressCentreCoordinate(Address *address_p, const double64 latitude, const double64 longitude, const double64 *elevation_p)
Set the Coordinate for the central point of a given address to the given latitude and longitude value...
char * ad_country_code_s
The ISO 3166-1 alpha-2 country code for the country that this Address is in.
Definition: address.h:60
const char * AD_LOCATION_S
The key for the location object for a given record.
Definition: address.h:171
bool ConvertAddressToJSON(const Address *address_p, json_t *dest_p)
Store the JSON-based representation of an Address in a given JSON fragment.
Coordinate * ad_gps_centre_p
A pointer to the Coordinate for the central point of this Address.
Definition: address.h:75
const char * AD_COUNTY_S
The key for specifying an object containing the county where the sample was collected.
Definition: address.h:153
bool SetAddressNorthEastCoordinate(Address *address_p, const double64 latitude, const double64 longitude, const double64 *elevation_p)
Set the Coordinate for the north-east bounds of a given address to the given latitude and longitude v...
Address * GetAddressFromJSON(const json_t *address_json_p)
Get a new Address from a JSON representation.
A datatype for storing a postal address as well as its geographic coordinates if possible.
Definition: address.h:21
void ClearAddress(Address *address_p)
Clear all of the values within an Address.
bool SetAddressSouthWestCoordinate(Address *address_p, const double64 latitude, const double64 longitude, const double64 *elevation_p)
Set the Coordinate for the south-west bounds of a given address to the given latitude and longitude v...
const char * AD_STREET_S
The key for specifying an object containing the street address where the sample was collected.
Definition: address.h:136
const char * AD_GPS_S
The key for specifying an object containing the GPS coordinates where the sample was collected.
Definition: address.h:117
char * GetAddressAsString(const Address *address_p)
Get a string represetnting an Address.
char * GetAddressAsDelimitedString(const Address *address_p, const char *sep_s)
Get a string represetnting an Address.
const char * AD_TOWN_S
The key for specifying an object containing the town where the sample was collected.
Definition: address.h:144
bool ParseAddressForSchemaOrg(const Address *address_p, json_t *values_p, const char *address_key_s)
Populate a JSON fragment with the values from a given Address conforming to the definition of a posta...
Coordinate * ad_gps_south_west_p
A pointer to the Coordinate for the south-west bounds of this Address.
Definition: address.h:89
Address * AllocateAddress(const char *name_s, const char *street_s, const char *town_s, const char *county_s, const char *country_s, const char *postcode_s, const char *country_code_s, const char *gps_s)
Allocte a new Address object.
char * ad_postcode_s
The postal code for this Address.
Definition: address.h:54
const char * AD_COUNTRY_S
The key for specifying an object containing the country where the sample was collected.
Definition: address.h:162
char * ad_gps_s
The string representation of the geographic coordinate for this Address such as "32....
Definition: address.h:69
char * ad_name_s
The building name or number for this Address.
Definition: address.h:27
void FreeAddress(Address *address_p)
Free an Address.
char * ad_country_s
The country that this Address is in.
Definition: address.h:49
char * ad_county_s
The county that this Address is in.
Definition: address.h:44
char * ad_town_s
The town, city or village that this Address is in.
Definition: address.h:38
char * ad_street_s
The street that this Address is on.
Definition: address.h:32
Coordinate * ad_gps_north_east_p
A pointer to the Coordinate for the north-east bounds of this Address.
Definition: address.h:82
const char * AD_POSTCODE_S
The key for specifying an object containing the postal code where the sample was collected.
Definition: address.h:126
A datatype for storing a geographic coordinate.
Definition: coordinate.h:34