// make like a "stack" of tag names
// like gpspoint's separated like /gpx/wpt/whatever
-void a_gpx_read_file( VikTrwLayer *vtl, FILE *f ) {
+gboolean a_gpx_read_file( VikTrwLayer *vtl, FILE *f ) {
XML_Parser parser = XML_ParserCreate(NULL);
int done=0, len;
+ enum XML_Status status = XML_STATUS_ERROR;
XML_SetElementHandler(parser, (XML_StartElementHandler) gpx_start, (XML_EndElementHandler) gpx_end);
XML_SetUserData(parser, vtl); /* in the future we could remove all global variables */
while (!done) {
len = fread(buf, 1, sizeof(buf)-7, f);
done = feof(f) || !len;
- XML_Parse(parser, buf, len, done);
+ status = XML_Parse(parser, buf, len, done);
}
XML_ParserFree (parser);
g_string_free ( xpath, TRUE );
g_string_free ( c_cdata, TRUE );
+
+ return status != XML_STATUS_ERROR;
}
/**** entitize from GPSBabel ****/
static void gpx_write_waypoint ( VikWaypoint *wp, GpxWritingContext *context )
{
+ // Don't write invisible waypoints when specified
+ if (context->options && !context->options->hidden && !wp->visible)
+ return;
+
FILE *f = context->file;
static struct LatLon ll;
gchar *s_lat,*s_lon;
vik_coord_to_latlon ( &(wp->coord), &ll );
s_lat = a_coords_dtostr( ll.lat );
s_lon = a_coords_dtostr( ll.lon );
+ // NB 'hidden' is not part of any GPX standard - this appears to be a made up Viking 'extension'
+ // luckily most other GPX processing software ignores things they don't understand
fprintf ( f, "<wpt lat=\"%s\" lon=\"%s\"%s>\n",
s_lat, s_lon, wp->visible ? "" : " hidden=\"hidden\"" );
g_free ( s_lat );
static void gpx_write_track ( VikTrack *t, GpxWritingContext *context )
{
+ // Don't write invisible tracks when specified
+ if (context->options && !context->options->hidden && !t->visible)
+ return;
+
FILE *f = context->file;
gchar *tmp;
gboolean first_tp_is_newsegment = FALSE; /* must temporarily make it not so, but we want to restore state. not that it matters. */
else
tmp = g_strdup ("track");
+ // NB 'hidden' is not part of any GPX standard - this appears to be a made up Viking 'extension'
+ // luckily most other GPX processing software ignores things they don't understand
fprintf ( f, "<trk%s>\n <name>%s</name>\n", t->visible ? "" : " hidden=\"hidden\"", tmp );
g_free ( tmp );
fprintf ( f, " <desc>%s</desc>\n", tmp );
g_free ( tmp );
}
-
fprintf ( f, " <trkseg>\n" );
if ( t->trackpoints && t->trackpoints->data ) {
return 0;
}
-void a_gpx_write_file( VikTrwLayer *vtl, FILE *f )
-{
- a_gpx_write_file_options(NULL, vtl, f);
-}
-
-void a_gpx_write_file_options ( GpxWritingOptions *options, VikTrwLayer *vtl, FILE *f )
+void a_gpx_write_file ( VikTrwLayer *vtl, FILE *f, GpxWritingOptions *options )
{
GpxWritingContext context = { options, f };
gpx_write_footer ( f );
}
-void a_gpx_write_track_file ( VikTrack *trk, FILE *f )
-{
- a_gpx_write_track_file_options ( NULL, trk, f );
-}
-
-void a_gpx_write_track_file_options ( GpxWritingOptions *options, VikTrack *trk, FILE *f )
+void a_gpx_write_track_file ( VikTrack *trk, FILE *f, GpxWritingOptions *options )
{
GpxWritingContext context = {options, f};
gpx_write_header ( f );