#include "vikcoord.h"
#include "vikwaypoint.h"
#include "globals.h"
+#include "garminsymbols.h"
+#include "dems.h"
#include <glib/gi18n.h>
VikWaypoint *vik_waypoint_new()
if ( wp->name )
g_free ( wp->name );
- if ( name && name[0] != '\0' )
- wp->name = g_strdup(name);
- else
- wp->name = NULL;
+ wp->name = g_strdup(name);
}
void vik_waypoint_set_comment_no_copy(VikWaypoint *wp, gchar *comment)
wp->description = NULL;
}
+void vik_waypoint_set_source(VikWaypoint *wp, const gchar *source)
+{
+ if ( wp->source )
+ g_free ( wp->source );
+
+ if ( source && source[0] != '\0' )
+ wp->source = g_strdup(source);
+ else
+ wp->source = NULL;
+}
+
+void vik_waypoint_set_type(VikWaypoint *wp, const gchar *type)
+{
+ if ( wp->type )
+ g_free ( wp->type );
+
+ if ( type && type[0] != '\0' )
+ wp->type = g_strdup(type);
+ else
+ wp->type = NULL;
+}
+
+void vik_waypoint_set_url(VikWaypoint *wp, const gchar *url)
+{
+ if ( wp->url )
+ g_free ( wp->url );
+
+ if ( url && url[0] != '\0' )
+ wp->url = g_strdup(url);
+ else
+ wp->url = NULL;
+}
+
void vik_waypoint_set_image(VikWaypoint *wp, const gchar *image)
{
if ( wp->image )
void vik_waypoint_set_symbol(VikWaypoint *wp, const gchar *symname)
{
+ const gchar *hashed_symname;
+
if ( wp->symbol )
g_free ( wp->symbol );
- if ( symname && symname[0] != '\0' )
- wp->symbol = g_strdup(symname);
- else
+ // NB symbol_pixbuf is just a reference, so no need to free it
+
+ if ( symname && symname[0] != '\0' ) {
+ hashed_symname = a_get_hashed_sym ( symname );
+ if ( hashed_symname )
+ symname = hashed_symname;
+ wp->symbol = g_strdup ( symname );
+ wp->symbol_pixbuf = a_get_wp_sym ( wp->symbol );
+ }
+ else {
wp->symbol = NULL;
+ wp->symbol_pixbuf = NULL;
+ }
}
void vik_waypoint_free(VikWaypoint *wp)
g_free ( wp->comment );
if ( wp->description )
g_free ( wp->description );
+ if ( wp->source )
+ g_free ( wp->source );
+ if ( wp->type )
+ g_free ( wp->type );
+ if ( wp->url )
+ g_free ( wp->url );
if ( wp->image )
g_free ( wp->image );
if ( wp->symbol )
new_wp->coord = wp->coord;
new_wp->visible = wp->visible;
new_wp->altitude = wp->altitude;
+ new_wp->has_timestamp = wp->has_timestamp;
+ new_wp->timestamp = wp->timestamp;
vik_waypoint_set_name(new_wp,wp->name);
vik_waypoint_set_comment(new_wp,wp->comment);
vik_waypoint_set_description(new_wp,wp->description);
+ vik_waypoint_set_source(new_wp,wp->source);
+ vik_waypoint_set_type(new_wp,wp->type);
+ vik_waypoint_set_url(new_wp,wp->url);
vik_waypoint_set_image(new_wp,wp->image);
vik_waypoint_set_symbol(new_wp,wp->symbol);
return new_wp;
}
+/**
+ * vik_waypoint_apply_dem_data:
+ * @wp: The Waypoint to operate on
+ * @skip_existing: When TRUE, don't change the elevation if the waypoint already has a value
+ *
+ * Set elevation data for a waypoint using available DEM information
+ *
+ * Returns: TRUE if the waypoint was updated
+ */
+gboolean vik_waypoint_apply_dem_data ( VikWaypoint *wp, gboolean skip_existing )
+{
+ gboolean updated = FALSE;
+ if ( !(skip_existing && wp->altitude != VIK_DEFAULT_ALTITUDE) ) {
+ gint16 elev = a_dems_get_elev_by_coord ( &(wp->coord), VIK_DEM_INTERPOL_BEST );
+ if ( elev != VIK_DEM_INVALID_ELEVATION ) {
+ wp->altitude = (gdouble)elev;
+ updated = TRUE;
+ }
+ }
+ return updated;
+}
+
/*
* Take a Waypoint and convert it into a byte array
*/
vwm_append(wp->name);
vwm_append(wp->comment);
vwm_append(wp->description);
+ vwm_append(wp->source);
+ vwm_append(wp->type);
+ vwm_append(wp->url);
vwm_append(wp->image);
vwm_append(wp->symbol);
vwu_get(new_wp->name);
vwu_get(new_wp->comment);
vwu_get(new_wp->description);
+ vwu_get(new_wp->source);
+ vwu_get(new_wp->type);
+ vwu_get(new_wp->url);
vwu_get(new_wp->image);
vwu_get(new_wp->symbol);