babel

babel — running external programs and redirecting to TRWLayers.

Functions

Types and Values

Description

GPSBabel may not be necessary for everything, one can use shell_command option but this will be OS platform specific

Functions

BabelStatusFunc ()

void
(*BabelStatusFunc) (BabelProgressCode Param1,
                    gpointer Param2,
                    gpointer Param3);

Callback function.


a_babel_foreach_file_with_mode ()

void
a_babel_foreach_file_with_mode (BabelMode mode,
                                GFunc func,
                                gpointer user_data);

a_babel_foreach_file_read_any ()

void
a_babel_foreach_file_read_any (GFunc func,
                               gpointer user_data);

Run a function on all file formats with any kind of read method (which is almost all but not quite - e.g. with GPSBabel v1.4.4 - PalmDoc is write only waypoints)

Parameters

func

The function to be called on any file format with a read method

 

user_data

Data passed into the function

 

a_babel_convert_from ()

gboolean
a_babel_convert_from (VikTrwLayer *vt,
                      ProcessOptions *process_options,
                      BabelStatusFunc cb,
                      gpointer user_data,
                      DownloadFileOptions *download_options);

Loads data into a trw layer from a file, using gpsbabel. This routine is synchronous; that is, it will block the calling program until the conversion is done. To avoid blocking, call this routine from a worker thread.

Parameters

vt

The TRW layer to place data into. Duplicate items will be overwritten.

 

process_options

The options to control the appropriate processing function. See ProcessOptions for more detail

 

cb

Optional callback function. Same usage as in a_babel_convert().

 

user_data

passed along to cb

 

download_options

If downloading from a URL use these options (may be NULL)

 

Returns

TRUE on success


a_babel_convert_to ()

gboolean
a_babel_convert_to (VikTrwLayer *vt,
                    VikTrack *track,
                    const char *babelargs,
                    const char *file,
                    BabelStatusFunc cb,
                    gpointer user_data);

Exports data using gpsbabel. This routine is synchronous; that is, it will block the calling program until the conversion is done. To avoid blocking, call this routine from a worker thread.

Parameters

vt

The TRW layer from which data is taken.

 

track

Operate on the individual track if specified. Use NULL when operating on a TRW layer

 

babelargs

A string containing gpsbabel output command line options. (i.e. must the contain '-o' file type and possibly any filter parameters)

 

to

Filename or device the data is written to.

 

cb

Optional callback function. Same usage as in a_babel_convert.

 

user_data

passed along to cb

 

Returns

TRUE on successful invocation of GPSBabel command


a_babel_init ()

void
a_babel_init ();

Just setup preferences first


a_babel_post_init ()

void
a_babel_post_init ();

Initialises babel module. Mainly check existence of gpsbabel progam and load all features available in that version.


a_babel_uninit ()

void
a_babel_uninit ();

Free resources acquired by a_babel_init.


a_babel_available ()

gboolean
a_babel_available ();

Indicates if babel is available or not.

Returns

true if babel available

Types and Values

enum BabelProgressCode

Used when calling BabelStatusFunc.

Members

BABEL_DIAG_OUTPUT

a line of diagnostic output is available. The pointer is to a NULL-terminated line of diagnostic output from gpsbabel.

 

BABEL_DONE

gpsbabel finished, or NULL if no callback is needed.

 

ProcessOptions

typedef struct {
  gchar* babelargs; // The standard initial arguments to gpsbabel (if gpsbabel is to be used) - normally should include the input file type (-i) option.
  gchar* filename; // Input filename (or device port e.g. /dev/ttyS0)
  gchar* input_file_type; // If NULL then uses internal file format handler (GPX only ATM), otherwise specify gpsbabel input type like "kml","tcx", etc...
  gchar* url; // URL input rather than a filename
  gchar* babel_filters; // Optional filter arguments to gpsbabel
  gchar* shell_command; // Optional shell command to run instead of gpsbabel - but will be (Unix) platform specific
} ProcessOptions;

All values are defaulted to NULL

Need to specify at least one of babelargs, URL or shell_command


BabelMode

typedef struct {
    unsigned waypointsRead : 1;
    unsigned waypointsWrite : 1;
    unsigned tracksRead : 1;
    unsigned tracksWrite : 1;
    unsigned routesRead : 1;
    unsigned routesWrite : 1;
} BabelMode;

Store the Read/Write support offered by gpsbabel for a given format.


BabelDevice

typedef struct {
    BabelMode mode;
    gchar *name;
    gchar *label;
} BabelDevice;

Representation of a supported device.

Members

BabelMode mode;

   

gchar *name;

gpsbabel's identifier of the device

 

gchar *label;

human readable label

 

BabelFile

typedef struct {
    BabelMode mode;
    gchar *name;
    gchar *ext;
    gchar *label;
} BabelFile;

Representation of a supported file format.

Members

BabelMode mode;

   

gchar *name;

gpsbabel's identifier of the format

 

gchar *ext;

file's extension for this format

 

gchar *label;

human readable label