X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/fffcc269ddb7ea0b688ffc2744f7b710453bcb04..a129aa51e2160d7bda45e8b57ee7a8f28e83a84b:/src/vikwaypoint.c?ds=inline diff --git a/src/vikwaypoint.c b/src/vikwaypoint.c index 48cd2f2f..8504185c 100644 --- a/src/vikwaypoint.c +++ b/src/vikwaypoint.c @@ -26,6 +26,7 @@ #include "vikwaypoint.h" #include "globals.h" #include "garminsymbols.h" +#include "dems.h" #include VikWaypoint *vik_waypoint_new() @@ -127,6 +128,8 @@ VikWaypoint *vik_waypoint_copy(const VikWaypoint *wp) 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); @@ -135,6 +138,28 @@ VikWaypoint *vik_waypoint_copy(const VikWaypoint *wp) 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 */