[geonames] Adding country_geonames_id to both geoname and postal code structs

This commit is contained in:
Al
2015-07-08 18:44:14 -04:00
parent 9af0b0ab65
commit 8c02073b54
2 changed files with 14 additions and 1 deletions

View File

@@ -220,6 +220,10 @@ bool geoname_deserialize_ctx(geoname_t *self, cmp_ctx_t *ctx) {
return false;
}
if (!cmp_read_uint(ctx, &self->country_geonames_id, &len)) {
return false;
}
if (!cmp_read_str_size_or_nil(ctx, &self->admin1_code, &len)) {
return false;
}
@@ -280,6 +284,7 @@ bool geoname_serialize_ctx(geoname_t *self, cmp_ctx_t *ctx) {
!cmp_write_double(ctx, self->longitude) ||
!cmp_write_str_or_nil(ctx, self->feature_code) ||
!cmp_write_str_or_nil(ctx, self->country_code) ||
!cmp_write_uint(ctx, self->country_geonames_id) ||
!cmp_write_str_or_nil(ctx, self->admin1_code) ||
!cmp_write_uint(ctx, self->admin1_geonames_id) ||
!cmp_write_str_or_nil(ctx, self->admin2_code) ||
@@ -317,6 +322,7 @@ void geoname_print(geoname_t *self) {
printf("longitude: %f\n", self->longitude);
printf("feature_code: %s\n", char_array_get_string(self->feature_code));
printf("country_code: %s\n", char_array_get_string(self->country_code));
printf("country_geonames_id: %d\n", self->country_geonames_id);
printf("admin1_code: %s\n", char_array_get_string(self->admin1_code));
printf("admin1_geonames_id: %d\n", self->admin1_geonames_id);
printf("admin2_code: %s\n", char_array_get_string(self->admin2_code));
@@ -391,6 +397,10 @@ bool gn_postal_code_deserialize_ctx(gn_postal_code_t *self, cmp_ctx_t *ctx) {
return false;
}
if (!cmp_read_uint(ctx, &self->country_geonames_id, &len)) {
return false;
}
if (!cmp_read_bool(ctx, &self->have_containing_geoname)) {
return false;
}
@@ -462,6 +472,7 @@ static bool gn_postal_code_serialize_ctx(gn_postal_code_t *self, cmp_ctx_t *ctx)
if (!cmp_write_str_or_nil(ctx, self->postal_code) ||
!cmp_write_str_or_nil(ctx, self->country_code) ||
!cmp_write_uint(ctx, self->country_geonames_id) ||
!cmp_write_bool(ctx, self->have_containing_geoname) ||
(self->have_containing_geoname &&
(!cmp_write_str_or_nil(ctx, self->containing_geoname) ||

View File

@@ -48,6 +48,7 @@ typedef struct geoname {
double longitude;
char_array *feature_code;
char_array *country_code;
uint32_t country_geonames_id;
char_array *admin1_code;
uint32_t admin1_geonames_id;
char_array *admin2_code;
@@ -73,6 +74,7 @@ void geoname_destroy(geoname_t *self);
typedef struct gn_postal_code {
char_array *postal_code;
char_array *country_code;
uint32_t country_geonames_id;
bool have_lat_lon;
double latitude;
double longitude;
@@ -114,4 +116,4 @@ bool geonames_generic_deserialize(gn_type *type, geoname_t *geoname, gn_postal_c
}
#endif
#endif
#endif