From 4b15b9dfe910fd0df63bdc8024a919a566c380be Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 11 Feb 2015 21:46:02 -0800 Subject: Save and parse dive site structures to XML Read and write divesite sections in the XML file. Read divelogs of version 2 and create dive site structures on the fly. Read version 3 files that have divesiteid instead of location / gps. Saves version 3 files where dives no longer have location and gps but instead refer to a divesiteid The commit contains quite a few fprintf(stderr,...) in order to allow better monitoring of the parsing / transforming of locations and gps to dive sites. This will need to be removed later. Signed-off-by: Dirk Hohndel --- dive.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'dive.h') diff --git a/dive.h b/dive.h index 2c9ef3336..c38016bb5 100644 --- a/dive.h +++ b/dive.h @@ -8,6 +8,7 @@ #include #include #include +#include "divesite.h" /* Windows has no MIN/MAX macros - so let's just roll our own */ #define MIN(x, y) ({ \ @@ -387,11 +388,6 @@ extern void dive_set_geodata_from_picture(struct dive *d, struct picture *pic); extern int explicit_first_cylinder(struct dive *dive, struct divecomputer *dc); -static inline int dive_has_gps_location(struct dive *dive) -{ - return dive->latitude.udeg || dive->longitude.udeg; -} - static inline void copy_gps_location(struct dive *from, struct dive *to) { if (from && to) { @@ -607,6 +603,16 @@ static inline int get_idx_by_uniq_id(int id) return i; } +static inline bool dive_site_has_gps_location(struct dive_site *ds) +{ + return ds && (ds->latitude.udeg || ds->longitude.udeg); +} + +static inline int dive_has_gps_location(struct dive *dive) +{ + return dive_site_has_gps_location(get_dive_site_by_uuid(dive->dive_site_uuid)); +} + #ifdef __cplusplus extern "C" { #endif -- cgit v1.2.3-70-g09d2