X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/b45865b4d393f3ec0353bd5cc634cf1784f68a39..db771541ff9b86b3ef5e204d5d5d659ccf66e7e6:/src/gpspoint.c?ds=sidebyside diff --git a/src/gpspoint.c b/src/gpspoint.c index 3c095a14..bee2d337 100644 --- a/src/gpspoint.c +++ b/src/gpspoint.c @@ -2,7 +2,7 @@ * viking -- GPS Data and Topo Analyzer, Explorer, and Manager * * Copyright (C) 2003-2005, Evan Battaglia - * Copyright (C) 2012, Rob Norris + * Copyright (C) 2012-2013, Rob Norris * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -46,7 +46,6 @@ static void a_gpspoint_write_track ( const gpointer id, const VikTrack *t, FILE static void a_gpspoint_write_trackpoint ( VikTrackpoint *tp, TP_write_info_type *write_info ); static void a_gpspoint_write_waypoint ( const gpointer id, const VikWaypoint *wp, FILE *f ); - /* outline for file gpspoint.c reading file: @@ -157,7 +156,7 @@ static gchar *deslashndup ( const gchar *str, guint16 len ) * No obvious way to test for a 'gpspoint' file, * thus set a flag if any actual tag found during processing of the file */ -gboolean a_gpspoint_read_file(VikTrwLayer *trw, FILE *f ) { +gboolean a_gpspoint_read_file(VikTrwLayer *trw, FILE *f, const gchar *dirpath ) { VikCoordMode coord_mode = vik_trw_layer_get_coord_mode ( trw ); gchar *tag_start, *tag_end; g_assert ( f != NULL && trw != NULL ); @@ -222,6 +221,8 @@ gboolean a_gpspoint_read_file(VikTrwLayer *trw, FILE *f ) { VikWaypoint *wp = vik_waypoint_new(); wp->visible = line_visible; wp->altitude = line_altitude; + wp->has_timestamp = line_has_timestamp; + wp->timestamp = line_timestamp; vik_coord_load_from_latlon ( &(wp->coord), coord_mode, &line_latlon ); @@ -235,8 +236,19 @@ gboolean a_gpspoint_read_file(VikTrwLayer *trw, FILE *f ) { if ( line_description ) vik_waypoint_set_description ( wp, line_description ); - if ( line_image ) - vik_waypoint_set_image ( wp, line_image ); + if ( line_image ) { + // Ensure the filename is absolute + if ( g_path_is_absolute ( line_image ) ) + vik_waypoint_set_image ( wp, line_image ); + else { + // Otherwise create the absolute filename from the directory of the .vik file & and the relative filename + gchar *full = g_strconcat(dirpath, G_DIR_SEPARATOR_S, line_image, NULL); + gchar *absolute = file_realpath_dup ( full ); // resolved into the canonical name + vik_waypoint_set_image ( wp, absolute ); + g_free ( absolute ); + g_free ( full ); + } + } if ( line_symbol ) vik_waypoint_set_symbol ( wp, line_symbol ); @@ -513,6 +525,8 @@ static void a_gpspoint_write_waypoint ( const gpointer id, const VikWaypoint *wp fprintf ( f, " altitude=\"%s\"", s_alt ); g_free(s_alt); } + if ( wp->has_timestamp ) + fprintf ( f, " unixtime=\"%ld\"", wp->timestamp ); if ( wp->comment ) { gchar *tmp_comment = slashdup(wp->comment);