gdouble lat, lon;
gtk_map_get_menu_latlon(_map, &lat, &lon);
-path_add_latlon(_route, lat, lon);
+path_add_latlon(_route, lat, lon, time(NULL), 0, 0);
return TRUE;
}
gtk_map_get_menu_latlon(_map, &lat, &lon);
if (poi_select(lat, lon, 4, &poi))
- path_add_latlon(_route, lat, lon);
+ path_add_latlon(_route, lat, lon, time(NULL), 0, 0);
return TRUE;
}
* @path
* @gps
*
- * Append a path point to path
+ * Append a point using given gps data. Adds a path break if gps is not valid.
*
* Returns: TRUE if the new point was added. FALSE is returned if new point distance was under sensitivity setting.
*/
return FALSE;
}
-latlon2unit(gps->lat, gps->lon, unitx, unity);
+return path_add_latlon(path, gps->lat, gps->lon, gps->time, gps->speed, gps->altitude);
+}
+
+/**
+ * path_add_latlon:
+ * @path
+ * @lat
+ * @lon
+ * @ptime
+ * @speed
+ * @altitude
+ *
+ * Append a point with given lat,lon,ptime,speed and altitude to given path.
+ *
+ * Returns: TRUE if the new point was added. FALSE is returned if new point distance was under sensitivity setting.
+ */
+gboolean
+path_add_latlon(Path *path, gdouble lat, gdouble lon, time_t ptime, gfloat speed, gfloat altitude)
+{
+guint unitx, unity;
+
+latlon2unit(lat, lon, unitx, unity);
if (abs((gint)unitx-path->tail->unitx) > path->sensitivity || abs((gint)unity-path->tail->unity) > path->sensitivity) {
if (path->tail->unity && path->tail->unitx) {
- gdouble lat, lon;
+ gdouble plat, plon;
unit2latlon(path->tail->unitx, path->tail->unity, lat, lon);
- path->length+=calculate_distance(lat, lon, gps->lat, gps->lon);
+ path->length+=calculate_distance(plat, plon, lat, lon);
}
MACRO_PATH_INCREMENT_TAIL(*path);
path->tail->unitx=unitx;
path->tail->unity=unity;
- path->tail->time=gps->time;
- path->tail->altitude=gps->altitude;
- path->maxspeed=gps->maxspeed;
- path->tspeed+=gps->speed;
+ path->tail->time=ptime;
+ path->tail->altitude=altitude;
+ if (speed>path->maxspeed)
+ path->maxspeed=speed;
+ path->tspeed+=speed;
path->avgspeed=(path->points>0) ? path->tspeed/path->points : 0.0;
path->points++;
g_debug("TRACK: %f %f (%d)", path->length, path->avgspeed, path->points);
}
return FALSE;
+
}
/**
#include <glib-object.h>
#include <gtk/gtk.h>
+#include "gpsdata.h"
+
G_BEGIN_DECLS
#define PATH_TYPE (path_get_type ())
void path_find_nearest_point(Path *path);
gboolean path_update_nears(Path *route, Point *point, gboolean quick);
+gboolean path_add_latlon(Path *path, gdouble lat, gdouble lon, time_t ptime, gfloat speed, gfloat altitude);
+gboolean path_add_point(Path *path, GpsData *gps);
+
+gboolean path_has_points(Path *path);
+gboolean path_has_waypoints(Path *path);
+
gboolean path_add_break(Path *path);
void path_insert_mark_text(Path *path, gchar *text);
void path_insert_mark_autonumber(Path *path);