/** * a_geotag_create_waypoint_positioned: * @filename: The image file to process * @coord: The location for positioning the Waypoint * @name: Returns a name for the Waypoint (can be NULL) * * Returns: An allocated Waypoint or NULL if Waypoint could not be generated * * Here EXIF processing is used to get non position related information (i.e. just the comment) * */ VikWaypoint* a_geotag_create_waypoint_positioned ( const gchar *filename, VikCoord coord, gdouble alt, gchar **name ) { *name = NULL; VikWaypoint *wp = vik_waypoint_new(); wp->visible = TRUE; wp->coord = coord; wp->altitude = alt; ExifData *ed = exif_data_new_from_file ( filename ); // Set info from exif values if ( ed ) { wp->comment = geotag_get_exif_comment ( ed ); gchar str[128]; ExifEntry *ee; // Name ee = exif_content_get_entry (ed->ifd[EXIF_IFD_0], EXIF_TAG_XP_TITLE); if ( ee ) { exif_entry_get_value ( ee, str, 128 ); *name = g_strdup ( str ); } // Finished with EXIF exif_data_free ( ed ); } vik_waypoint_set_image ( wp, filename ); return wp; }
VikWaypoint *vik_waypoint_copy(const VikWaypoint *wp) { VikWaypoint *new_wp = vik_waypoint_new(); *new_wp = *wp; new_wp->comment = NULL; /* if the waypoint had a comment, FOR CRYING OUT LOUD DON'T FREE IT! This lousy bug took me TWO HOURS to figure out... sigh... */ vik_waypoint_set_comment(new_wp,wp->comment); new_wp->image = NULL; vik_waypoint_set_image(new_wp,wp->image); new_wp->symbol = NULL; vik_waypoint_set_symbol(new_wp,wp->symbol); return new_wp; }
void a_geonames_wikipedia_box(VikWindow *vw, VikTrwLayer *vtl, VikLayersPanel *vlp, struct LatLon maxmin[2]) { gchar *uri; gchar *tmpname; GList *wiki_places; GList *selected; GList *wp_runner; VikWaypoint *wiki_wp; found_geoname *wiki_geoname; /* encode doubles in a C locale */ gchar *north = a_coords_dtostr(maxmin[0].lat); gchar *south = a_coords_dtostr(maxmin[1].lat); gchar *east = a_coords_dtostr(maxmin[0].lon); gchar *west = a_coords_dtostr(maxmin[1].lon); uri = g_strdup_printf(GEONAMES_WIKIPEDIA_URL_FMT, north, south, east, west); g_free(north); north = NULL; g_free(south); south = NULL; g_free(east); east = NULL; g_free(west); west = NULL; tmpname = download_url(uri); if (!tmpname) { none_found(vw); return; } wiki_places = get_entries_from_file(tmpname); if (g_list_length(wiki_places) == 0) { none_found(vw); return; } selected = a_select_geoname_from_list(VIK_GTK_WINDOW_FROM_WIDGET(vw), wiki_places, TRUE, "Select articles", "Select the articles you want to add."); wp_runner = selected; while (wp_runner) { wiki_geoname = (found_geoname *)wp_runner->data; wiki_wp = vik_waypoint_new(); wiki_wp->visible = TRUE; vik_coord_load_from_latlon(&(wiki_wp->coord), vik_trw_layer_get_coord_mode ( vtl ), &(wiki_geoname->ll)); vik_waypoint_set_comment(wiki_wp, wiki_geoname->desc); vik_trw_layer_filein_add_waypoint ( vtl, wiki_geoname->name, wiki_wp ); wp_runner = g_list_next(wp_runner); } free_geoname_list(wiki_places); free_geoname_list(selected); g_free(uri); if (tmpname) { g_free(tmpname); } vik_layers_panel_emit_update(vlp); }
/** * Load a single JPG into a Trackwaypoint Layer as a waypoint * * @top: The Aggregate layer that a new TRW layer may be created in * @filename: The JPG filename * @vvp: The viewport * * Returns: Whether the loading was a success or not * * If the JPG has geotag information then the waypoint will be created with the appropriate position. * Otherwise the waypoint will be positioned at the current screen center. * If a TRW layer is already selected the waypoint will be created in that layer. */ gboolean a_jpg_load_file ( VikAggregateLayer *top, const gchar *filename, VikViewport *vvp ) { gboolean auto_zoom = TRUE; VikWindow *vw = (VikWindow *)(VIK_GTK_WINDOW_FROM_LAYER(VIK_LAYER(top))); VikLayersPanel *vlp = vik_window_layers_panel ( vw ); // Auto load into TrackWaypoint layer if one is selected VikLayer *vtl = vik_layers_panel_get_selected ( vlp ); gboolean create_layer = FALSE; if ( vtl == NULL || vtl->type != VIK_LAYER_TRW ) { // Create layer if necessary vtl = vik_layer_create ( VIK_LAYER_TRW, vvp, FALSE ); vik_layer_rename ( vtl, a_file_basename ( filename ) ); create_layer = TRUE; } gchar *name = NULL; VikWaypoint *wp = NULL; #ifdef VIK_CONFIG_GEOTAG wp = a_geotag_create_waypoint_from_file ( filename, vik_viewport_get_coord_mode (vvp), &name ); #endif if ( wp ) { // Create name if geotag method didn't return one if ( !name ) name = g_strdup ( a_file_basename ( filename ) ); vik_trw_layer_filein_add_waypoint ( VIK_TRW_LAYER(vtl), name, wp ); g_free ( name ); } else { wp = vik_waypoint_new (); wp->visible = TRUE; vik_trw_layer_filein_add_waypoint ( VIK_TRW_LAYER(vtl), (gchar*) a_file_basename(filename), wp ); vik_waypoint_set_image ( wp, filename ); // Simply set position to the current center wp->coord = *( vik_viewport_get_center ( vvp ) ); auto_zoom = FALSE; } // Complete the setup vik_layer_post_read ( vtl, vvp, TRUE ); if ( create_layer ) vik_aggregate_layer_add_layer ( top, vtl, FALSE ); if ( auto_zoom ) vik_trw_layer_auto_set_view ( VIK_TRW_LAYER(vtl), vvp ); // ATM This routine can't fail return TRUE; }
/** * a_geotag_waypoint_positioned: * @filename: The image file to process * @coord: The location for positioning the Waypoint * @name: Returns a name for the Waypoint (can be NULL) * @waypoint: An existing waypoint to update (can be NULL to generate a new waypoint) * * Returns: An allocated waypoint if the input waypoint is NULL, * otherwise the passed in waypoint is updated * * Here EXIF processing is used to get non position related information (i.e. just the comment) * */ VikWaypoint* a_geotag_waypoint_positioned ( const gchar *filename, VikCoord coord, gdouble alt, gchar **name, VikWaypoint *wp ) { *name = NULL; if ( wp == NULL ) { // Need to create waypoint wp = vik_waypoint_new(); wp->visible = TRUE; } wp->coord = coord; wp->altitude = alt; #ifdef HAVE_LIBGEXIV2 GExiv2Metadata *gemd = gexiv2_metadata_new (); if ( gexiv2_metadata_open_path ( gemd, filename, NULL ) ) { wp->comment = geotag_get_exif_comment ( gemd ); if ( gexiv2_metadata_has_tag ( gemd, "Exif.Image.XPTitle" ) ) *name = g_strdup ( gexiv2_metadata_get_tag_interpreted_string ( gemd, "Exif.Image.XPTitle" ) ); } metadata_free ( gemd ); #else #ifdef HAVE_LIBEXIF ExifData *ed = exif_data_new_from_file ( filename ); // Set info from exif values if ( ed ) { wp->comment = geotag_get_exif_comment ( ed ); gchar str[128]; ExifEntry *ee; // Name ee = exif_content_get_entry (ed->ifd[EXIF_IFD_0], EXIF_TAG_XP_TITLE); if ( ee ) { exif_entry_get_value ( ee, str, 128 ); *name = g_strdup ( str ); } // Finished with EXIF exif_data_free ( ed ); } #endif #endif vik_waypoint_set_image ( wp, filename ); return wp; }
VikWaypoint *vik_waypoint_unmarshall (guint8 *data, guint datalen) { guint len; VikWaypoint *new_wp = vik_waypoint_new(); memcpy(new_wp, data, sizeof(*new_wp)); data += sizeof(*new_wp); #define vwu_get(s) \ len = *(guint *)data; \ data += sizeof(len); \ if (len) { \ (s) = g_strdup((gchar *)data); \ } else { \ (s) = NULL; \ } \ data += len; vwu_get(new_wp->comment); vwu_get(new_wp->image); vwu_get(new_wp->symbol); return new_wp; #undef vwu_get }
static void gpx_start(VikTrwLayer *vtl, const char *el, const char **attr) { static const gchar *tmp; g_string_append_c ( xpath, '/' ); g_string_append ( xpath, el ); current_tag = get_tag ( xpath->str ); switch ( current_tag ) { case tt_gpx: c_md = vik_trw_metadata_new(); break; case tt_wpt: if ( set_c_ll( attr ) ) { c_wp = vik_waypoint_new (); c_wp->visible = TRUE; if ( get_attr ( attr, "hidden" ) ) c_wp->visible = FALSE; vik_coord_load_from_latlon ( &(c_wp->coord), vik_trw_layer_get_coord_mode ( vtl ), &c_ll ); } break; case tt_trk: case tt_rte: c_tr = vik_track_new (); vik_track_set_defaults ( c_tr ); c_tr->is_route = (current_tag == tt_rte) ? TRUE : FALSE; c_tr->visible = TRUE; if ( get_attr ( attr, "hidden" ) ) c_tr->visible = FALSE; break; case tt_trk_trkseg: f_tr_newseg = TRUE; break; case tt_trk_trkseg_trkpt: if ( set_c_ll( attr ) ) { c_tp = vik_trackpoint_new (); vik_coord_load_from_latlon ( &(c_tp->coord), vik_trw_layer_get_coord_mode ( vtl ), &c_ll ); if ( f_tr_newseg ) { c_tp->newsegment = TRUE; f_tr_newseg = FALSE; } c_tr->trackpoints = g_list_append ( c_tr->trackpoints, c_tp ); } break; case tt_gpx_name: case tt_gpx_author: case tt_gpx_desc: case tt_gpx_keywords: case tt_gpx_time: case tt_trk_trkseg_trkpt_name: case tt_trk_trkseg_trkpt_ele: case tt_trk_trkseg_trkpt_time: case tt_wpt_cmt: case tt_wpt_desc: case tt_wpt_name: case tt_wpt_ele: case tt_wpt_time: case tt_wpt_url: case tt_wpt_link: case tt_trk_cmt: case tt_trk_desc: case tt_trk_name: g_string_erase ( c_cdata, 0, -1 ); /* clear the cdata buffer */ break; case tt_waypoint: c_wp = vik_waypoint_new (); c_wp->visible = TRUE; break; case tt_waypoint_coord: if ( set_c_ll( attr ) ) vik_coord_load_from_latlon ( &(c_wp->coord), vik_trw_layer_get_coord_mode ( vtl ), &c_ll ); break; case tt_waypoint_name: if ( ( tmp = get_attr(attr, "id") ) ) { if ( c_wp_name ) g_free ( c_wp_name ); c_wp_name = g_strdup ( tmp ); } g_string_erase ( c_cdata, 0, -1 ); /* clear the cdata buffer for description */ break; default: break; } }
/* todo: less on this side, like add track */ gchar *a_dialog_waypoint ( GtkWindow *parent, gchar *default_name, VikTrwLayer *vtl, VikWaypoint *wp, VikCoordMode coord_mode, gboolean is_new, gboolean *updated ) { GtkWidget *dialog = gtk_dialog_new_with_buttons (_("Waypoint Properties"), parent, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); struct LatLon ll; GtkWidget *latlabel, *lonlabel, *namelabel, *latentry, *lonentry, *altentry, *altlabel, *nameentry=NULL; GtkWidget *commentlabel, *commententry, *descriptionlabel, *descriptionentry, *imagelabel, *imageentry, *symbollabel, *symbolentry; GtkWidget *sourcelabel = NULL, *sourceentry = NULL; GtkWidget *typelabel = NULL, *typeentry = NULL; GtkWidget *timelabel = NULL; GtkWidget *timevaluebutton = NULL; GtkWidget *hasGeotagCB = NULL; GtkWidget *consistentGeotagCB = NULL; GtkWidget *direction_sb = NULL; GtkWidget *direction_hb = NULL; GtkListStore *store; gchar *lat, *lon, *alt; vik_coord_to_latlon ( &(wp->coord), &ll ); lat = g_strdup_printf ( "%f", ll.lat ); lon = g_strdup_printf ( "%f", ll.lon ); vik_units_height_t height_units = a_vik_get_units_height (); switch (height_units) { case VIK_UNITS_HEIGHT_METRES: alt = g_strdup_printf ( "%f", wp->altitude ); break; case VIK_UNITS_HEIGHT_FEET: alt = g_strdup_printf ( "%f", VIK_METERS_TO_FEET(wp->altitude) ); break; default: alt = g_strdup_printf ( "%f", wp->altitude ); g_critical("Houston, we've had a problem. height=%d", height_units); } *updated = FALSE; namelabel = gtk_label_new (_("Name:")); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), namelabel, FALSE, FALSE, 0); // Name is now always changeable nameentry = gtk_entry_new (); if ( default_name ) gtk_entry_set_text( GTK_ENTRY(nameentry), default_name ); g_signal_connect_swapped ( nameentry, "activate", G_CALLBACK(a_dialog_response_accept), GTK_DIALOG(dialog) ); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), nameentry, FALSE, FALSE, 0); latlabel = gtk_label_new (_("Latitude:")); latentry = gtk_entry_new (); gtk_entry_set_text ( GTK_ENTRY(latentry), lat ); g_free ( lat ); lonlabel = gtk_label_new (_("Longitude:")); lonentry = gtk_entry_new (); gtk_entry_set_text ( GTK_ENTRY(lonentry), lon ); g_free ( lon ); altlabel = gtk_label_new (_("Altitude:")); altentry = gtk_entry_new (); gtk_entry_set_text ( GTK_ENTRY(altentry), alt ); g_free ( alt ); if ( wp->comment && !strncmp(wp->comment, "http", 4) ) commentlabel = gtk_link_button_new_with_label (wp->comment, _("Comment:") ); else commentlabel = gtk_label_new (_("Comment:")); commententry = gtk_entry_new (); gchar *cmt = NULL; // Auto put in some kind of 'name' as a comment if one previously 'goto'ed this exact location cmt = a_vik_goto_get_search_string_for_this_place(VIK_WINDOW(parent)); if (cmt) gtk_entry_set_text(GTK_ENTRY(commententry), cmt); if ( wp->description && !strncmp(wp->description, "http", 4) ) descriptionlabel = gtk_link_button_new_with_label (wp->description, _("Description:") ); else descriptionlabel = gtk_label_new (_("Description:")); descriptionentry = gtk_entry_new (); sourcelabel = gtk_label_new (_("Source:")); if ( wp->source ) { sourceentry = gtk_entry_new (); gtk_entry_set_text(GTK_ENTRY(sourceentry), wp->source); } typelabel = gtk_label_new (_("Type:")); if ( wp->type ) { typeentry = gtk_entry_new (); gtk_entry_set_text(GTK_ENTRY(typeentry), wp->type); } imagelabel = gtk_label_new (_("Image:")); imageentry = vik_file_entry_new (GTK_FILE_CHOOSER_ACTION_OPEN, VF_FILTER_IMAGE, NULL, NULL); { GtkCellRenderer *r; symbollabel = gtk_label_new (_("Symbol:")); GtkTreeIter iter; store = gtk_list_store_new(3, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_STRING); symbolentry = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store)); gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(symbolentry), 6); g_signal_connect(symbolentry, "changed", G_CALLBACK(symbol_entry_changed_cb), store); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, NULL, 1, NULL, 2, _("(none)"), -1); a_populate_sym_list(store); r = gtk_cell_renderer_pixbuf_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (symbolentry), r, FALSE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (symbolentry), r, "pixbuf", 1, NULL); r = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (symbolentry), r, FALSE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (symbolentry), r, "text", 2, NULL); if ( !is_new && wp->symbol ) { gboolean ok; gchar *sym; for (ok = gtk_tree_model_get_iter_first ( GTK_TREE_MODEL(store), &iter ); ok; ok = gtk_tree_model_iter_next ( GTK_TREE_MODEL(store), &iter)) { gtk_tree_model_get ( GTK_TREE_MODEL(store), &iter, 0, (void *)&sym, -1 ); if (sym && !strcmp(sym, wp->symbol)) { g_free(sym); break; } else { g_free(sym); } } // Ensure is it a valid symbol in the given symbol set (large vs small) // Not all symbols are available in both // The check prevents a Gtk Critical message if ( iter.stamp ) gtk_combo_box_set_active_iter(GTK_COMBO_BOX(symbolentry), &iter); } } if ( !is_new && wp->comment ) gtk_entry_set_text ( GTK_ENTRY(commententry), wp->comment ); if ( !is_new && wp->description ) gtk_entry_set_text ( GTK_ENTRY(descriptionentry), wp->description ); if ( !edit_wp ) edit_wp = vik_waypoint_new (); edit_wp = vik_waypoint_copy ( wp ); if ( !is_new && wp->image ) { vik_file_entry_set_filename ( VIK_FILE_ENTRY(imageentry), wp->image ); #ifdef VIK_CONFIG_GEOTAG // Geotag Info [readonly] hasGeotagCB = gtk_check_button_new_with_label ( _("Has Geotag") ); gtk_widget_set_sensitive ( hasGeotagCB, FALSE ); gboolean hasGeotag; gchar *ignore = a_geotag_get_exif_date_from_file ( wp->image, &hasGeotag ); g_free ( ignore ); gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON(hasGeotagCB), hasGeotag ); consistentGeotagCB = gtk_check_button_new_with_label ( _("Consistent Position") ); gtk_widget_set_sensitive ( consistentGeotagCB, FALSE ); if ( hasGeotag ) { struct LatLon ll = a_geotag_get_position ( wp->image ); VikCoord coord; vik_coord_load_from_latlon ( &coord, coord_mode, &ll ); gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON(consistentGeotagCB), vik_coord_equalish(&coord, &wp->coord) ); } // ATM the direction value box is always shown, even when there is no information. // It would be nice to be able to hide it until the 'Add' has been performed, // however I've not been able to achieve this. // Thus simply sensistizing it instead. GtkWidget *direction_label = gtk_label_new ( _("Image Direction:") ); direction_hb = gtk_hbox_new ( FALSE, 0 ); gtk_box_pack_start (GTK_BOX(direction_hb), direction_label, FALSE, FALSE, 0); direction_sb = gtk_spin_button_new ( (GtkAdjustment*)gtk_adjustment_new (0, 0.0, 359.9, 5.0, 1, 0 ), 1, 1 ); if ( !is_new && !isnan(wp->image_direction) ) { GtkWidget *direction_ref = gtk_label_new ( NULL ); if ( wp->image_direction_ref == WP_IMAGE_DIRECTION_REF_MAGNETIC ) gtk_label_set_label ( GTK_LABEL(direction_ref), _("Magnetic") ); else gtk_label_set_label ( GTK_LABEL(direction_ref), _("True") ); gtk_box_pack_start (GTK_BOX(direction_hb), direction_ref, TRUE, FALSE, 0); gtk_spin_button_set_value ( GTK_SPIN_BUTTON(direction_sb), wp->image_direction ); } else { GtkWidget *direction_ref_button = gtk_button_new (); gtk_button_set_relief ( GTK_BUTTON(direction_ref_button), GTK_RELIEF_NONE ); GtkWidget *img = gtk_image_new_from_stock ( GTK_STOCK_ADD, GTK_ICON_SIZE_MENU ); gtk_button_set_image ( GTK_BUTTON(direction_ref_button), img ); gtk_box_pack_start (GTK_BOX(direction_hb), direction_ref_button, TRUE, FALSE, 0); gtk_widget_set_sensitive ( direction_sb, FALSE ); direction_signal_id = g_signal_connect ( G_OBJECT(direction_ref_button), "button-release-event", G_CALLBACK(direction_add_click), direction_sb ); } #endif } timelabel = gtk_label_new ( _("Time:") ); timevaluebutton = gtk_button_new(); gtk_button_set_relief ( GTK_BUTTON(timevaluebutton), GTK_RELIEF_NONE ); // TODO: Consider if there should be a remove time button... if ( !is_new && wp->has_timestamp ) { update_time ( timevaluebutton, wp ); } else { GtkWidget *img = gtk_image_new_from_stock ( GTK_STOCK_ADD, GTK_ICON_SIZE_MENU ); gtk_button_set_image ( GTK_BUTTON(timevaluebutton), img ); // Initially use current time or otherwise whatever the last value used was if ( edit_wp->timestamp == 0 ) { time ( &edit_wp->timestamp ); } } g_signal_connect ( G_OBJECT(timevaluebutton), "button-release-event", G_CALLBACK(time_edit_click), edit_wp ); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), latlabel, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), latentry, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), lonlabel, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), lonentry, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), timelabel, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), timevaluebutton, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), altlabel, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), altentry, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), commentlabel, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), commententry, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), descriptionlabel, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), descriptionentry, FALSE, FALSE, 0); if ( wp->source ) { gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), sourcelabel, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), sourceentry, FALSE, FALSE, 0); } if ( wp->type ) { gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), typelabel, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), typeentry, FALSE, FALSE, 0); } gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), imagelabel, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), imageentry, FALSE, FALSE, 0); if ( hasGeotagCB ) { GtkWidget *hbox = gtk_hbox_new ( FALSE, 0 ); gtk_box_pack_start (GTK_BOX(hbox), hasGeotagCB, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(hbox), consistentGeotagCB, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), hbox, FALSE, FALSE, 0); } if ( direction_hb ) gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), direction_hb, FALSE, FALSE, 0); if ( direction_sb ) gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), direction_sb, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), symbollabel, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), GTK_WIDGET(symbolentry), FALSE, FALSE, 0); gtk_dialog_set_default_response ( GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT ); gtk_widget_show_all ( gtk_dialog_get_content_area(GTK_DIALOG(dialog)) ); if ( !is_new ) { // Shift left<->right to try not to obscure the waypoint. trw_layer_dialog_shift ( vtl, GTK_WINDOW(dialog), &(wp->coord), FALSE ); } while ( gtk_dialog_run ( GTK_DIALOG(dialog) ) == GTK_RESPONSE_ACCEPT ) { if ( strlen((gchar*)gtk_entry_get_text ( GTK_ENTRY(nameentry) )) == 0 ) /* TODO: other checks (isalpha or whatever ) */ a_dialog_info_msg ( parent, _("Please enter a name for the waypoint.") ); else { // NB: No check for unique names - this allows generation of same named entries. gchar *entered_name = g_strdup ( (gchar*)gtk_entry_get_text ( GTK_ENTRY(nameentry) ) ); /* Do It */ ll.lat = convert_dms_to_dec ( gtk_entry_get_text ( GTK_ENTRY(latentry) ) ); ll.lon = convert_dms_to_dec ( gtk_entry_get_text ( GTK_ENTRY(lonentry) ) ); vik_coord_load_from_latlon ( &(wp->coord), coord_mode, &ll ); // Always store in metres switch (height_units) { case VIK_UNITS_HEIGHT_METRES: wp->altitude = atof ( gtk_entry_get_text ( GTK_ENTRY(altentry) ) ); break; case VIK_UNITS_HEIGHT_FEET: wp->altitude = VIK_FEET_TO_METERS(atof ( gtk_entry_get_text ( GTK_ENTRY(altentry) ) )); break; default: wp->altitude = atof ( gtk_entry_get_text ( GTK_ENTRY(altentry) ) ); g_critical("Houston, we've had a problem. height=%d", height_units); } if ( g_strcmp0 ( wp->comment, gtk_entry_get_text ( GTK_ENTRY(commententry) ) ) ) vik_waypoint_set_comment ( wp, gtk_entry_get_text ( GTK_ENTRY(commententry) ) ); if ( g_strcmp0 ( wp->description, gtk_entry_get_text ( GTK_ENTRY(descriptionentry) ) ) ) vik_waypoint_set_description ( wp, gtk_entry_get_text ( GTK_ENTRY(descriptionentry) ) ); if ( g_strcmp0 ( wp->image, vik_file_entry_get_filename ( VIK_FILE_ENTRY(imageentry) ) ) ) vik_waypoint_set_image ( wp, vik_file_entry_get_filename ( VIK_FILE_ENTRY(imageentry) ) ); if ( sourceentry && g_strcmp0 ( wp->source, gtk_entry_get_text ( GTK_ENTRY(sourceentry) ) ) ) vik_waypoint_set_source ( wp, gtk_entry_get_text ( GTK_ENTRY(sourceentry) ) ); if ( typeentry && g_strcmp0 ( wp->type, gtk_entry_get_text ( GTK_ENTRY(typeentry) ) ) ) vik_waypoint_set_type ( wp, gtk_entry_get_text ( GTK_ENTRY(typeentry) ) ); if ( wp->image && *(wp->image) && (!a_thumbnails_exists(wp->image)) ) a_thumbnails_create ( wp->image ); if ( edit_wp->timestamp ) { wp->timestamp = edit_wp->timestamp; wp->has_timestamp = TRUE; } if ( direction_sb ) { if ( gtk_widget_get_sensitive (direction_sb) ) { wp->image_direction = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(direction_sb) ); if ( wp->image_direction != edit_wp->image_direction ) a_geotag_write_exif_gps ( wp->image, wp->coord, wp->altitude, wp->image_direction, wp->image_direction_ref, TRUE ); } } GtkTreeIter iter, first; gtk_tree_model_get_iter_first ( GTK_TREE_MODEL(store), &first ); if ( !gtk_combo_box_get_active_iter ( GTK_COMBO_BOX(symbolentry), &iter ) || !memcmp(&iter, &first, sizeof(GtkTreeIter)) ) { vik_waypoint_set_symbol ( wp, NULL ); } else { gchar *sym; gtk_tree_model_get ( GTK_TREE_MODEL(store), &iter, 0, (void *)&sym, -1 ); vik_waypoint_set_symbol ( wp, sym ); g_free(sym); } gtk_widget_destroy ( dialog ); if ( is_new ) return entered_name; else { *updated = TRUE; // See if name has been changed if ( g_strcmp0 (default_name, entered_name ) ) return entered_name; else return NULL; } } } gtk_widget_destroy ( dialog ); return NULL; }
/** * a_geotag_create_waypoint_from_file: * @filename: The image file to process * @vcmode: The current location mode to use in the positioning of Waypoint * @name: Returns a name for the Waypoint (can be NULL) * * Returns: An allocated Waypoint or NULL if Waypoint could not be generated (e.g. no EXIF info) * */ VikWaypoint* a_geotag_create_waypoint_from_file ( const gchar *filename, VikCoordMode vcmode, gchar **name ) { // Default return values (for failures) *name = NULL; VikWaypoint *wp = NULL; // TODO use log? //ExifLog *log = NULL; // open image with libexif ExifData *ed = exif_data_new_from_file ( filename ); // Detect EXIF load failure if ( !ed ) // return with no Waypoint return wp; struct LatLon ll; gchar str[128]; ExifEntry *ee; ee = exif_content_get_entry (ed->ifd[EXIF_IFD_GPS], EXIF_TAG_GPS_VERSION_ID); // Confirm this has a GPS Id - normally "2.0.0.0" or "2.2.0.0" if ( ! ( ee && ee->components == 4 ) ) goto MyReturn; // Could test for these versions explicitly but may have byte order issues... //if ( ! ( ee->data[0] == 2 && ee->data[2] == 0 && ee->data[3] == 0 ) ) // goto MyReturn; ee = exif_content_get_entry (ed->ifd[EXIF_IFD_GPS], EXIF_TAG_GPS_MAP_DATUM); if ( ! ( ee && ee->components > 0 && ee->format == EXIF_FORMAT_ASCII ) ) goto MyReturn; // If map datum specified - only deal in WGS-84 - the defacto standard if ( ee && ee->components > 0 ) { exif_entry_get_value ( ee, str, 128 ); if ( strncmp (str, "WGS-84", 6) ) goto MyReturn; } // // Lat & Long is necessary to form a waypoint. // ee = exif_content_get_entry (ed->ifd[EXIF_IFD_GPS], EXIF_TAG_GPS_LATITUDE); if ( ! ( ee && ee->components == 3 && ee->format == EXIF_FORMAT_RATIONAL ) ) goto MyReturn; ll.lat = Rational2Double ( ee->data, exif_format_get_size(ee->format), exif_data_get_byte_order(ed) ); ee = exif_content_get_entry (ed->ifd[EXIF_IFD_GPS], EXIF_TAG_GPS_LATITUDE_REF); if ( ee ) { exif_entry_get_value ( ee, str, 128 ); if ( str[0] == 'S' ) ll.lat = -ll.lat; } ee = exif_content_get_entry (ed->ifd[EXIF_IFD_GPS], EXIF_TAG_GPS_LONGITUDE); if ( ! ( ee && ee->components == 3 && ee->format == EXIF_FORMAT_RATIONAL ) ) goto MyReturn; ll.lon = Rational2Double ( ee->data, exif_format_get_size(ee->format), exif_data_get_byte_order(ed) ); ee = exif_content_get_entry (ed->ifd[EXIF_IFD_GPS], EXIF_TAG_GPS_LONGITUDE_REF); if ( ee ) { exif_entry_get_value ( ee, str, 128 ); if ( str[0] == 'W' ) ll.lon = -ll.lon; } // // Not worried if none of the other fields exist, as can default the values to something // gdouble alt = VIK_DEFAULT_ALTITUDE; ee = exif_content_get_entry (ed->ifd[EXIF_IFD_GPS], EXIF_TAG_GPS_ALTITUDE); if ( ee && ee->components == 1 && ee->format == EXIF_FORMAT_RATIONAL ) { alt = Rational2Double ( ee->data, 0, exif_data_get_byte_order(ed) ); ee = exif_content_get_entry (ed->ifd[EXIF_IFD_GPS], EXIF_TAG_GPS_ALTITUDE_REF); if ( ee && ee->components == 1 && ee->format == EXIF_FORMAT_BYTE && ee->data[0] == 1 ) alt = -alt; } // Name ee = exif_content_get_entry (ed->ifd[EXIF_IFD_0], EXIF_TAG_XP_TITLE); if ( ee ) { exif_entry_get_value ( ee, str, 128 ); *name = g_strdup ( str ); } // // Now create Waypoint with acquired information // wp = vik_waypoint_new(); wp->visible = TRUE; // Set info from exif values // Location vik_coord_load_from_latlon ( &(wp->coord), vcmode, &ll ); // Altitude wp->altitude = alt; wp->comment = geotag_get_exif_comment ( ed ); vik_waypoint_set_image ( wp, filename ); MyReturn: // Finished with EXIF exif_data_free ( ed ); return wp; }
void a_gpspoint_read_file(VikTrwLayer *trw, FILE *f ) { VikCoordMode coord_mode = vik_trw_layer_get_coord_mode ( trw ); gchar *tag_start, *tag_end; g_assert ( f != NULL && trw != NULL ); line_type = 0; line_timestamp = 0; line_newsegment = FALSE; line_image = NULL; line_symbol = NULL; current_track = NULL; while (fgets(line_buffer, 2048, f)) { gboolean inside_quote = 0; gboolean backslash = 0; line_buffer[strlen(line_buffer)-1] = '\0'; /* chop off newline */ /* for gpspoint files wrapped inside */ if ( strlen(line_buffer) >= 13 && strncmp ( line_buffer, "~EndLayerData", 13 ) == 0 ) break; /* each line: nullify stuff, make thing if nes, free name if ness */ tag_start = line_buffer; for (;;) { /* my addition: find first non-whitespace character. if the null, skip line. */ while (*tag_start != '\0' && isspace(*tag_start)) tag_start++; if (tag_start == '\0') break; if (*tag_start == '#') break; tag_end = tag_start; if (*tag_end == '"') inside_quote = !inside_quote; while (*tag_end != '\0' && (!isspace(*tag_end) || inside_quote)) { tag_end++; if (*tag_end == '\\' && !backslash) backslash = TRUE; else if (backslash) backslash = FALSE; else if (*tag_end == '"') inside_quote = !inside_quote; } gpspoint_process_tag ( tag_start, tag_end - tag_start ); if (*tag_end == '\0' ) break; else tag_start = tag_end+1; } if (line_type == GPSPOINT_TYPE_WAYPOINT && line_name) { VikWaypoint *wp = vik_waypoint_new(); wp->visible = line_visible; wp->altitude = line_altitude; vik_coord_load_from_latlon ( &(wp->coord), coord_mode, &line_latlon ); vik_trw_layer_filein_add_waypoint ( trw, line_name, wp ); g_free ( line_name ); line_name = NULL; if ( line_comment ) { vik_waypoint_set_comment ( wp, line_comment ); line_comment = NULL; } if ( line_image ) { vik_waypoint_set_image ( wp, line_image ); line_image = NULL; } if ( line_symbol ) { vik_waypoint_set_symbol ( wp, line_symbol ); line_symbol = NULL; } } else if (line_type == GPSPOINT_TYPE_TRACK && line_name) { VikTrack *pl = vik_track_new(); /* Thanks to Peter Jones for this Fix */ if (!line_name) line_name = g_strdup("UNK"); pl->visible = line_visible; if ( line_comment ) { vik_track_set_comment ( pl, line_comment ); line_comment = NULL; } pl->trackpoints = NULL; vik_trw_layer_filein_add_track ( trw, line_name, pl ); g_free ( line_name ); line_name = NULL; current_track = pl; } else if (line_type == GPSPOINT_TYPE_TRACKPOINT && current_track) { VikTrackpoint *tp = vik_trackpoint_new(); vik_coord_load_from_latlon ( &(tp->coord), coord_mode, &line_latlon ); tp->newsegment = line_newsegment; tp->has_timestamp = line_has_timestamp; tp->timestamp = line_timestamp; tp->altitude = line_altitude; if (line_extended) { tp->extended = TRUE; tp->speed = line_speed; tp->course = line_course; tp->nsats = line_sat; tp->fix_mode = line_fix; } else { tp->extended = FALSE; } current_track->trackpoints = g_list_append ( current_track->trackpoints, tp ); } if (line_name) g_free ( line_name ); line_name = NULL; if (line_comment) g_free ( line_comment ); if (line_image) g_free ( line_image ); if (line_symbol) g_free ( line_symbol ); line_comment = NULL; line_image = NULL; line_symbol = NULL; line_type = GPSPOINT_TYPE_NONE; line_newsegment = FALSE; line_has_timestamp = FALSE; line_timestamp = 0; line_altitude = VIK_DEFAULT_ALTITUDE; line_visible = TRUE; line_symbol = NULL; line_extended = FALSE; line_speed = NAN; line_course = NAN; line_sat = 0; line_fix = 0; } }
/* * Returns whether file read was a success * 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, const gchar *dirpath ) { VikCoordMode coord_mode = vik_trw_layer_get_coord_mode ( trw ); gchar *tag_start, *tag_end; g_assert ( f != NULL && trw != NULL ); line_type = 0; line_timestamp = 0; line_newsegment = FALSE; line_image = NULL; line_symbol = NULL; current_track = NULL; gboolean have_read_something = FALSE; while (fgets(line_buffer, VIKING_LINE_SIZE, f)) { gboolean inside_quote = 0; gboolean backslash = 0; line_buffer[strlen(line_buffer)-1] = '\0'; /* chop off newline */ /* for gpspoint files wrapped inside */ if ( strlen(line_buffer) >= 13 && strncmp ( line_buffer, "~EndLayerData", 13 ) == 0 ) { // Even just a blank TRW is ok when in a .vik file have_read_something = TRUE; break; } /* each line: nullify stuff, make thing if nes, free name if ness */ tag_start = line_buffer; for (;;) { /* my addition: find first non-whitespace character. if the null, skip line. */ while (*tag_start != '\0' && isspace(*tag_start)) tag_start++; if (*tag_start == '\0') break; if (*tag_start == '#') break; tag_end = tag_start; if (*tag_end == '"') inside_quote = !inside_quote; while (*tag_end != '\0' && (!isspace(*tag_end) || inside_quote)) { tag_end++; if (*tag_end == '\\' && !backslash) backslash = TRUE; else if (backslash) backslash = FALSE; else if (*tag_end == '"') inside_quote = !inside_quote; } // Won't have super massively long strings, so potential truncation in cast is acceptable. guint len = (guint)(tag_end - tag_start); gpspoint_process_tag ( tag_start, len ); if (*tag_end == '\0' ) break; else tag_start = tag_end+1; } if (line_type == GPSPOINT_TYPE_WAYPOINT && line_name) { have_read_something = TRUE; 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 ); vik_trw_layer_filein_add_waypoint ( trw, line_name, wp ); g_free ( line_name ); line_name = NULL; if ( line_comment ) vik_waypoint_set_comment ( wp, line_comment ); if ( line_description ) vik_waypoint_set_description ( wp, line_description ); if ( line_source ) vik_waypoint_set_source ( wp, line_source ); if ( line_xtype ) vik_waypoint_set_type ( wp, line_xtype ); 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 ); } else if ((line_type == GPSPOINT_TYPE_TRACK || line_type == GPSPOINT_TYPE_ROUTE) && line_name) { have_read_something = TRUE; VikTrack *pl = vik_track_new(); // NB don't set defaults here as all properties are stored in the GPS_POINT format //vik_track_set_defaults ( pl ); /* Thanks to Peter Jones for this Fix */ if (!line_name) line_name = g_strdup("UNK"); pl->visible = line_visible; pl->is_route = (line_type == GPSPOINT_TYPE_ROUTE); if ( line_comment ) vik_track_set_comment ( pl, line_comment ); if ( line_description ) vik_track_set_description ( pl, line_description ); if ( line_source ) vik_track_set_source ( pl, line_source ); if ( line_xtype ) vik_track_set_type ( pl, line_xtype ); if ( line_color ) { if ( gdk_color_parse ( line_color, &(pl->color) ) ) pl->has_color = TRUE; } pl->draw_name_mode = line_name_label; pl->max_number_dist_labels = line_dist_label; pl->trackpoints = NULL; vik_trw_layer_filein_add_track ( trw, line_name, pl ); g_free ( line_name ); line_name = NULL; current_track = pl; } else if ((line_type == GPSPOINT_TYPE_TRACKPOINT || line_type == GPSPOINT_TYPE_ROUTEPOINT) && current_track) { have_read_something = TRUE; VikTrackpoint *tp = vik_trackpoint_new(); vik_coord_load_from_latlon ( &(tp->coord), coord_mode, &line_latlon ); tp->newsegment = line_newsegment; tp->has_timestamp = line_has_timestamp; tp->timestamp = line_timestamp; tp->altitude = line_altitude; vik_trackpoint_set_name ( tp, line_name ); if (line_extended) { tp->speed = line_speed; tp->course = line_course; tp->nsats = line_sat; tp->fix_mode = line_fix; tp->hdop = line_hdop; tp->vdop = line_vdop; tp->pdop = line_pdop; } current_track->trackpoints = g_list_append ( current_track->trackpoints, tp ); } if (line_name) g_free ( line_name ); line_name = NULL; if (line_comment) g_free ( line_comment ); if (line_description) g_free ( line_description ); if (line_source) g_free ( line_source ); if (line_xtype) g_free ( line_xtype ); if (line_color) g_free ( line_color ); if (line_image) g_free ( line_image ); if (line_symbol) g_free ( line_symbol ); line_comment = NULL; line_description = NULL; line_source = NULL; line_xtype = NULL; line_color = NULL; line_image = NULL; line_symbol = NULL; line_type = GPSPOINT_TYPE_NONE; line_newsegment = FALSE; line_has_timestamp = FALSE; line_timestamp = 0; line_altitude = VIK_DEFAULT_ALTITUDE; line_visible = TRUE; line_symbol = NULL; line_extended = FALSE; line_speed = NAN; line_course = NAN; line_sat = 0; line_fix = 0; line_hdop = VIK_DEFAULT_DOP; line_vdop = VIK_DEFAULT_DOP; line_pdop = VIK_DEFAULT_DOP; line_name_label = 0; line_dist_label = 0; } return have_read_something; }
/** * a_geotag_create_waypoint_from_file: * @filename: The image file to process * @vcmode: The current location mode to use in the positioning of Waypoint * @name: Returns a name for the Waypoint (can be NULL) * * Returns: An allocated Waypoint or NULL if Waypoint could not be generated (e.g. no EXIF info) * */ VikWaypoint* a_geotag_create_waypoint_from_file ( const gchar *filename, VikCoordMode vcmode, gchar **name ) { // Default return values (for failures) *name = NULL; VikWaypoint *wp = NULL; #ifdef HAVE_LIBGEXIV2 GExiv2Metadata *gemd = gexiv2_metadata_new (); if ( gexiv2_metadata_open_path ( gemd, filename, NULL ) ) { gdouble lat; gdouble lon; gdouble alt; if ( gexiv2_metadata_get_gps_info ( gemd, &lon, &lat, &alt ) ) { struct LatLon ll; ll.lat = lat; ll.lon = lon; // // Now create Waypoint with acquired information // wp = vik_waypoint_new(); wp->visible = TRUE; // Set info from exif values // Location vik_coord_load_from_latlon ( &(wp->coord), vcmode, &ll ); // Altitude wp->altitude = alt; if ( gexiv2_metadata_has_tag ( gemd, "Exif.Image.XPTitle" ) ) *name = g_strdup ( gexiv2_metadata_get_tag_interpreted_string ( gemd, "Exif.Image.XPTitle" ) ); wp->comment = geotag_get_exif_comment ( gemd ); // Direction VikWaypointImageDirectionRef ref = WP_IMAGE_DIRECTION_REF_TRUE; if ( gexiv2_metadata_has_tag ( gemd, EXIF_GPS_IMGDIR_REF ) ) { gchar* ref_str = gexiv2_metadata_get_tag_interpreted_string(gemd, EXIF_GPS_IMGDIR_REF); if ( ref_str && g_ascii_strncasecmp ("M", ref_str, 1) == 0 ) ref = WP_IMAGE_DIRECTION_REF_MAGNETIC; g_free ( ref_str ); } if ( gexiv2_metadata_has_tag ( gemd, EXIF_GPS_IMGDIR ) ) { gint nom; gint den; gdouble direction = NAN; if ( gexiv2_metadata_get_exif_tag_rational (gemd, EXIF_GPS_IMGDIR, &nom, &den) ) if ( den != 0 ) direction = (gdouble)nom/(gdouble)den; if ( !isnan(direction) ) vik_waypoint_set_image_direction_info ( wp, direction, ref ); } vik_waypoint_set_image ( wp, filename ); } } metadata_free ( gemd ); #else #ifdef HAVE_LIBEXIF // TODO use log? //ExifLog *log = NULL; // open image with libexif ExifData *ed = exif_data_new_from_file ( filename ); // Detect EXIF load failure if ( !ed ) // return with no Waypoint return wp; struct LatLon ll; gchar str[128]; ExifEntry *ee; ee = exif_content_get_entry (ed->ifd[EXIF_IFD_GPS], EXIF_TAG_GPS_VERSION_ID); // Confirm this has a GPS Id - normally "2.0.0.0" or "2.2.0.0" if ( ! ( ee && ee->components == 4 ) ) goto MyReturn; // Could test for these versions explicitly but may have byte order issues... //if ( ! ( ee->data[0] == 2 && ee->data[2] == 0 && ee->data[3] == 0 ) ) // goto MyReturn; ll = get_latlon ( ed ); // Hopefully won't have valid images at 0,0! if ( ll.lat == 0.0 && ll.lon == 0.0 ) goto MyReturn; // // Not worried if none of the other fields exist, as can default the values to something // gdouble alt = VIK_DEFAULT_ALTITUDE; ee = exif_content_get_entry (ed->ifd[EXIF_IFD_GPS], EXIF_TAG_GPS_ALTITUDE); if ( ee && ee->components == 1 && ee->format == EXIF_FORMAT_RATIONAL ) { alt = Rational2Double ( ee->data, 0, exif_data_get_byte_order(ed) ); ee = exif_content_get_entry (ed->ifd[EXIF_IFD_GPS], EXIF_TAG_GPS_ALTITUDE_REF); if ( ee && ee->components == 1 && ee->format == EXIF_FORMAT_BYTE && ee->data[0] == 1 ) alt = -alt; } // Name ee = exif_content_get_entry (ed->ifd[EXIF_IFD_0], EXIF_TAG_XP_TITLE); if ( ee ) { exif_entry_get_value ( ee, str, 128 ); *name = g_strdup ( str ); } // // Now create Waypoint with acquired information // wp = vik_waypoint_new(); wp->visible = TRUE; // Set info from exif values // Location vik_coord_load_from_latlon ( &(wp->coord), vcmode, &ll ); // Altitude wp->altitude = alt; wp->comment = geotag_get_exif_comment ( ed ); vik_waypoint_set_image ( wp, filename ); MyReturn: // Finished with EXIF exif_data_free ( ed ); #endif #endif return wp; }