GtkWidget *dialog;
VikFileList *files;
VikTrwLayer *vtl; // to pass on
+ VikWaypoint *wpt; // Use specified waypoint or otherwise the track(s) if NULL
VikTrack *track; // Use specified track or all tracks if NULL
GtkCheckButton *create_waypoints_b;
GtkLabel *overwrite_waypoints_l; // Referenced so the sensitivity can be changed
typedef struct {
VikTrwLayer *vtl;
gchar *image;
+ VikWaypoint *wpt; // Use specified waypoint or otherwise the track(s) if NULL
VikTrack *track; // Use specified track or all tracks if NULL
// User options...
option_values_t ov;
options->altitude = trkpt->altitude + ((trkpt_next->altitude - trkpt->altitude) * scale);
break;
}
-
+ }
+}
+
+/**
+ * Simply align the images the waypoint position
+ */
+static void trw_layer_geotag_waypoint ( geotag_options_t *options )
+{
+ // Write EXIF if specified - although a fairly useless process if you've turned it off!
+ if ( options->ov.write_exif ) {
+ gboolean has_gps_exif = FALSE;
+ gchar* datetime = a_geotag_get_exif_date_from_file ( options->image, &has_gps_exif );
+ // If image already has gps info - don't attempt to change it unless forced
+ if ( options->ov.overwrite_gps_exif || !has_gps_exif ) {
+ gint ans = a_geotag_write_exif_gps ( options->image, options->wpt->coord, options->wpt->altitude, options->ov.no_change_mtime );
+ if ( ans != 0 ) {
+ gchar *message = g_strdup_printf ( _("Failed updating EXIF on %s"), options->image );
+ vik_window_statusbar_update ( VIK_WINDOW(VIK_GTK_WINDOW_FROM_LAYER(options->vtl)), message, VIK_STATUSBAR_INFO );
+ g_free ( message );
+ }
+ }
+ g_free ( datetime );
}
}
if ( !options->image )
return;
+ if ( options->wpt ) {
+ trw_layer_geotag_waypoint ( options );
+ return;
+ }
+
gboolean has_gps_exif = FALSE;
gchar* datetime = a_geotag_get_exif_date_from_file ( options->image, &has_gps_exif );
// Write EXIF if specified
if ( options->ov.write_exif ) {
- a_geotag_write_exif_gps ( options->image, options->coord, options->altitude, options->ov.no_change_mtime );
+ gint ans = a_geotag_write_exif_gps ( options->image, options->coord, options->altitude, options->ov.no_change_mtime );
+ if ( ans != 0 ) {
+ gchar *message = g_strdup_printf ( _("Failed updating EXIF on %s"), options->image );
+ vik_window_statusbar_update ( VIK_WINDOW(VIK_GTK_WINDOW_FROM_LAYER(options->vtl)), message, VIK_STATUSBAR_INFO );
+ g_free ( message );
+ }
}
}
}
if ( options->redraw ) {
if ( IS_VIK_LAYER(options->vtl) ) {
+ trw_layer_calculate_bounds_waypoints ( options->vtl );
// Ensure any new images get shown
trw_layer_verify_thumbnails ( options->vtl, NULL ); // NB second parameter not used ATM
// Force redraw as verify only redraws if there are new thumbnails (they may already exist)
// Get options
geotag_options_t *options = g_malloc ( sizeof(geotag_options_t) );
options->vtl = widgets->vtl;
+ options->wpt = widgets->wpt;
options->track = widgets->track;
// Values extracted from the widgets:
options->ov.create_waypoints = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON(widgets->create_waypoints_b) );
gchar *tmp = g_strdup_printf ( _("Geotagging %d Images..."), len );
// Processing lots of files can take time - so run a background effort
- a_background_thread ( VIK_GTK_WINDOW_FROM_LAYER(options->vtl),
- tmp,
- (vik_thr_func) trw_layer_geotag_thread,
- options,
- (vik_thr_free_func) trw_layer_geotag_thread_free,
- NULL,
- len );
+ a_background_thread ( BACKGROUND_POOL_LOCAL,
+ VIK_GTK_WINDOW_FROM_LAYER(options->vtl),
+ tmp,
+ (vik_thr_func) trw_layer_geotag_thread,
+ options,
+ (vik_thr_free_func) trw_layer_geotag_thread_free,
+ NULL,
+ len );
g_free ( tmp );
* @track: Optional - The particular track to use (if specified) for correlating images
* @track_name: Optional - The name of specified track to use
*/
-void trw_layer_geotag_dialog ( GtkWindow *parent, VikTrwLayer *vtl, VikTrack *track, const gchar *track_name )
+void trw_layer_geotag_dialog ( GtkWindow *parent,
+ VikTrwLayer *vtl,
+ VikWaypoint *wpt,
+ VikTrack *track )
{
GeoTagWidgets *widgets = geotag_widgets_new();
widgets->files = VIK_FILE_LIST(vik_file_list_new ( _("Images"), filter ));
widgets->vtl = vtl;
+ widgets->wpt = wpt;
widgets->track = track;
widgets->create_waypoints_b = GTK_CHECK_BUTTON ( gtk_check_button_new () );
widgets->overwrite_waypoints_l = GTK_LABEL ( gtk_label_new ( _("Overwrite Existing Waypoints:") ) );
g_signal_connect ( G_OBJECT(widgets->create_waypoints_b), "toggled", G_CALLBACK(create_waypoints_b_cb), widgets );
GtkWidget *cw_hbox = gtk_hbox_new ( FALSE, 0 );
- gtk_box_pack_start ( GTK_BOX(cw_hbox), gtk_label_new ( _("Create Waypoints:") ), FALSE, FALSE, 5 );
+ GtkWidget *create_waypoints_l = gtk_label_new ( _("Create Waypoints:") );
+ gtk_box_pack_start ( GTK_BOX(cw_hbox), create_waypoints_l, FALSE, FALSE, 5 );
gtk_box_pack_start ( GTK_BOX(cw_hbox), GTK_WIDGET(widgets->create_waypoints_b), FALSE, FALSE, 5 );
GtkWidget *ow_hbox = gtk_hbox_new ( FALSE, 0 );
gtk_box_pack_start ( GTK_BOX(fm_hbox), GTK_WIDGET(widgets->no_change_mtime_b), FALSE, FALSE, 5 );
GtkWidget *is_hbox = gtk_hbox_new ( FALSE, 0 );
- gtk_box_pack_start ( GTK_BOX(is_hbox), gtk_label_new ( _("Interpolate Between Track Segments:") ), FALSE, FALSE, 5 );
+ GtkWidget *interpolate_segments_l = gtk_label_new ( _("Interpolate Between Track Segments:") );
+ gtk_box_pack_start ( GTK_BOX(is_hbox), interpolate_segments_l, FALSE, FALSE, 5 );
gtk_box_pack_start ( GTK_BOX(is_hbox), GTK_WIDGET(widgets->interpolate_segments_b), FALSE, FALSE, 5 );
GtkWidget *to_hbox = gtk_hbox_new ( FALSE, 0 );
- gtk_box_pack_start ( GTK_BOX(to_hbox), gtk_label_new ( _("Image Time Offset (Seconds):") ), FALSE, FALSE, 5 );
+ GtkWidget *time_offset_l = gtk_label_new ( _("Image Time Offset (Seconds):") );
+ gtk_box_pack_start ( GTK_BOX(to_hbox), time_offset_l, FALSE, FALSE, 5 );
gtk_box_pack_start ( GTK_BOX(to_hbox), GTK_WIDGET(widgets->time_offset_b), FALSE, FALSE, 5 );
gtk_widget_set_tooltip_text ( GTK_WIDGET(widgets->time_offset_b), _("The number of seconds to ADD to the photos time to make it match the GPS data. Calculate this with (GPS - Photo). Can be negative or positive. Useful to adjust times when a camera's timestamp was incorrect.") );
GtkWidget *tz_hbox = gtk_hbox_new ( FALSE, 0 );
- gtk_box_pack_start ( GTK_BOX(tz_hbox), gtk_label_new ( _("Image Timezone:") ), FALSE, FALSE, 5 );
+ GtkWidget *time_zone_l = gtk_label_new ( _("Image Timezone:") );
+ gtk_box_pack_start ( GTK_BOX(tz_hbox), time_zone_l, FALSE, FALSE, 5 );
gtk_box_pack_start ( GTK_BOX(tz_hbox), GTK_WIDGET(widgets->time_zone_b), FALSE, FALSE, 5 );
gtk_widget_set_tooltip_text ( GTK_WIDGET(widgets->time_zone_b), _("The timezone that was used when the images were created. For example, if a camera is set to AWST or +8:00 hours. Enter +8:00 here so that the correct adjustment to the images' time can be made. GPS data is always in UTC.") );
gchar *track_string = NULL;
- if ( widgets->track )
- track_string = g_strdup_printf ( _("Using track: %s"), track_name );
+ if ( widgets->wpt ) {
+ track_string = g_strdup_printf ( _("Using waypoint: %s"), wpt->name );
+ // Control sensitivities
+ gtk_widget_set_sensitive ( GTK_WIDGET(widgets->create_waypoints_b), FALSE );
+ gtk_widget_set_sensitive ( GTK_WIDGET(create_waypoints_l), FALSE );
+ gtk_widget_set_sensitive ( GTK_WIDGET(widgets->overwrite_waypoints_b), FALSE );
+ gtk_widget_set_sensitive ( GTK_WIDGET(widgets->overwrite_waypoints_l), FALSE );
+ gtk_widget_set_sensitive ( GTK_WIDGET(widgets->interpolate_segments_b), FALSE );
+ gtk_widget_set_sensitive ( GTK_WIDGET(interpolate_segments_l), FALSE );
+ gtk_widget_set_sensitive ( GTK_WIDGET(widgets->time_offset_b), FALSE );
+ gtk_widget_set_sensitive ( GTK_WIDGET(time_offset_l), FALSE );
+ gtk_widget_set_sensitive ( GTK_WIDGET(widgets->time_zone_b), FALSE );
+ gtk_widget_set_sensitive ( GTK_WIDGET(time_zone_l), FALSE );
+ }
+ else if ( widgets->track )
+ track_string = g_strdup_printf ( _("Using track: %s"), track->name );
else
track_string = g_strdup_printf ( _("Using all tracks in: %s"), VIK_LAYER(widgets->vtl)->name );