- if ( file_type == FILE_TYPE_GPSMAPPER )
- a_gpsmapper_write_file ( vtl, f );
- else if ( file_type == FILE_TYPE_GPX )
- a_gpx_write_file ( vtl, f );
- else
- a_gpspoint_write_file ( vtl, f );
+ gboolean result = TRUE;
+
+ if ( trk ) {
+ switch ( file_type ) {
+ case FILE_TYPE_GPX:
+ // trk defined so can set the option
+ options.is_route = trk->is_route;
+ a_gpx_write_track_file ( trk, f, &options );
+ break;
+ default:
+ g_critical("Houston, we've had a problem. file_type=%d", file_type);
+ }
+ } else {
+ switch ( file_type ) {
+ case FILE_TYPE_GPSMAPPER:
+ a_gpsmapper_write_file ( vtl, f );
+ break;
+ case FILE_TYPE_GPX:
+ a_gpx_write_file ( vtl, f, &options );
+ break;
+ case FILE_TYPE_GPSPOINT:
+ a_gpspoint_write_file ( vtl, f );
+ break;
+ case FILE_TYPE_GEOJSON:
+ result = a_geojson_write_file ( vtl, f );
+ break;
+ case FILE_TYPE_KML:
+ fclose ( f );
+ switch ( a_vik_get_kml_export_units () ) {
+ case VIK_KML_EXPORT_UNITS_STATUTE:
+ return a_babel_convert_to ( vtl, NULL, "-o kml", filename, NULL, NULL );
+ break;
+ case VIK_KML_EXPORT_UNITS_NAUTICAL:
+ return a_babel_convert_to ( vtl, NULL, "-o kml,units=n", filename, NULL, NULL );
+ break;
+ default:
+ // VIK_KML_EXPORT_UNITS_METRIC:
+ return a_babel_convert_to ( vtl, NULL, "-o kml,units=m", filename, NULL, NULL );
+ break;
+ }
+ break;
+ default:
+ g_critical("Houston, we've had a problem. file_type=%d", file_type);
+ }
+ }